Changeset 192565b in mainline for uspace/lib


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
Files:
9 added
43 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/bithenge/src/blob.c

    rd120133 r192565b  
    477477                if (rc != EOK)
    478478                        return rc;
    479                 if (size_a != size_b || bcmp(buffer_a, buffer_b, size_a)) {
     479                if (size_a != size_b || memcmp(buffer_a, buffer_b, size_a) != 0) {
    480480                        *out = false;
    481481                        return EOK;
  • 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
  • uspace/lib/clui/tinput.c

    rd120133 r192565b  
    4545#define LIN_TO_COL(ti, lpos) ((lpos) % ((ti)->con_cols))
    4646#define LIN_TO_ROW(ti, lpos) ((lpos) / ((ti)->con_cols))
     47#define LIN_POS(ti, col, row) ((col) + (row) * (ti)->con_cols)
    4748
    4849/** Seek direction */
     
    383384}
    384385
     386static void tinput_seek_scrpos(tinput_t *ti, int col, int line, bool shift_held)
     387{
     388        unsigned lpos;
     389        tinput_pre_seek(ti, shift_held);
     390
     391        lpos = LIN_POS(ti, col, line);
     392
     393        if (lpos > ti->text_coord)
     394                ti->pos = lpos -  ti->text_coord;
     395        else
     396                ti->pos = 0;
     397        if (ti->pos > ti->nc)
     398                ti->pos = ti->nc;
     399
     400        tinput_post_seek(ti, shift_held);
     401}
     402
    385403static void tinput_seek_max(tinput_t *ti, seek_dir_t dir, bool shift_held)
    386404{
     
    787805}
    788806
     807/** Handle key press event. */
     808static void tinput_key_press(tinput_t *ti, kbd_event_t *kev)
     809{
     810        if (kev->key == KC_LSHIFT)
     811                ti->lshift_held = true;
     812        if (kev->key == KC_RSHIFT)
     813                ti->rshift_held = true;
     814
     815        if (((kev->mods & KM_CTRL) != 0) &&
     816            ((kev->mods & (KM_ALT | KM_SHIFT)) == 0))
     817                tinput_key_ctrl(ti, kev);
     818       
     819        if (((kev->mods & KM_SHIFT) != 0) &&
     820            ((kev->mods & (KM_CTRL | KM_ALT)) == 0))
     821                tinput_key_shift(ti, kev);
     822       
     823        if (((kev->mods & KM_CTRL) != 0) &&
     824            ((kev->mods & KM_SHIFT) != 0) &&
     825            ((kev->mods & KM_ALT) == 0))
     826                tinput_key_ctrl_shift(ti, kev);
     827       
     828        if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
     829                tinput_key_unmod(ti, kev);
     830       
     831        if (kev->c >= ' ') {
     832                tinput_sel_delete(ti);
     833                tinput_insert_char(ti, kev->c);
     834        }
     835}
     836
     837/** Handle key release event. */
     838static void tinput_key_release(tinput_t *ti, kbd_event_t *kev)
     839{
     840        if (kev->key == KC_LSHIFT)
     841                ti->lshift_held = false;
     842        if (kev->key == KC_RSHIFT)
     843                ti->rshift_held = false;
     844}
     845
     846/** Position event */
     847static void tinput_pos(tinput_t *ti, pos_event_t *ev)
     848{
     849        if (ev->type == POS_PRESS) {
     850                tinput_seek_scrpos(ti, ev->hpos, ev->vpos,
     851                    ti->lshift_held || ti->rshift_held);
     852        }
     853}
     854
    789855/** Read in one line of input.
    790856 *
     
    816882                console_flush(ti->console);
    817883               
    818                 kbd_event_t ev;
    819                 if (!console_get_kbd_event(ti->console, &ev))
     884                cons_event_t ev;
     885                if (!console_get_event(ti->console, &ev))
    820886                        return EIO;
    821887               
    822                 if (ev.type != KEY_PRESS)
    823                         continue;
    824                
    825                 if (((ev.mods & KM_CTRL) != 0) &&
    826                     ((ev.mods & (KM_ALT | KM_SHIFT)) == 0))
    827                         tinput_key_ctrl(ti, &ev);
    828                
    829                 if (((ev.mods & KM_SHIFT) != 0) &&
    830                     ((ev.mods & (KM_CTRL | KM_ALT)) == 0))
    831                         tinput_key_shift(ti, &ev);
    832                
    833                 if (((ev.mods & KM_CTRL) != 0) &&
    834                     ((ev.mods & KM_SHIFT) != 0) &&
    835                     ((ev.mods & KM_ALT) == 0))
    836                         tinput_key_ctrl_shift(ti, &ev);
    837                
    838                 if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
    839                         tinput_key_unmod(ti, &ev);
    840                
    841                 if (ev.c >= ' ') {
    842                         tinput_sel_delete(ti);
    843                         tinput_insert_char(ti, ev.c);
     888                switch (ev.type) {
     889                case CEV_KEY:
     890                        if (ev.ev.key.type == KEY_PRESS)
     891                                tinput_key_press(ti, &ev.ev.key);
     892                        else
     893                                tinput_key_release(ti, &ev.ev.key);
     894                        break;
     895                case CEV_POS:
     896                        tinput_pos(ti, &ev.ev.pos);
     897                        break;
    844898                }
    845899        }
  • uspace/lib/clui/tinput.h

    rd120133 r192565b  
    146146        /** @c true if user requested to abort interactive loop */
    147147        bool exit_clui;
     148
     149        /** @c true if left shift key is currently held */
     150        bool lshift_held;
     151
     152        /** @c true if right shift key is currently held */
     153        bool rshift_held;
    148154} tinput_t;
    149155
  • uspace/lib/drv/generic/remote_nic.c

    rd120133 r192565b  
    104104       
    105105        nic_address_t address;
    106         bzero(&address, sizeof(nic_address_t));
     106        memset(&address, 0, sizeof(nic_address_t));
    107107       
    108108        int rc = nic_iface->get_address(dev, &address);
     
    173173       
    174174        nic_device_stats_t stats;
    175         bzero(&stats, sizeof(nic_device_stats_t));
     175        memset(&stats, 0, sizeof(nic_device_stats_t));
    176176       
    177177        int rc = nic_iface->get_stats(dev, &stats);
     
    208208       
    209209        nic_device_info_t info;
    210         bzero(&info, sizeof(nic_device_info_t));
     210        memset(&info, 0, sizeof(nic_device_info_t));
    211211       
    212212        int rc = nic_iface->get_device_info(dev, &info);
     
    399399        }
    400400       
    401         bzero(address_list, max_count * sizeof(nic_address_t));
     401        memset(address_list, 0, max_count * sizeof(nic_address_t));
    402402        nic_unicast_mode_t mode = NIC_UNICAST_DEFAULT;
    403403        size_t address_count = 0;
     
    503503        }
    504504       
    505         bzero(address_list, max_count * sizeof(nic_address_t));
     505        memset(address_list, 0, max_count * sizeof(nic_address_t));
    506506        nic_multicast_mode_t mode = NIC_MULTICAST_BLOCKED;
    507507        size_t address_count = 0;
     
    667667        }
    668668       
    669         bzero(address_list, max_count * sizeof(nic_address_t));
     669        memset(address_list, 0, max_count * sizeof(nic_address_t));
    670670        size_t address_count = 0;
    671671       
     
    759759       
    760760        nic_vlan_mask_t vlan_mask;
    761         bzero(&vlan_mask, sizeof(nic_vlan_mask_t));
     761        memset(&vlan_mask, 0, sizeof(nic_vlan_mask_t));
    762762       
    763763        int rc = nic_iface->vlan_get_mask(dev, &vlan_mask);
     
    932932        }
    933933       
    934         bzero(data, max_length);
     934        memset(data, 0, max_length);
    935935       
    936936        int rc = nic_iface->wol_virtue_probe(dev, id, &type, max_length,
     
    982982        }
    983983       
    984         bzero(id_list, max_count * sizeof (nic_wv_id_t));
     984        memset(id_list, 0, max_count * sizeof (nic_wv_id_t));
    985985       
    986986        int rc = nic_iface->wol_virtue_list(dev, type, max_count, id_list,
     
    10471047        }
    10481048       
    1049         bzero(data, max_length);
     1049        memset(data, 0, max_length);
    10501050       
    10511051        int rc = nic_iface->wol_load_info(dev, &type, max_length, data,
  • uspace/lib/ext4/libext4_directory.c

    rd120133 r192565b  
    725725                            name_len) {
    726726                                /* Compare names */
    727                                 if (bcmp((uint8_t *) name, dentry->name, name_len) == 0) {
     727                                if (memcmp((uint8_t *) name, dentry->name, name_len) == 0) {
    728728                                        *res_entry = dentry;
    729729                                        return EOK;
  • uspace/lib/gui/Makefile

    rd120133 r192565b  
    3535SOURCES = \
    3636        button.c \
     37        canvas.c \
    3738        connection.c \
    3839        grid.c \
  • uspace/lib/gui/grid.c

    rd120133 r192565b  
    11/*
    22 * Copyright (c) 2012 Petr Koupy
     3 * Copyright (c) 2013 Martin Decky
    34 * All rights reserved.
    45 *
     
    3839#include <malloc.h>
    3940#include <surface.h>
    40 
    4141#include "window.h"
    4242#include "grid.h"
    4343
    44 static void paint_internal(widget_t *w)
    45 {
    46         grid_t *grid = (grid_t *) w;
    47 
     44typedef struct {
     45        sysarg_t min;
     46        sysarg_t max;
     47        sysarg_t val;
     48} constraints_t;
     49
     50static void paint_internal(widget_t *widget)
     51{
     52        grid_t *grid = (grid_t *) widget;
     53       
    4854        surface_t *surface = window_claim(grid->widget.window);
    4955        if (!surface) {
    5056                window_yield(grid->widget.window);
    51         }
    52 
    53         for (sysarg_t y = w->vpos; y <  w->vpos + w->height; ++y) {
    54                 for (sysarg_t x = w->hpos; x < w->hpos + w->width; ++x) {
     57                return;
     58        }
     59       
     60        // FIXME: Replace with (accelerated) rectangle fill
     61        for (sysarg_t y = widget->vpos; y < widget->vpos + widget->height; y++) {
     62                for (sysarg_t x = widget->hpos; x < widget->hpos + widget->width; x++)
    5563                        surface_put_pixel(surface, x, y, grid->background);
    56                 }
    57         }
    58 
     64        }
     65       
    5966        window_yield(grid->widget.window);
    6067}
    6168
    62 static widget_t **widget_at(grid_t *grid, size_t row, size_t col)
    63 {
    64         if (row < grid->rows && col < grid->cols) {
     69static grid_cell_t *grid_cell_at(grid_t *grid, size_t col, size_t row)
     70{
     71        if ((col < grid->cols) && (row < grid->rows))
    6572                return grid->layout + (row * grid->cols + col);
    66         } else {
    67                 return NULL;
    68         }
     73       
     74        return NULL;
     75}
     76
     77static grid_cell_t *grid_coords_at(grid_t *grid, sysarg_t hpos, sysarg_t vpos)
     78{
     79        for (size_t c = 0; c < grid->cols; c++) {
     80                for (size_t r = 0; r < grid->rows; r++) {
     81                        grid_cell_t *cell = grid_cell_at(grid, c, r);
     82                        if (cell) {
     83                                widget_t *widget = cell->widget;
     84                               
     85                                if ((widget) && (hpos >= widget->hpos) &&
     86                                    (vpos >= widget->vpos) &&
     87                                    (hpos < widget->hpos + widget->width) &&
     88                                    (vpos < widget->vpos + widget->height))
     89                                        return cell;
     90                        }
     91                }
     92        }
     93       
     94        return NULL;
    6995}
    7096
     
    78104{
    79105        grid_t *grid = (grid_t *) widget;
    80 
     106       
    81107        deinit_grid(grid);
    82 
    83108        free(grid);
    84109}
     
    86111static void grid_reconfigure(widget_t *widget)
    87112{
    88         /* no-op */
     113        /* No-op */
     114}
     115
     116static void adjust_constraints(constraints_t *cons, size_t run,
     117    sysarg_t dim_min, sysarg_t dim_max)
     118{
     119        assert(run > 0);
     120       
     121        sysarg_t dim_min_part = dim_min / run;
     122        sysarg_t dim_min_rem = dim_min % run;
     123       
     124        sysarg_t dim_max_part = dim_max / run;
     125        sysarg_t dim_max_rem = dim_max % run;
     126       
     127        for (size_t i = 0; i < run; i++) {
     128                sysarg_t dim_min_cur = dim_min_part;
     129                sysarg_t dim_max_cur = dim_max_part;
     130               
     131                if (i == run - 1) {
     132                        dim_min_cur += dim_min_rem;
     133                        dim_max_cur += dim_max_rem;
     134                }
     135               
     136                /*
     137                 * We want the strongest constraint
     138                 * for the minimum.
     139                 */
     140                if (cons[i].min < dim_min_cur)
     141                        cons[i].min = dim_min_cur;
     142               
     143                /*
     144                 * The comparison is correct, we want
     145                 * the weakest constraint for the
     146                 * maximum.
     147                 */
     148                if (cons[i].max < dim_max_cur)
     149                        cons[i].max = dim_max_cur;
     150        }
     151}
     152
     153static void solve_constraints(constraints_t *cons, size_t run, sysarg_t sum)
     154{
     155        /* Initial solution */
     156        sysarg_t cur_sum = 0;
     157       
     158        for (size_t i = 0; i < run; i++) {
     159                cons[i].val = cons[i].min;
     160                cur_sum += cons[i].val;
     161        }
     162       
     163        /* Iterative improvement */
     164        while (cur_sum < sum) {
     165                sysarg_t delta = (sum - cur_sum) / run;
     166                if (delta == 0)
     167                        break;
     168               
     169                cur_sum = 0;
     170               
     171                for (size_t i = 0; i < run; i++) {
     172                        if (cons[i].val + delta < cons[i].max)
     173                                cons[i].val += delta;
     174                       
     175                        cur_sum += cons[i].val;
     176                }
     177        }
    89178}
    90179
     
    93182{
    94183        grid_t *grid = (grid_t *) widget;
    95 
     184       
    96185        widget_modify(widget, hpos, vpos, width, height);
    97186        paint_internal(widget);
    98 
    99         sysarg_t cell_width = width / grid->cols;
    100         sysarg_t cell_height = height / grid->rows;
    101 
    102         list_foreach(widget->children, link) {
    103                 widget_t *child = list_get_instance(link, widget_t, link);
    104 
    105                 sysarg_t widget_hpos = 0;
    106                 sysarg_t widget_vpos = 0;
    107                 sysarg_t widget_width = 0;
    108                 sysarg_t widget_height = 0;
    109 
    110                 size_t r = 0;
    111                 size_t c = 0;
    112                 for (r = 0; r < grid->rows; ++r) {
    113                         bool found = false;
    114                         for (c = 0; c < grid->cols; ++c) {
    115                                 widget_t **cell = widget_at(grid, r, c);
    116                                 if (cell && *cell == child) {
    117                                         found = true;
    118                                         break;
     187       
     188        /* Compute column widths */
     189        constraints_t *widths =
     190            (constraints_t *) calloc(grid->cols, sizeof(constraints_t));
     191        if (widths) {
     192                /* Constrain widths */
     193                for (size_t c = 0; c < grid->cols; c++) {
     194                        widths[c].min = 0;
     195                       
     196                        for (size_t r = 0; r < grid->rows; r++) {
     197                                grid_cell_t *cell = grid_cell_at(grid, c, r);
     198                                if (!cell)
     199                                        continue;
     200                               
     201                                widget_t *widget = cell->widget;
     202                                if (widget)
     203                                        adjust_constraints(&widths[c], cell->cols,
     204                                            widget->width_min, widget->width_max);
     205                        }
     206                }
     207               
     208                solve_constraints(widths, grid->cols, width);
     209        }
     210       
     211        /* Compute row heights */
     212        constraints_t *heights =
     213            (constraints_t *) calloc(grid->rows, sizeof(constraints_t));
     214        if (heights) {
     215                /* Constrain heights */
     216                for (size_t r = 0; r < grid->rows; r++) {
     217                        heights[r].min = 0;
     218                       
     219                        for (size_t c = 0; c < grid->cols; c++) {
     220                                grid_cell_t *cell = grid_cell_at(grid, c, r);
     221                                if (!cell)
     222                                        continue;
     223                               
     224                                widget_t *widget = cell->widget;
     225                                if (widget) {
     226                                        adjust_constraints(&heights[r], cell->rows,
     227                                            widget->height_min, widget->height_max);
    119228                                }
    120229                        }
    121                         if (found) {
    122                                 break;
     230                }
     231               
     232                solve_constraints(heights, grid->rows, height);
     233        }
     234       
     235        /* Rearrange widgets */
     236        if ((widths) && (heights)) {
     237                sysarg_t cur_vpos = vpos;
     238               
     239                for (size_t r = 0; r < grid->rows; r++) {
     240                        sysarg_t cur_hpos = hpos;
     241                       
     242                        for (size_t c = 0; c < grid->cols; c++) {
     243                                grid_cell_t *cell = grid_cell_at(grid, c, r);
     244                                if (!cell)
     245                                        continue;
     246                               
     247                                widget_t *widget = cell->widget;
     248                                if (widget) {
     249                                        sysarg_t cur_width = 0;
     250                                        sysarg_t cur_height = 0;
     251                                       
     252                                        for (size_t cd = 0; cd < cell->cols; cd++)
     253                                                cur_width += widths[c + cd].val;
     254                                       
     255                                        for (size_t rd = 0; rd < cell->rows; rd++)
     256                                                cur_height += heights[r + rd].val;
     257                                       
     258                                        if ((cur_width > 0) && (cur_height > 0)) {
     259                                                sysarg_t wwidth = cur_width;
     260                                                sysarg_t wheight = cur_height;
     261                                               
     262                                                /*
     263                                                 * Make sure the widget is respects its
     264                                                 * maximal constrains.
     265                                                 */
     266                                               
     267                                                if ((widget->width_max > 0) &&
     268                                                    (wwidth > widget->width_max))
     269                                                        wwidth = widget->width_max;
     270                                               
     271                                                if ((widget->height_max > 0) &&
     272                                                    (wheight > widget->height_max))
     273                                                        wheight = widget->height_max;
     274                                               
     275                                                widget->rearrange(widget, cur_hpos, cur_vpos,
     276                                                    wwidth, wheight);
     277                                        }
     278                                       
     279                                       
     280                                }
     281                               
     282                                cur_hpos += widths[c].val;
    123283                        }
    124                 }
    125 
    126                 widget_hpos = cell_width * c + hpos;
    127                 widget_vpos = cell_height * r + vpos;
    128 
    129                 for (size_t _c = c; _c < grid->cols; ++_c) {
    130                         widget_t **cell = widget_at(grid, r, _c);
    131                         if (cell && *cell == child) {
    132                                 widget_width += cell_width;
    133                         } else {
    134                                 break;
    135                         }
    136                 }
    137 
    138                 for (size_t _r = r; _r < grid->rows; ++_r) {
    139                         widget_t **cell = widget_at(grid, _r, c);
    140                         if (cell && *cell == child) {
    141                                 widget_height += cell_height;
    142                         } else {
    143                                 break;
    144                         }
    145                 }
    146 
    147                 if (widget_width > 0 && widget_height > 0) {
    148                         child->rearrange(child,
    149                             widget_hpos, widget_vpos, widget_width, widget_height);
    150                 }
    151         }
     284                       
     285                        cur_vpos += heights[r].val;
     286                }
     287        }
     288       
     289        if (widths)
     290                free(widths);
     291       
     292        if (heights)
     293                free(heights);
    152294}
    153295
     
    155297{
    156298        paint_internal(widget);
     299       
    157300        list_foreach(widget->children, link) {
    158301                widget_t *child = list_get_instance(link, widget_t, link);
    159302                child->repaint(child);
    160303        }
     304       
    161305        window_damage(widget->window);
    162306}
     
    164308static void grid_handle_keyboard_event(widget_t *widget, kbd_event_t event)
    165309{
    166         /* no-op */
     310        /* No-op */
    167311}
    168312
     
    170314{
    171315        grid_t *grid = (grid_t *) widget;
    172 
    173         if ((widget->height / grid->rows) == 0) {
    174                 return;
    175         }
    176         if ((widget->width / grid->cols) == 0) {
    177                 return;
    178         }
    179 
    180         sysarg_t row = (event.vpos - widget->vpos) / (widget->height / grid->rows);
    181         sysarg_t col = (event.hpos - widget->hpos) / (widget->width / grid->cols);
    182 
    183         widget_t **cell = widget_at(grid, row, col);
    184         if (cell && *cell) {
    185                 (*cell)->handle_position_event(*cell, event);
    186         }
    187 }
    188 
    189 static void grid_add(grid_t *grid, widget_t *widget,
    190     size_t row, size_t col, size_t rows, size_t cols)
    191 {
    192         assert(row + rows <= grid->rows);
    193         assert(col + cols <= grid->cols);
    194 
     316       
     317        grid_cell_t *cell = grid_coords_at(grid, event.hpos, event.vpos);
     318        if ((cell) && (cell->widget))
     319                cell->widget->handle_position_event(cell->widget, event);
     320}
     321
     322static bool grid_add(struct grid *grid, widget_t *widget, size_t col,
     323    size_t row, size_t cols, size_t rows)
     324{
     325        if ((cols == 0) || (rows == 0) || (col + cols > grid->cols) ||
     326            (row + rows > grid->rows))
     327                return false;
     328       
     329        grid_cell_t *cell = grid_cell_at(grid, col, row);
     330        if (!cell)
     331                return false;
     332       
     333        /*
     334         * Check whether the cell is not occupied by an
     335         * extension of a different cell.
     336         */
     337        if ((!cell->widget) && (cell->cols > 0) && (cell->rows > 0))
     338                return false;
     339       
    195340        widget->parent = (widget_t *) grid;
     341       
    196342        list_append(&widget->link, &grid->widget.children);
    197343        widget->window = grid->widget.window;
    198 
    199         for (size_t r = row; r < row + rows; ++r) {
    200                 for (size_t c = col; c < col + cols; ++c) {
    201                         widget_t **cell = widget_at(grid, r, c);
    202                         if (cell) {
    203                                 *cell = widget;
     344       
     345        /* Mark cells in layout */
     346        for (size_t r = row; r < row + rows; r++) {
     347                for (size_t c = col; c < col + cols; c++) {
     348                        if ((r == row) && (c == col)) {
     349                                cell->widget = widget;
     350                                cell->cols = cols;
     351                                cell->rows = rows;
     352                        } else {
     353                                grid_cell_t *extension = grid_cell_at(grid, c, r);
     354                                if (extension) {
     355                                        extension->widget = NULL;
     356                                        extension->cols = 1;
     357                                        extension->rows = 1;
     358                                }
    204359                        }
    205360                }
    206361        }
    207 }
    208 
    209 bool init_grid(grid_t *grid,
    210     widget_t *parent, size_t rows, size_t cols, pixel_t background)
    211 {
    212         assert(rows > 0);
    213         assert(cols > 0);
    214 
    215         widget_t **layout = (widget_t **) malloc(rows * cols * sizeof(widget_t *));
    216         if (!layout) {
     362       
     363        return true;
     364}
     365
     366bool init_grid(grid_t *grid, widget_t *parent, size_t cols, size_t rows,
     367    pixel_t background)
     368{
     369        if ((cols == 0) || (rows == 0))
    217370                return false;
    218         }
    219         memset(layout, 0, rows * cols * sizeof(widget_t *));
    220 
     371       
     372        grid->layout =
     373            (grid_cell_t *) calloc(cols * rows, sizeof(grid_cell_t));
     374        if (!grid->layout)
     375                return false;
     376       
     377        memset(grid->layout, 0, cols * rows * sizeof(grid_cell_t));
     378       
    221379        widget_init(&grid->widget, parent);
    222 
     380       
    223381        grid->widget.destroy = grid_destroy;
    224382        grid->widget.reconfigure = grid_reconfigure;
     
    227385        grid->widget.handle_keyboard_event = grid_handle_keyboard_event;
    228386        grid->widget.handle_position_event = grid_handle_position_event;
    229 
     387       
    230388        grid->add = grid_add;
    231389        grid->background = background;
     390        grid->cols = cols;
    232391        grid->rows = rows;
    233         grid->cols = cols;
    234         grid->layout = layout;
    235 
     392       
    236393        return true;
    237394}
    238395
    239 grid_t *create_grid(widget_t *parent, size_t rows, size_t cols, pixel_t background)
     396grid_t *create_grid(widget_t *parent, size_t cols, size_t rows, pixel_t background)
    240397{
    241398        grid_t *grid = (grid_t *) malloc(sizeof(grid_t));
    242         if (!grid) {
     399        if (!grid)
    243400                return NULL;
    244         }
    245 
    246         if (init_grid(grid, parent, rows, cols, background)) {
     401       
     402        if (init_grid(grid, parent, cols, rows, background))
    247403                return grid;
    248         } else {
    249                 free(grid);
    250                 return NULL;
    251         }
     404       
     405        free(grid);
     406        return NULL;
    252407}
    253408
  • uspace/lib/gui/grid.h

    rd120133 r192565b  
    3939#include <sys/types.h>
    4040#include <io/pixel.h>
    41 
    4241#include "widget.h"
    4342
    44 struct grid;
    45 typedef struct grid grid_t;
     43typedef struct {
     44        widget_t *widget;
     45        size_t cols;
     46        size_t rows;
     47} grid_cell_t;
    4648
    4749typedef struct grid {
    4850        widget_t widget;
    4951        pixel_t background;
     52        size_t cols;
    5053        size_t rows;
    51         size_t cols;
    52         widget_t **layout;
    53         void (*add)(grid_t *, widget_t *, size_t, size_t, size_t, size_t);
     54        grid_cell_t *layout;
     55        bool (*add)(struct grid *, widget_t *, size_t, size_t, size_t, size_t);
    5456} grid_t;
    5557
  • uspace/lib/gui/terminal.c

    rd120133 r192565b  
    7777static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
    7878static void term_set_cursor_visibility(con_srv_t *, bool);
    79 static int term_get_event(con_srv_t *, kbd_event_t *);
     79static int term_get_event(con_srv_t *, cons_event_t *);
    8080
    8181static con_ops_t con_ops = {
     
    420420                if (pos < size) {
    421421                        link_t *link = prodcons_consume(&term->input_pc);
    422                         kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
     422                        cons_event_t *event = list_get_instance(link, cons_event_t, link);
    423423                       
    424424                        /* Accept key presses of printable chars only. */
    425                         if ((event->type == KEY_PRESS) && (event->c != 0)) {
     425                        if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS &&
     426                            event->ev.key.c != 0) {
    426427                                wchar_t tmp[2] = {
    427                                         event->c,
     428                                        event->ev.key.c,
    428429                                        0
    429430                                };
     
    579580}
    580581
    581 static int term_get_event(con_srv_t *srv, kbd_event_t *event)
     582static int term_get_event(con_srv_t *srv, cons_event_t *event)
    582583{
    583584        terminal_t *term = srv_to_terminal(srv);
    584585        link_t *link = prodcons_consume(&term->input_pc);
    585         kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
    586        
    587         *event = *kevent;
    588         free(kevent);
     586        cons_event_t *ev = list_get_instance(link, cons_event_t, link);
     587       
     588        *event = *ev;
     589        free(ev);
    589590        return EOK;
    590591}
     
    634635}
    635636
     637static void terminal_queue_cons_event(terminal_t *term, cons_event_t *ev)
     638{
     639        /* Got key press/release event */
     640        cons_event_t *event =
     641            (cons_event_t *) malloc(sizeof(cons_event_t));
     642        if (event == NULL)
     643                return;
     644       
     645        *event = *ev;
     646        link_initialize(&event->link);
     647       
     648        prodcons_produce(&term->input_pc, &event->link);
     649}
     650
     651/* Got key press/release event */
    636652static void terminal_handle_keyboard_event(widget_t *widget,
    637653    kbd_event_t kbd_event)
    638654{
    639655        terminal_t *term = (terminal_t *) widget;
    640        
    641         /* Got key press/release event */
    642         kbd_event_t *event =
    643             (kbd_event_t *) malloc(sizeof(kbd_event_t));
    644         if (event == NULL)
    645                 return;
    646        
    647         link_initialize(&event->link);
    648         event->type = kbd_event.type;
    649         event->key = kbd_event.key;
    650         event->mods = kbd_event.mods;
    651         event->c = kbd_event.c;
    652        
    653         prodcons_produce(&term->input_pc, &event->link);
    654 }
    655 
    656 static void terminal_handle_position_event(widget_t *widget, pos_event_t event)
    657 {
    658         /*
    659          * Mouse events are ignored so far.
    660          * There is no consumer for it.
    661          */
     656        cons_event_t event;
     657       
     658        event.type = CEV_KEY;
     659        event.ev.key = kbd_event;
     660       
     661        terminal_queue_cons_event(term, &event);
     662}
     663
     664static void terminal_handle_position_event(widget_t *widget, pos_event_t pos_event)
     665{
     666        cons_event_t event;
     667        terminal_t *term = (terminal_t *) widget;
     668        sysarg_t sx = term->widget.hpos;
     669        sysarg_t sy = term->widget.vpos;
     670
     671        if (pos_event.type == POS_PRESS) {
     672                event.type = CEV_POS;
     673                event.ev.pos.type = pos_event.type;
     674                event.ev.pos.pos_id = pos_event.pos_id;
     675                event.ev.pos.btn_num = pos_event.btn_num;
     676
     677                event.ev.pos.hpos = (pos_event.hpos - sx) / FONT_WIDTH;
     678                event.ev.pos.vpos = (pos_event.vpos - sy) / FONT_SCANLINES;
     679                terminal_queue_cons_event(term, &event);
     680        }
    662681}
    663682
  • uspace/lib/gui/window.c

    rd120133 r192565b  
    424424
    425425        while (!list_empty(&win->events.list)) {
    426                 list_remove(list_first(&win->events.list));
     426                window_event_t *event = (window_event_t *) list_first(&win->events.list);
     427                list_remove(&event->link);
     428                free(event);
    427429        }
    428430
  • uspace/lib/nic/src/nic_addr_db.c

    rd120133 r192565b  
    7070        nic_addr_entry_t *entry = member_to_inst(item, nic_addr_entry_t, link);
    7171       
    72         return 0 == bcmp(entry->addr, key->addr, entry->len);
     72        return memcmp(entry->addr, key->addr, entry->len) == 0;
    7373}
    7474
  • uspace/lib/nic/src/nic_driver.c

    rd120133 r192565b  
    682682        fibril_rwlock_initialize(&nic_data->wv_lock);
    683683       
    684         bzero(&nic_data->mac, sizeof(nic_address_t));
    685         bzero(&nic_data->default_mac, sizeof(nic_address_t));
    686         bzero(&nic_data->stats, sizeof(nic_device_stats_t));
     684        memset(&nic_data->mac, 0, sizeof(nic_address_t));
     685        memset(&nic_data->default_mac, 0, sizeof(nic_address_t));
     686        memset(&nic_data->stats, 0, sizeof(nic_device_stats_t));
    687687       
    688688        return nic_data;
  • uspace/lib/nic/src/nic_impl.c

    rd120133 r192565b  
    129129
    130130                fibril_rwlock_write_lock(&nic_data->stats_lock);
    131                 bzero(&nic_data->stats, sizeof (nic_device_stats_t));
     131                memset(&nic_data->stats, 0, sizeof(nic_device_stats_t));
    132132                fibril_rwlock_write_unlock(&nic_data->stats_lock);
    133133
     
    535535                return ENOMEM;
    536536        }
    537         bzero(virtue, sizeof (nic_wol_virtue_t));
     537        memset(virtue, 0, sizeof(nic_wol_virtue_t));
    538538        if (length != 0) {
    539539                virtue->data = malloc(length);
  • uspace/lib/nic/src/nic_rx_control.c

    rd120133 r192565b  
    5555int nic_rxc_init(nic_rxc_t *rxc)
    5656{
    57         bzero(rxc, sizeof (nic_rxc_t));
     57        memset(rxc, 0, sizeof(nic_rxc_t));
    5858        int rc;
    5959        rc = nic_addr_db_init(&rxc->blocked_sources, ETH_ADDR);
  • uspace/lib/nic/src/nic_wol_virtues.c

    rd120133 r192565b  
    7373int nic_wol_virtues_init(nic_wol_virtues_t *wvs)
    7474{
    75         bzero(wvs, sizeof(nic_wol_virtues_t));
     75        memset(wvs, 0, sizeof(nic_wol_virtues_t));
    7676        wvs->table_operations.hash = nic_wv_hash;
    7777        wvs->table_operations.key_hash = nic_wv_key_hash;
  • uspace/lib/posix/include/posix/fcntl.h

    rd120133 r192565b  
    4444#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
    4545
     46/* Dummy compatibility flag */
     47#undef O_NOCTTY
     48#define O_NOCTTY 0
     49
    4650/* fcntl commands */
    4751#undef F_DUPFD
  • uspace/lib/posix/include/posix/float.h

    rd120133 r192565b  
    3636#define POSIX_FLOAT_H_
    3737
    38 /* Empty. Just to satisfy preprocessor. */
     38/* Rouding direction -1 - unknown */
     39#define FLT_ROUNDS (-1)
     40
     41/* define some standard C constants in terms of GCC built-ins */
     42#ifdef __GNUC__
     43        #undef DBL_MANT_DIG
     44        #define DBL_MANT_DIG __DBL_MANT_DIG__
     45        #undef DBL_MIN_EXP
     46        #define DBL_MIN_EXP __DBL_MIN_EXP__
     47        #undef DBL_MAX_EXP
     48        #define DBL_MAX_EXP __DBL_MAX_EXP__
     49        #undef DBL_MAX
     50        #define DBL_MAX __DBL_MAX__
     51        #undef DBL_MAX_10_EXP
     52        #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
     53        #undef DBL_MIN_10_EXP
     54        #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
     55        #undef DBL_MIN
     56        #define DBL_MIN __DBL_MIN__
     57        #undef DBL_DIG
     58        #define DBL_DIG __DBL_DIG__
     59        #undef DBL_EPSILON
     60        #define DBL_EPSILON __DBL_EPSILON__
     61        #undef FLT_RADIX
     62        #define FLT_RADIX __FLT_RADIX__
     63#endif
    3964
    4065#endif /* POSIX_FLOAT_H_ */
  • uspace/lib/posix/include/posix/limits.h

    rd120133 r192565b  
    4949#define PATH_MAX 256
    5050
     51/* it's probably a safe assumption */
     52#undef CHAR_BIT
     53#define CHAR_BIT 8
     54
    5155#endif /* POSIX_LIMITS_H_ */
    5256
  • uspace/lib/posix/include/posix/math.h

    rd120133 r192565b  
    3636#define POSIX_MATH_H_
    3737
     38#ifdef __GNUC__
     39        #define HUGE_VAL (__builtin_huge_val())
     40#endif
     41
    3842/* Normalization Functions */
    3943extern double posix_ldexp(double x, int exp);
    4044extern double posix_frexp(double num, int *exp);
    4145
     46double posix_fabs(double x);
     47double posix_floor(double x);
     48double posix_modf(double x, double *iptr);
     49double posix_fmod(double x, double y);
     50double posix_pow(double x, double y);
     51double posix_exp(double x);
     52double posix_sqrt(double x);
     53double posix_log(double x);
     54double posix_sin(double x);
     55double posix_cos(double x);
     56double posix_atan2(double y, double x);
     57
    4258#ifndef LIBPOSIX_INTERNAL
    4359        #define ldexp posix_ldexp
    4460        #define frexp posix_frexp
     61
     62        #define fabs posix_fabs
     63        #define floor posix_floor
     64        #define modf posix_modf
     65        #define fmod posix_fmod
     66        #define pow posix_pow
     67        #define exp posix_exp
     68        #define sqrt posix_sqrt
     69        #define log posix_log
     70        #define sin posix_sin
     71        #define cos posix_cos
     72        #define atan2 posix_atan2
    4573#endif
    4674
  • uspace/lib/posix/include/posix/stdio.h

    rd120133 r192565b  
    6161
    6262typedef struct _IO_FILE FILE;
     63
     64#ifndef LIBPOSIX_INTERNAL
     65        enum _buffer_type {
     66                /** No buffering */
     67                _IONBF,
     68                /** Line buffering */
     69                _IOLBF,
     70                /** Full buffering */
     71                _IOFBF
     72        };
     73#endif
    6374
    6475extern FILE *stdin;
  • uspace/lib/posix/source/math.c

    rd120133 r192565b  
    6262}
    6363
     64/**
     65 *
     66 * @param x
     67 * @return
     68 */
     69double posix_cos(double x)
     70{
     71        // TODO: Python dependency
     72        not_implemented();
     73}
     74
     75/**
     76 *
     77 * @param x
     78 * @param y
     79 * @return
     80 */
     81double posix_pow(double x, double y)
     82{
     83        // TODO: Python dependency
     84        not_implemented();
     85}
     86
     87/**
     88 *
     89 * @param x
     90 * @return
     91 */
     92double posix_floor(double x)
     93{
     94        // TODO: Python dependency
     95        not_implemented();
     96}
     97
     98/**
     99 *
     100 * @param x
     101 * @return
     102 */
     103double posix_fabs(double x)
     104{
     105        // TODO: Python dependency
     106        not_implemented();
     107}
     108
     109/**
     110 *
     111 * @param x
     112 * @param iptr
     113 * @return
     114 */
     115double posix_modf(double x, double *iptr)
     116{
     117        // TODO: Python dependency
     118        not_implemented();
     119}
     120
     121/**
     122 *
     123 * @param x
     124 * @param y
     125 * @return
     126 */
     127double posix_fmod(double x, double y)
     128{
     129        // TODO: Python dependency
     130        not_implemented();
     131}
     132
     133/**
     134 *
     135 * @param x
     136 * @return
     137 */
     138double posix_log(double x)
     139{
     140        // TODO: Python dependency
     141        not_implemented();
     142}
     143
     144/**
     145 *
     146 * @param x
     147 * @param y
     148 * @return
     149 */
     150double posix_atan2(double y, double x)
     151{
     152        // TODO: Python dependency
     153        not_implemented();
     154}
     155
     156/**
     157 *
     158 * @param x
     159 * @return
     160 */
     161double posix_sin(double x)
     162{
     163        // TODO: Python dependency
     164        not_implemented();
     165}
     166
     167/**
     168 *
     169 * @param x
     170 * @return
     171 */
     172double posix_exp(double x)
     173{
     174        // TODO: Python dependency
     175        not_implemented();
     176}
     177
     178/**
     179 *
     180 * @param x
     181 * @return
     182 */
     183double posix_sqrt(double x)
     184{
     185        // TODO: Python dependency
     186        not_implemented();
     187}
     188
    64189/** @}
    65190 */
  • uspace/lib/posix/source/strings.c

    rd120133 r192565b  
    131131int posix_bcmp(const void *mem1, const void *mem2, size_t n)
    132132{
    133         return bcmp(mem1, mem2, n);
     133        return memcmp(mem1, mem2, n);
    134134}
    135135
     
    155155void posix_bzero(void *mem, size_t n)
    156156{
    157         bzero(mem, n);
     157        memset(mem, 0, n);
    158158}
    159159
  • uspace/lib/usb/src/debug.c

    rd120133 r192565b  
    8484         * Remove previous string.
    8585         */
    86         bzero(buffer_dump[buffer_dump_index], BUFFER_DUMP_LEN);
     86        memset(buffer_dump[buffer_dump_index], 0, BUFFER_DUMP_LEN);
    8787
    8888        /* Do the actual dump. */
Note: See TracChangeset for help on using the changeset viewer.