Changeset 197ef43 in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2011-01-29T23:52:07Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
12573db, 40fb017
Parents:
6aef742 (diff), 47b7006 (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 various cosmetic run-time support improvements

  • coding style cleanups, comments cleanups, unsigned types for bit flags, indentation, etc.
  • SYS_TASK_EXIT for proper termination of a task (optionally with udebug notification)
    • get rid of exit(), _exit(), core()
    • reimplement robust main(), exit() and abort()
    • call abort() if some part of libc initialization fails
  • add more private libc headers to reduce the namespace pollution
Location:
uspace/lib/c/include
Files:
15 edited

Legend:

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

    r6aef742 r197ef43  
    5757extern atomic_t threads_in_ipc_wait;
    5858
    59 extern int __async_init(void);
     59#define async_manager() \
     60        fibril_switch(FIBRIL_TO_MANAGER)
     61
     62#define async_get_call(data) \
     63        async_get_call_timeout(data, 0)
     64
    6065extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
    61 
    62 static inline ipc_callid_t async_get_call(ipc_call_t *data)
    63 {
    64         return async_get_call_timeout(data, 0);
    65 }
    66 
    67 static inline void async_manager(void)
    68 {
    69         fibril_switch(FIBRIL_TO_MANAGER);
    70 }
    7166
    7267/*
     
    143138 */
    144139
    145 extern int async_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
    146 extern int async_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
    147     sysarg_t, sysarg_t, sysarg_t, int);
     140extern int async_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
     141    unsigned int);
     142extern int async_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
     143    sysarg_t, sysarg_t, sysarg_t, unsigned int);
    148144
    149145/*
     
    306302        async_share_in_start((phoneid), (dst), (size), (arg), (flags))
    307303
    308 extern int async_share_in_start(int, void *, size_t, sysarg_t, int *);
    309 extern int async_share_in_receive(ipc_callid_t *, size_t *);
    310 extern int async_share_in_finalize(ipc_callid_t, void *, int );
    311 extern int async_share_out_start(int, void *, int);
    312 extern int async_share_out_receive(ipc_callid_t *, size_t *, int *);
     304extern int async_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
     305extern bool async_share_in_receive(ipc_callid_t *, size_t *);
     306extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int);
     307
     308extern int async_share_out_start(int, void *, unsigned int);
     309extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *);
    313310extern int async_share_out_finalize(ipc_callid_t, void *);
    314311
     
    344341
    345342extern int async_data_read_start(int, void *, size_t);
    346 extern int async_data_read_receive(ipc_callid_t *, size_t *);
     343extern bool async_data_read_receive(ipc_callid_t *, size_t *);
    347344extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
    348345
     
    383380
    384381extern int async_data_write_start(int, const void *, size_t);
    385 extern int async_data_write_receive(ipc_callid_t *, size_t *);
     382extern bool async_data_write_receive(ipc_callid_t *, size_t *);
    386383extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
    387384
    388385extern int async_data_write_accept(void **, const bool, const size_t,
    389386    const size_t, const size_t, size_t *);
    390 extern void async_data_write_void(const int);
     387extern void async_data_write_void(sysarg_t);
    391388
    392389extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
  • uspace/lib/c/include/async_sess.h

    r6aef742 r197ef43  
    4545} async_sess_t;
    4646
    47 extern void _async_sess_init(void);
    4847extern void async_session_create(async_sess_t *, int, sysarg_t);
    4948extern void async_session_destroy(async_sess_t *);
  • uspace/lib/c/include/byteorder.h

    r6aef742 r197ef43  
    8080#endif
    8181
    82 #define htons(n)        host2uint16_t_be((n))
    83 #define htonl(n)        host2uint32_t_be((n))
    84 #define ntohs(n)        uint16_t_be2host((n))
    85 #define ntohl(n)        uint32_t_be2host((n))
     82#define htons(n)  host2uint16_t_be((n))
     83#define htonl(n)  host2uint32_t_be((n))
     84#define ntohs(n)  uint16_t_be2host((n))
     85#define ntohl(n)  uint32_t_be2host((n))
    8686
    8787static inline uint64_t uint64_t_byteorder_swap(uint64_t n)
  • uspace/lib/c/include/err.h

    r6aef742 r197ef43  
    3939
    4040#define errx(status, fmt, ...) \
    41         { \
     41        do { \
    4242                printf((fmt), ##__VA_ARGS__); \
    43                 _exit(status); \
    44         }
     43                exit(status); \
     44        } while (0)
    4545
    4646#endif
  • uspace/lib/c/include/errno.h

    r6aef742 r197ef43  
    3939#include <fibril.h>
    4040
     41#define errno _errno
     42
    4143extern int _errno;
    42 
    43 #define errno _errno
    4444
    4545#define EMFILE        (-18)
     
    5757
    5858/** An API function is called while another blocking function is in progress. */
    59 #define EINPROGRESS     (-10036)
     59#define EINPROGRESS  (-10036)
    6060
    6161/** The socket identifier is not valid. */
    62 #define ENOTSOCK        (-10038)
     62#define ENOTSOCK  (-10038)
    6363
    6464/** The destination address required. */
    65 #define EDESTADDRREQ    (-10039)
     65#define EDESTADDRREQ  (-10039)
    6666
    6767/** Protocol is not supported.  */
    68 #define EPROTONOSUPPORT (-10043)
     68#define EPROTONOSUPPORT  (-10043)
    6969
    7070/** Socket type is not supported. */
    71 #define ESOCKTNOSUPPORT (-10044)
     71#define ESOCKTNOSUPPORT  (-10044)
    7272
    7373/** Protocol family is not supported. */
    74 #define EPFNOSUPPORT    (-10046)
     74#define EPFNOSUPPORT  (-10046)
    7575
    7676/** Address family is not supported. */
    77 #define EAFNOSUPPORT    (-10047)
     77#define EAFNOSUPPORT  (-10047)
    7878
    7979/** Address is already in use. */
    80 #define EADDRINUSE      (-10048)
     80#define EADDRINUSE  (-10048)
    8181
    8282/** The socket is not connected or bound. */
    83 #define ENOTCONN        (-10057)
     83#define ENOTCONN  (-10057)
    8484
    8585/** The requested operation was not performed. Try again later. */
    86 #define EAGAIN          (-11002)
     86#define EAGAIN  (-11002)
    8787
    88 /** No data.
    89  */
    90 #define NO_DATA         (-11004)
     88/** No data. */
     89#define NO_DATA (-11004)
    9190
    9291#endif
  • uspace/lib/c/include/ipc/ipc.h

    r6aef742 r197ef43  
    5353 * possible, the fast version is used.
    5454 */
     55
    5556#define ipc_call_sync_0_0(phoneid, method) \
    5657        ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
     
    182183    sysarg_t *);
    183184
    184 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int);
    185 extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, uint32_t);
     185extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
    186186extern void ipc_poke(void);
    187187
    188 static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data)
    189 {
    190         return ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
    191 }
    192 
     188#define ipc_wait_for_call(data) \
     189        ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
     190
     191extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
    193192extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
    194193
     
    199198 * to m.
    200199 */
     200
    201201#define ipc_answer_0(callid, retval) \
    202202        ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
     
    223223 * to m.
    224224 */
     225
    225226#define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \
    226227        ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \
     
    248249
    249250extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    250     sysarg_t, void *, ipc_async_callback_t, int);
     251    sysarg_t, void *, ipc_async_callback_t, bool);
    251252extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    252     sysarg_t, sysarg_t, void *, ipc_async_callback_t, int);
    253 
    254 extern int ipc_connect_to_me(int, int, int, int, sysarg_t *, sysarg_t *);
    255 extern int ipc_connect_me_to(int, int, int, int);
    256 extern int ipc_connect_me_to_blocking(int, int, int, int);
     253    sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool);
     254
     255extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t *,
     256    sysarg_t *);
     257extern int ipc_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
     258extern int ipc_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
     259
    257260extern int ipc_hangup(int);
    258 extern int ipc_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
    259 extern int ipc_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
    260     sysarg_t, sysarg_t, sysarg_t, int);
     261
     262extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
     263    unsigned int);
     264extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
     265    sysarg_t, sysarg_t, sysarg_t, unsigned int);
    261266
    262267/*
    263268 * User-friendly wrappers for ipc_share_in_start().
    264269 */
     270
    265271#define ipc_share_in_start_0_0(phoneid, dst, size) \
    266272        ipc_share_in_start((phoneid), (dst), (size), 0, NULL)
     
    272278        ipc_share_in_start((phoneid), (dst), (size), (arg), (flags))
    273279
    274 extern int ipc_share_in_start(int, void *, size_t, sysarg_t, int *);
    275 extern int ipc_share_in_finalize(ipc_callid_t, void *, int );
    276 extern int ipc_share_out_start(int, void *, int);
     280extern int ipc_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
     281extern int ipc_share_in_finalize(ipc_callid_t, void *, unsigned int);
     282extern int ipc_share_out_start(int, void *, unsigned int);
    277283extern int ipc_share_out_finalize(ipc_callid_t, void *);
    278284extern int ipc_data_read_start(int, void *, size_t);
  • uspace/lib/c/include/loader/pcb.h

    r6aef742 r197ef43  
    5252        /** Program entry point. */
    5353        entry_point_t entry;
    54 
     54       
    5555        /** Current working directory. */
    5656        char *cwd;
  • uspace/lib/c/include/malloc.h

    r6aef742 r197ef43  
    3838#include <sys/types.h>
    3939
    40 extern void __heap_init(void);
    4140extern uintptr_t get_max_heap_addr(void);
    4241
  • uspace/lib/c/include/setjmp.h

    r6aef742 r197ef43  
    4141
    4242extern int setjmp(jmp_buf env);
    43 extern void longjmp(jmp_buf env,int val) __attribute__((__noreturn__));
     43extern void longjmp(jmp_buf env, int val) __attribute__((noreturn));
    4444
    4545#endif
  • uspace/lib/c/include/stdlib.h

    r6aef742 r197ef43  
    4040#include <stacktrace.h>
    4141
    42 #define abort() \
    43         do { \
    44                 stacktrace_print(); \
    45                 _exit(1); \
    46         } while (0)
     42#define RAND_MAX  714025
    4743
    48 #define core() \
    49         *((int *) 0) = 0xbadbad;
    50 
    51 #define exit(status)  _exit((status))
    52 
    53 #define RAND_MAX  714025
     44#define rand()       random()
     45#define srand(seed)  srandom(seed)
    5446
    5547extern long int random(void);
    5648extern void srandom(unsigned int seed);
    5749
    58 static inline int rand(void)
    59 {
    60         return random();
    61 }
    62 
    63 static inline void srand(unsigned int seed)
    64 {
    65         srandom(seed);
    66 }
     50extern void abort(void) __attribute__((noreturn));
    6751
    6852#endif
  • uspace/lib/c/include/syscall.h

    r6aef742 r197ef43  
    3232/**
    3333 * @file
    34  * @brief       Syscall function declaration for architectures that don't
    35  *              inline syscalls or architectures that handle syscalls
    36  *              according to the number of arguments.
     34 * @brief Syscall function declaration for architectures that don't
     35 *        inline syscalls or architectures that handle syscalls
     36 *        according to the number of arguments.
    3737 */
    3838
     
    4040#define LIBC_SYSCALL_H_
    4141
    42 #ifndef LIBARCH_SYSCALL_GENERIC
    43 #error "You can't include this file directly."
     42#ifndef LIBARCH_SYSCALL_GENERIC
     43        #error You cannot include this file directly
    4444#endif
    4545
     
    4747#include <kernel/syscall/syscall.h>
    4848
    49 #define __syscall0      __syscall
    50 #define __syscall1      __syscall
    51 #define __syscall2      __syscall
    52 #define __syscall3      __syscall
    53 #define __syscall4      __syscall
    54 #define __syscall5      __syscall
    55 #define __syscall6      __syscall
     49#define __syscall0  __syscall
     50#define __syscall1  __syscall
     51#define __syscall2  __syscall
     52#define __syscall3  __syscall
     53#define __syscall4  __syscall
     54#define __syscall5  __syscall
     55#define __syscall6  __syscall
    5656
    5757extern sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2,
  • uspace/lib/c/include/thread.h

    r6aef742 r197ef43  
    3636#define LIBC_THREAD_H_
    3737
    38 #include <kernel/proc/uarg.h>
    3938#include <libarch/thread.h>
    4039#include <sys/types.h>
     
    4241typedef uint64_t thread_id_t;
    4342
    44 extern void __thread_entry(void);
    45 extern void __thread_main(uspace_arg_t *);
    46 
    4743extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *);
    48 extern void thread_exit(int) __attribute__ ((noreturn));
     44extern void thread_exit(int) __attribute__((noreturn));
    4945extern void thread_detach(thread_id_t);
    5046extern int thread_join(thread_id_t);
  • uspace/lib/c/include/tls.h

    r6aef742 r197ef43  
    5757extern void tls_free_variant_1(tcb_t *, size_t);
    5858#endif
     59
    5960#ifdef CONFIG_TLS_VARIANT_2
    6061extern tcb_t *tls_alloc_variant_2(void **, size_t);
  • uspace/lib/c/include/unistd.h

    r6aef742 r197ef43  
    4141
    4242#ifndef NULL
    43         #define NULL    ((void *) 0)
     43        #define NULL  ((void *) 0)
    4444#endif
    4545
     
    7474extern int chdir(const char *);
    7575
    76 extern void _exit(int) __attribute__((noreturn));
     76extern void exit(int) __attribute__((noreturn));
    7777extern int usleep(useconds_t);
    7878extern unsigned int sleep(unsigned int);
  • uspace/lib/c/include/vfs/vfs.h

    r6aef742 r197ef43  
    5757extern int unmount(const char *);
    5858
    59 extern void __stdio_init(int filc, fdi_node_t *filv[]);
    60 extern void __stdio_done(void);
    61 
    6259extern int open_node(fdi_node_t *, int);
    6360extern int fd_phone(int);
Note: See TracChangeset for help on using the changeset viewer.