Changeset 47b7006 in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2011-01-29T23:02:39Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
197ef43
Parents:
fd483ce
Message:

improve run-time termination

  • get rid of exit()
  • get rid of _exit(), use the common exit()
  • get rid of core(), use the common abort()
  • make main() more fail-safe (call abort() on unhealthy conditions), call async_sess_init() explicitly
  • add several libc-private headers for cleaner environment
  • use SYS_TASK_EXIT in exit() and abort()
Location:
uspace/lib/c/include
Files:
14 edited

Legend:

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

    rfd483ce r47b7006  
    5757extern atomic_t threads_in_ipc_wait;
    5858
     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
    5965extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
    60 
    61 static inline ipc_callid_t async_get_call(ipc_call_t *data)
    62 {
    63         return async_get_call_timeout(data, 0);
    64 }
    65 
    66 static inline void async_manager(void)
    67 {
    68         fibril_switch(FIBRIL_TO_MANAGER);
    69 }
    7066
    7167/*
     
    142138 */
    143139
    144 extern int async_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
    145 extern int async_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
    146     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);
    147144
    148145/*
     
    305302        async_share_in_start((phoneid), (dst), (size), (arg), (flags))
    306303
    307 extern int async_share_in_start(int, void *, size_t, sysarg_t, int *);
    308 extern int async_share_in_receive(ipc_callid_t *, size_t *);
    309 extern int async_share_in_finalize(ipc_callid_t, void *, int );
    310 extern int async_share_out_start(int, void *, int);
    311 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 *);
    312310extern int async_share_out_finalize(ipc_callid_t, void *);
    313311
     
    343341
    344342extern int async_data_read_start(int, void *, size_t);
    345 extern int async_data_read_receive(ipc_callid_t *, size_t *);
     343extern bool async_data_read_receive(ipc_callid_t *, size_t *);
    346344extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
    347345
     
    382380
    383381extern int async_data_write_start(int, const void *, size_t);
    384 extern int async_data_write_receive(ipc_callid_t *, size_t *);
     382extern bool async_data_write_receive(ipc_callid_t *, size_t *);
    385383extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
    386384
    387385extern int async_data_write_accept(void **, const bool, const size_t,
    388386    const size_t, const size_t, size_t *);
    389 extern void async_data_write_void(const int);
     387extern void async_data_write_void(sysarg_t);
    390388
    391389extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
  • uspace/lib/c/include/async_sess.h

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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/loader/pcb.h

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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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

    rfd483ce r47b7006  
    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.