Changeset 6e8ed225 in mainline for uspace/lib/c


Ignore:
Timestamp:
2013-05-20T18:43:13Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4a5a18be
Parents:
d242cb6 (diff), acdb5bac (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: Replacement of BSD functions bzero, bcmp with C standard memset, memcmp.

Location:
uspace/lib/c
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/device/hw_res_parsed.c

    rd242cb6 r6e8ed225  
    188188        hw_resource_list_t hw_resources;
    189189        hw_res_list_parsed_clean(hw_res_parsed);
    190         bzero(&hw_resources, sizeof(hw_resource_list_t));
     190        memset(&hw_resources, 0, sizeof(hw_resource_list_t));
    191191       
    192192        int rc = hw_res_get_resource_list(sess, &hw_resources);
  • uspace/lib/c/generic/mem.c

    rd242cb6 r6e8ed225  
    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

    rd242cb6 r6e8ed225  
    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

    rd242cb6 r6e8ed225  
    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

    rd242cb6 r6e8ed225  
    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/mem.h

    rd242cb6 r6e8ed225  
    3838#include <sys/types.h>
    3939
    40 #define bzero(ptr, len)  memset((ptr), 0, (len))
    41 
    4240extern void *memset(void *, int, size_t)
    4341    __attribute__ ((optimize("-fno-tree-loop-distribute-patterns")));
     
    4543    __attribute__ ((optimize("-fno-tree-loop-distribute-patterns")));
    4644extern void *memmove(void *, const void *, size_t);
    47 
    48 extern int bcmp(const void *, const void *, size_t);
     45extern int memcmp(const void *, const void *, size_t);
    4946
    5047#endif
Note: See TracChangeset for help on using the changeset viewer.