Changeset 985e26d2 in mainline for uspace/lib/libc/include


Ignore:
Timestamp:
2010-01-07T19:06:59Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8190e63
Parents:
743e17b (diff), eca2435 (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/include
Files:
4 added
20 edited
4 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/include/async.h

    r743e17b r985e26d2  
    259259}
    260260
     261/*
     262 * User-friendly wrappers for async_share_in_start().
     263 */
     264#define async_share_in_start_0_0(phoneid, dst, size) \
     265        async_share_in_start((phoneid), (dst), (size), 0, NULL)
     266#define async_share_in_start_0_1(phoneid, dst, size, flags) \
     267        async_share_in_start((phoneid), (dst), (size), 0, (flags))
     268#define async_share_in_start_1_0(phoneid, dst, size, arg) \
     269        async_share_in_start((phoneid), (dst), (size), (arg), NULL)
     270#define async_share_in_start_1_1(phoneid, dst, size, arg, flags) \
     271        async_share_in_start((phoneid), (dst), (size), (arg), (flags))
     272
     273extern int async_share_in_start(int, void *, size_t, ipcarg_t, int *);
     274extern int async_share_in_receive(ipc_callid_t *, size_t *);
     275extern int async_share_in_finalize(ipc_callid_t, void *, int );
     276extern int async_share_out_start(int, void *, int);
     277extern int async_share_out_receive(ipc_callid_t *, size_t *, int *);
     278extern int async_share_out_finalize(ipc_callid_t, void *);
     279extern int async_data_read_start(int, void *, size_t);
     280extern int async_data_read_receive(ipc_callid_t *, size_t *);
     281extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
     282extern int async_data_write_start(int, const void *, size_t);
     283extern int async_data_write_receive(ipc_callid_t *, size_t *);
     284extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
     285
     286extern int async_data_blob_receive(char **, const size_t, size_t *);
     287extern int async_data_string_receive(char **, const size_t);
     288
    261289#endif
    262290
  • uspace/lib/libc/include/async_priv.h

    r743e17b r985e26d2  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2006 Ondrej Palkovsky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_mips32_ARG_H_
    36 #define KERN_mips32_ARG_H_
     35#ifndef LIBC_ASYNC_PRIV_H_
     36#define LIBC_ASYNC_PRIV_H_
    3737
    38 #include <arch/types.h>
     38#include <adt/list.h>
     39#include <fibril.h>
     40#include <sys/time.h>
     41#include <bool.h>
    3942
    40 /**
    41  * va_arg macro for MIPS32 - problem is that 64 bit values must be aligned on an 8-byte boundary (32bit values not)
    42  * To satisfy this, paddings must be sometimes inserted.
    43  */
     43/** Structures of this type are used to track the timeout events. */
     44typedef struct {
     45        /** If true, this struct is in the timeout list. */
     46        bool inlist;
     47       
     48        /** Timeout list link. */
     49        link_t link;
     50       
     51        /** If true, we have timed out. */
     52        bool occurred;
    4453
    45 typedef uintptr_t va_list;
     54        /** Expiration time. */
     55        struct timeval expires;
     56} to_event_t;
    4657
    47 #define va_start(ap, lst) \
    48         ((ap) = (va_list)&(lst) + sizeof(lst))
     58/** Structures of this type are used to track the wakeup events. */
     59typedef struct {
     60        /** If true, this struct is in a synchronization object wait queue. */
     61        bool inlist;
     62       
     63        /** Wait queue linkage. */
     64        link_t link;
     65} wu_event_t;
    4966
    50 #define va_arg(ap, type)        \
    51         (((type *)((ap) = (va_list)( (sizeof(type) <= 4) ? ((uintptr_t)((ap) + 2*4 - 1) & (~3)) : ((uintptr_t)((ap) + 2*8 -1) & (~7)) )))[-1])
    5267
    53 #define va_copy(dst,src) ((dst)=(src))
     68/** Structures of this type represent a waiting fibril. */
     69typedef struct {
     70        /** Identification of and link to the waiting fibril. */
     71        fid_t fid;
     72       
     73        /** If true, this fibril is currently active. */
     74        bool active;
    5475
    55 #define va_end(ap)
     76        /** Timeout wait data. */
     77        to_event_t to_event;
     78        /** Wakeup wait data. */
     79        wu_event_t wu_event;
     80} awaiter_t;
     81
     82extern void async_insert_timeout(awaiter_t *wd);
    5683
    5784#endif
  • uspace/lib/libc/include/atomic.h

    r743e17b r985e26d2  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2009 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    3636#define LIBC_ATOMIC_H_
    3737
    38 typedef struct atomic {
    39         volatile long count;
    40 } atomic_t;
    41 
    4238#include <libarch/atomic.h>
    43 
    44 static inline void atomic_set(atomic_t *val, long i)
    45 {
    46         val->count = i;
    47 }
    48 
    49 static inline long atomic_get(atomic_t *val)
    50 {
    51         return val->count;
    52 }
    5339
    5440#endif
  • uspace/lib/libc/include/atomicdflt.h

    r743e17b r985e26d2  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2006 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 /*
    36  * Variable argument list manipulation macros
    37  * for architectures using stack to pass arguments.
    38  */
    39  
    40 #ifndef KERN_STACKARG_H_
    41 #define KERN_STACKARG_H_
     35#ifndef LIBC_ATOMICDFLT_H_
     36#define LIBC_ATOMICDFLT_H_
    4237
    43 #include <arch/types.h>
     38#ifndef LIBC_ARCH_ATOMIC_H_
     39#error This file cannot be included directly, include atomic.h instead.
     40#endif
    4441
    45 typedef struct va_list {
    46         int pos;
    47         uint8_t *last;
    48 } va_list;
     42#include <bool.h>
    4943
    50 #define va_start(ap, lst)               \
    51         (ap).pos = sizeof(lst);                         \
    52         (ap).last = (uint8_t *) &(lst)
     44typedef struct atomic {
     45        volatile long count;
     46} atomic_t;
    5347
    54 #define va_arg(ap, type)                \
    55         (*((type *)((ap).last + ((ap).pos += sizeof(type)) - sizeof(type))))
     48static inline void atomic_set(atomic_t *val, long i)
     49{
     50        val->count = i;
     51}
    5652
    57 #define va_copy(dst, src) dst = src
    58 #define va_end(ap)
     53static inline long atomic_get(atomic_t *val)
     54{
     55        return val->count;
     56}
    5957
     58#ifndef CAS
     59static inline bool cas(atomic_t *val, long ov, long nv)
     60{
     61        return __sync_bool_compare_and_swap(&val->count, ov, nv);
     62}
     63#endif
    6064
    6165#endif
  • uspace/lib/libc/include/clipboard.h

    r743e17b r985e26d2  
    11/*
    2  * Copyright (c) 2005 Ondrej Palkovsky
     2 * Copyright (c) 2009 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup amd64   
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_amd64_ARG_H_
    36 #define KERN_amd64_ARG_H_
     35#ifndef LIBC_CLIPBOARD_H_
     36#define LIBC_CLIPBOARD_H_
    3737
    38 #include <stdarg.h>
     38extern int clipboard_put_str(const char *);
     39extern int clipboard_get_str(char **);
    3940
    4041#endif
     
    4243/** @}
    4344 */
    44 
  • uspace/lib/libc/include/devmap.h

    r743e17b r985e26d2  
    3838#include <ipc/devmap.h>
    3939#include <async.h>
     40#include <bool.h>
    4041
    4142extern int devmap_get_phone(devmap_interface_t, unsigned int);
     
    4647
    4748extern int devmap_device_get_handle(const char *, dev_handle_t *, unsigned int);
     49extern int devmap_namespace_get_handle(const char *, dev_handle_t *, unsigned int);
     50extern devmap_handle_type_t devmap_handle_probe(dev_handle_t);
     51
    4852extern int devmap_device_connect(dev_handle_t, unsigned int);
    4953
     
    5155extern void devmap_null_destroy(int);
    5256
    53 extern ipcarg_t devmap_device_get_count(void);
    54 extern ipcarg_t devmap_device_get_devices(ipcarg_t, dev_desc_t *);
     57extern size_t devmap_count_namespaces(void);
     58extern size_t devmap_count_devices(dev_handle_t);
     59
     60extern size_t devmap_get_namespaces(dev_desc_t **);
     61extern size_t devmap_get_devices(dev_handle_t, dev_desc_t **);
    5562
    5663#endif
  • uspace/lib/libc/include/fcntl.h

    r743e17b r985e26d2  
    4343#define O_RDWR    32
    4444#define O_WRONLY  64
     45#define O_DESC    128
    4546
    4647extern int open(const char *, int, ...);
  • uspace/lib/libc/include/fibril_synch.h

    r743e17b r985e26d2  
    3333 */
    3434
    35 #ifndef LIBC_FIBRIL_SYNC_H_
    36 #define LIBC_FIBRIL_SYNC_H_
     35#ifndef LIBC_FIBRIL_SYNCH_H_
     36#define LIBC_FIBRIL_SYNCH_H_
    3737
    3838#include <async.h>
     
    4040#include <adt/list.h>
    4141#include <libarch/tls.h>
     42#include <sys/time.h>
    4243
    4344typedef struct {
     
    9596
    9697extern void fibril_condvar_initialize(fibril_condvar_t *);
     98extern int fibril_condvar_wait_timeout(fibril_condvar_t *, fibril_mutex_t *,
     99    suseconds_t);
    97100extern void fibril_condvar_wait(fibril_condvar_t *, fibril_mutex_t *);
    98101extern void fibril_condvar_signal(fibril_condvar_t *);
  • uspace/lib/libc/include/futex.h

    r743e17b r985e26d2  
    4646extern int futex_down(futex_t *futex);
    4747extern int futex_trydown(futex_t *futex);
    48 extern int futex_down_timeout(futex_t *futex, uint32_t usec, int flags);
    4948extern int futex_up(futex_t *futex);
    5049
  • uspace/lib/libc/include/io/console.h

    r743e17b r985e26d2  
    6969
    7070extern int console_get_size(int phone, int *cols, int *rows);
     71extern int console_get_pos(int phone, int *col, int *row);
    7172extern void console_goto(int phone, int col, int row);
    7273
  • uspace/lib/libc/include/ipc/console.h

    r743e17b r985e26d2  
    4343        CONSOLE_GET_COLOR_CAP,
    4444        CONSOLE_GET_EVENT,
     45        CONSOLE_GET_POS,
    4546        CONSOLE_GOTO,
    4647        CONSOLE_CLEAR,
  • uspace/lib/libc/include/ipc/devmap.h

    r743e17b r985e26d2  
    4343
    4444typedef enum {
     45        DEV_HANDLE_NONE,
     46        DEV_HANDLE_NAMESPACE,
     47        DEV_HANDLE_DEVICE
     48} devmap_handle_type_t;
     49
     50typedef enum {
    4551        DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
    4652        DEVMAP_DRIVER_UNREGISTER,
    4753        DEVMAP_DEVICE_REGISTER,
    4854        DEVMAP_DEVICE_UNREGISTER,
    49         DEVMAP_DEVICE_GET_NAME,
    5055        DEVMAP_DEVICE_GET_HANDLE,
    51         DEVMAP_DEVICE_NULL_CREATE,
    52         DEVMAP_DEVICE_NULL_DESTROY,
    53         DEVMAP_DEVICE_GET_COUNT,
    54         DEVMAP_DEVICE_GET_DEVICES
     56        DEVMAP_NAMESPACE_GET_HANDLE,
     57        DEVMAP_HANDLE_PROBE,
     58        DEVMAP_NULL_CREATE,
     59        DEVMAP_NULL_DESTROY,
     60        DEVMAP_GET_NAMESPACE_COUNT,
     61        DEVMAP_GET_DEVICE_COUNT,
     62        DEVMAP_GET_NAMESPACES,
     63        DEVMAP_GET_DEVICES
    5564} devmap_request_t;
    5665
  • uspace/lib/libc/include/ipc/ipc.h

    r743e17b r985e26d2  
    283283
    284284extern int ipc_share_in_start(int, void *, size_t, ipcarg_t, int *);
    285 extern int ipc_share_in_receive(ipc_callid_t *, size_t *);
    286285extern int ipc_share_in_finalize(ipc_callid_t, void *, int );
    287286extern int ipc_share_out_start(int, void *, int);
    288 extern int ipc_share_out_receive(ipc_callid_t *, size_t *, int *);
    289287extern int ipc_share_out_finalize(ipc_callid_t, void *);
    290288extern int ipc_data_read_start(int, void *, size_t);
    291 extern int ipc_data_read_receive(ipc_callid_t *, size_t *);
    292289extern int ipc_data_read_finalize(ipc_callid_t, const void *, size_t);
    293290extern int ipc_data_write_start(int, const void *, size_t);
    294 extern int ipc_data_write_receive(ipc_callid_t *, size_t *);
    295291extern int ipc_data_write_finalize(ipc_callid_t, void *, size_t);
    296292
  • uspace/lib/libc/include/ipc/loader.h

    r743e17b r985e26d2  
    4141        LOADER_HELLO = IPC_FIRST_USER_METHOD,
    4242        LOADER_GET_TASKID,
     43        LOADER_SET_CWD,
    4344        LOADER_SET_PATHNAME,
    4445        LOADER_SET_ARGS,
  • uspace/lib/libc/include/ipc/services.h

    r743e17b r985e26d2  
    4141        SERVICE_LOAD = 1,
    4242        SERVICE_PCI,
    43         SERVICE_KEYBOARD,
    4443        SERVICE_VIDEO,
    4544        SERVICE_CONSOLE,
     
    4746        SERVICE_DEVMAP,
    4847        SERVICE_FHC,
    49         SERVICE_OBIO
     48        SERVICE_OBIO,
     49        SERVICE_CLIPBOARD
    5050} services_t;
    5151
  • uspace/lib/libc/include/ipc/vfs.h

    r743e17b r985e26d2  
    7373        VFS_IN_UNLINK,
    7474        VFS_IN_RENAME,
    75         VFS_IN_STAT
     75        VFS_IN_STAT,
     76        VFS_IN_DUP
    7677} vfs_in_request_t;
    7778
  • uspace/lib/libc/include/loader/loader.h

    r743e17b r985e26d2  
    4949extern loader_t *loader_connect(void);
    5050extern int loader_get_task_id(loader_t *, task_id_t *);
     51extern int loader_set_cwd(loader_t *);
    5152extern int loader_set_pathname(loader_t *, const char *);
    5253extern int loader_set_args(loader_t *, char *const[]);
  • uspace/lib/libc/include/loader/pcb.h

    r743e17b r985e26d2  
    5252        /** Program entry point. */
    5353        entry_point_t entry;
     54
     55        /** Current working directory. */
     56        char *cwd;
    5457       
    5558        /** Number of command-line arguments. */
  • uspace/lib/libc/include/malloc.h

    r743e17b r985e26d2  
    4242
    4343extern void *malloc(const size_t size);
     44extern void *calloc(const size_t nmemb, const size_t size);
    4445extern void *memalign(const size_t align, const size_t size);
    4546extern void *realloc(const void *addr, const size_t size);
  • uspace/lib/libc/include/stdarg.h

    r743e17b r985e26d2  
    3737
    3838#include <sys/types.h>
    39 #include <libarch/stackarg.h>
    40 
    41 #ifndef __VARARGS_DEFINED
    42 # define __VARARGS_DEFINED
    4339
    4440typedef __builtin_va_list va_list;
    4541
    46 # define va_start(ap, last)             __builtin_va_start(ap, last)
    47 # define va_arg(ap, type)               __builtin_va_arg(ap, type)
    48 # define va_end(ap)                     __builtin_va_end(ap)
    49 
    50 # endif
     42#define va_start(ap, last)  __builtin_va_start(ap, last)
     43#define va_arg(ap, type)    __builtin_va_arg(ap, type)
     44#define va_end(ap)          __builtin_va_end(ap)
    5145
    5246#endif
  • uspace/lib/libc/include/stdlib.h

    r743e17b r985e26d2  
    3838#include <unistd.h>
    3939#include <malloc.h>
     40#include <stacktrace.h>
    4041
    41 #define abort()       _exit(1)
     42#define abort() \
     43        do { \
     44                stack_trace(); \
     45                _exit(1); \
     46        } while (0)
     47
    4248#define exit(status)  _exit((status))
    4349
  • uspace/lib/libc/include/string.h

    r743e17b r985e26d2  
    7373extern void str_append(char *dest, size_t size, const char *src);
    7474
    75 extern void wstr_nstr(char *dst, const wchar_t *src, size_t size);
     75extern void wstr_to_str(char *dest, size_t size, const wchar_t *src);
     76extern char *wstr_to_astr(const wchar_t *src);
     77extern void str_to_wstr(wchar_t *dest, size_t dlen, const char *src);
    7678
    7779extern char *str_chr(const char *str, wchar_t ch);
     
    8284
    8385extern char *str_dup(const char *);
     86extern char *str_ndup(const char *, size_t max_size);
    8487
    8588/*
  • uspace/lib/libc/include/sys/stat.h

    r743e17b r985e26d2  
    4242
    4343struct stat {
    44         fs_handle_t     fs_handle;
    45         dev_handle_t    dev_handle;
    46         fs_index_t      index;
    47         unsigned        lnkcnt;
    48         bool            is_file;
    49         off_t           size;
    50         union {
    51                 struct {
    52                         dev_handle_t    device;
    53                 } devfs_stat;
    54         };
     44        fs_handle_t fs_handle;
     45        dev_handle_t dev_handle;
     46        fs_index_t index;
     47        unsigned int lnkcnt;
     48        bool is_file;
     49        bool is_directory;
     50        off_t size;
     51        dev_handle_t device;
    5552};
    5653
  • uspace/lib/libc/include/unistd.h

    r743e17b r985e26d2  
    5151#endif
    5252
     53typedef uint32_t useconds_t;
     54
     55extern int dup2(int oldfd, int newfd);
     56
    5357extern ssize_t write(int, const void *, size_t);
    5458extern ssize_t read(int, void *, size_t);
     
    6670
    6771extern void _exit(int status) __attribute__ ((noreturn));
    68 extern int usleep(unsigned long usec);
    69 extern unsigned int sleep(unsigned int seconds);
     72extern int usleep(useconds_t uses);
     73extern unsigned int sleep(unsigned int se);
    7074
    7175#endif
Note: See TracChangeset for help on using the changeset viewer.