On Fri, Oct 16, 2015 at 03:13:48PM +0300, Petri Savolainen wrote:
> 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.savolai...@nokia.com>

Reviewed-by: Jerin Jacob <jerin.ja...@caviumnetworks.com>

> ---
>  include/odp.h                                 |  1 +
>  include/odp/api/std_clib.h                    | 64 
> +++++++++++++++++++++++++++
>  platform/linux-generic/Makefile.am            |  2 +
>  platform/linux-generic/include/odp/std_clib.h | 30 +++++++++++++
>  4 files changed, 97 insertions(+)
>  create mode 100644 include/odp/api/std_clib.h
>  create mode 100644 platform/linux-generic/include/odp/std_clib.h
> 
> diff --git a/include/odp.h b/include/odp.h
> index 825c7e1..f2cd2d3 100644
> --- a/include/odp.h
> +++ b/include/odp.h
> @@ -56,6 +56,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 0000000..2119ec4
> --- /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/linux-generic/Makefile.am 
> b/platform/linux-generic/Makefile.am
> index 85c976d..fc202cc 100644
> --- a/platform/linux-generic/Makefile.am
> +++ b/platform/linux-generic/Makefile.am
> @@ -41,6 +41,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 \
> @@ -108,6 +109,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/include/odp/std_clib.h 
> b/platform/linux-generic/include/odp/std_clib.h
> new file mode 100644
> index 0000000..c939c48
> --- /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
> -- 
> 2.6.0
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to