Changeset b79d450 in mainline for uspace/lib/libc/generic


Ignore:
Timestamp:
2010-01-27T20:35:49Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fb6f1a5
Parents:
fccc236 (diff), 95e6c4f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/lib/libc/generic
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/adt/hash_table.c

    rfccc236 rb79d450  
    193193}
    194194
     195/** Apply fucntion to all items in hash table.
     196 *
     197 * @param h             Hash table.
     198 * @param f             Function to be applied.
     199 * @param arg           Argument to be passed to the function.
     200 */
     201void
     202hash_table_apply(hash_table_t *h, void (*f)(link_t *, void *), void *arg)
     203{
     204        hash_index_t bucket;
     205        link_t *cur;
     206
     207        for (bucket = 0; bucket < h->entries; bucket++) {
     208                for (cur = h->entry[bucket].next; cur != &h->entry[bucket];
     209                    cur = cur->next) {
     210                        f(cur, arg);
     211                }
     212        }
     213}
     214
    195215/** @}
    196216 */
  • uspace/lib/libc/generic/io/io.c

    rfccc236 rb79d450  
    554554}
    555555
     556int ftell(FILE *stream)
     557{
     558        off_t rc = lseek(stream->fd, 0, SEEK_CUR);
     559        if (rc == (off_t) (-1)) {
     560                /* errno has been set by lseek. */
     561                return -1;
     562        }
     563
     564        return rc;
     565}
     566
    556567void rewind(FILE *stream)
    557568{
     
    584595}
    585596
     597void clearerr(FILE *stream)
     598{
     599        stream->eof = false;
     600        stream->error = false;
     601}
     602
    586603int fphone(FILE *stream)
    587604{
  • uspace/lib/libc/generic/stacktrace.c

    rfccc236 rb79d450  
    11/*
    22 * Copyright (c) 2009 Jakub Jermar
     3 * Copyright (c) 2010 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3637#include <stdio.h>
    3738#include <sys/types.h>
     39#include <errno.h>
    3840
    39 void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc)
     41static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
     42
     43void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
    4044{
    41         printf("Printing stack trace:\n");
    42         printf("=====================\n");
    43         while (frame_pointer_validate(fp)) {
     45        stacktrace_t st;
     46        uintptr_t nfp;
     47
     48        st.op_arg = NULL;
     49        st.read_uintptr = stacktrace_read_uintptr;
     50
     51        while (stacktrace_fp_valid(&st, fp)) {
    4452                printf("%p: %p()\n", fp, pc);
    45                 pc = return_address_get(fp);
    46                 fp = frame_pointer_prev(fp);
     53                (void) stacktrace_ra_get(&st, fp, &pc);
     54                (void) stacktrace_fp_prev(&st, fp, &nfp);
     55                fp = nfp;
    4756        }
    48         printf("=====================\n");
    4957}
    5058
    51 void stack_trace(void)
     59void stacktrace_print(void)
    5260{
    53         stack_trace_fp_pc(frame_pointer_get(), program_counter_get());
     61        stacktrace_prepare();
     62        stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get());
    5463        /*
    5564         * Prevent the tail call optimization of the previous call by
    5665         * making it a non-tail call.
    5766         */
    58         (void) frame_pointer_get();
     67        (void) stacktrace_fp_get();
     68}
     69
     70static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data)
     71{
     72        (void) arg;
     73        *data = *((uintptr_t *) addr);
     74        return EOK;
    5975}
    6076
  • uspace/lib/libc/generic/udebug.c

    rfccc236 rb79d450  
    6969}
    7070
     71int udebug_name_read(int phoneid, void *buffer, size_t n,
     72        size_t *copied, size_t *needed)
     73{
     74        ipcarg_t a_copied, a_needed;
     75        int rc;
     76
     77        rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_NAME_READ,
     78                (sysarg_t)buffer, n, NULL, &a_copied, &a_needed);
     79
     80        *copied = (size_t)a_copied;
     81        *needed = (size_t)a_needed;
     82
     83        return rc;
     84}
     85
     86int udebug_areas_read(int phoneid, void *buffer, size_t n,
     87        size_t *copied, size_t *needed)
     88{
     89        ipcarg_t a_copied, a_needed;
     90        int rc;
     91
     92        rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_AREAS_READ,
     93                (sysarg_t)buffer, n, NULL, &a_copied, &a_needed);
     94
     95        *copied = (size_t)a_copied;
     96        *needed = (size_t)a_needed;
     97
     98        return rc;
     99}
     100
    71101int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n)
    72102{
     
    78108{
    79109        return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_ARGS_READ,
     110            tid, (sysarg_t)buffer);
     111}
     112
     113int udebug_regs_read(int phoneid, thash_t tid, void *buffer)
     114{
     115        return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_REGS_READ,
    80116            tid, (sysarg_t)buffer);
    81117}
  • uspace/lib/libc/generic/vfs/vfs.c

    rfccc236 rb79d450  
    197197}
    198198
     199int unmount(const char *mp)
     200{
     201        ipcarg_t rc;
     202        ipcarg_t rc_orig;
     203        aid_t req;
     204        size_t mpa_size;
     205        char *mpa;
     206       
     207        mpa = absolutize(mp, &mpa_size);
     208        if (!mpa)
     209                return ENOMEM;
     210       
     211        futex_down(&vfs_phone_futex);
     212        async_serialize_start();
     213        vfs_connect();
     214       
     215        req = async_send_0(vfs_phone, VFS_IN_UNMOUNT, NULL);
     216        rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);
     217        if (rc != EOK) {
     218                async_wait_for(req, &rc_orig);
     219                async_serialize_end();
     220                futex_up(&vfs_phone_futex);
     221                free(mpa);
     222                if (rc_orig == EOK)
     223                        return (int) rc;
     224                else
     225                        return (int) rc_orig;
     226        }
     227       
     228
     229        async_wait_for(req, &rc);
     230        async_serialize_end();
     231        futex_up(&vfs_phone_futex);
     232        free(mpa);
     233       
     234        return (int) rc;
     235}
     236
    199237static int open_internal(const char *abs, size_t abs_size, int lflag, int oflag)
    200238{
Note: See TracChangeset for help on using the changeset viewer.