Changeset 46c20c8 in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2010-11-26T20:08:10Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45df59a
Parents:
fb150d78 (diff), ffdd2b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/lib/c/include
Files:
43 added
85 moved

Legend:

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

    rfb150d78 r46c20c8  
    5151
    5252#ifndef NDEBUG
    53 #       define assert(expr) \
    54                 do { \
    55                         if (!(expr)) { \
    56                                 printf("Assertion failed (%s) at file '%s', " \
    57                                     "line %d.\n", #expr, __FILE__, __LINE__); \
    58                                 abort(); \
    59                         } \
    60                 } while (0)
    61 #else
    62 #       define assert(expr)
    63 #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 */
    6468
    6569#endif
  • uspace/lib/c/include/async.h

    rfb150d78 r46c20c8  
    259259}
    260260
     261extern int async_connect_me_to(int, ipcarg_t, ipcarg_t, ipcarg_t);
     262extern int async_connect_me_to_blocking(int, ipcarg_t, ipcarg_t, ipcarg_t);
     263
    261264/*
    262265 * User-friendly wrappers for async_share_in_start().
  • uspace/lib/c/include/async_rel.h

    rfb150d78 r46c20c8  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    35 #include <libc.h>
    36 #include <sysinfo.h>
    37 #include <string.h>
     35#ifndef LIBC_ASYNC_REL_H_
     36#define LIBC_ASYNC_REL_H_
    3837
    39 sysarg_t sysinfo_value(char *name)
    40 {
    41         return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t ) name,
    42             (sysarg_t) str_size(name));
    43 }
     38extern int async_rel_init(void);
     39extern int async_relation_create(int);
     40extern void async_relation_destroy(int, int);
     41
     42#endif
    4443
    4544/** @}
  • uspace/lib/c/include/atomicdflt.h

    rfb150d78 r46c20c8  
    3737
    3838#ifndef LIBC_ARCH_ATOMIC_H_
    39 #error This file cannot be included directly, include atomic.h instead.
     39        #error This file cannot be included directly, include atomic.h instead.
    4040#endif
    4141
     42#include <stdint.h>
    4243#include <bool.h>
    4344
    4445typedef struct atomic {
    45         volatile long count;
     46        volatile atomic_count_t count;
    4647} atomic_t;
    4748
    48 static inline void atomic_set(atomic_t *val, long i)
     49static inline void atomic_set(atomic_t *val, atomic_count_t i)
    4950{
    50         val->count = i;
     51        val->count = i;
    5152}
    5253
    53 static inline long atomic_get(atomic_t *val)
     54static inline atomic_count_t atomic_get(atomic_t *val)
    5455{
    55         return val->count;
     56        return val->count;
    5657}
    5758
    58 #ifndef CAS 
    59 static inline bool cas(atomic_t *val, long ov, long nv)
     59#ifndef CAS
     60static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
    6061{
    6162        return __sync_bool_compare_and_swap(&val->count, ov, nv);
  • uspace/lib/c/include/bool.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    4141extern int physmem_map(void *, void *, unsigned long, int);
    4242extern int iospace_enable(task_id_t, void *, unsigned long);
    43 extern int preemption_control(int);
    4443extern int pio_enable(void *, size_t, void **);
     44extern int interrupt_enable(int);
     45extern int interrupt_disable(int);
    4546
    4647#endif
  • uspace/lib/c/include/device/char.h

    rfb150d78 r46c20c8  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2010 Lenka Trochtova
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
     29 /** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef BOOT_PRINTF_H_
    36 #define BOOT_PRINTF_H_
     35#ifndef LIBC_DEVICE_HW_RES_H_
     36#define LIBC_DEVICE_HW_RES_H_
    3737
    38 #define INT8    1
    39 #define INT16   2
    40 #define INT32   4
    41 #define INT64   8
     38typedef enum {
     39        CHAR_READ_DEV = 0,
     40        CHAR_WRITE_DEV
     41} hw_res_funcs_t;
    4242
    43 extern void puts(const char *str);
    44 extern void printf(const char *fmt, ...);
    45 
    46 extern void write(const char *str, const int len);
     43ssize_t read_dev(int dev_phone, void *buf, size_t len);
     44ssize_t write_dev(int dev_phone, void *buf, size_t len);
    4745
    4846#endif
  • uspace/lib/c/include/devmap.h

    rfb150d78 r46c20c8  
    4444
    4545extern int devmap_driver_register(const char *, async_client_conn_t);
    46 extern int devmap_device_register(const char *, dev_handle_t *);
     46extern int devmap_device_register(const char *, devmap_handle_t *);
    4747
    48 extern int devmap_device_get_handle(const char *, dev_handle_t *, unsigned int);
    49 extern int devmap_namespace_get_handle(const char *, dev_handle_t *, unsigned int);
    50 extern devmap_handle_type_t devmap_handle_probe(dev_handle_t);
     48extern int devmap_device_get_handle(const char *, devmap_handle_t *, unsigned int);
     49extern int devmap_namespace_get_handle(const char *, devmap_handle_t *, unsigned int);
     50extern devmap_handle_type_t devmap_handle_probe(devmap_handle_t);
    5151
    52 extern int devmap_device_connect(dev_handle_t, unsigned int);
     52extern int devmap_device_connect(devmap_handle_t, unsigned int);
    5353
    5454extern int devmap_null_create(void);
     
    5656
    5757extern size_t devmap_count_namespaces(void);
    58 extern size_t devmap_count_devices(dev_handle_t);
     58extern size_t devmap_count_devices(devmap_handle_t);
    5959
    6060extern size_t devmap_get_namespaces(dev_desc_t **);
    61 extern size_t devmap_get_devices(dev_handle_t, dev_desc_t **);
     61extern size_t devmap_get_devices(devmap_handle_t, dev_desc_t **);
    6262
    6363#endif
  • uspace/lib/c/include/err.h

    rfb150d78 r46c20c8  
    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        { \
     42                printf((fmt), ##__VA_ARGS__); \
     43                _exit(status); \
     44        }
    4245
    4346#endif
  • uspace/lib/c/include/fibril.h

    rfb150d78 r46c20c8  
    4848#define FIBRIL_WRITER      2
    4949
     50struct fibril;
     51
     52typedef struct {
     53        struct fibril *owned_by;
     54} fibril_owner_info_t;
     55
    5056typedef enum {
    5157        FIBRIL_PREEMPT,
     
    6874        int retval;
    6975        int flags;
     76
     77        fibril_owner_info_t *waits_for;
    7078} fibril_t;
    7179
  • uspace/lib/c/include/fibril_synch.h

    rfb150d78 r46c20c8  
    4343
    4444typedef struct {
     45        fibril_owner_info_t oi;         /* Keep this the first thing. */
    4546        int counter;
    4647        link_t waiters;
    4748} fibril_mutex_t;
    4849
    49 #define FIBRIL_MUTEX_INITIALIZE(name) \
    50         fibril_mutex_t name = { \
     50#define FIBRIL_MUTEX_INITIALIZER(name) \
     51        { \
     52                .oi = { \
     53                        .owned_by = NULL \
     54                }, \
    5155                .counter = 1, \
    5256                .waiters = { \
     
    5559                } \
    5660        }
     61       
     62#define FIBRIL_MUTEX_INITIALIZE(name) \
     63        fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name)
    5764
    5865typedef struct {
     66        fibril_owner_info_t oi; /* Keep this the first thing. */
    5967        unsigned writers;
    6068        unsigned readers;
     
    6270} fibril_rwlock_t;
    6371
    64 #define FIBRIL_RWLOCK_INITIALIZE(name) \
    65         fibril_rwlock_t name = { \
     72#define FIBRIL_RWLOCK_INITIALIZER(name) \
     73        { \
     74                .oi = { \
     75                        .owned_by = NULL \
     76                }, \
    6677                .readers = 0, \
    6778                .writers = 0, \
     
    7283        }
    7384
     85#define FIBRIL_RWLOCK_INITIALIZE(name) \
     86        fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name)
     87
    7488typedef struct {
    7589        link_t waiters;
    7690} fibril_condvar_t;
    7791
    78 #define FIBRIL_CONDVAR_INITIALIZE(name) \
    79         fibril_condvar_t name = { \
     92#define FIBRIL_CONDVAR_INITIALIZER(name) \
     93        { \
    8094                .waiters = { \
    8195                        .next = &name.waiters, \
     
    8397                } \
    8498        }
     99
     100#define FIBRIL_CONDVAR_INITIALIZE(name) \
     101        fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name)
    85102
    86103extern void fibril_mutex_initialize(fibril_mutex_t *);
  • uspace/lib/c/include/futex.h

    rfb150d78 r46c20c8  
    3939#include <sys/types.h>
    4040
    41 #define FUTEX_INITIALIZER     {1}
     41#define FUTEX_INITIALIZER  {1}
    4242
    4343typedef atomic_t futex_t;
  • uspace/lib/c/include/io/color.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    4444} console_ev_type_t;
    4545
    46 enum {
     46typedef enum {
    4747        CONSOLE_CCAP_NONE = 0,
    4848        CONSOLE_CCAP_STYLE,
    4949        CONSOLE_CCAP_INDEXED,
    5050        CONSOLE_CCAP_RGB
    51 };
     51} console_caps_t;
    5252
    5353/** Console event structure. */
     
    6868extern void console_clear(int phone);
    6969
    70 extern int console_get_size(int phone, int *cols, int *rows);
    71 extern int console_get_pos(int phone, int *col, int *row);
    72 extern void console_goto(int phone, int col, int row);
     70extern int console_get_size(int phone, ipcarg_t *cols, ipcarg_t *rows);
     71extern int console_get_pos(int phone, ipcarg_t *col, ipcarg_t *row);
     72extern void console_set_pos(int phone, ipcarg_t col, ipcarg_t row);
    7373
    74 extern void console_set_style(int phone, int style);
    75 extern void console_set_color(int phone, int fg_color, int bg_color, int flags);
    76 extern void console_set_rgb_color(int phone, int fg_color, int bg_color);
     74extern void console_set_style(int phone, uint8_t style);
     75extern void console_set_color(int phone, uint8_t fg_color, uint8_t bg_color,
     76    uint8_t flags);
     77extern void console_set_rgb_color(int phone, uint32_t fg_color, uint32_t bg_color);
    7778
    7879extern void console_cursor_visibility(int phone, bool show);
    79 extern int console_get_color_cap(int phone, int *ccap);
     80extern int console_get_color_cap(int phone, ipcarg_t *ccap);
    8081extern void console_kcon_enable(int phone);
    8182
  • uspace/lib/c/include/io/keycode.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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>
    3939#include <sys/types.h>
     40#include <ipc/ipc.h>
    4041#include <bool.h>
    4142
    42 #define DEFAULT_FOREGROUND  0x0       /**< default console foreground color */
    43 #define DEFAULT_BACKGROUND  0xf0f0f0  /**< default console background color */
     43typedef enum {
     44        at_style,
     45        at_idx,
     46        at_rgb
     47} attr_type_t;
    4448
    4549typedef struct {
     
    5862} attr_rgb_t;
    5963
     64typedef union {
     65        attr_style_t s;
     66        attr_idx_t i;
     67        attr_rgb_t r;
     68} attr_val_t;
     69
    6070typedef 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;
     71        attr_type_t t;
     72        attr_val_t a;
    7173} attrs_t;
    7274
     
    8284        keyfield_t *buffer;      /**< Screen content - characters and
    8385                                      their attributes (used as a circular buffer) */
    84         size_t size_x;           /**< Number of columns  */
    85         size_t size_y;           /**< Number of rows */
     86        ipcarg_t size_x;         /**< Number of columns  */
     87        ipcarg_t size_y;         /**< Number of rows */
    8688       
    8789        /** Coordinates of last printed character for determining cursor position */
    88         size_t position_x;
    89         size_t position_y;
     90        ipcarg_t position_x;
     91        ipcarg_t position_y;
    9092       
    9193        attrs_t attrs;           /**< Current attributes. */
     
    107109 *
    108110 */
    109 static inline keyfield_t *get_field_at(screenbuffer_t *scr, size_t x, size_t y)
     111static inline keyfield_t *get_field_at(screenbuffer_t *scr, ipcarg_t x, ipcarg_t y)
    110112{
    111113        return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
     
    120122 *
    121123 */
    122 static inline int attrs_same(attrs_t a1, attrs_t a2)
     124static inline bool attrs_same(attrs_t a1, attrs_t a2)
    123125{
    124126        if (a1.t != a2.t)
    125                 return 0;
     127                return false;
    126128       
    127129        switch (a1.t) {
     
    137139        }
    138140       
    139         return 0;
     141        return false;
    140142}
    141143
     144extern void screenbuffer_putchar(screenbuffer_t *, wchar_t);
     145extern screenbuffer_t *screenbuffer_init(screenbuffer_t *, ipcarg_t, ipcarg_t);
    142146
    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);
     147extern void screenbuffer_clear(screenbuffer_t *);
     148extern void screenbuffer_clear_line(screenbuffer_t *, ipcarg_t);
     149extern void screenbuffer_copy_buffer(screenbuffer_t *, keyfield_t *);
     150extern void screenbuffer_goto(screenbuffer_t *, ipcarg_t, ipcarg_t);
     151extern void screenbuffer_set_style(screenbuffer_t *, uint8_t);
     152extern void screenbuffer_set_color(screenbuffer_t *, uint8_t, uint8_t, uint8_t);
     153extern void screenbuffer_set_rgb_color(screenbuffer_t *, uint32_t, uint32_t);
    155154
    156155#endif
  • uspace/lib/c/include/io/style.h

    rfb150d78 r46c20c8  
    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/devmap.h

    rfb150d78 r46c20c8  
    4040#define DEVMAP_NAME_MAXLEN  255
    4141
    42 typedef ipcarg_t dev_handle_t;
     42typedef ipcarg_t devmap_handle_t;
    4343
    4444typedef enum {
     
    8181
    8282typedef struct {
    83         dev_handle_t handle;
     83        devmap_handle_t handle;
    8484        char name[DEVMAP_NAME_MAXLEN + 1];
    8585} dev_desc_t;
  • uspace/lib/c/include/ipc/net_net.h

    rfb150d78 r46c20c8  
    11/*
    2  * Copyright (c) 2006 Ondrej Palkovsky
     2 * Copyright (c) 2009 Lukas Mejdrech
    33 * All rights reserved.
    44 *
     
    3030 * @{
    3131 */
     32
    3233/** @file
     34 * Networking subsystem central module messages.
     35 * @see net_interface.h
    3336 */
    3437
    35 #ifndef LIBC_ERRNO_H_
    36 #define LIBC_ERRNO_H_
     38#ifndef LIBC_NET_NET_MESSAGES_H_
     39#define LIBC_NET_NET_MESSAGES_H_
    3740
    38 #include <kernel/errno.h>
    39 #include <fibril.h>
     41#include <ipc/ipc.h>
     42#include <ipc/net.h>
    4043
    41 extern int _errno;
    42 
    43 #define errno _errno
    44 
    45 #define EMFILE        (-17)
    46 #define ENAMETOOLONG  (-256)
    47 #define EISDIR        (-257)
    48 #define ENOTDIR       (-258)
    49 #define ENOSPC        (-259)
    50 #define EEXIST        (-260)
    51 #define ENOTEMPTY     (-261)
    52 #define EBADF         (-262)
    53 #define ERANGE        (-263)
    54 #define EXDEV         (-264)
    55 #define EIO           (-265)
    56 #define EMLINK        (-266)
     44/** Networking subsystem central module messages. */
     45typedef enum {
     46        /** Returns the general configuration
     47         * @see net_get_conf_req()
     48         */
     49        NET_NET_GET_CONF = NET_FIRST,
     50        /** Returns the device specific configuration
     51         * @see net_get_device_conf_req()
     52         */
     53        NET_NET_GET_DEVICE_CONF,
     54        /** Starts the networking stack. */
     55        NET_NET_STARTUP,
     56} net_messages;
    5757
    5858#endif
  • uspace/lib/c/include/ipc/packet.h

    rfb150d78 r46c20c8  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2009 Lukas Mejdrech
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup sync
    30  * @{
    31  */
    32 /** @file
     29/** @addtogroup libc
     30 *  @{
    3331 */
    3432
    35 #ifndef KERN_RWLOCK_H_
    36 #define KERN_RWLOCK_H_
     33/** @file
     34 *  Packet server module messages.
     35 */
    3736
    38 #include <arch/types.h>
    39 #include <synch/mutex.h>
    40 #include <synch/synch.h>
    41 #include <synch/spinlock.h>
     37#ifndef LIBC_PACKET_MESSAGES_
     38#define LIBC_PACKET_MESSAGES_
    4239
     40#include <ipc/ipc.h>
     41#include <ipc/net.h>
     42
     43/** Packet server module messages. */
    4344typedef enum {
    44         RWLOCK_NONE,
    45         RWLOCK_READER,
    46         RWLOCK_WRITER
    47 } rwlock_type_t;
     45        /** Create packet message with specified content length.
     46         * @see packet_get_1()
     47         */
     48        NET_PACKET_CREATE_1 = NET_PACKET_FIRST,
     49       
     50        /**
     51         * Create packet message with specified address length, prefix, content
     52         * and suffix.
     53         * @see packet_get_4()
     54         */
     55        NET_PACKET_CREATE_4,
     56       
     57        /** Get packet message.
     58         * @see packet_return() */
     59        NET_PACKET_GET,
     60       
     61        /** Get packet size message.
     62         * @see packet_translate()
     63         */
     64        NET_PACKET_GET_SIZE,
     65       
     66        /** Release packet message.
     67         * @see pq_release()
     68         */
     69        NET_PACKET_RELEASE
     70} packet_messages;
    4871
    49 typedef struct {
    50         SPINLOCK_DECLARE(lock);
    51         /**
    52          * Mutex for writers, readers can bypass it if readers_in is positive.
    53          */
    54         mutex_t exclusive;
    55         /** Number of readers in critical section. */
    56         size_t readers_in;
    57 } rwlock_t;
     72/** Returns the protocol service message parameter. */
     73#define ARP_GET_PROTO(call)     (services_t) IPC_GET_ARG2(*call)
    5874
    59 #define rwlock_write_lock(rwl) \
    60         _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    61 #define rwlock_read_lock(rwl) \
    62         _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    63 #define rwlock_write_trylock(rwl) \
    64         _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    65             SYNCH_FLAGS_NON_BLOCKING)
    66 #define rwlock_read_trylock(rwl) \
    67         _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    68             SYNCH_FLAGS_NON_BLOCKING)
    69 #define rwlock_write_lock_timeout(rwl, usec) \
    70         _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
    71 #define rwlock_read_lock_timeout(rwl, usec) \
    72         _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
     75/** Returns the packet identifier message parameter. */
     76#define IPC_GET_ID(call)        (packet_id_t) IPC_GET_ARG1(*call)
    7377
    74 extern void rwlock_initialize(rwlock_t *rwl);
    75 extern void rwlock_read_unlock(rwlock_t *rwl);
    76 extern void rwlock_write_unlock(rwlock_t *rwl);
    77 extern int _rwlock_read_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
    78 extern int _rwlock_write_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
     78/** Returns the maximal content length message parameter. */
     79#define IPC_GET_CONTENT(call)   (size_t) IPC_GET_ARG1(*call)
     80
     81/** Returns the maximal address length message parameter. */
     82#define IPC_GET_ADDR_LEN(call)  (size_t) IPC_GET_ARG2(*call)
     83
     84/** Returns the maximal prefix length message parameter. */
     85#define IPC_GET_PREFIX(call)    (size_t) IPC_GET_ARG3(*call)
     86
     87/** Returns the maximal suffix length message parameter. */
     88#define IPC_GET_SUFFIX(call)    (size_t) IPC_GET_ARG4(*call)
    7989
    8090#endif
  • uspace/lib/c/include/ipc/services.h

    rfb150d78 r46c20c8  
    3939
    4040typedef enum {
    41         SERVICE_LOAD = 1,
     41        SERVICE_NONE = 0,
     42        SERVICE_LOAD,
    4243        SERVICE_PCI,
    4344        SERVICE_VIDEO,
     
    4546        SERVICE_VFS,
    4647        SERVICE_DEVMAP,
     48        SERVICE_DEVMAN,
    4749        SERVICE_FHC,
    4850        SERVICE_OBIO,
    49         SERVICE_CLIPBOARD
     51        SERVICE_CLIPBOARD,
     52        SERVICE_NETWORKING,
     53        SERVICE_LO,
     54        SERVICE_DP8390,
     55        SERVICE_ETHERNET,
     56        SERVICE_NILDUMMY,
     57        SERVICE_IP,
     58        SERVICE_ARP,
     59        SERVICE_RARP,
     60        SERVICE_ICMP,
     61        SERVICE_UDP,
     62        SERVICE_TCP,
     63        SERVICE_SOCKET
    5064} services_t;
    5165
  • uspace/lib/c/include/loader/loader.h

    rfb150d78 r46c20c8  
    5151extern int loader_set_cwd(loader_t *);
    5252extern int loader_set_pathname(loader_t *, const char *);
    53 extern int loader_set_args(loader_t *, char *const[]);
     53extern int loader_set_args(loader_t *, const char *const[]);
    5454extern int loader_set_files(loader_t *, fdi_node_t *const[]);
    5555extern int loader_load_program(loader_t *);
  • uspace/lib/c/include/macros.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    4141extern uintptr_t get_max_heap_addr(void);
    4242
    43 extern void *malloc(const size_t size);
    44 extern void *calloc(const size_t nmemb, const size_t size);
    45 extern void *memalign(const size_t align, const size_t size);
     43extern void *malloc(const size_t size)
     44    __attribute__((malloc));
     45extern void *calloc(const size_t nmemb, const size_t size)
     46    __attribute__((malloc));
     47extern void *memalign(const size_t align, const size_t size)
     48    __attribute__((malloc));
    4649extern void *realloc(const void *addr, const size_t size);
    4750extern void free(const void *addr);
  • uspace/lib/c/include/net/inet.h

    rfb150d78 r46c20c8  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2009 Lukas Mejdrech
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup debug
    30  * @{
    31  */
    32 /** @file
     29/** @addtogroup libc
     30 *  @{
    3331 */
    3432
    35 #ifndef LIBC_ia32__ISTATE_H_
    36 #define LIBC_ia32__ISTATE_H_
     33/** @file
     34 *  Internet common definitions.
     35 */
     36
     37#ifndef LIBC_INET_H_
     38#define LIBC_INET_H_
    3739
    3840#include <sys/types.h>
     41#include <byteorder.h>
    3942
    40 /** Interrupt context.
    41  *
    42  * This is a copy of the kernel definition with which it must be kept in sync.
     43/** Type definition of the socket address.
     44 * @see sockaddr
    4345 */
    44 typedef struct istate {
    45         uint32_t eax;
    46         uint32_t ecx;
    47         uint32_t edx;
    48         uint32_t ebp;
     46typedef struct sockaddr         sockaddr_t;
    4947
    50         uint32_t gs;
    51         uint32_t fs;
    52         uint32_t es;
    53         uint32_t ds;
     48/** Type definition of the address information.
     49 * @see addrinfo
     50 */
     51typedef struct addrinfo         addrinfo_t;
    5452
    55         uint32_t error_word;
    56         uint32_t eip;
    57         uint32_t cs;
    58         uint32_t eflags;
    59         uint32_t stack[];
    60 } istate_t;
     53/** Socket address. */
     54struct sockaddr {
     55        /** Address family. @see socket.h */
     56        uint16_t sa_family;
     57        /** 14 byte protocol address. */
     58        uint8_t sa_data[14];
     59};
    6160
    62 static inline uintptr_t istate_get_pc(istate_t *istate)
    63 {
    64         return istate->eip;
    65 }
    66 
    67 static inline uintptr_t istate_get_fp(istate_t *istate)
    68 {
    69         return istate->ebp;
    70 }
     61extern int inet_ntop(uint16_t, const uint8_t *, char *, size_t);
     62extern int inet_pton(uint16_t, const char *, uint8_t *);
    7163
    7264#endif
  • uspace/lib/c/include/stacktrace.h

    rfb150d78 r46c20c8  
    5757extern void stacktrace_prepare(void);
    5858extern uintptr_t stacktrace_fp_get(void);
    59 extern uintptr_t stacktrace_pc_get();
     59extern uintptr_t stacktrace_pc_get(void);
    6060
    6161#endif
  • uspace/lib/c/include/stdio.h

    rfb150d78 r46c20c8  
    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/str.h

    rfb150d78 r46c20c8  
    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>
     
    8686extern char *str_ndup(const char *, size_t max_size);
    8787
     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);
     92
    8893/*
    8994 * TODO: Get rid of this.
  • uspace/lib/c/include/sys/mman.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    3131 */
    3232/** @file
    33  */ 
     33 */
    3434
    3535#ifndef LIBC_SYS_STAT_H_
     
    4343struct stat {
    4444        fs_handle_t fs_handle;
    45         dev_handle_t dev_handle;
     45        devmap_handle_t devmap_handle;
    4646        fs_index_t index;
    4747        unsigned int lnkcnt;
    4848        bool is_file;
    4949        bool is_directory;
    50         off_t size;
    51         dev_handle_t device;
     50        aoff64_t size;
     51        devmap_handle_t device;
    5252};
    5353
  • uspace/lib/c/include/sys/time.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    3838#include <libarch/types.h>
    3939
    40 typedef long off_t;
    41 typedef int mode_t;
    42 typedef uint64_t bn_t;  /**< Block number type. */
     40typedef unsigned int mode_t;
    4341
    44 typedef int32_t wchar_t;
     42/** Relative offset */
     43typedef int64_t off64_t;
     44
     45/** Absolute offset */
     46typedef uint64_t aoff64_t;
    4547
    4648typedef volatile uint8_t ioport8_t;
  • uspace/lib/c/include/sysinfo.h

    rfb150d78 r46c20c8  
    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

    rfb150d78 r46c20c8  
    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 task_id_t task_spawn(const char *, const char *const[], int *);
     50extern int task_spawnv(task_id_t *, const char *path, const char *const []);
     51extern int task_spawnl(task_id_t *, const char *path, ...);
    5252
     53extern int task_wait(task_id_t id, task_exit_t *, int *);
     54extern int task_retval(int);
    5355
    5456#endif
  • uspace/lib/c/include/thread.h

    rfb150d78 r46c20c8  
    4545extern void __thread_main(uspace_arg_t *);
    4646
    47 extern int thread_create(void (*)(void *), void *, char *, thread_id_t *);
     47extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *);
    4848extern void thread_exit(int) __attribute__ ((noreturn));
    4949extern void thread_detach(thread_id_t);
  • uspace/lib/c/include/unistd.h

    rfb150d78 r46c20c8  
    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)
    4344#endif
    4445
     
    4748#ifndef SEEK_SET
    4849        #define SEEK_SET  0
     50#endif
     51
     52#ifndef SEEK_CUR
    4953        #define SEEK_CUR  1
     54#endif
     55
     56#ifndef SEEK_END
    5057        #define SEEK_END  2
    5158#endif
    52 
    53 typedef uint32_t useconds_t;
    5459
    5560extern int dup2(int oldfd, int newfd);
     
    5863extern ssize_t read(int, void *, size_t);
    5964
    60 extern off_t lseek(int, off_t, int);
    61 extern int ftruncate(int, off_t);
     65extern off64_t lseek(int, off64_t, int);
     66extern int ftruncate(int, aoff64_t);
    6267
    6368extern int close(int);
     
    6974extern int chdir(const char *);
    7075
    71 extern void _exit(int status) __attribute__ ((noreturn));
    72 extern int usleep(useconds_t uses);
    73 extern unsigned int sleep(unsigned int se);
     76extern void _exit(int) __attribute__((noreturn));
     77extern int usleep(useconds_t);
     78extern unsigned int sleep(unsigned int);
    7479
    7580#endif
  • uspace/lib/c/include/vfs/vfs.h

    rfb150d78 r46c20c8  
    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;
Note: See TracChangeset for help on using the changeset viewer.