Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> | ||||
Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 5 | */ |
6 | |||||
7 | #include "ndn_memory.h" | ||||
8 | |||||
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame^] | 9 | #if !NDN_CPP_HAVE_MEMCMP |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 10 | int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, size_t len) |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 11 | { |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 12 | size_t i; |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 13 | |
14 | for (i = 0; i < len; i++) { | ||||
15 | if (buf1[i] > buf2[i]) | ||||
16 | return 1; | ||||
17 | else if (buf1[i] < buf2[i]) | ||||
18 | return -1; | ||||
19 | } | ||||
20 | |||||
21 | return 0; | ||||
22 | } | ||||
23 | #else | ||||
24 | int ndn_memcmp_stub_to_avoid_empty_file_warning = 0; | ||||
25 | #endif | ||||
26 | |||||
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame^] | 27 | #if !NDN_CPP_HAVE_MEMCPY |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 28 | void ndn_memcpy(uint8_t *dest, uint8_t *src, size_t len) |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 29 | { |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 30 | size_t i; |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 31 | |
32 | for (i = 0; i < len; i++) | ||||
33 | dest[i] = src[i]; | ||||
34 | } | ||||
Jeff Thompson | 2275e60 | 2013-06-28 22:24:47 -0700 | [diff] [blame] | 35 | #else |
36 | int ndn_memcpy_stub_to_avoid_empty_file_warning = 0; | ||||
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 37 | #endif |
38 | |||||
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame^] | 39 | #if !NDN_CPP_HAVE_MEMSET |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 40 | void ndn_memset(uint8_t *dest, int val, size_t len) |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 41 | { |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 42 | size_t i; |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 43 | |
44 | for (i = 0; i < len; i++) | ||||
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 45 | dest[i] = (uint8_t)val; |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 46 | } |
Jeff Thompson | 2275e60 | 2013-06-28 22:24:47 -0700 | [diff] [blame] | 47 | #else |
48 | int ndn_memset_stub_to_avoid_empty_file_warning = 0; | ||||
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 49 | #endif |