Changeset 192565b in mainline for uspace/lib/c


Ignore:
Timestamp:
2013-05-27T13:18:13Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f2c19b0
Parents:
d120133 (diff), c90aed4 (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:
7 added
20 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    rd120133 r192565b  
    7474        generic/device/pci.c \
    7575        generic/device/ahci.c \
     76        generic/dnsr.c \
    7677        generic/dlfcn.c \
    7778        generic/elf/elf_load.c \
     
    9192        generic/task.c \
    9293        generic/futex.c \
     94        generic/inet/addr.c \
    9395        generic/inet.c \
    9496        generic/inetcfg.c \
  • uspace/lib/c/arch/ia32/src/setjmp.S

    rd120133 r192565b  
    3535.type setjmp,@function
    3636setjmp:
    37         movl 0(%esp),%eax       # save pc value into eax       
    38         movl 4(%esp),%edx       # address of the jmp_buf structure to save context to
    39 
    40                 # save registers to the jmp_buf structure
     37        movl 0(%esp),%eax  # save pc value into eax
     38        movl 4(%esp),%edx  # address of the jmp_buf structure to save context to
     39       
     40        # save registers to the jmp_buf structure
    4141        CONTEXT_SAVE_ARCH_CORE %edx %eax
    42 
    43         xorl %eax,%eax          # set_jmp returns 0
     42       
     43        xorl %eax,%eax  # set_jmp returns 0
    4444        ret
    4545
    4646.type longjmp,@function
    4747longjmp:
    48 
    49         movl 4(%esp), %ecx      # put address of jmp_buf into ecx
    50         movl 8(%esp), %eax      # put return value into eax     
    51 
    52                 # restore registers from the jmp_buf structure
     48        movl 4(%esp), %ecx  # put address of jmp_buf into ecx
     49        movl 8(%esp), %eax  # put return value into eax
     50       
     51        # restore registers from the jmp_buf structure
    5352        CONTEXT_RESTORE_ARCH_CORE %ecx %edx
    54 
    55         movl %edx,0(%esp)       # put saved pc on stack
     53       
     54        movl %edx,0(%esp)  # put saved pc on stack
    5655        ret
    57 
  • uspace/lib/c/generic/adt/hash_table.c

    rd120133 r192565b  
    8181 * @param init_size Initial desired number of hash table buckets. Pass zero
    8282 *                 if you want the default initial size.
    83  * @param max_keys Maximal number of keys needed to identify an item.
     83 * @param max_load The table is resized when the average load per bucket
     84 *                 exceeds this number. Pass zero if you want the default.
    8485 * @param op       Hash table operations structure. remove_callback()
    8586 *                 is optional and can be NULL if no action is to be taken
  • uspace/lib/c/generic/async.c

    rd120133 r192565b  
    20902090 * @param arg   User defined argument.
    20912091 * @param flags Storage for the received flags. Can be NULL.
    2092  * @param dst   Destination address space area base. Cannot be NULL.
     2092 * @param dst   Address of the storage for the destination address space area
     2093 *              base address. Cannot be NULL.
    20932094 *
    20942095 * @return Zero on success or a negative error code from errno.h.
     
    22182219 *
    22192220 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
    2220  * @param dst    Destination address space area base address.
     2221 * @param dst    Address of the storage for the destination address space area
     2222 *               base address.
    22212223 *
    22222224 * @return Zero on success or a value from @ref errno.h on failure.
  • uspace/lib/c/generic/device/hw_res_parsed.c

    rd120133 r192565b  
    221221        hw_resource_list_t hw_resources;
    222222        hw_res_list_parsed_clean(hw_res_parsed);
    223         bzero(&hw_resources, sizeof(hw_resource_list_t));
     223        memset(&hw_resources, 0, sizeof(hw_resource_list_t));
    224224       
    225225        int rc = hw_res_get_resource_list(sess, &hw_resources);
  • uspace/lib/c/generic/io/con_srv.c

    rd120133 r192565b  
    3535 */
    3636#include <errno.h>
     37#include <io/cons_event.h>
    3738#include <ipc/console.h>
    3839#include <stdlib.h>
     
    4041
    4142#include <io/con_srv.h>
     43
     44static int console_ev_encode(cons_event_t *event, ipc_call_t *call)
     45{
     46        IPC_SET_ARG1(*call, event->type);
     47
     48        switch (event->type) {
     49        case CEV_KEY:
     50                IPC_SET_ARG2(*call, event->ev.key.type);
     51                IPC_SET_ARG3(*call, event->ev.key.key);
     52                IPC_SET_ARG4(*call, event->ev.key.mods);
     53                IPC_SET_ARG5(*call, event->ev.key.c);
     54                break;
     55        case CEV_POS:
     56                IPC_SET_ARG2(*call, (event->ev.pos.pos_id << 16) | (event->ev.pos.type & 0xffff));
     57                IPC_SET_ARG3(*call, event->ev.pos.btn_num);
     58                IPC_SET_ARG4(*call, event->ev.pos.hpos);
     59                IPC_SET_ARG5(*call, event->ev.pos.vpos);
     60                break;
     61        default:
     62                return EIO;
     63        }
     64
     65        return EOK;
     66}
    4267
    4368static void con_read_srv(con_srv_t *srv, ipc_callid_t callid,
     
    273298{
    274299        int rc;
    275         kbd_event_t event;
     300        cons_event_t event;
     301        ipc_call_t result;
    276302
    277303        if (srv->srvs->ops->get_event == NULL) {
     
    281307
    282308        rc = srv->srvs->ops->get_event(srv, &event);
    283         async_answer_4(callid, rc, event.type, event.key, event.mods, event.c);
     309        if (rc != EOK) {
     310                async_answer_0(callid, rc);
     311                return;
     312        }
     313
     314        rc = console_ev_encode(&event, &result);
     315        if (rc != EOK) {
     316                async_answer_0(callid, rc);
     317                return;
     318        }
     319
     320        async_answer_5(callid, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result),
     321            IPC_GET_ARG3(result), IPC_GET_ARG4(result), IPC_GET_ARG5(result));
    284322}
    285323
  • uspace/lib/c/generic/io/console.c

    rd120133 r192565b  
    154154}
    155155
    156 bool console_get_kbd_event(console_ctrl_t *ctrl, kbd_event_t *event)
     156static int console_ev_decode(ipc_call_t *call, cons_event_t *event)
     157{
     158        event->type = IPC_GET_ARG1(*call);
     159
     160        switch (event->type) {
     161        case CEV_KEY:
     162                event->ev.key.type = IPC_GET_ARG2(*call);
     163                event->ev.key.key = IPC_GET_ARG3(*call);
     164                event->ev.key.mods = IPC_GET_ARG4(*call);
     165                event->ev.key.c = IPC_GET_ARG5(*call);
     166                break;
     167        case CEV_POS:
     168                event->ev.pos.pos_id = IPC_GET_ARG2(*call) >> 16;
     169                event->ev.pos.type = IPC_GET_ARG2(*call) & 0xffff;
     170                event->ev.pos.btn_num = IPC_GET_ARG3(*call);
     171                event->ev.pos.hpos = IPC_GET_ARG4(*call);
     172                event->ev.pos.vpos = IPC_GET_ARG5(*call);
     173                break;
     174        default:
     175                return EIO;
     176        }
     177
     178        return EOK;
     179}
     180
     181bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event)
    157182{
    158183        if (ctrl->input_aid == 0) {
    159                 sysarg_t type;
    160                 sysarg_t key;
    161                 sysarg_t mods;
    162                 sysarg_t c;
     184                ipc_call_t result;
    163185               
    164186                async_exch_t *exch = async_exchange_begin(ctrl->input_sess);
    165                 int rc = async_req_0_4(exch, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
     187                aid_t aid = async_send_0(exch, CONSOLE_GET_EVENT, &result);
    166188                async_exchange_end(exch);
     189               
     190                sysarg_t rc;
     191                async_wait_for(aid, &rc);
    167192               
    168193                if (rc != EOK) {
     
    171196                }
    172197               
    173                 event->type = type;
    174                 event->key = key;
    175                 event->mods = mods;
    176                 event->c = c;
     198                rc = console_ev_decode(&result, event);
     199                if (rc != EOK) {
     200                        errno = rc;
     201                        return false;
     202                }
    177203        } else {
    178204                sysarg_t retval;
     
    186212                }
    187213               
    188                 event->type = IPC_GET_ARG1(ctrl->input_call);
    189                 event->key = IPC_GET_ARG2(ctrl->input_call);
    190                 event->mods = IPC_GET_ARG3(ctrl->input_call);
    191                 event->c = IPC_GET_ARG4(ctrl->input_call);
     214                int rc = console_ev_decode(&ctrl->input_call, event);
     215                if (rc != EOK) {
     216                        errno = rc;
     217                        return false;
     218                }
    192219        }
    193220       
     
    195222}
    196223
    197 bool console_get_kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,
     224bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event,
    198225    suseconds_t *timeout)
    199226{
     
    223250        }
    224251       
    225         event->type = IPC_GET_ARG1(ctrl->input_call);
    226         event->key = IPC_GET_ARG2(ctrl->input_call);
    227         event->mods = IPC_GET_ARG3(ctrl->input_call);
    228         event->c = IPC_GET_ARG4(ctrl->input_call);
     252        rc = console_ev_decode(&ctrl->input_call, event);
     253        if (rc != EOK) {
     254                errno = rc;
     255                return false;
     256        }
    229257       
    230258        /* Update timeout */
  • uspace/lib/c/generic/mem.c

    rd120133 r192565b  
    224224 * @param s1  Pointer to the first area to compare.
    225225 * @param s2  Pointer to the second area to compare.
    226  * @param len Size of the first area in bytes. Both areas must have
    227  *            the same length.
    228  *
    229  * @return If len is 0, return zero. If the areas match, return
    230  *         zero. Otherwise return non-zero.
    231  *
    232  */
    233 int bcmp(const void *s1, const void *s2, size_t len)
     226 * @param len Size of the areas in bytes.
     227 *
     228 * @return Zero if areas have the same contents. If they differ,
     229 *         the sign of the result is the same as the sign of the
     230 *         difference of the first pair of different bytes.
     231 *
     232 */
     233int memcmp(const void *s1, const void *s2, size_t len)
    234234{
    235235        uint8_t *u1 = (uint8_t *) s1;
    236236        uint8_t *u2 = (uint8_t *) s2;
    237        
    238         for (; (len != 0) && (*u1++ == *u2++); len--);
    239        
    240         return len;
     237        size_t i;
     238
     239        for (i = 0; i < len; i++) {
     240                if (*u1 != *u2)
     241                        return (int)(*u1) - (int)(*u2);
     242                ++u1;
     243                ++u2;
     244        }
     245
     246        return 0;
    241247}
    242248
  • uspace/lib/c/generic/net/inet.c

    rd120133 r192565b  
    144144        /* Erase if no address */
    145145        if (!address) {
    146                 bzero(data, count);
     146                memset(data, 0, count);
    147147                return ENOENT;
    148148        }
     
    181181                } else {
    182182                        /* Erase the rest of the address */
    183                         bzero(data + index, count - index);
     183                        memset(data + index, 0, count - index);
    184184                        return EOK;
    185185                }
  • uspace/lib/c/generic/net/socket_client.c

    rd120133 r192565b  
    446446                return ENOMEM;
    447447
    448         bzero(socket, sizeof(*socket));
     448        memset(socket, 0, sizeof(*socket));
    449449        fibril_rwlock_write_lock(&socket_globals.lock);
    450450
     
    657657                return ENOMEM;
    658658        }
    659         bzero(new_socket, sizeof(*new_socket));
     659        memset(new_socket, 0, sizeof(*new_socket));
    660660        socket_id = socket_generate_new_id();
    661661        if (socket_id <= 0) {
  • uspace/lib/c/include/device/hw_res_parsed.h

    rd120133 r192565b  
    127127        free(list->dma_channels.channels);
    128128       
    129         bzero(list, sizeof(hw_res_list_parsed_t));
     129        memset(list, 0, sizeof(hw_res_list_parsed_t));
    130130}
    131131
     
    136136static inline void hw_res_list_parsed_init(hw_res_list_parsed_t *list)
    137137{
    138         bzero(list, sizeof(hw_res_list_parsed_t));
     138        memset(list, 0, sizeof(hw_res_list_parsed_t));
    139139}
    140140
  • uspace/lib/c/include/inet/inet.h

    rd120133 r192565b  
    3636#define LIBC_INET_INET_H_
    3737
     38#include <inet/addr.h>
    3839#include <sys/types.h>
    3940
    4041#define INET_TTL_MAX 255
    41 
    42 typedef struct {
    43         uint32_t ipv4;
    44 } inet_addr_t;
    4542
    4643typedef struct {
  • uspace/lib/c/include/inet/inetcfg.h

    rd120133 r192565b  
    3838#include <inet/inet.h>
    3939#include <sys/types.h>
    40 
    41 /** Network address */
    42 typedef struct {
    43         /** Address */
    44         uint32_t ipv4;
    45         /** Number of valid bits in @c ipv4 */
    46         int bits;
    47 } inet_naddr_t;
    4840
    4941/** Address object info */
  • uspace/lib/c/include/io/con_srv.h

    rd120133 r192565b  
    4141#include <io/color.h>
    4242#include <io/concaps.h>
    43 #include <io/kbd_event.h>
     43#include <io/cons_event.h>
    4444#include <io/pixel.h>
    4545#include <io/style.h>
     
    8282        void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t);
    8383        void (*set_cursor_visibility)(con_srv_t *, bool);
    84         int (*get_event)(con_srv_t *, kbd_event_t *);
     84        int (*get_event)(con_srv_t *, cons_event_t *);
    8585} con_ops_t;
    8686
  • uspace/lib/c/include/io/console.h

    rd120133 r192565b  
    3939#include <io/concaps.h>
    4040#include <io/kbd_event.h>
     41#include <io/cons_event.h>
    4142#include <io/keycode.h>
    4243#include <async.h>
     
    8283extern void console_cursor_visibility(console_ctrl_t *, bool);
    8384extern int console_get_color_cap(console_ctrl_t *, sysarg_t *);
    84 extern bool console_get_kbd_event(console_ctrl_t *, kbd_event_t *);
    85 extern bool console_get_kbd_event_timeout(console_ctrl_t *, kbd_event_t *,
     85extern bool console_get_event(console_ctrl_t *, cons_event_t *);
     86extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *,
    8687    suseconds_t *);
    8788
  • uspace/lib/c/include/io/window.h

    rd120133 r192565b  
    4040#include <async.h>
    4141#include <loc.h>
    42 #include <io/console.h>
    43 
    44 typedef enum {
    45         POS_UPDATE,
    46         POS_PRESS,
    47         POS_RELEASE
    48 } pos_event_type_t;
    49 
    50 typedef struct {
    51         sysarg_t pos_id;
    52         pos_event_type_t type;
    53         sysarg_t btn_num;
    54         sysarg_t hpos;
    55         sysarg_t vpos;
    56 } pos_event_t;
     42#include <io/kbd_event.h>
     43#include <io/pos_event.h>
    5744
    5845typedef struct {
  • uspace/lib/c/include/ipc/services.h

    rd120133 r192565b  
    5353} services_t;
    5454
     55#define SERVICE_NAME_DNSR     "net/dnsr"
    5556#define SERVICE_NAME_INET     "net/inet"
    5657#define SERVICE_NAME_INETCFG  "net/inetcfg"
  • uspace/lib/c/include/mem.h

    rd120133 r192565b  
    3838#include <sys/types.h>
    3939
    40 #define bzero(ptr, len)  memset((ptr), 0, (len))
    41 
    42 extern void *memset(void *, int, size_t);
    43 extern void *memcpy(void *, const void *, size_t);
     40extern void *memset(void *, int, size_t)
     41    __attribute__ ((optimize("-fno-tree-loop-distribute-patterns")));
     42extern void *memcpy(void *, const void *, size_t)
     43    __attribute__ ((optimize("-fno-tree-loop-distribute-patterns")));
    4444extern void *memmove(void *, const void *, size_t);
    45 
    46 extern int bcmp(const void *, const void *, size_t);
     45extern int memcmp(const void *, const void *, size_t);
    4746
    4847#endif
  • uspace/lib/c/include/setjmp.h

    rd120133 r192565b  
    3838#include <libarch/fibril.h>
    3939
    40 typedef context_t jmp_buf;
     40typedef context_t jmp_buf[1];
    4141
    4242extern int setjmp(jmp_buf env);
     
    4747/** @}
    4848 */
    49 
  • uspace/lib/c/include/sys/types.h

    rd120133 r192565b  
    5050typedef volatile uint32_t ioport32_t;
    5151
     52typedef int16_t unaligned_int16_t __attribute__ ((aligned(1)));
     53typedef int32_t unaligned_int32_t __attribute__ ((aligned(1)));
     54typedef int64_t unaligned_int64_t __attribute__ ((aligned(1)));
     55
     56typedef uint16_t unaligned_uint16_t __attribute__ ((aligned(1)));
     57typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
     58typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
     59
    5260#endif
    5361
Note: See TracChangeset for help on using the changeset viewer.