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 | /* |
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame] | 8 | * Based on NDN_CPP_HAVE_MEMCPY and NDN_CPP_HAVE_MEMSET in ndn-cpp-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] | 9 | */ |
| 10 | |
| 11 | #ifndef NDN_MEMORY_H |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 12 | #define NDN_MEMORY_H |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 13 | |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 14 | #include <ndn-cpp/c/common.h> |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 15 | |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 16 | #ifdef __cplusplus |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame] | 20 | #if NDN_CPP_HAVE_MEMCMP |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 21 | #include <memory.h> |
| 22 | /** |
| 23 | * Use the library version of memcmp. |
| 24 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 25 | static inline int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, size_t len) { return memcmp(buf1, buf2, len); } |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 26 | #else |
| 27 | /** |
| 28 | * Use a local implementation of memcmp instead of the library version. |
| 29 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 30 | int ndn_memcmp(uint8_t *buf1, uint8_t *buf2, size_t len); |
Jeff Thompson | d4a1e16 | 2013-07-11 12:41:31 -0700 | [diff] [blame] | 31 | #endif |
| 32 | |
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame] | 33 | #if NDN_CPP_HAVE_MEMCPY |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 34 | #include <memory.h> |
| 35 | /** |
| 36 | * Use the library version of memcpy. |
| 37 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 38 | static inline void ndn_memcpy(uint8_t *dest, uint8_t *src, size_t len) { memcpy(dest, src, len); } |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 39 | #else |
| 40 | /** |
| 41 | * Use a local implementation of memcpy instead of the library version. |
| 42 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 43 | void ndn_memcpy(uint8_t *dest, uint8_t *src, size_t len); |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 44 | #endif |
| 45 | |
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame] | 46 | #if NDN_CPP_HAVE_MEMSET |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 47 | #include <memory.h> |
| 48 | /** |
| 49 | * Use the library version of memset. |
| 50 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 51 | static inline void ndn_memset(uint8_t *dest, int val, size_t len) { memset(dest, val, len); } |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 52 | #else |
| 53 | /** |
| 54 | * Use a local implementation of memset instead of the library version. |
| 55 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 56 | void ndn_memset(uint8_t *dest, int val, size_t len); |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 57 | #endif |
| 58 | |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 59 | #ifdef __cplusplus |
Jeff Thompson | f418fe0 | 2013-06-27 17:28:55 -0700 | [diff] [blame] | 60 | } |
| 61 | #endif |
| 62 | |
| 63 | #endif |
| 64 | |