Changeset 04803bf in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2011-03-21T22:00:17Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (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 (needs fixes).

Location:
uspace/lib/c/include
Files:
53 added
76 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/hash_table.h

    rb50b5af2 r04803bf  
    4141typedef unsigned long hash_count_t;
    4242typedef unsigned long hash_index_t;
    43 typedef struct hash_table hash_table_t;
    44 typedef struct hash_table_operations hash_table_operations_t;
     43
     44/** Set of operations for hash table. */
     45typedef struct {
     46        /** Hash function.
     47         *
     48         * @param key Array of keys needed to compute hash index.
     49         *            All keys must be passed.
     50         *
     51         * @return Index into hash table.
     52         *
     53         */
     54        hash_index_t (*hash)(unsigned long key[]);
     55       
     56        /** Hash table item comparison function.
     57         *
     58         * @param key Array of keys that will be compared with item. It is
     59         *            not necessary to pass all keys.
     60         *
     61         * @return True if the keys match, false otherwise.
     62         *
     63         */
     64        int (*compare)(unsigned long key[], hash_count_t keys, link_t *item);
     65       
     66        /** Hash table item removal callback.
     67         *
     68         * @param item Item that was removed from the hash table.
     69         *
     70         */
     71        void (*remove_callback)(link_t *item);
     72} hash_table_operations_t;
    4573
    4674/** Hash table structure. */
    47 struct hash_table {
     75typedef struct {
    4876        link_t *entry;
    4977        hash_count_t entries;
    5078        hash_count_t max_keys;
    5179        hash_table_operations_t *op;
    52 };
    53 
    54 /** Set of operations for hash table. */
    55 struct hash_table_operations {
    56         /** Hash function.
    57          *
    58          * @param key   Array of keys needed to compute hash index. All keys
    59          *              must be passed.
    60          *
    61          * @return      Index into hash table.
    62          */
    63         hash_index_t (* hash)(unsigned long key[]);
    64        
    65         /** Hash table item comparison function.
    66          *
    67          * @param key   Array of keys that will be compared with item. It is
    68          *              not necessary to pass all keys.
    69          *
    70          * @return      true if the keys match, false otherwise.
    71          */
    72         int (*compare)(unsigned long key[], hash_count_t keys, link_t *item);
    73 
    74         /** Hash table item removal callback.
    75          *
    76          * @param item  Item that was removed from the hash table.
    77          */
    78         void (*remove_callback)(link_t *item);
    79 };
     80} hash_table_t;
    8081
    8182#define hash_table_get_instance(item, type, member) \
     
    8889extern void hash_table_remove(hash_table_t *, unsigned long [], hash_count_t);
    8990extern void hash_table_destroy(hash_table_t *);
     91extern void hash_table_apply(hash_table_t *, void (*)(link_t *, void *),
     92    void *);
    9093
    9194#endif
  • uspace/lib/c/include/as.h

    rb50b5af2 r04803bf  
    4141#include <libarch/config.h>
    4242
     43static inline size_t SIZE2PAGES(size_t size)
     44{
     45        if (size == 0)
     46                return 0;
     47       
     48        return (size_t) ((size - 1) >> PAGE_WIDTH) + 1;
     49}
     50
     51static inline size_t PAGES2SIZE(size_t pages)
     52{
     53        return (size_t) (pages << PAGE_WIDTH);
     54}
     55
    4356extern void *as_area_create(void *address, size_t size, int flags);
    4457extern int as_area_resize(void *address, size_t size, int flags);
  • uspace/lib/c/include/assert.h

    rb50b5af2 r04803bf  
    5151
    5252#ifndef NDEBUG
    53 #       define assert(expr) if (!(expr)) { printf("Assertion failed (%s) at file '%s', line %d.\n", #expr, __FILE__, __LINE__); abort();}
    54 #else
    55 #       define assert(expr)
    56 #endif
     53
     54#define assert(expr) \
     55        do { \
     56                if (!(expr)) { \
     57                        printf("Assertion failed (%s) at file '%s', " \
     58                            "line %d.\n", #expr, __FILE__, __LINE__); \
     59                        abort(); \
     60                } \
     61        } while (0)
     62
     63#else /* NDEBUG */
     64
     65#define assert(expr)
     66
     67#endif /* NDEBUG */
    5768
    5869#endif
  • uspace/lib/c/include/async.h

    rb50b5af2 r04803bf  
    3333 */
    3434
     35#if ((defined(LIBC_IPC_H_)) && (!defined(LIBC_ASYNC_C_)))
     36        #error Do not intermix low-level IPC interface and async framework
     37#endif
     38
    3539#ifndef LIBC_ASYNC_H_
    3640#define LIBC_ASYNC_H_
    3741
    38 #include <ipc/ipc.h>
     42#include <ipc/common.h>
     43#include <async_sess.h>
    3944#include <fibril.h>
    4045#include <sys/time.h>
    4146#include <atomic.h>
    4247#include <bool.h>
     48#include <task.h>
    4349
    4450typedef ipc_callid_t aid_t;
    45 typedef void (*async_client_conn_t)(ipc_callid_t callid, ipc_call_t *call);
    46 
    47 extern atomic_t async_futex;
     51
     52typedef void *(*async_client_data_ctor_t)(void);
     53typedef void (*async_client_data_dtor_t)(void *);
     54
     55typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *);
    4856
    4957extern atomic_t threads_in_ipc_wait;
    5058
    51 extern int __async_init(void);
    52 extern ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs);
    53 
    54 static inline ipc_callid_t async_get_call(ipc_call_t *data)
    55 {
    56         return async_get_call_timeout(data, 0);
    57 }
    58 
    59 static inline void async_manager(void)
    60 {
    61         fibril_switch(FIBRIL_TO_MANAGER);
    62 }
     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
     65extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
    6366
    6467/*
     
    8487            (arg5), (dataptr))
    8588
    86 extern aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
    87     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr);
    88 extern aid_t async_send_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
    89     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
    90     ipc_call_t *dataptr);
    91 extern void async_wait_for(aid_t amsgid, ipcarg_t *result);
    92 extern int async_wait_timeout(aid_t amsgid, ipcarg_t *retval,
    93     suseconds_t timeout);
    94 
    95 extern fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid,
    96     ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *));
    97 extern void async_usleep(suseconds_t timeout);
     89extern aid_t async_send_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     90    sysarg_t, ipc_call_t *);
     91extern aid_t async_send_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     92    sysarg_t, sysarg_t, ipc_call_t *);
     93extern void async_wait_for(aid_t, sysarg_t *);
     94extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t);
     95
     96extern fid_t async_new_connection(sysarg_t, sysarg_t, ipc_callid_t,
     97    ipc_call_t *, void (*)(ipc_callid_t, ipc_call_t *));
     98extern void async_usleep(suseconds_t);
    9899extern void async_create_manager(void);
    99100extern void async_destroy_manager(void);
    100101
    101 extern void async_set_client_connection(async_client_conn_t conn);
    102 extern void async_set_interrupt_received(async_client_conn_t conn);
    103 
    104 /* Wrappers for simple communication */
    105 #define async_msg_0(phone, method) \
    106         ipc_call_async_0((phone), (method), NULL, NULL, true)
    107 #define async_msg_1(phone, method, arg1) \
    108         ipc_call_async_1((phone), (method), (arg1), NULL, NULL, \
    109             true)
    110 #define async_msg_2(phone, method, arg1, arg2) \
    111         ipc_call_async_2((phone), (method), (arg1), (arg2), NULL, NULL, \
    112             true)
    113 #define async_msg_3(phone, method, arg1, arg2, arg3) \
    114         ipc_call_async_3((phone), (method), (arg1), (arg2), (arg3), NULL, NULL, \
    115             true)
    116 #define async_msg_4(phone, method, arg1, arg2, arg3, arg4) \
    117         ipc_call_async_4((phone), (method), (arg1), (arg2), (arg3), (arg4), NULL, \
    118             NULL, true)
    119 #define async_msg_5(phone, method, arg1, arg2, arg3, arg4, arg5) \
    120         ipc_call_async_5((phone), (method), (arg1), (arg2), (arg3), (arg4), \
    121             (arg5), NULL, NULL, true)
     102extern void async_set_client_data_constructor(async_client_data_ctor_t);
     103extern void async_set_client_data_destructor(async_client_data_dtor_t);
     104
     105extern void *async_client_data_get(void);
     106
     107extern void async_set_client_connection(async_client_conn_t);
     108extern void async_set_interrupt_received(async_client_conn_t);
     109
     110/*
     111 * Wrappers for simple communication.
     112 */
     113
     114extern void async_msg_0(int, sysarg_t);
     115extern void async_msg_1(int, sysarg_t, sysarg_t);
     116extern void async_msg_2(int, sysarg_t, sysarg_t, sysarg_t);
     117extern void async_msg_3(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     118extern void async_msg_4(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     119extern void async_msg_5(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     120    sysarg_t);
     121
     122/*
     123 * Wrappers for answer routines.
     124 */
     125
     126extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
     127extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
     128extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
     129extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     130    sysarg_t);
     131extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     132    sysarg_t, sysarg_t);
     133extern sysarg_t async_answer_5(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     134    sysarg_t, sysarg_t, sysarg_t);
     135
     136/*
     137 * Wrappers for forwarding routines.
     138 */
     139
     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);
    122144
    123145/*
     
    127149 * and slow verion based on m.
    128150 */
     151
    129152#define async_req_0_0(phoneid, method) \
    130153        async_req_fast((phoneid), (method), 0, 0, 0, 0, NULL, NULL, NULL, NULL, \
     
    242265            (arg5), (rc1), (rc2), (rc3), (rc4), (rc5))
    243266
    244 extern ipcarg_t async_req_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
    245     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t *r1, ipcarg_t *r2,
    246     ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5);
    247 extern ipcarg_t async_req_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
    248     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *r1,
    249     ipcarg_t *r2, ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5);
     267extern sysarg_t async_req_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     268    sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
     269extern sysarg_t async_req_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     270    sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
     271    sysarg_t *);
    250272
    251273static inline void async_serialize_start(void)
     
    259281}
    260282
     283extern int async_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t,
     284    async_client_conn_t);
     285extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
     286extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
     287extern int async_connect_kbox(task_id_t);
     288extern int async_hangup(int);
     289extern void async_poke(void);
     290
     291/*
     292 * User-friendly wrappers for async_share_in_start().
     293 */
     294
     295#define async_share_in_start_0_0(phoneid, dst, size) \
     296        async_share_in_start((phoneid), (dst), (size), 0, NULL)
     297#define async_share_in_start_0_1(phoneid, dst, size, flags) \
     298        async_share_in_start((phoneid), (dst), (size), 0, (flags))
     299#define async_share_in_start_1_0(phoneid, dst, size, arg) \
     300        async_share_in_start((phoneid), (dst), (size), (arg), NULL)
     301#define async_share_in_start_1_1(phoneid, dst, size, arg, flags) \
     302        async_share_in_start((phoneid), (dst), (size), (arg), (flags))
     303
     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 *);
     310extern int async_share_out_finalize(ipc_callid_t, void *);
     311
     312/*
     313 * User-friendly wrappers for async_data_read_forward_fast().
     314 */
     315
     316#define async_data_read_forward_0_0(phoneid, method, answer) \
     317        async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     318#define async_data_read_forward_0_1(phoneid, method, answer) \
     319        async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer))
     320#define async_data_read_forward_1_0(phoneid, method, arg1, answer) \
     321        async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL)
     322#define async_data_read_forward_1_1(phoneid, method, arg1, answer) \
     323        async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, (answer))
     324#define async_data_read_forward_2_0(phoneid, method, arg1, arg2, answer) \
     325        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, NULL)
     326#define async_data_read_forward_2_1(phoneid, method, arg1, arg2, answer) \
     327        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
     328            (answer))
     329#define async_data_read_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \
     330        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
     331            NULL)
     332#define async_data_read_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \
     333        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
     334            (answer))
     335#define async_data_read_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     336        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     337            (arg4), NULL)
     338#define async_data_read_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     339        async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     340            (arg4), (answer))
     341
     342extern int async_data_read_start(int, void *, size_t);
     343extern bool async_data_read_receive(ipc_callid_t *, size_t *);
     344extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
     345
     346extern int async_data_read_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
     347    sysarg_t, sysarg_t, ipc_call_t *);
     348
     349/*
     350 * User-friendly wrappers for async_data_write_forward_fast().
     351 */
     352
     353#define async_data_write_forward_0_0(phoneid, method, answer) \
     354        async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     355#define async_data_write_forward_0_1(phoneid, method, answer) \
     356        async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer))
     357#define async_data_write_forward_1_0(phoneid, method, arg1, answer) \
     358        async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL)
     359#define async_data_write_forward_1_1(phoneid, method, arg1, answer) \
     360        async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, \
     361            (answer))
     362#define async_data_write_forward_2_0(phoneid, method, arg1, arg2, answer) \
     363        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
     364            NULL)
     365#define async_data_write_forward_2_1(phoneid, method, arg1, arg2, answer) \
     366        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
     367            (answer))
     368#define async_data_write_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \
     369        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     370            0, NULL)
     371#define async_data_write_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \
     372        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     373            0, (answer))
     374#define async_data_write_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     375        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     376            (arg4), NULL)
     377#define async_data_write_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \
     378        async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     379            (arg4), (answer))
     380
     381extern int async_data_write_start(int, const void *, size_t);
     382extern bool async_data_write_receive(ipc_callid_t *, size_t *);
     383extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
     384
     385extern int async_data_write_accept(void **, const bool, const size_t,
     386    const size_t, const size_t, size_t *);
     387extern void async_data_write_void(sysarg_t);
     388
     389extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
     390    sysarg_t, sysarg_t, ipc_call_t *);
     391
    261392#endif
    262393
  • uspace/lib/c/include/atomic.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2009 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup ia32   
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_ia32_ARG_H_
    36 #define KERN_ia32_ARG_H_
     35#ifndef LIBC_ATOMIC_H_
     36#define LIBC_ATOMIC_H_
    3737
    38 #include <stackarg.h>
     38#include <libarch/atomic.h>
    3939
    4040#endif
  • uspace/lib/c/include/bool.h

    rb50b5af2 r04803bf  
    3636#define LIBC_BOOL_H_
    3737
    38 #define false 0
    39 #define true 1
     38#include <libarch/types.h>
    4039
    41 typedef short bool;
     40#define false  0
     41#define true   1
     42
     43typedef uint8_t bool;
    4244
    4345#endif
  • uspace/lib/c/include/byteorder.h

    rb50b5af2 r04803bf  
    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))
     86
    8287static inline uint64_t uint64_t_byteorder_swap(uint64_t n)
    8388{
  • uspace/lib/c/include/ddi.h

    rb50b5af2 r04803bf  
    3636#define LIBC_DDI_H_
    3737
     38#include <sys/types.h>
     39#include <kernel/ddi/irq.h>
    3840#include <task.h>
    3941
     
    4143extern int physmem_map(void *, void *, unsigned long, int);
    4244extern int iospace_enable(task_id_t, void *, unsigned long);
    43 extern int preemption_control(int);
    4445extern int pio_enable(void *, size_t, void **);
     46extern int register_irq(int, int, int, irq_code_t *);
     47extern int unregister_irq(int, int);
    4548
    4649#endif
  • uspace/lib/c/include/devmap.h

    rb50b5af2 r04803bf  
    3838#include <ipc/devmap.h>
    3939#include <async.h>
     40#include <bool.h>
    4041
    4142extern int devmap_get_phone(devmap_interface_t, unsigned int);
     
    4344
    4445extern int devmap_driver_register(const char *, async_client_conn_t);
    45 extern int devmap_device_register(const char *, dev_handle_t *);
     46extern int devmap_device_register(const char *, devmap_handle_t *);
     47extern int devmap_device_register_with_iface(const char *, devmap_handle_t *, sysarg_t);
    4648
    47 extern int devmap_device_get_handle(const char *, dev_handle_t *, unsigned int);
    48 extern int devmap_device_connect(dev_handle_t, unsigned int);
     49extern int devmap_device_get_handle(const char *, devmap_handle_t *, unsigned int);
     50extern int devmap_namespace_get_handle(const char *, devmap_handle_t *, unsigned int);
     51extern devmap_handle_type_t devmap_handle_probe(devmap_handle_t);
     52
     53extern int devmap_device_connect(devmap_handle_t, unsigned int);
    4954
    5055extern int devmap_null_create(void);
    5156extern void devmap_null_destroy(int);
    5257
    53 extern ipcarg_t devmap_device_get_count(void);
    54 extern ipcarg_t devmap_device_get_devices(ipcarg_t, dev_desc_t *);
     58extern size_t devmap_count_namespaces(void);
     59extern size_t devmap_count_devices(devmap_handle_t);
     60
     61extern size_t devmap_get_namespaces(dev_desc_t **);
     62extern size_t devmap_get_devices(devmap_handle_t, dev_desc_t **);
    5563
    5664#endif
  • uspace/lib/c/include/err.h

    rb50b5af2 r04803bf  
    3636#define LIBC_ERR_H_
    3737
    38 #define errx(status, fmt, ...) { \
    39         printf((fmt), ##__VA_ARGS__); \
    40         _exit(status); \
    41 }
     38#include <stdio.h>
     39
     40#define errx(status, fmt, ...) \
     41        do { \
     42                printf((fmt), ##__VA_ARGS__); \
     43                exit(status); \
     44        } while (0)
    4245
    4346#endif
  • uspace/lib/c/include/errno.h

    rb50b5af2 r04803bf  
    3939#include <fibril.h>
    4040
     41#define errno _errno
     42
    4143extern int _errno;
    4244
    43 #define errno _errno
    44 
    45 #define EMFILE        (-17)
     45#define EMFILE        (-18)
    4646#define ENAMETOOLONG  (-256)
    4747#define EISDIR        (-257)
     
    5656#define EMLINK        (-266)
    5757
     58/** An API function is called while another blocking function is in progress. */
     59#define EINPROGRESS  (-10036)
     60
     61/** The socket identifier is not valid. */
     62#define ENOTSOCK  (-10038)
     63
     64/** The destination address required. */
     65#define EDESTADDRREQ  (-10039)
     66
     67/** Protocol is not supported.  */
     68#define EPROTONOSUPPORT  (-10043)
     69
     70/** Socket type is not supported. */
     71#define ESOCKTNOSUPPORT  (-10044)
     72
     73/** Protocol family is not supported. */
     74#define EPFNOSUPPORT  (-10046)
     75
     76/** Address family is not supported. */
     77#define EAFNOSUPPORT  (-10047)
     78
     79/** Address is already in use. */
     80#define EADDRINUSE  (-10048)
     81
     82/** The socket is not connected or bound. */
     83#define ENOTCONN  (-10057)
     84
     85/** The requested operation was not performed. Try again later. */
     86#define EAGAIN  (-11002)
     87
     88/** No data. */
     89#define NO_DATA (-11004)
     90
    5891#endif
    5992
  • uspace/lib/c/include/event.h

    rb50b5af2 r04803bf  
    3737
    3838#include <kernel/ipc/event_types.h>
    39 #include <ipc/ipc.h>
    4039
    41 extern int event_subscribe(event_type_t, ipcarg_t);
     40extern int event_subscribe(event_type_t, sysarg_t);
    4241
    4342#endif
  • uspace/lib/c/include/fcntl.h

    rb50b5af2 r04803bf  
    4343#define O_RDWR    32
    4444#define O_WRONLY  64
     45#define O_DESC    128
    4546
    4647extern int open(const char *, int, ...);
  • uspace/lib/c/include/fibril.h

    rb50b5af2 r04803bf  
    4040#include <libarch/tls.h>
    4141
    42 #ifndef context_set
    43 #define context_set(c, _pc, stack, size, ptls) \
     42#define context_set_generic(c, _pc, stack, size, ptls) \
    4443        (c)->pc = (sysarg_t) (_pc); \
    4544        (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
    4645        (c)->tls = (sysarg_t) (ptls);
    47 #endif /* context_set */
    4846
    49 #define FIBRIL_SERIALIZED       1
    50 #define FIBRIL_WRITER           2
     47#define FIBRIL_SERIALIZED  1
     48#define FIBRIL_WRITER      2
     49
     50struct fibril;
     51
     52typedef struct {
     53        struct fibril *owned_by;
     54} fibril_owner_info_t;
    5155
    5256typedef enum {
     
    5963typedef sysarg_t fid_t;
    6064
    61 struct fibril {
     65typedef struct fibril {
    6266        link_t link;
    6367        context_t ctx;
     
    7074        int retval;
    7175        int flags;
    72 };
    73 typedef struct fibril fibril_t;
     76
     77        fibril_owner_info_t *waits_for;
     78} fibril_t;
    7479
    7580/** Fibril-local variable specifier */
    7681#define fibril_local __thread
    7782
    78 extern int context_save(context_t *c) __attribute__ ((returns_twice));
    79 extern void context_restore(context_t *c) __attribute__ ((noreturn));
     83extern int context_save(context_t *ctx) __attribute__((returns_twice));
     84extern void context_restore(context_t *ctx) __attribute__((noreturn));
    8085
    8186extern fid_t fibril_create(int (*func)(void *), void *arg);
     
    8994extern void fibril_inc_sercount(void);
    9095extern void fibril_dec_sercount(void);
     96extern int fibril_get_sercount(void);
    9197
    92 static inline int fibril_yield(void) {
     98static inline int fibril_yield(void)
     99{
    93100        return fibril_switch(FIBRIL_PREEMPT);
    94101}
  • uspace/lib/c/include/fibril_synch.h

    rb50b5af2 r04803bf  
    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 {
     45        fibril_owner_info_t oi;         /* Keep this the first thing. */
    4446        int counter;
    4547        link_t waiters;
    4648} fibril_mutex_t;
    4749
    48 #define FIBRIL_MUTEX_INITIALIZE(name) \
    49         fibril_mutex_t name = { \
     50#define FIBRIL_MUTEX_INITIALIZER(name) \
     51        { \
     52                .oi = { \
     53                        .owned_by = NULL \
     54                }, \
    5055                .counter = 1, \
    5156                .waiters = { \
     
    5459                } \
    5560        }
     61       
     62#define FIBRIL_MUTEX_INITIALIZE(name) \
     63        fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name)
    5664
    5765typedef struct {
     66        fibril_owner_info_t oi; /* Keep this the first thing. */
    5867        unsigned writers;
    5968        unsigned readers;
     
    6170} fibril_rwlock_t;
    6271
    63 #define FIBRIL_RWLOCK_INITIALIZE(name) \
    64         fibril_rwlock_t name = { \
     72#define FIBRIL_RWLOCK_INITIALIZER(name) \
     73        { \
     74                .oi = { \
     75                        .owned_by = NULL \
     76                }, \
    6577                .readers = 0, \
    6678                .writers = 0, \
     
    7183        }
    7284
     85#define FIBRIL_RWLOCK_INITIALIZE(name) \
     86        fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name)
     87
    7388typedef struct {
    7489        link_t waiters;
    7590} fibril_condvar_t;
    7691
    77 #define FIBRIL_CONDVAR_INITIALIZE(name) \
    78         fibril_condvar_t name = { \
     92#define FIBRIL_CONDVAR_INITIALIZER(name) \
     93        { \
    7994                .waiters = { \
    8095                        .next = &name.waiters, \
     
    8398        }
    8499
     100#define FIBRIL_CONDVAR_INITIALIZE(name) \
     101        fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name)
     102
    85103extern void fibril_mutex_initialize(fibril_mutex_t *);
    86104extern void fibril_mutex_lock(fibril_mutex_t *);
    87105extern bool fibril_mutex_trylock(fibril_mutex_t *);
    88106extern void fibril_mutex_unlock(fibril_mutex_t *);
     107extern bool fibril_mutex_is_locked(fibril_mutex_t *);
    89108
    90109extern void fibril_rwlock_initialize(fibril_rwlock_t *);
     
    93112extern void fibril_rwlock_read_unlock(fibril_rwlock_t *);
    94113extern void fibril_rwlock_write_unlock(fibril_rwlock_t *);
     114extern bool fibril_rwlock_is_read_locked(fibril_rwlock_t *);
     115extern bool fibril_rwlock_is_write_locked(fibril_rwlock_t *);
     116extern bool fibril_rwlock_is_locked(fibril_rwlock_t *);
    95117
    96118extern void fibril_condvar_initialize(fibril_condvar_t *);
     119extern int fibril_condvar_wait_timeout(fibril_condvar_t *, fibril_mutex_t *,
     120    suseconds_t);
    97121extern void fibril_condvar_wait(fibril_condvar_t *, fibril_mutex_t *);
    98122extern void fibril_condvar_signal(fibril_condvar_t *);
  • uspace/lib/c/include/futex.h

    rb50b5af2 r04803bf  
    3939#include <sys/types.h>
    4040
    41 #define FUTEX_INITIALIZER     {1}
     41#define FUTEX_INITIALIZER  {1}
    4242
    4343typedef atomic_t futex_t;
     
    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/c/include/inttypes.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2005 Ondrej Palkovsky
     2 * Copyright (c) 2010 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_INTTYPES_H_
     36#define LIBC_INTTYPES_H_
    3737
    38 #include <stdarg.h>
     38#include <libarch/inttypes.h>
    3939
    4040#endif
     
    4242/** @}
    4343 */
    44 
  • uspace/lib/c/include/io/color.h

    rb50b5af2 r04803bf  
    3636#define LIBC_IO_COLOR_H_
    3737
    38 enum console_color {
     38typedef enum {
    3939        COLOR_BLACK   = 0,
    4040        COLOR_BLUE    = 1,
     
    4848        CATTR_BRIGHT  = 8,
    4949        CATTR_BLINK   = 8
    50 };
     50} console_color_t;
    5151
    5252#endif
  • uspace/lib/c/include/io/console.h

    rb50b5af2 r04803bf  
    3636#define LIBC_IO_CONSOLE_H_
    3737
    38 #include <ipc/ipc.h>
    3938#include <bool.h>
    4039
     
    4443} console_ev_type_t;
    4544
    46 enum {
     45typedef enum {
    4746        CONSOLE_CCAP_NONE = 0,
    4847        CONSOLE_CCAP_STYLE,
    4948        CONSOLE_CCAP_INDEXED,
    5049        CONSOLE_CCAP_RGB
    51 };
     50} console_caps_t;
    5251
    5352/** Console event structure. */
     
    6867extern void console_clear(int phone);
    6968
    70 extern int console_get_size(int phone, ipcarg_t *rows, ipcarg_t *cols);
    71 extern void console_goto(int phone, ipcarg_t row, ipcarg_t col);
     69extern int console_get_size(int phone, sysarg_t *cols, sysarg_t *rows);
     70extern int console_get_pos(int phone, sysarg_t *col, sysarg_t *row);
     71extern void console_set_pos(int phone, sysarg_t col, sysarg_t row);
    7272
    73 extern void console_set_style(int phone, int style);
    74 extern void console_set_color(int phone, int fg_color, int bg_color, int flags);
    75 extern void console_set_rgb_color(int phone, int fg_color, int bg_color);
     73extern void console_set_style(int phone, uint8_t style);
     74extern void console_set_color(int phone, uint8_t fg_color, uint8_t bg_color,
     75    uint8_t flags);
     76extern void console_set_rgb_color(int phone, uint32_t fg_color, uint32_t bg_color);
    7677
    7778extern void console_cursor_visibility(int phone, bool show);
    78 extern int console_get_color_cap(int phone, int *ccap);
     79extern int console_get_color_cap(int phone, sysarg_t *ccap);
    7980extern void console_kcon_enable(int phone);
    8081
  • uspace/lib/c/include/io/keycode.h

    rb50b5af2 r04803bf  
    5151 * they really are organized here by position, rather than by label.
    5252 */
    53 enum keycode {
     53typedef enum {
    5454
    5555        /* Main block row 1 */
     
    199199} keycode_t;
    200200
    201 enum keymod {
     201typedef enum {
    202202        KM_LSHIFT      = 0x001,
    203203        KM_RSHIFT      = 0x002,
  • uspace/lib/c/include/io/klog.h

    rb50b5af2 r04803bf  
    3333 */
    3434
    35 #ifndef LIBC_STREAM_H_
    36 #define LIBC_STREAM_H_
     35#ifndef LIBC_IO_KLOG_H_
     36#define LIBC_IO_KLOG_H_
    3737
    3838#include <sys/types.h>
    3939
    40 extern size_t klog_write(const void *buf, size_t size);
     40extern size_t klog_write(const void *, size_t);
    4141extern void klog_update(void);
    4242
  • uspace/lib/c/include/io/printf_core.h

    rb50b5af2 r04803bf  
    4040
    4141/** Structure for specifying output methods for different printf clones. */
    42 typedef struct printf_spec {
     42typedef struct {
    4343        /* String output function, returns number of printed characters or EOF */
    4444        int (*str_write)(const char *, size_t, void *);
     
    5151} printf_spec_t;
    5252
    53 int printf_core(const char *fmt, printf_spec_t *ps, va_list ap);
     53extern int printf_core(const char *, printf_spec_t *, va_list);
    5454
    5555#endif
  • uspace/lib/c/include/io/screenbuffer.h

    rb50b5af2 r04803bf  
    3333 */
    3434
    35 #ifndef SCREENBUFFER_H__
    36 #define SCREENBUFFER_H__
     35#ifndef LIBC_SCREENBUFFER_H__
     36#define LIBC_SCREENBUFFER_H__
    3737
    3838#include <stdint.h>
     
    4040#include <bool.h>
    4141
    42 #define DEFAULT_FOREGROUND  0x0       /**< default console foreground color */
    43 #define DEFAULT_BACKGROUND  0xf0f0f0  /**< default console background color */
     42typedef enum {
     43        at_style,
     44        at_idx,
     45        at_rgb
     46} attr_type_t;
    4447
    4548typedef struct {
     
    5861} attr_rgb_t;
    5962
     63typedef union {
     64        attr_style_t s;
     65        attr_idx_t i;
     66        attr_rgb_t r;
     67} attr_val_t;
     68
    6069typedef struct {
    61         enum {
    62                 at_style,
    63                 at_idx,
    64                 at_rgb
    65         } t;
    66         union {
    67                 attr_style_t s;
    68                 attr_idx_t i;
    69                 attr_rgb_t r;
    70         } a;
     70        attr_type_t t;
     71        attr_val_t a;
    7172} attrs_t;
    7273
     
    8283        keyfield_t *buffer;      /**< Screen content - characters and
    8384                                      their attributes (used as a circular buffer) */
    84         size_t size_x;           /**< Number of columns  */
    85         size_t size_y;           /**< Number of rows */
     85        sysarg_t size_x;         /**< Number of columns  */
     86        sysarg_t size_y;         /**< Number of rows */
    8687       
    8788        /** Coordinates of last printed character for determining cursor position */
    88         size_t position_x;
    89         size_t position_y;
     89        sysarg_t position_x;
     90        sysarg_t position_y;
    9091       
    9192        attrs_t attrs;           /**< Current attributes. */
     
    107108 *
    108109 */
    109 static inline keyfield_t *get_field_at(screenbuffer_t *scr, size_t x, size_t y)
     110static inline keyfield_t *get_field_at(screenbuffer_t *scr, sysarg_t x, sysarg_t y)
    110111{
    111112        return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
     
    120121 *
    121122 */
    122 static inline int attrs_same(attrs_t a1, attrs_t a2)
     123static inline bool attrs_same(attrs_t a1, attrs_t a2)
    123124{
    124125        if (a1.t != a2.t)
    125                 return 0;
     126                return false;
    126127       
    127128        switch (a1.t) {
     
    137138        }
    138139       
    139         return 0;
     140        return false;
    140141}
    141142
     143extern void screenbuffer_putchar(screenbuffer_t *, wchar_t);
     144extern screenbuffer_t *screenbuffer_init(screenbuffer_t *, sysarg_t, sysarg_t);
    142145
    143 void screenbuffer_putchar(screenbuffer_t *scr, wchar_t c);
    144 screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, size_t size_x, size_t size_y);
    145 
    146 void screenbuffer_clear(screenbuffer_t *scr);
    147 void screenbuffer_clear_line(screenbuffer_t *scr, size_t line);
    148 void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest);
    149 void screenbuffer_goto(screenbuffer_t *scr, size_t x, size_t y);
    150 void screenbuffer_set_style(screenbuffer_t *scr, uint8_t style);
    151 void screenbuffer_set_color(screenbuffer_t *scr, uint8_t fg_color,
    152     uint8_t bg_color, uint8_t attr);
    153 void screenbuffer_set_rgb_color(screenbuffer_t *scr, uint32_t fg_color,
    154     uint32_t bg_color);
     146extern void screenbuffer_clear(screenbuffer_t *);
     147extern void screenbuffer_clear_line(screenbuffer_t *, sysarg_t);
     148extern void screenbuffer_copy_buffer(screenbuffer_t *, keyfield_t *);
     149extern void screenbuffer_goto(screenbuffer_t *, sysarg_t, sysarg_t);
     150extern void screenbuffer_set_style(screenbuffer_t *, uint8_t);
     151extern void screenbuffer_set_color(screenbuffer_t *, uint8_t, uint8_t, uint8_t);
     152extern void screenbuffer_set_rgb_color(screenbuffer_t *, uint32_t, uint32_t);
    155153
    156154#endif
  • uspace/lib/c/include/io/style.h

    rb50b5af2 r04803bf  
    3636#define LIBC_IO_STYLE_H_
    3737
    38 enum console_style {
     38typedef enum {
    3939        STYLE_NORMAL   = 0,
    40         STYLE_EMPHASIS = 1
    41 };
     40        STYLE_EMPHASIS = 1,
     41        STYLE_INVERTED = 2,
     42        STYLE_SELECTED = 3
     43} console_style_t;
    4244
    4345#endif
  • uspace/lib/c/include/ipc/bd.h

    rb50b5af2 r04803bf  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_IPC_BD_H_
    3636#define LIBC_IPC_BD_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
    41         BD_READ_BLOCK = IPC_FIRST_USER_METHOD,
    42         BD_WRITE_BLOCK
     41        BD_GET_BLOCK_SIZE = IPC_FIRST_USER_METHOD,
     42        BD_GET_NUM_BLOCKS,
     43        BD_READ_BLOCKS,
     44        BD_WRITE_BLOCKS
    4345} bd_request_t;
    4446
  • uspace/lib/c/include/ipc/console.h

    rb50b5af2 r04803bf  
    3636#define LIBC_IPC_CONSOLE_H_
    3737
    38 #include <ipc/ipc.h>
    3938#include <ipc/vfs.h>
    4039
     
    4342        CONSOLE_GET_COLOR_CAP,
    4443        CONSOLE_GET_EVENT,
     44        CONSOLE_GET_POS,
    4545        CONSOLE_GOTO,
    4646        CONSOLE_CLEAR,
  • uspace/lib/c/include/ipc/devmap.h

    rb50b5af2 r04803bf  
    3434#define DEVMAP_DEVMAP_H_
    3535
    36 #include <atomic.h>
    37 #include <ipc/ipc.h>
    38 #include <adt/list.h>
     36#include <ipc/common.h>
    3937
    4038#define DEVMAP_NAME_MAXLEN  255
    4139
    42 typedef ipcarg_t dev_handle_t;
     40typedef sysarg_t devmap_handle_t;
     41
     42typedef enum {
     43        DEV_HANDLE_NONE,
     44        DEV_HANDLE_NAMESPACE,
     45        DEV_HANDLE_DEVICE
     46} devmap_handle_type_t;
    4347
    4448typedef enum {
     
    4751        DEVMAP_DEVICE_REGISTER,
    4852        DEVMAP_DEVICE_UNREGISTER,
    49         DEVMAP_DEVICE_GET_NAME,
    5053        DEVMAP_DEVICE_GET_HANDLE,
    51         DEVMAP_DEVICE_NULL_CREATE,
    52         DEVMAP_DEVICE_NULL_DESTROY,
    53         DEVMAP_DEVICE_GET_COUNT,
    54         DEVMAP_DEVICE_GET_DEVICES
     54        DEVMAP_NAMESPACE_GET_HANDLE,
     55        DEVMAP_HANDLE_PROBE,
     56        DEVMAP_NULL_CREATE,
     57        DEVMAP_NULL_DESTROY,
     58        DEVMAP_GET_NAMESPACE_COUNT,
     59        DEVMAP_GET_DEVICE_COUNT,
     60        DEVMAP_GET_NAMESPACES,
     61        DEVMAP_GET_DEVICES
    5562} devmap_request_t;
    5663
     
    7279
    7380typedef struct {
    74         dev_handle_t handle;
     81        devmap_handle_t handle;
    7582        char name[DEVMAP_NAME_MAXLEN + 1];
    7683} dev_desc_t;
  • uspace/lib/c/include/ipc/fb.h

    rb50b5af2 r04803bf  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_FB_H_
    3636#define LIBC_FB_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
  • uspace/lib/c/include/ipc/ipc.h

    rb50b5af2 r04803bf  
    3333 */
    3434
    35 #ifndef LIBIPC_IPC_H_
    36 #define LIBIPC_IPC_H_
    37 
     35#if ((defined(LIBC_ASYNC_H_)) && (!defined(LIBC_ASYNC_C_)))
     36        #error Do not intermix low-level IPC interface and async framework
     37#endif
     38
     39#ifndef LIBC_IPC_H_
     40#define LIBC_IPC_H_
     41
     42#include <sys/types.h>
     43#include <ipc/common.h>
     44#include <kernel/synch/synch.h>
    3845#include <task.h>
    39 #include <kernel/ipc/ipc.h>
    40 #include <kernel/ddi/irq.h>
    41 #include <sys/types.h>
    42 #include <kernel/synch/synch.h>
    43 
    44 #define IPC_FLAG_BLOCKING  0x01
    45 
    46 typedef sysarg_t ipcarg_t;
    47 
    48 typedef struct {
    49         ipcarg_t args[IPC_CALL_LEN];
    50         ipcarg_t in_phone_hash;
    51 } ipc_call_t;
    52 
    53 typedef sysarg_t ipc_callid_t;
    54 
    55 typedef void (* ipc_async_callback_t)(void *, int, ipc_call_t *);
     46
     47typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
    5648
    5749/*
     
    6153 * possible, the fast version is used.
    6254 */
     55
    6356#define ipc_call_sync_0_0(phoneid, method) \
    6457        ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
     
    183176            (arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
    184177
    185 extern int ipc_call_sync_fast(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
    186     ipcarg_t *, ipcarg_t *, ipcarg_t *, ipcarg_t *, ipcarg_t *);
    187 
    188 extern int ipc_call_sync_slow(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
    189     ipcarg_t, ipcarg_t, ipcarg_t *, ipcarg_t *, ipcarg_t *, ipcarg_t *,
    190     ipcarg_t *);
    191 
    192 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int);
    193 extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, uint32_t);
     178extern int ipc_call_sync_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     179    sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
     180
     181extern int ipc_call_sync_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     182    sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
     183    sysarg_t *);
     184
     185extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
    194186extern void ipc_poke(void);
    195187
    196 static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data)
    197 {
    198         return ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
    199 }
    200 
     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);
    201192extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
    202193
     
    207198 * to m.
    208199 */
     200
    209201#define ipc_answer_0(callid, retval) \
    210202        ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
     
    220212        ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
    221213
    222 extern ipcarg_t ipc_answer_fast(ipc_callid_t, ipcarg_t, ipcarg_t, ipcarg_t,
    223     ipcarg_t, ipcarg_t);
    224 extern ipcarg_t ipc_answer_slow(ipc_callid_t, ipcarg_t, ipcarg_t, ipcarg_t,
    225     ipcarg_t, ipcarg_t, ipcarg_t);
     214extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     215    sysarg_t, sysarg_t);
     216extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     217    sysarg_t, sysarg_t, sysarg_t);
    226218
    227219/*
     
    231223 * to m.
    232224 */
     225
    233226#define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \
    234227        ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \
     
    255248            (arg4), (arg5), (private), (callback), (can_preempt))
    256249
    257 extern void ipc_call_async_fast(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
    258     ipcarg_t, void *, ipc_async_callback_t, int);
    259 extern void ipc_call_async_slow(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
    260     ipcarg_t, ipcarg_t, void *, ipc_async_callback_t, int);
    261 
    262 extern int ipc_connect_to_me(int, int, int, int, ipcarg_t *);
    263 extern int ipc_connect_me_to(int, int, int, int);
    264 extern int ipc_connect_me_to_blocking(int, int, int, int);
     250extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     251    sysarg_t, void *, ipc_async_callback_t, bool);
     252extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     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
    265260extern int ipc_hangup(int);
    266 extern int ipc_register_irq(int, int, int, irq_code_t *);
    267 extern int ipc_unregister_irq(int, int);
    268 extern int ipc_forward_fast(ipc_callid_t, int, int, ipcarg_t, ipcarg_t, int);
    269 extern int ipc_forward_slow(ipc_callid_t, int, int, ipcarg_t, ipcarg_t,
    270     ipcarg_t, ipcarg_t, ipcarg_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);
    271266
    272267/*
    273268 * User-friendly wrappers for ipc_share_in_start().
    274269 */
     270
    275271#define ipc_share_in_start_0_0(phoneid, dst, size) \
    276272        ipc_share_in_start((phoneid), (dst), (size), 0, NULL)
     
    282278        ipc_share_in_start((phoneid), (dst), (size), (arg), (flags))
    283279
    284 extern int ipc_share_in_start(int, void *, size_t, ipcarg_t, int *);
    285 extern int ipc_share_in_receive(ipc_callid_t *, size_t *);
    286 extern int ipc_share_in_finalize(ipc_callid_t, void *, int );
    287 extern int ipc_share_out_start(int, void *, int);
    288 extern int ipc_share_out_receive(ipc_callid_t *, size_t *, 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);
    289283extern int ipc_share_out_finalize(ipc_callid_t, void *);
    290284extern int ipc_data_read_start(int, void *, size_t);
    291 extern int ipc_data_read_receive(ipc_callid_t *, size_t *);
    292285extern int ipc_data_read_finalize(ipc_callid_t, const void *, size_t);
    293286extern int ipc_data_write_start(int, const void *, size_t);
    294 extern int ipc_data_write_receive(ipc_callid_t *, size_t *);
    295287extern int ipc_data_write_finalize(ipc_callid_t, void *, size_t);
    296288
  • uspace/lib/c/include/ipc/irc.h

    rb50b5af2 r04803bf  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    35 #ifndef LIBC_BUS_H_
    36 #define LIBC_BUS_H_
     35#ifndef LIBC_IRC_H_
     36#define LIBC_IRC_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
    41         BUS_CLEAR_INTERRUPT = IPC_FIRST_USER_METHOD
    42 } bus_request_t;
     41        IRC_ENABLE_INTERRUPT = IPC_FIRST_USER_METHOD,
     42        IRC_CLEAR_INTERRUPT
     43} irc_request_t;
    4344
    4445#endif
  • uspace/lib/c/include/ipc/kbd.h

    rb50b5af2 r04803bf  
    3838#define LIBC_IPC_KBD_H_
    3939
    40 #include <ipc/ipc.h>
     40#include <ipc/common.h>
    4141
    4242typedef enum {
  • uspace/lib/c/include/ipc/loader.h

    rb50b5af2 r04803bf  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_IPC_LOADER_H_
    3636#define LIBC_IPC_LOADER_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <ipc/common.h>
    3939
    4040typedef enum {
    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/c/include/ipc/ns.h

    rb50b5af2 r04803bf  
    3333 */
    3434
    35 #ifndef LIBIPC_NS_H_
    36 #define LIBIPC_NS_H_
     35#ifndef LIBC_NS_H_
     36#define LIBC_NS_H_
    3737
    38 #include <ipc/ipc.h>
     38#include <sys/types.h>
     39#include <ipc/common.h>
    3940
    4041typedef enum {
     
    4546} ns_request_t;
    4647
     48extern int service_register(sysarg_t);
     49extern int service_connect(sysarg_t, sysarg_t, sysarg_t);
     50extern int service_connect_blocking(sysarg_t, sysarg_t, sysarg_t);
     51
    4752#endif
    4853
  • uspace/lib/c/include/ipc/services.h

    rb50b5af2 r04803bf  
    3535 */
    3636
    37 #ifndef LIBIPC_SERVICES_H_
    38 #define LIBIPC_SERVICES_H_
     37#ifndef LIBC_SERVICES_H_
     38#define LIBC_SERVICES_H_
    3939
    4040typedef enum {
    41         SERVICE_LOAD = 1,
     41        SERVICE_NONE = 0,
     42        SERVICE_LOAD,
    4243        SERVICE_PCI,
    43         SERVICE_KEYBOARD,
    4444        SERVICE_VIDEO,
    4545        SERVICE_CONSOLE,
    4646        SERVICE_VFS,
    4747        SERVICE_DEVMAP,
     48        SERVICE_DEVMAN,
    4849        SERVICE_FHC,
    49         SERVICE_OBIO
     50        SERVICE_OBIO,
     51        SERVICE_APIC,
     52        SERVICE_I8259,
     53        SERVICE_CLIPBOARD,
     54        SERVICE_NETWORKING,
     55        SERVICE_LO,
     56        SERVICE_NE2000,
     57        SERVICE_ETHERNET,
     58        SERVICE_NILDUMMY,
     59        SERVICE_IP,
     60        SERVICE_ARP,
     61        SERVICE_RARP,
     62        SERVICE_ICMP,
     63        SERVICE_UDP,
     64        SERVICE_TCP,
     65        SERVICE_SOCKET
    5066} services_t;
    51 
    52 /* Memory area to be received from NS */
    53 #define SERVICE_MEM_REALTIME    1
    54 #define SERVICE_MEM_KLOG        2
    5567
    5668#endif
  • uspace/lib/c/include/ipc/vfs.h

    rb50b5af2 r04803bf  
    3636#define LIBC_IPC_VFS_H_
    3737
     38#include <ipc/common.h>
    3839#include <sys/types.h>
    39 #include <ipc/ipc.h>
     40#include <bool.h>
    4041
    4142#define FS_NAME_MAXLEN  20
     
    5556        /** Unique identifier of the fs. */
    5657        char name[FS_NAME_MAXLEN + 1];
     58        bool concurrent_read_write;
     59        bool write_retains_size;
    5760} vfs_info_t;
    5861
     
    7376        VFS_IN_UNLINK,
    7477        VFS_IN_RENAME,
    75         VFS_IN_STAT
     78        VFS_IN_STAT,
     79        VFS_IN_DUP
    7680} vfs_in_request_t;
    7781
     
    8589        VFS_OUT_MOUNTED,
    8690        VFS_OUT_UNMOUNT,
     91        VFS_OUT_UNMOUNTED,
    8792        VFS_OUT_SYNC,
    8893        VFS_OUT_STAT,
     
    99104 * No lookup flags used.
    100105 */
    101 #define L_NONE  0
     106#define L_NONE                  0
    102107
    103108/**
     
    106111 * with L_DIRECTORY.
    107112 */
    108 #define L_FILE  1
     113#define L_FILE                  1
    109114
    110115/**
    111  * Lookup wil succeed only if the object is a directory. If L_CREATE is
     116 * Lookup will succeed only if the object is a directory. If L_CREATE is
    112117 * specified, an empty directory will be created. This flag is mutually
    113118 * exclusive with L_FILE.
    114119 */
    115 #define L_DIRECTORY  2
     120#define L_DIRECTORY             2
     121
     122/**
     123 * Lookup will succeed only if the object is a root directory. The flag is
     124 * mutually exclusive with L_FILE and L_MP.
     125 */
     126#define L_ROOT                  4
     127
     128/**
     129 * Lookup will succeed only if the object is a mount point. The flag is mutually
     130 * exclusive with L_FILE and L_ROOT.
     131 */
     132#define L_MP                    8
     133
    116134
    117135/**
     
    119137 * object already exists. L_EXCLUSIVE is implied when L_DIRECTORY is used.
    120138 */
    121 #define L_EXCLUSIVE  4
     139#define L_EXCLUSIVE             16
    122140
    123141/**
    124142 * L_CREATE is used for creating both regular files and directories.
    125143 */
    126 #define L_CREATE  8
     144#define L_CREATE                32
    127145
    128146/**
    129147 * L_LINK is used for linking to an already existing nodes.
    130148 */
    131 #define L_LINK  16
     149#define L_LINK                  64
    132150
    133151/**
     
    136154 * VFS_UNLINK.
    137155 */
    138 #define L_UNLINK  32
     156#define L_UNLINK                128
    139157
    140158/**
    141  * L_OPEN is used to indicate that the lookup operation is a part of VFS_OPEN
     159 * L_OPEN is used to indicate that the lookup operation is a part of VFS_IN_OPEN
    142160 * call from the client. This means that the server might allocate some
    143161 * resources for the opened file. This flag cannot be passed directly by the
    144162 * client.
    145163 */
    146 #define L_OPEN  64
     164#define L_OPEN                  256
    147165
    148166#endif
  • uspace/lib/c/include/libc.h

    rb50b5af2 r04803bf  
    4040#include <libarch/syscall.h>
    4141
     42#ifdef __32_BITS__
     43
     44/** Explicit 64-bit arguments passed to syscalls. */
     45typedef uint64_t sysarg64_t;
     46
     47#endif /* __32_BITS__ */
     48
    4249#define __SYSCALL0(id) \
    4350        __syscall0(0, 0, 0, 0, 0, 0, id)
     
    5360        __syscall5(p1, p2, p3, p4, p5, 0, id)
    5461#define __SYSCALL6(id, p1, p2, p3, p4, p5, p6) \
    55     __syscall6(p1, p2, p3, p4, p5, p6, id)
    56 
    57 extern void __main(void *pcb_ptr);
    58 extern void __exit(void);
     62        __syscall6(p1, p2, p3, p4, p5, p6, id)
    5963
    6064#endif
  • uspace/lib/c/include/loader/loader.h

    rb50b5af2 r04803bf  
    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 *);
    52 extern int loader_set_args(loader_t *, char *const[]);
     53extern int loader_set_args(loader_t *, const char *const[]);
    5354extern int loader_set_files(loader_t *, fdi_node_t *const[]);
    5455extern int loader_load_program(loader_t *);
  • uspace/lib/c/include/loader/pcb.h

    rb50b5af2 r04803bf  
    5353        entry_point_t entry;
    5454       
     55        /** Current working directory. */
     56        char *cwd;
     57       
    5558        /** Number of command-line arguments. */
    5659        int argc;
  • uspace/lib/c/include/macros.h

    rb50b5af2 r04803bf  
    4848#define STRING_ARG(arg)  #arg
    4949
    50 #define LOWER32(arg)  ((arg) & 0xffffffff)
    51 #define UPPER32(arg)  (((arg) >> 32) & 0xffffffff)
     50#define LOWER32(arg)  (((uint64_t) (arg)) & 0xffffffff)
     51#define UPPER32(arg)  (((((uint64_t) arg)) >> 32) & 0xffffffff)
    5252
    5353#define MERGE_LOUP32(lo, up) \
  • uspace/lib/c/include/malloc.h

    rb50b5af2 r04803bf  
    3838#include <sys/types.h>
    3939
    40 extern void __heap_init(void);
    41 extern uintptr_t get_max_heap_addr(void);
    42 
    43 extern void *malloc(const size_t size);
    44 extern void *memalign(const size_t align, const size_t size);
     40extern void *malloc(const size_t size)
     41    __attribute__((malloc));
     42extern void *calloc(const size_t nmemb, const size_t size)
     43    __attribute__((malloc));
     44extern void *memalign(const size_t align, const size_t size)
     45    __attribute__((malloc));
    4546extern void *realloc(const void *addr, const size_t size);
    4647extern void free(const void *addr);
  • uspace/lib/c/include/mem.h

    rb50b5af2 r04803bf  
    4444extern void *memmove(void *, const void *, size_t);
    4545
    46 extern int bcmp(const char *, const char *, size_t);
     46extern int bcmp(const void *, const void *, size_t);
    4747
    4848#endif
  • uspace/lib/c/include/net/icmp_common.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2009 Lukas Mejdrech
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup libc
    30  * @{
    31  */
    32 /** @file
     30 *  @{
    3331 */
    3432
    35 #ifndef LIBC_ATOMIC_H_
    36 #define LIBC_ATOMIC_H_
     33/** @file
     34 * ICMP module common interface.
     35 */
    3736
    38 typedef struct atomic {
    39         volatile long count;
    40 } atomic_t;
     37#ifndef LIBC_ICMP_COMMON_H_
     38#define LIBC_ICMP_COMMON_H_
    4139
    42 #include <libarch/atomic.h>
     40#include <ipc/services.h>
     41#include <sys/time.h>
    4342
    44 static inline void atomic_set(atomic_t *val, long i)
    45 {
    46         val->count = i;
    47 }
     43/** Default timeout for incoming connections in microseconds (1 sec). */
     44#define ICMP_CONNECT_TIMEOUT  1000000
    4845
    49 static inline long atomic_get(atomic_t *val)
    50 {
    51         return val->count;
    52 }
     46extern int icmp_connect_module(suseconds_t);
    5347
    5448#endif
  • uspace/lib/c/include/net/ip_protocols.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2009 Martin Decky
     2 * Copyright (c) 2009 Lukas Mejdrech
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup libc
    30  * @{
    31  */
    32 /** @file
     30 *  @{
    3331 */
    3432
    35 #ifndef BOOT_MACROS_H_
    36 #define BOOT_MACROS_H_
     33/** @file
     34 * Internet protocol numbers according to the on-line IANA - Assigned Protocol
     35 * numbers:
     36 *
     37 * http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml
     38 */
    3739
    38 #define min(a, b)  ((a) < (b) ? (a) : (b))
    39 #define max(a, b)  ((a) > (b) ? (a) : (b))
     40#ifndef LIBC_IP_PROTOCOLS_H_
     41#define LIBC_IP_PROTOCOLS_H_
    4042
    41 #define SIZE2KB(size)  ((size) >> 10)
    42 #define SIZE2MB(size)  ((size) >> 20)
     43/** @name IP protocols definitions */
     44/*@{*/
    4345
    44 #define KB2SIZE(kb)  ((kb) << 10)
    45 #define MB2SIZE(mb)  ((mb) << 20)
     46#define IPPROTO_ICMP    1
     47#define IPPROTO_TCP     6
     48#define IPPROTO_UDP     17
    4649
    47 #define STRING(arg)      STRING_ARG(arg)
    48 #define STRING_ARG(arg)  #arg
     50/*@}*/
    4951
    5052#endif
  • uspace/lib/c/include/setjmp.h

    rb50b5af2 r04803bf  
    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/stdarg.h

    rb50b5af2 r04803bf  
    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/c/include/stdio.h

    rb50b5af2 r04803bf  
    3838#include <sys/types.h>
    3939#include <stdarg.h>
    40 #include <string.h>
     40#include <str.h>
    4141#include <adt/list.h>
     42
     43#ifndef NVERIFY_PRINTF
     44
     45#define PRINTF_ATTRIBUTE(start, end) \
     46        __attribute__((format(gnu_printf, start, end)))
     47
     48#else /* NVERIFY_PRINTF */
     49
     50#define PRINTF_ATTRIBUTE(start, end)
     51
     52#endif /* NVERIFY_PRINTF */
    4253
    4354#define EOF  (-1)
     
    5667#ifndef SEEK_SET
    5768        #define SEEK_SET  0
     69#endif
     70
     71#ifndef SEEK_CUR
    5872        #define SEEK_CUR  1
     73#endif
     74
     75#ifndef SEEK_END
    5976        #define SEEK_END  2
    6077#endif
     
    6986};
    7087
     88enum _buffer_state {
     89        /** Buffer is empty */
     90        _bs_empty,
     91
     92        /** Buffer contains data to be written */
     93        _bs_write,
     94
     95        /** Buffer contains prefetched data for reading */
     96        _bs_read
     97};
     98
    7199typedef struct {
    72100        /** Linked list pointer. */
     
    88116        int phone;
    89117
     118        /**
     119         * Non-zero if the stream needs sync on fflush(). XXX change
     120         * console semantics so that sync is not needed.
     121         */
     122        int need_sync;
     123
    90124        /** Buffering type */
    91125        enum _buffer_type btype;
     126
    92127        /** Buffer */
    93128        uint8_t *buf;
     129
    94130        /** Buffer size */
    95131        size_t buf_size;
     132
     133        /** Buffer state */
     134        enum _buffer_state buf_state;
     135
    96136        /** Buffer I/O pointer */
    97137        uint8_t *buf_head;
     138
     139        /** Points to end of occupied space when in read mode. */
     140        uint8_t *buf_tail;
    98141} FILE;
    99142
     
    104147/* Character and string input functions */
    105148extern int fgetc(FILE *);
    106 extern char *fgets(char *, size_t, FILE *);
     149extern char *fgets(char *, int, FILE *);
    107150
    108151extern int getchar(void);
     
    117160
    118161/* Formatted string output functions */
    119 extern int fprintf(FILE *, const char*, ...);
     162extern int fprintf(FILE *, const char*, ...)
     163    PRINTF_ATTRIBUTE(2, 3);
    120164extern int vfprintf(FILE *, const char *, va_list);
    121165
    122 extern int printf(const char *, ...);
     166extern int printf(const char *, ...)
     167    PRINTF_ATTRIBUTE(1, 2);
    123168extern int vprintf(const char *, va_list);
    124169
    125 extern int snprintf(char *, size_t , const char *, ...);
    126 extern int asprintf(char **, const char *, ...);
     170extern int snprintf(char *, size_t , const char *, ...)
     171    PRINTF_ATTRIBUTE(3, 4);
     172extern int asprintf(char **, const char *, ...)
     173    PRINTF_ATTRIBUTE(2, 3);
    127174extern int vsnprintf(char *, size_t, const char *, va_list);
    128175
     
    135182extern size_t fwrite(const void *, size_t, size_t, FILE *);
    136183
    137 extern int fseek(FILE *, long, int);
     184extern int fseek(FILE *, off64_t, int);
    138185extern void rewind(FILE *);
    139 extern int ftell(FILE *);
     186extern off64_t ftell(FILE *);
    140187extern int feof(FILE *);
     188extern int fileno(FILE *);
    141189
    142190extern int fflush(FILE *);
  • uspace/lib/c/include/stdlib.h

    rb50b5af2 r04803bf  
    3838#include <unistd.h>
    3939#include <malloc.h>
    40 
    41 #define abort()       _exit(1)
    42 #define exit(status)  _exit((status))
     40#include <stacktrace.h>
    4341
    4442#define RAND_MAX  714025
     43
     44#define rand()       random()
     45#define srand(seed)  srandom(seed)
    4546
    4647extern long int random(void);
    4748extern void srandom(unsigned int seed);
    4849
    49 static inline int rand(void)
    50 {
    51         return random();
    52 }
    53 
    54 static inline void srand(unsigned int seed)
    55 {
    56         srandom(seed);
    57 }
     50extern void abort(void) __attribute__((noreturn));
    5851
    5952#endif
  • uspace/lib/c/include/str.h

    rb50b5af2 r04803bf  
    3333 */
    3434
    35 #ifndef LIBC_STRING_H_
    36 #define LIBC_STRING_H_
     35#ifndef LIBC_STR_H_
     36#define LIBC_STR_H_
    3737
    3838#include <mem.h>
     
    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);
     87
     88extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
     89extern int str_size_t(const char *, char **, unsigned int, bool, size_t *);
     90
     91extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix);
    8492
    8593/*
  • uspace/lib/c/include/sys/mman.h

    rb50b5af2 r04803bf  
    4141#define MAP_FAILED  ((void *) -1)
    4242
    43 #define MAP_SHARED       (1 << 0)
    44 #define MAP_PRIVATE      (1 << 1)
    45 #define MAP_FIXED        (1 << 2)
    46 #define MAP_ANONYMOUS    (1 << 3)
     43#define MAP_SHARED     (1 << 0)
     44#define MAP_PRIVATE    (1 << 1)
     45#define MAP_FIXED      (1 << 2)
     46#define MAP_ANONYMOUS  (1 << 3)
    4747
    4848#define PROTO_READ   AS_AREA_READ
     
    5050#define PROTO_EXEC   AS_AREA_EXEC
    5151
    52 extern void *mmap(void  *start, size_t length, int prot, int flags, int fd,
    53     off_t offset);
     52extern void *mmap(void *start, size_t length, int prot, int flags, int fd,
     53    aoff64_t offset);
    5454extern int munmap(void *start, size_t length);
    5555
  • uspace/lib/c/include/sys/stat.h

    rb50b5af2 r04803bf  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_SYS_STAT_H_
     
    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        devmap_handle_t devmap_handle;
     46        fs_index_t index;
     47        unsigned int lnkcnt;
     48        bool is_file;
     49        bool is_directory;
     50        aoff64_t size;
     51        devmap_handle_t device;
    5552};
    5653
  • uspace/lib/c/include/sys/time.h

    rb50b5af2 r04803bf  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_SYS_TIME_H_
     
    4343typedef long suseconds_t;
    4444
     45typedef uint32_t useconds_t;
     46typedef uint32_t mseconds_t;
     47
    4548struct timeval {
    46         time_t         tv_sec;        /* seconds */
    47         suseconds_t    tv_usec;  /* microseconds */
     49        time_t tv_sec;        /* seconds */
     50        suseconds_t tv_usec;  /* microseconds */
    4851};
    4952
    5053struct timezone {
    51         int  tz_minuteswest; /* minutes W of Greenwich */
    52         int  tz_dsttime;     /* type of dst correction */
     54        int tz_minuteswest; /* minutes W of Greenwich */
     55        int tz_dsttime;      /* type of dst correction */
    5356};
    5457
  • uspace/lib/c/include/sys/types.h

    rb50b5af2 r04803bf  
    3838#include <libarch/types.h>
    3939
    40 typedef long off_t;
    41 typedef int mode_t;
     40typedef unsigned int mode_t;
    4241
    43 typedef int32_t wchar_t;
     42/** Relative offset */
     43typedef int64_t off64_t;
     44
     45/** Absolute offset */
     46typedef uint64_t aoff64_t;
    4447
    4548typedef volatile uint8_t ioport8_t;
  • uspace/lib/c/include/syscall.h

    rb50b5af2 r04803bf  
    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/sysinfo.h

    rb50b5af2 r04803bf  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_SYSINFO_H_
     
    3737
    3838#include <libc.h>
    39 #include <sysinfo.h>
    40 #include <string.h>
    4139
    42 sysarg_t sysinfo_value(char *name);
     40/** Sysinfo value types
     41 *
     42 */
     43typedef enum {
     44        SYSINFO_VAL_UNDEFINED = 0,
     45        SYSINFO_VAL_VAL = 1,
     46        SYSINFO_VAL_DATA = 2
     47} sysinfo_item_tag_t;
     48
     49extern sysinfo_item_tag_t sysinfo_get_tag(const char *);
     50extern int sysinfo_get_value(const char *, sysarg_t *);
     51extern void *sysinfo_get_data(const char *, size_t *);
    4352
    4453#endif
  • uspace/lib/c/include/task.h

    rb50b5af2 r04803bf  
    4646
    4747extern task_id_t task_get_id(void);
    48 extern int task_set_name(const char *name);
    49 extern task_id_t task_spawn(const char *path, char *const argv[]);
    50 extern int task_wait(task_id_t id, task_exit_t *texit, int *retval);
    51 extern int task_retval(int val);
     48extern int task_set_name(const char *);
     49extern int task_kill(task_id_t);
    5250
     51extern task_id_t task_spawn(const char *, const char *const[], int *);
     52extern int task_spawnv(task_id_t *, const char *path, const char *const []);
     53extern int task_spawnl(task_id_t *, const char *path, ...);
     54
     55extern int task_wait(task_id_t id, task_exit_t *, int *);
     56extern int task_retval(int);
    5357
    5458#endif
  • uspace/lib/c/include/thread.h

    rb50b5af2 r04803bf  
    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 
    47 extern int thread_create(void (*)(void *), void *, char *, thread_id_t *);
    48 extern void thread_exit(int) __attribute__ ((noreturn));
     43extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *);
     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

    rb50b5af2 r04803bf  
    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/udebug.h

    rb50b5af2 r04803bf  
    3838#include <kernel/udebug/udebug.h>
    3939#include <sys/types.h>
    40 #include <libarch/types.h>
    4140
    4241typedef sysarg_t thash_t;
    4342
    44 int udebug_begin(int phoneid);
    45 int udebug_end(int phoneid);
    46 int udebug_set_evmask(int phoneid, udebug_evmask_t mask);
    47 int udebug_thread_read(int phoneid, void *buffer, size_t n,
    48         size_t *copied, size_t *needed);
    49 int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n);
    50 int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer);
    51 int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type,
    52         sysarg_t *val0, sysarg_t *val1);
    53 int udebug_stop(int phoneid, thash_t tid);
     43int udebug_begin(int);
     44int udebug_end(int);
     45int udebug_set_evmask(int, udebug_evmask_t);
     46int udebug_thread_read(int, void *, size_t , size_t *, size_t *);
     47int udebug_name_read(int, void *, size_t, size_t *, size_t *);
     48int udebug_areas_read(int, void *, size_t, size_t *, size_t *);
     49int udebug_mem_read(int, void *, uintptr_t, size_t);
     50int udebug_args_read(int, thash_t, sysarg_t *);
     51int udebug_regs_read(int, thash_t, void *);
     52int udebug_go(int, thash_t, udebug_event_t *, sysarg_t *, sysarg_t *);
     53int udebug_stop(int, thash_t);
    5454
    5555#endif
  • uspace/lib/c/include/unistd.h

    rb50b5af2 r04803bf  
    3737
    3838#include <sys/types.h>
     39#include <time.h>
    3940#include <libarch/config.h>
    4041
    4142#ifndef NULL
    42         #define NULL  0
     43        #define NULL  ((void *) 0)
     44#endif
     45
     46#ifndef SEEK_SET
     47        #define SEEK_SET  0
     48#endif
     49
     50#ifndef SEEK_CUR
     51        #define SEEK_CUR  1
     52#endif
     53
     54#ifndef SEEK_END
     55        #define SEEK_END  2
    4356#endif
    4457
    4558#define getpagesize()  (PAGE_SIZE)
    4659
    47 #ifndef SEEK_SET
    48         #define SEEK_SET  0
    49         #define SEEK_CUR  1
    50         #define SEEK_END  2
    51 #endif
     60extern int dup2(int oldfd, int newfd);
    5261
    5362extern ssize_t write(int, const void *, size_t);
    5463extern ssize_t read(int, void *, size_t);
    5564
    56 extern off_t lseek(int, off_t, int);
    57 extern int ftruncate(int, off_t);
     65extern off64_t lseek(int, off64_t, int);
     66extern int ftruncate(int, aoff64_t);
    5867
    5968extern int close(int);
     
    6574extern int chdir(const char *);
    6675
    67 extern void _exit(int status) __attribute__ ((noreturn));
    68 extern int usleep(unsigned long usec);
    69 extern unsigned int sleep(unsigned int seconds);
     76extern void exit(int) __attribute__((noreturn));
     77extern int usleep(useconds_t);
     78extern unsigned int sleep(unsigned int);
    7079
    7180#endif
  • uspace/lib/c/include/vfs/vfs.h

    rb50b5af2 r04803bf  
    4343/**
    4444 * This type is a libc version of the VFS triplet.
    45  * It uniquelly identifies a file system node within a file system instance.
     45 * It uniquely identifies a file system node within a file system instance.
    4646 */
    4747typedef struct {
    4848        fs_handle_t fs_handle;
    49         dev_handle_t dev_handle;
     49        devmap_handle_t devmap_handle;
    5050        fs_index_t index;
    5151} fdi_node_t;
     
    5555extern int mount(const char *, const char *, const char *, const char *,
    5656    unsigned int);
    57 
    58 extern void __stdio_init(int filc, fdi_node_t *filv[]);
    59 extern void __stdio_done(void);
     57extern int unmount(const char *);
    6058
    6159extern int open_node(fdi_node_t *, int);
Note: See TracChangeset for help on using the changeset viewer.