blob: 85b01b3c20b621e74a7f5d7db140ed9801257692 [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson47eecfc2013-07-07 22:56:46 -07004 * See COPYING for copyright and distribution information.
Jeff Thompsonf418fe02013-06-27 17:28:55 -07005 */
6
7/*
Jeff Thompson7ca936b2013-07-11 12:43:44 -07008 * Based on HAVE_MEMCPY and HAVE_MEMSET in config.h, use the library version or a local implementation of memcmp, memcpy and memset.
Jeff Thompsonf418fe02013-06-27 17:28:55 -07009 */
10
11#ifndef NDN_MEMORY_H
Jeff Thompsona0d18c92013-08-06 13:55:32 -070012#define NDN_MEMORY_H
Jeff Thompsonf418fe02013-06-27 17:28:55 -070013
Jeff Thompson6cb56f92013-07-01 15:38:09 -070014#include "../../../config.h"
Jeff Thompsonf418fe02013-06-27 17:28:55 -070015
Jeff Thompsona0d18c92013-08-06 13:55:32 -070016#ifdef __cplusplus
Jeff Thompsonf418fe02013-06-27 17:28:55 -070017extern "C" {
18#endif
19
Jeff Thompsond4a1e162013-07-11 12:41:31 -070020#if HAVE_MEMCMP
21#include <memory.h>
22/**
23 * Use the library version of memcmp.
24 */
Jeff Thompson2f0bd002013-08-16 18:58:19 -070025static inline int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len) { return memcmp(buf1, buf2, len); }
Jeff Thompsond4a1e162013-07-11 12:41:31 -070026#else
27/**
28 * Use a local implementation of memcmp instead of the library version.
29 */
30int ndn_memcmp(unsigned char *buf1, unsigned char *buf2, unsigned int len);
31#endif
32
Jeff Thompsonf418fe02013-06-27 17:28:55 -070033#if HAVE_MEMCPY
34#include <memory.h>
35/**
36 * Use the library version of memcpy.
37 */
38static inline void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len) { memcpy(dest, src, len); }
39#else
40/**
41 * Use a local implementation of memcpy instead of the library version.
42 */
43void ndn_memcpy(unsigned char *dest, unsigned char *src, unsigned int len);
44#endif
45
46#if HAVE_MEMSET
47#include <memory.h>
48/**
49 * Use the library version of memset.
50 */
51static inline void ndn_memset(unsigned char *dest, int val, unsigned int len) { memset(dest, val, len); }
52#else
53/**
54 * Use a local implementation of memset instead of the library version.
55 */
56void ndn_memset(unsigned char *dest, int val, unsigned int len);
57#endif
58
Jeff Thompsona0d18c92013-08-06 13:55:32 -070059#ifdef __cplusplus
Jeff Thompsonf418fe02013-06-27 17:28:55 -070060}
61#endif
62
63#endif
64