Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | /* |
Jeff Thompson | 7ca936b | 2013-07-11 12:43:44 -0700 | [diff] [blame] | 7 | * Based on HAVE_MEMCPY and HAVE_MEMSET in config.h, use the library version or a local implementation of memcmp, memcpy and memset. |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef NDN_MEMORY_H |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 11 | #define NDN_MEMORY_H |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 12 | |
Jeff Thompson | 6cb56f9 | 2013-07-01 15:38:09 -0700 | [diff] [blame] | 13 | #include "../../../config.h" |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 14 | |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 15 | #ifdef __cplusplus |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 16 | extern "C" { |
| 17 | #endif |
| 18 | |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 19 | #if HAVE_MEMCMP |
| 20 | #include <memory.h> |
| 21 | /** |
| 22 | * Use the library version of memcmp. |
| 23 | */ |
Jeff Thompson | 2f0bd00 | 2013-08-16 18:58:19 -0700 | [diff] [blame] | 24 | static inline int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len) { return memcmp(buf1, buf2, len); } |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 25 | #else |
| 26 | /** |
| 27 | * Use a local implementation of memcmp instead of the library version. |
| 28 | */ |
| 29 | int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len); |
| 30 | #endif |
| 31 | |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 32 | #if HAVE_MEMCPY |
| 33 | #include <memory.h> |
| 34 | /** |
| 35 | * Use the library version of memcpy. |
| 36 | */ |
| 37 | static inline void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len) { memcpy(dest, src, len); } |
| 38 | #else |
| 39 | /** |
| 40 | * Use a local implementation of memcpy instead of the library version. |
| 41 | */ |
| 42 | void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len); |
| 43 | #endif |
| 44 | |
| 45 | #if HAVE_MEMSET |
| 46 | #include <memory.h> |
| 47 | /** |
| 48 | * Use the library version of memset. |
| 49 | */ |
| 50 | static inline void ndn_memset(unsigned char *dest, int val, unsigned int len) { memset(dest, val, len); } |
| 51 | #else |
| 52 | /** |
| 53 | * Use a local implementation of memset instead of the library version. |
| 54 | */ |
| 55 | void ndn_memset(unsigned char *dest, int val, unsigned int len); |
| 56 | #endif |
| 57 | |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 58 | #ifdef __cplusplus |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 59 | } |
| 60 | #endif |
| 61 | |
| 62 | #endif |
| 63 | |