Changeset 432a269 in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-09-16T21:13:57Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a11f17
Parents:
c0e53ff (diff), fd07e526 (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
Files:
2 added
4 deleted
27 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    rc0e53ff r432a269  
    6363        generic/as.c \
    6464        generic/cap.c \
     65        generic/cfg.c \
    6566        generic/clipboard.c \
    6667        generic/devman.c \
     
    9394        generic/io/printf_core.c \
    9495        generic/io/console.c \
    95         generic/io/screenbuffer.c \
    9696        generic/malloc.c \
    9797        generic/sysinfo.c \
    9898        generic/ipc.c \
    9999        generic/ns.c \
    100         generic/ns_obsolete.c \
    101100        generic/async.c \
    102         generic/async_obsolete.c \
    103101        generic/loader.c \
    104102        generic/getopt.c \
  • uspace/lib/c/arch/abs32le/include/types.h

    rc0e53ff r432a269  
    5252
    5353typedef uint32_t uintptr_t;
     54typedef int32_t intptr_t;
    5455typedef uint32_t atomic_count_t;
    5556typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/amd64/include/atomic.h

    rc0e53ff r432a269  
    4444static inline void atomic_inc(atomic_t *val)
    4545{
     46#ifdef __PCC__
     47        asm volatile (
     48                "lock incq %0\n"
     49                : "+m" (val->count)
     50        );
     51#else
    4652        asm volatile (
    4753                "lock incq %[count]\n"
    4854                : [count] "+m" (val->count)
    4955        );
     56#endif
    5057}
    5158
    5259static inline void atomic_dec(atomic_t *val)
    5360{
     61#ifdef __PCC__
     62        asm volatile (
     63                "lock decq %0\n"
     64                : "+m" (val->count)
     65        );
     66#else
    5467        asm volatile (
    5568                "lock decq %[count]\n"
    5669                : [count] "+m" (val->count)
    5770        );
     71#endif
    5872}
    5973
     
    6276        atomic_count_t r = 1;
    6377       
     78#ifdef __PCC__
     79        asm volatile (
     80                "lock xaddq %1, %0\n"
     81                : "+m" (val->count),
     82                  "+r" (r)
     83        );
     84#else
    6485        asm volatile (
    6586                "lock xaddq %[r], %[count]\n"
     
    6788                  [r] "+r" (r)
    6889        );
     90#endif
    6991       
    7092        return r;
     
    7597        atomic_count_t r = -1;
    7698       
     99#ifdef __PCC__
     100        asm volatile (
     101                "lock xaddq %1, %0\n"
     102                : "+m" (val->count),
     103                  "+r" (r)
     104        );
     105#else
    77106        asm volatile (
    78107                "lock xaddq %[r], %[count]\n"
     
    80109                  [r] "+r" (r)
    81110        );
     111#endif
    82112       
    83113        return r;
  • uspace/lib/c/arch/amd64/include/types.h

    rc0e53ff r432a269  
    5252
    5353typedef uint64_t uintptr_t;
     54typedef int64_t intptr_t;
    5455typedef uint64_t atomic_count_t;
    5556typedef int64_t atomic_signed_t;
  • uspace/lib/c/arch/arm32/include/types.h

    rc0e53ff r432a269  
    5353
    5454typedef uint32_t uintptr_t;
     55typedef int32_t intptr_t;
    5556typedef uint32_t atomic_count_t;
    5657typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/ia32/include/atomic.h

    rc0e53ff r432a269  
    4242static inline void atomic_inc(atomic_t *val)
    4343{
     44#ifdef __PCC__
     45        asm volatile (
     46                "lock incl %0\n"
     47                : "+m" (val->count)
     48        );
     49#else
    4450        asm volatile (
    4551                "lock incl %[count]\n"
    4652                : [count] "+m" (val->count)
    4753        );
     54#endif
    4855}
    4956
    5057static inline void atomic_dec(atomic_t *val)
    5158{
     59#ifdef __PCC__
     60        asm volatile (
     61                "lock decl %0\n"
     62                : "+m" (val->count)
     63        );
     64#else
    5265        asm volatile (
    5366                "lock decl %[count]\n"
    5467                : [count] "+m" (val->count)
    5568        );
     69#endif
    5670}
    5771
     
    6074        atomic_count_t r = 1;
    6175       
     76#ifdef __PCC__
     77        asm volatile (
     78                "lock xaddl %1, %0\n"
     79                : "+m" (val->count),
     80                  "+r" (r)
     81        );
     82#else
    6283        asm volatile (
    6384                "lock xaddl %[r], %[count]\n"
     
    6586                  [r] "+r" (r)
    6687        );
     88#endif
    6789       
    6890        return r;
     
    7395        atomic_count_t r = -1;
    7496       
     97#ifdef __PCC__
     98        asm volatile (
     99                "lock xaddl %1, %0\n"
     100                : "+m" (val->count),
     101                  "+r" (r)
     102        );
     103#else
    75104        asm volatile (
    76105                "lock xaddl %[r], %[count]\n"
     
    78107                  [r] "+r" (r)
    79108        );
     109#endif
    80110       
    81111        return r;
  • uspace/lib/c/arch/ia32/include/types.h

    rc0e53ff r432a269  
    5252
    5353typedef uint32_t uintptr_t;
     54typedef int32_t intptr_t;
    5455typedef uint32_t atomic_count_t;
    5556typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/ia64/include/types.h

    rc0e53ff r432a269  
    6262
    6363typedef uint64_t uintptr_t;
     64typedef int64_t intptr_t;
    6465typedef uint64_t atomic_count_t;
    6566typedef int64_t atomic_signed_t;
  • uspace/lib/c/arch/mips32/include/types.h

    rc0e53ff r432a269  
    5353
    5454typedef uint32_t uintptr_t;
     55typedef int32_t intptr_t;
    5556typedef uint32_t atomic_count_t;
    5657typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/mips64/include/types.h

    rc0e53ff r432a269  
    5353
    5454typedef uint64_t uintptr_t;
     55typedef int64_t intptr_t;
    5556typedef uint64_t atomic_count_t;
    5657typedef int64_t atomic_signed_t;
  • uspace/lib/c/arch/ppc32/include/types.h

    rc0e53ff r432a269  
    5252
    5353typedef uint32_t uintptr_t;
     54typedef int32_t intptr_t;
    5455typedef uint32_t atomic_count_t;
    5556typedef int32_t atomic_signed_t;
  • uspace/lib/c/arch/sparc64/include/types.h

    rc0e53ff r432a269  
    5252
    5353typedef uint64_t uintptr_t;
     54typedef int64_t intptr_t;
    5455typedef uint64_t atomic_count_t;
    5556typedef int64_t atomic_signed_t;
  • uspace/lib/c/generic/adt/hash_table.c

    rc0e53ff r432a269  
    152152       
    153153        if (keys == h->max_keys) {
    154                 link_t *cur;
    155                
    156154                /*
    157155                 * All keys are known, hash_table_find() can be used to find the
     
    159157                 */
    160158               
    161                 cur = hash_table_find(h, key);
     159                link_t *cur = hash_table_find(h, key);
    162160                if (cur) {
    163161                        list_remove(cur);
     
    174172        hash_index_t chain;
    175173        for (chain = 0; chain < h->entries; chain++) {
    176                 link_t *cur;
    177                
    178                 for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head;
     174                for (link_t *cur = h->entry[chain].head.next;
     175                    cur != &h->entry[chain].head;
    179176                    cur = cur->next) {
    180177                        if (h->op->compare(key, keys, cur)) {
  • uspace/lib/c/generic/adt/list.c

    rc0e53ff r432a269  
    5050 * @param list  List to look in.
    5151 *
    52  * @return true if link is contained in head, false otherwise.
     52 * @return true if link is contained in list, false otherwise.
    5353 *
    5454 */
  • uspace/lib/c/generic/as.c

    rc0e53ff r432a269  
    123123 * @retval ENOENT Mapping not found.
    124124 */
    125 int as_get_physical_mapping(void *address, uintptr_t *frame)
     125int as_get_physical_mapping(const void *address, uintptr_t *frame)
    126126{
    127127        uintptr_t tmp_frame;
  • uspace/lib/c/generic/async.c

    rc0e53ff r432a269  
    118118#define CONN_HASH_TABLE_BUCKETS    32
    119119
     120/** Session data */
     121struct async_sess {
     122        /** List of inactive exchanges */
     123        list_t exch_list;
     124       
     125        /** Exchange management style */
     126        exch_mgmt_t mgmt;
     127       
     128        /** Session identification */
     129        int phone;
     130       
     131        /** First clone connection argument */
     132        sysarg_t arg1;
     133       
     134        /** Second clone connection argument */
     135        sysarg_t arg2;
     136       
     137        /** Third clone connection argument */
     138        sysarg_t arg3;
     139       
     140        /** Exchange mutex */
     141        fibril_mutex_t mutex;
     142       
     143        /** Number of opened exchanges */
     144        atomic_t refcnt;
     145       
     146        /** Mutex for stateful connections */
     147        fibril_mutex_t remote_state_mtx;
     148       
     149        /** Data for stateful connections */
     150        void *remote_state_data;
     151};
     152
     153/** Exchange data */
     154struct async_exch {
     155        /** Link into list of inactive exchanges */
     156        link_t sess_link;
     157       
     158        /** Link into global list of inactive exchanges */
     159        link_t global_link;
     160       
     161        /** Session pointer */
     162        async_sess_t *sess;
     163       
     164        /** Exchange identification */
     165        int phone;
     166};
     167
    120168/** Async framework global futex */
    121169atomic_t async_futex = FUTEX_INITIALIZER;
     
    134182        ipc_call_t call;
    135183} msg_t;
     184
     185/** Message data */
     186typedef struct {
     187        awaiter_t wdata;
     188       
     189        /** If reply was received. */
     190        bool done;
     191       
     192        /** Pointer to where the answer data is stored. */
     193        ipc_call_t *dataptr;
     194       
     195        sysarg_t retval;
     196} amsg_t;
    136197
    137198/* Client connection data */
  • uspace/lib/c/generic/io/console.c

    rc0e53ff r432a269  
    8787{
    8888        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    89         async_msg_0(exch, CONSOLE_CLEAR);
     89        async_req_0_0(exch, CONSOLE_CLEAR);
    9090        async_exchange_end(exch);
    9191}
     
    103103{
    104104        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    105         async_msg_1(exch, CONSOLE_SET_STYLE, style);
    106         async_exchange_end(exch);
    107 }
    108 
    109 void console_set_color(console_ctrl_t *ctrl, uint8_t fg_color, uint8_t bg_color,
     105        async_req_1_0(exch, CONSOLE_SET_STYLE, style);
     106        async_exchange_end(exch);
     107}
     108
     109void console_set_color(console_ctrl_t *ctrl, uint8_t bgcolor, uint8_t fgcolor,
    110110    uint8_t flags)
    111111{
    112112        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    113         async_msg_3(exch, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
    114         async_exchange_end(exch);
    115 }
    116 
    117 void console_set_rgb_color(console_ctrl_t *ctrl, uint32_t fg_color,
    118     uint32_t bg_color)
    119 {
    120         async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    121         async_msg_2(exch, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
     113        async_req_3_0(exch, CONSOLE_SET_COLOR, bgcolor, fgcolor, flags);
     114        async_exchange_end(exch);
     115}
     116
     117void console_set_rgb_color(console_ctrl_t *ctrl, uint32_t bgcolor,
     118    uint32_t fgcolor)
     119{
     120        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
     121        async_req_2_0(exch, CONSOLE_SET_RGB_COLOR, bgcolor, fgcolor);
    122122        async_exchange_end(exch);
    123123}
     
    126126{
    127127        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    128         async_msg_1(exch, CONSOLE_CURSOR_VISIBILITY, (show != false));
     128        async_req_1_0(exch, CONSOLE_CURSOR_VISIBILITY, (show != false));
    129129        async_exchange_end(exch);
    130130}
     
    151151{
    152152        async_exch_t *exch = async_exchange_begin(ctrl->output_sess);
    153         async_msg_2(exch, CONSOLE_GOTO, col, row);
     153        async_req_2_0(exch, CONSOLE_GOTO, col, row);
    154154        async_exchange_end(exch);
    155155}
  • uspace/lib/c/generic/io/io.c

    rc0e53ff r432a269  
    418418
    419419        bytes_used = stream->buf_head - stream->buf_tail;
    420         if (bytes_used == 0)
    421                 return;
    422420
    423421        /* If buffer has prefetched read data, we need to seek back. */
    424         if (stream->buf_state == _bs_read)
     422        if (bytes_used > 0 && stream->buf_state == _bs_read)
    425423                lseek(stream->fd, - (ssize_t) bytes_used, SEEK_CUR);
    426424
    427425        /* If buffer has unwritten data, we need to write them out. */
    428         if (stream->buf_state == _bs_write)
     426        if (bytes_used > 0 && stream->buf_state == _bs_write)
    429427                (void) _fwrite(stream->buf_tail, 1, bytes_used, stream);
    430428
  • uspace/lib/c/generic/private/async.h

    rc0e53ff r432a269  
    4343#include <bool.h>
    4444
    45 /** Session data */
    46 struct _async_sess {
    47         /** List of inactive exchanges */
    48         list_t exch_list;
    49        
    50         /** Exchange management style */
    51         exch_mgmt_t mgmt;
    52        
    53         /** Session identification */
    54         int phone;
    55        
    56         /** First clone connection argument */
    57         sysarg_t arg1;
    58        
    59         /** Second clone connection argument */
    60         sysarg_t arg2;
    61        
    62         /** Third clone connection argument */
    63         sysarg_t arg3;
    64        
    65         /** Exchange mutex */
    66         fibril_mutex_t mutex;
    67        
    68         /** Number of opened exchanges */
    69         atomic_t refcnt;
    70        
    71         /** Mutex for stateful connections */
    72         fibril_mutex_t remote_state_mtx;
    73        
    74         /** Data for stateful connections */
    75         void *remote_state_data;
    76 };
    77 
    78 /** Exchange data */
    79 struct _async_exch {
    80         /** Link into list of inactive exchanges */
    81         link_t sess_link;
    82        
    83         /** Link into global list of inactive exchanges */
    84         link_t global_link;
    85        
    86         /** Session pointer */
    87         async_sess_t *sess;
    88        
    89         /** Exchange identification */
    90         int phone;
    91 };
    92 
    9345/** Structures of this type are used to track the timeout events. */
    9446typedef struct {
     
    12981} awaiter_t;
    13082
    131 /** Message data */
    132 typedef struct {
    133         awaiter_t wdata;
    134        
    135         /** If reply was received. */
    136         bool done;
    137        
    138         /** Pointer to where the answer data is stored. */
    139         ipc_call_t *dataptr;
    140        
    141         sysarg_t retval;
    142 } amsg_t;
    143 
    14483extern void __async_init(void);
    14584extern void async_insert_timeout(awaiter_t *);
  • uspace/lib/c/generic/vfs/vfs.c

    rc0e53ff r432a269  
    654654        async_exch_t *exch = vfs_exchange_begin();
    655655       
    656         req = async_send_0(exch, VFS_IN_UNLINK, NULL);
     656        req = async_send_1(exch, VFS_IN_UNLINK, lflag, NULL);
    657657        rc = async_data_write_start(exch, pa, pa_size);
    658658        if (rc != EOK) {
  • uspace/lib/c/include/adt/list.h

    rc0e53ff r432a269  
    7272
    7373#define assert_link_not_used(link) \
    74         assert((link)->prev == NULL && (link)->next == NULL)
     74        assert(((link)->prev == NULL) && ((link)->next == NULL))
    7575
    7676/** Initialize doubly-linked circular list link
     
    158158static inline void list_remove(link_t *link)
    159159{
    160         link->next->prev = link->prev;
    161         link->prev->next = link->next;
     160        if ((link->prev != NULL) && (link->next != NULL)) {
     161                link->next->prev = link->prev;
     162                link->prev->next = link->next;
     163        }
     164       
    162165        link_initialize(link);
    163166}
     
    170173 *
    171174 */
    172 static inline int list_empty(list_t *list)
     175static inline int list_empty(const list_t *list)
    173176{
    174177        return (list->head.next == &list->head);
     
    183186 *
    184187 */
    185 static inline link_t *list_first(list_t *list)
     188static inline link_t *list_first(const list_t *list)
    186189{
    187190        return ((list->head.next == &list->head) ? NULL : list->head.next);
  • uspace/lib/c/include/as.h

    rc0e53ff r432a269  
    6060extern void *set_maxheapsize(size_t);
    6161extern void *as_get_mappable_page(size_t);
    62 extern int as_get_physical_mapping(void *, uintptr_t *);
     62extern int as_get_physical_mapping(const void *, uintptr_t *);
    6363
    6464#endif
  • uspace/lib/c/include/async.h

    rc0e53ff r432a269  
    9696
    9797/** Forward declarations */
    98 struct _async_exch;
    99 struct _async_sess;
    100 
    101 typedef struct _async_sess async_sess_t;
    102 typedef struct _async_exch async_exch_t;
     98struct async_exch;
     99struct async_sess;
     100
     101typedef struct async_sess async_sess_t;
     102typedef struct async_exch async_exch_t;
    103103
    104104extern atomic_t threads_in_ipc_wait;
  • uspace/lib/c/include/io/color.h

    rc0e53ff r432a269  
    4444        COLOR_MAGENTA = 5,
    4545        COLOR_YELLOW  = 6,
    46         COLOR_WHITE   = 7,
    47        
    48         CATTR_BRIGHT  = 8,
    49         CATTR_BLINK   = 8
     46        COLOR_WHITE   = 7
    5047} console_color_t;
     48
     49typedef enum {
     50        CATTR_NORMAL = 0,
     51        CATTR_BRIGHT = 8,
     52        CATTR_BLINK  = 16
     53} console_color_attr_t;
    5154
    5255#endif
  • uspace/lib/c/include/io/console.h

    rc0e53ff r432a269  
    3737
    3838#include <sys/time.h>
     39#include <io/keycode.h>
    3940#include <async.h>
    4041#include <bool.h>
     
    4243
    4344typedef enum {
    44         CONSOLE_CCAP_NONE = 0,
    45         CONSOLE_CCAP_STYLE,
    46         CONSOLE_CCAP_INDEXED,
    47         CONSOLE_CCAP_RGB
     45        CONSOLE_CAP_NONE = 0,
     46        CONSOLE_CAP_STYLE = 1,
     47        CONSOLE_CAP_INDEXED = 2,
     48        CONSOLE_CAP_RGB = 4
    4849} console_caps_t;
    4950
     
    7677/** Console event structure. */
    7778typedef struct {
     79        /** List handle */
     80        link_t link;
     81       
    7882        /** Press or release event. */
    7983        kbd_event_type_t type;
    8084       
    8185        /** Keycode of the key that was pressed or released. */
    82         unsigned int key;
     86        keycode_t key;
    8387       
    8488        /** Bitmask of modifiers held. */
    85         unsigned int mods;
     89        keymod_t mods;
    8690       
    8791        /** The character that was generated or '\0' for none. */
  • uspace/lib/c/include/ipc/loc.h

    rc0e53ff r432a269  
    9797
    9898#endif
     99
     100/** @}
     101 */
  • uspace/lib/c/include/ipc/services.h

    rc0e53ff r432a269  
    4343        SERVICE_NONE       = 0,
    4444        SERVICE_LOAD       = FOURCC('l', 'o', 'a', 'd'),
    45         SERVICE_VIDEO      = FOURCC('v', 'i', 'd', ' '),
    4645        SERVICE_VFS        = FOURCC('v', 'f', 's', ' '),
    4746        SERVICE_LOC        = FOURCC('l', 'o', 'c', ' '),
Note: See TracChangeset for help on using the changeset viewer.