diff options
author | Petri Savolainen <petri.savolainen@nokia.com> | 2015-10-16 15:13:48 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2015-12-29 14:07:52 +0300 |
commit | 6a5988533e877629ac0c800e5cf2b09d6fb56285 (patch) | |
tree | ec8b74f022728401320faed4753aa50e56425017 | |
parent | bbf9c099e4a9c1a9d27330e424f8e15cee3651da (diff) |
api: clib: added standard c library api
Some C library calls are often used in data plane code. This
API enables possibility to HW optimized implementation of those.
Added first memcpy and memset.
Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Conflicts:
platform/linux-generic/Makefile.am
-rw-r--r-- | include/odp.h | 1 | ||||
-rw-r--r-- | include/odp/api/std_clib.h | 64 | ||||
-rw-r--r-- | platform/Makefile.inc | 1 | ||||
-rw-r--r-- | platform/linux-generic/Makefile.am | 1 | ||||
-rw-r--r-- | platform/linux-generic/include/odp/std_clib.h | 30 |
5 files changed, 97 insertions, 0 deletions
diff --git a/include/odp.h b/include/odp.h index da57da824..2adcb8b74 100644 --- a/include/odp.h +++ b/include/odp.h @@ -57,6 +57,7 @@ extern "C" { #include <odp/thrmask.h> #include <odp/spinlock_recursive.h> #include <odp/rwlock_recursive.h> +#include <odp/std_clib.h> #ifdef __cplusplus } diff --git a/include/odp/api/std_clib.h b/include/odp/api/std_clib.h new file mode 100644 index 000000000..2119ec481 --- /dev/null +++ b/include/odp/api/std_clib.h @@ -0,0 +1,64 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP version of often used C library calls + */ + +#ifndef ODP_API_STD_CLIB_H_ +#define ODP_API_STD_CLIB_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup odp_std_clib ODP STD CLIB + * @details + * ODP version of often used C library calls + * @{ + */ + +/** + * Memcpy + * + * ODP version of C library memcpy function. It copies 'num' bytes from source + * to destination address. Source and destination memory blocks must not + * overlap. + * + * @param dst Pointer to destination memory block + * @param src Pointer to source memory block + * @param num Number of bytes to copy + * + * @return 'dst' address + */ +void *odp_memcpy(void *dst, const void *src, size_t num); + +/** + * Memset + * + * ODP version of C library memset function. It sets 'value' to first 'num' + * bytes of memory block pointed by 'ptr'. + * + * @param ptr Pointer to the memory block + * @param value Value to be set + * @param num Number of bytes to set + * + * @return 'ptr' address + */ +void *odp_memset(void *ptr, int value, size_t num); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/Makefile.inc b/platform/Makefile.inc index 86c46508e..ef9724baa 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -48,6 +48,7 @@ odpapiinclude_HEADERS = \ $(top_srcdir)/include/odp/api/shared_memory.h \ $(top_srcdir)/include/odp/api/spinlock.h \ $(top_srcdir)/include/odp/api/spinlock_recursive.h \ + $(top_srcdir)/include/odp/api/std_clib.h \ $(top_srcdir)/include/odp/api/std_types.h \ $(top_srcdir)/include/odp/api/sync.h \ $(top_srcdir)/include/odp/api/system_info.h \ diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 451b96e96..806419359 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -42,6 +42,7 @@ odpinclude_HEADERS = \ $(srcdir)/include/odp/shared_memory.h \ $(srcdir)/include/odp/spinlock.h \ $(srcdir)/include/odp/spinlock_recursive.h \ + $(srcdir)/include/odp/std_clib.h \ $(srcdir)/include/odp/std_types.h \ $(srcdir)/include/odp/sync.h \ $(srcdir)/include/odp/system_info.h \ diff --git a/platform/linux-generic/include/odp/std_clib.h b/platform/linux-generic/include/odp/std_clib.h new file mode 100644 index 000000000..c939c48e9 --- /dev/null +++ b/platform/linux-generic/include/odp/std_clib.h @@ -0,0 +1,30 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_STD_CLIB_H_ +#define ODP_PLAT_STD_CLIB_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/std_types.h> + +static inline void *odp_memcpy(void *dst, const void *src, size_t num) +{ + return memcpy(dst, src, num); +} + +static inline void *odp_memset(void *ptr, int value, size_t num) +{ + return memset(ptr, value, num); +} + +#ifdef __cplusplus +} +#endif + +#endif |