@@ -16,8 +16,6 @@
#include <unistd.h>
#include <odp.h>
-#include <odp_align.h>
-#include <odp_crypto.h>
#include <odph_linux.h>
#include <odph_packet.h>
#include <odph_eth.h>
@@ -8,8 +8,6 @@
#include <string.h>
#include <odp.h>
-#include <odp_align.h>
-#include <odp_crypto.h>
#include <odph_ipsec.h>
#include <odp_ipsec_cache.h>
@@ -8,7 +8,6 @@
#include <string.h>
#include <odp.h>
-#include <odp_align.h>
#include <odp_crypto.h>
#include <odp_ipsec_fwd_db.h>
@@ -8,8 +8,6 @@
#include <string.h>
#include <odp.h>
-#include <odp_align.h>
-#include <odp_crypto.h>
#include <odp_ipsec_loop_db.h>
@@ -8,8 +8,6 @@
#include <string.h>
#include <odp.h>
-#include <odp_align.h>
-#include <odp_crypto.h>
#include <odp_ipsec_sa_db.h>
@@ -8,8 +8,6 @@
#include <string.h>
#include <odp.h>
-#include <odp_align.h>
-#include <odp_crypto.h>
#include <odp_ipsec_sp_db.h>
@@ -13,9 +13,6 @@
#include <openssl/evp.h>
#include <odp.h>
-#include <odp_align.h>
-#include <odp_crypto.h>
-#include <odp_packet.h>
#include <odph_packet.h>
#include <odph_eth.h>
#include <odph_ip.h>
@@ -18,10 +18,6 @@
extern "C" {
#endif
-#include <odp_std_types.h>
-#include <odp_byteorder.h>
-#include <odp_align.h>
-#include <odp_debug.h>
#define ODPH_ETHADDR_LEN 6 /**< Ethernet address length */
#define ODPH_ETHHDR_LEN 14 /**< Ethernet header length */
@@ -18,9 +18,6 @@
extern "C" {
#endif
-#include <odp_align.h>
-#include <odp_debug.h>
-#include <odp_byteorder.h>
/** ICMP header length */
#define ODPH_ICMPHDR_LEN 8
@@ -18,9 +18,6 @@
extern "C" {
#endif
-#include <odp_align.h>
-#include <odp_debug.h>
-#include <odp_byteorder.h>
#include <odph_chksum.h>
#include <string.h>
@@ -18,10 +18,6 @@
extern "C" {
#endif
-#include <odp_std_types.h>
-#include <odp_byteorder.h>
-#include <odp_align.h>
-#include <odp_debug.h>
#define ODPH_ESPHDR_LEN 8 /**< IPSec ESP header length */
#define ODPH_ESPTRL_LEN 2 /**< IPSec ESP trailer length */
@@ -18,9 +18,6 @@
extern "C" {
#endif
-#include <odp_align.h>
-#include <odp_debug.h>
-#include <odp_byteorder.h>
/** UDP header length */
#define ODPH_UDPHDR_LEN 8
@@ -18,6 +18,9 @@
extern "C" {
#endif
+#include <odp_platform_defines.h>
+#include <odp_platform_inlines.h>
+
#include <odp_config.h>
#include <odp_version.h>
@@ -32,6 +35,7 @@ extern "C" {
#include <odp_barrier.h>
#include <odp_spinlock.h>
#include <odp_atomic.h>
+#include <odp_rwlock.h>
#include <odp_init.h>
#include <odp_system_info.h>
@@ -49,6 +53,8 @@ extern "C" {
#include <odp_packet_flags.h>
#include <odp_packet_io.h>
+#include <odp_crypto.h>
+
#ifdef __cplusplus
}
#endif
@@ -23,34 +23,19 @@ extern "C" {
/**
- * Atomic integer
- */
-typedef volatile int32_t odp_atomic_int_t;
-
-/**
- * Atomic unsigned integer 64 bits
- */
-typedef volatile uint64_t odp_atomic_u64_t;
-
-/**
- * Atomic unsigned integer 32 bits
- */
-typedef volatile uint32_t odp_atomic_u32_t;
-
-
-/**
+ * @anchor odp_atomic_init_int
+ *
* Initialize atomic integer
*
* @param ptr An integer atomic variable
*
* @note The operation is not synchronized with other threads
*/
-static inline void odp_atomic_init_int(odp_atomic_int_t *ptr)
-{
- *ptr = 0;
-}
+void odp_atomic_init_int(odp_atomic_int_t *ptr);
/**
+ * @anchor odp_atomic_load_int
+ *
* Load value of atomic integer
*
* @param ptr An atomic variable
@@ -59,12 +44,11 @@ static inline void odp_atomic_init_int(odp_atomic_int_t *ptr)
*
* @note The operation is not synchronized with other threads
*/
-static inline int odp_atomic_load_int(odp_atomic_int_t *ptr)
-{
- return *ptr;
-}
+int odp_atomic_load_int(odp_atomic_int_t *ptr);
/**
+ * @anchor odp_atomic_store_int
+ *
* Store value to atomic integer
*
* @param ptr An atomic variable
@@ -72,12 +56,11 @@ static inline int odp_atomic_load_int(odp_atomic_int_t *ptr)
*
* @note The operation is not synchronized with other threads
*/
-static inline void odp_atomic_store_int(odp_atomic_int_t *ptr, int new_value)
-{
- *ptr = new_value;
-}
+void odp_atomic_store_int(odp_atomic_int_t *ptr, int new_value);
/**
+ * @anchor odp_fetch_add_int
+ *
* Fetch and add atomic integer
*
* @param ptr An atomic variable
@@ -85,12 +68,11 @@ static inline void odp_atomic_store_int(odp_atomic_int_t *ptr, int new_value)
*
* @return Value of the variable before the operation
*/
-static inline int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr, int value)
-{
- return __sync_fetch_and_add(ptr, value);
-}
+int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr, int value);
/**
+ * @anchor odp_atomic_fetch_sub_int
+ *
* Fetch and subtract atomic integer
*
* @param ptr An atomic integer variable
@@ -98,70 +80,64 @@ static inline int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr, int value)
*
* @return Value of the variable before the operation
*/
-static inline int odp_atomic_fetch_sub_int(odp_atomic_int_t *ptr, int value)
-{
- return __sync_fetch_and_sub(ptr, value);
-}
+int odp_atomic_fetch_sub_int(odp_atomic_int_t *ptr, int value);
/**
+ * @anchor odp_atomic_fetch_inc_int
+ *
* Fetch and increment atomic integer by 1
*
* @param ptr An atomic variable
*
* @return Value of the variable before the operation
*/
-static inline int odp_atomic_fetch_inc_int(odp_atomic_int_t *ptr)
-{
- return odp_atomic_fetch_add_int(ptr, 1);
-}
+int odp_atomic_fetch_inc_int(odp_atomic_int_t *ptr);
/**
+ * @anchor odp_atomic_inc_int
+ *
* Increment atomic integer by 1
*
* @param ptr An atomic variable
*
*/
-static inline void odp_atomic_inc_int(odp_atomic_int_t *ptr)
-{
- odp_atomic_fetch_add_int(ptr, 1);
-}
+void odp_atomic_inc_int(odp_atomic_int_t *ptr);
/**
+ * @anchor odp_atomic_fetch_dec_int
+ *
* Fetch and decrement atomic integer by 1
*
* @param ptr An atomic int variable
*
* @return Value of the variable before the operation
*/
-static inline int odp_atomic_fetch_dec_int(odp_atomic_int_t *ptr)
-{
- return odp_atomic_fetch_sub_int(ptr, 1);
-}
+int odp_atomic_fetch_dec_int(odp_atomic_int_t *ptr);
/**
+ * @anchor odp_atomic_dec_int
+ *
* Decrement atomic integer by 1
*
* @param ptr An atomic variable
*
*/
-static inline void odp_atomic_dec_int(odp_atomic_int_t *ptr)
-{
- odp_atomic_fetch_sub_int(ptr, 1);
-}
+void odp_atomic_dec_int(odp_atomic_int_t *ptr);
/**
+ * @anchor odp_atomic_init_u32
+ *
* Initialize atomic uint32
*
* @param ptr An atomic variable
*
* @note The operation is not synchronized with other threads
*/
-static inline void odp_atomic_init_u32(odp_atomic_u32_t *ptr)
-{
- *ptr = 0;
-}
+void odp_atomic_init_u32(odp_atomic_u32_t *ptr);
/**
+ * @anchor odp_atomic_load_u32
+ *
* Load value of atomic uint32
*
* @param ptr An atomic variable
@@ -170,12 +146,11 @@ static inline void odp_atomic_init_u32(odp_atomic_u32_t *ptr)
*
* @note The operation is not synchronized with other threads
*/
-static inline uint32_t odp_atomic_load_u32(odp_atomic_u32_t *ptr)
-{
- return *ptr;
-}
+uint32_t odp_atomic_load_u32(odp_atomic_u32_t *ptr);
/**
+ * @anchor odp_atomic_store_u32
+ *
* Store value to atomic uint32
*
* @param ptr An atomic variable
@@ -183,13 +158,12 @@ static inline uint32_t odp_atomic_load_u32(odp_atomic_u32_t *ptr)
*
* @note The operation is not synchronized with other threads
*/
-static inline void odp_atomic_store_u32(odp_atomic_u32_t *ptr,
- uint32_t new_value)
-{
- *ptr = new_value;
-}
+void odp_atomic_store_u32(odp_atomic_u32_t *ptr,
+ uint32_t new_value);
/**
+ * @anchor odp_atomic_fetch_add_u32
+ *
* Fetch and add atomic uint32
*
* @param ptr An atomic variable
@@ -197,13 +171,12 @@ static inline void odp_atomic_store_u32(odp_atomic_u32_t *ptr,
*
* @return Value of the variable before the operation
*/
-static inline uint32_t odp_atomic_fetch_add_u32(odp_atomic_u32_t *ptr,
- uint32_t value)
-{
- return __sync_fetch_and_add(ptr, value);
-}
+uint32_t odp_atomic_fetch_add_u32(odp_atomic_u32_t *ptr,
+ uint32_t value);
/**
+ * @anchor odp_atomic_fetch_sub_u32
+ *
* Fetch and subtract uint32
*
* @param ptr An atomic variable
@@ -211,76 +184,54 @@ static inline uint32_t odp_atomic_fetch_add_u32(odp_atomic_u32_t *ptr,
*
* @return Value of the variable before the operation
*/
-static inline uint32_t odp_atomic_fetch_sub_u32(odp_atomic_u32_t *ptr,
- uint32_t value)
-{
- return __sync_fetch_and_sub(ptr, value);
-}
+uint32_t odp_atomic_fetch_sub_u32(odp_atomic_u32_t *ptr,
+ uint32_t value);
/**
+ * @anchor odp_atomic_fetch_inc_u32
+ *
* Fetch and increment atomic uint32 by 1
*
* @param ptr An atomic variable
*
* @return Value of the variable before the operation
*/
-#if defined __OCTEON__
-
-static inline uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *ptr)
-{
- uint32_t ret;
-
- __asm__ __volatile__ ("syncws");
- __asm__ __volatile__ ("lai %0,(%2)" : "=r" (ret), "+m" (ptr) :
- "r" (ptr));
-
- return ret;
-}
-
-#else
-
-static inline uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *ptr)
-{
- return odp_atomic_fetch_add_u32(ptr, 1);
-}
-
-#endif
+uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *ptr);
/**
+ * @anchor odp_atomic_inc_u32
+ *
* Increment atomic uint32 by 1
*
* @param ptr An atomic variable
*
*/
-static inline void odp_atomic_inc_u32(odp_atomic_u32_t *ptr)
-{
- odp_atomic_fetch_add_u32(ptr, 1);
-}
+void odp_atomic_inc_u32(odp_atomic_u32_t *ptr);
/**
+ * @anchor odp_atomic_fetch_dec_u32
+ *
* Fetch and decrement uint32 by 1
*
* @param ptr An atomic variable
*
* @return Value of the variable before the operation
*/
-static inline uint32_t odp_atomic_fetch_dec_u32(odp_atomic_u32_t *ptr)
-{
- return odp_atomic_fetch_sub_u32(ptr, 1);
-}
+uint32_t odp_atomic_fetch_dec_u32(odp_atomic_u32_t *ptr);
/**
+ * @anchor odp_atomic_dec_u32
+ *
* Decrement atomic uint32 by 1
*
* @param ptr An atomic variable
*
*/
-static inline void odp_atomic_dec_u32(odp_atomic_u32_t *ptr)
-{
- odp_atomic_fetch_sub_u32(ptr, 1);
-}
+void odp_atomic_dec_u32(odp_atomic_u32_t *ptr);
/**
+ * @anchor odp_atomic_cmpset_u32
+ *
* Atomic compare and set for 32bit
*
* @param dst destination location into which the value will be written.
@@ -288,25 +239,23 @@ static inline void odp_atomic_dec_u32(odp_atomic_u32_t *ptr)
* @param src new value.
* @return Non-zero on success; 0 on failure.
*/
-static inline int
-odp_atomic_cmpset_u32(odp_atomic_u32_t *dst, uint32_t exp, uint32_t src)
-{
- return __sync_bool_compare_and_swap(dst, exp, src);
-}
+int
+odp_atomic_cmpset_u32(odp_atomic_u32_t *dst, uint32_t exp, uint32_t src);
/**
+ * @anchor odp_atomic_init_u64
+ *
* Initialize atomic uint64
*
* @param ptr An atomic variable
*
* @note The operation is not synchronized with other threads
*/
-static inline void odp_atomic_init_u64(odp_atomic_u64_t *ptr)
-{
- *ptr = 0;
-}
+void odp_atomic_init_u64(odp_atomic_u64_t *ptr);
/**
+ * @anchor odp_atomic_load_u64
+ *
* Load value of atomic uint64
*
* @param ptr An atomic variable
@@ -315,12 +264,11 @@ static inline void odp_atomic_init_u64(odp_atomic_u64_t *ptr)
*
* @note The operation is not synchronized with other threads
*/
-static inline uint64_t odp_atomic_load_u64(odp_atomic_u64_t *ptr)
-{
- return *ptr;
-}
+uint64_t odp_atomic_load_u64(odp_atomic_u64_t *ptr);
/**
+ * @anchor odp_atomic_store_u64
+ *
* Store value to atomic uint64
*
* @param ptr An atomic variable
@@ -328,25 +276,23 @@ static inline uint64_t odp_atomic_load_u64(odp_atomic_u64_t *ptr)
*
* @note The operation is not synchronized with other threads
*/
-static inline void odp_atomic_store_u64(odp_atomic_u64_t *ptr,
- uint64_t new_value)
-{
- *ptr = new_value;
-}
+void odp_atomic_store_u64(odp_atomic_u64_t *ptr,
+ uint64_t new_value);
/**
+ * @anchor odp_atomic_add_u64
+ *
* Add atomic uint64
*
* @param ptr An atomic variable
* @param value A value to be added to the variable
*
*/
-static inline void odp_atomic_add_u64(odp_atomic_u64_t *ptr, uint64_t value)
-{
- __sync_fetch_and_add(ptr, value);
-}
+void odp_atomic_add_u64(odp_atomic_u64_t *ptr, uint64_t value);
/**
+ * @anchor odp_atomic_fetch_add_u64
+ *
* Fetch and add atomic uint64
*
* @param ptr An atomic variable
@@ -354,34 +300,21 @@ static inline void odp_atomic_add_u64(odp_atomic_u64_t *ptr, uint64_t value)
*
* @return Value of the variable before the operation
*/
-
-#if defined __powerpc__ && !defined __powerpc64__
-static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr,
- uint64_t value)
-{
- return __sync_fetch_and_add((odp_atomic_u32_t *)ptr,
- (uint32_t)value);
-}
-#else
-static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr,
- uint64_t value)
-{
- return __sync_fetch_and_add(ptr, value);
-}
-#endif
+uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr, uint64_t value);
/**
+ * @anchor odp_atomic_sub_u64
+ *
* Subtract atomic uint64
*
* @param ptr An atomic variable
* @param value A value to be subtracted from the variable
*
*/
-static inline void odp_atomic_sub_u64(odp_atomic_u64_t *ptr, uint64_t value)
-{
- __sync_fetch_and_sub(ptr, value);
-}
+void odp_atomic_sub_u64(odp_atomic_u64_t *ptr, uint64_t value);
/**
+ * @anchor odp_atomic_fetch_sub_u64
+ *
* Fetch and subtract atomic uint64
*
* @param ptr An atomic variable
@@ -389,67 +322,52 @@ static inline void odp_atomic_sub_u64(odp_atomic_u64_t *ptr, uint64_t value)
*
* @return Value of the variable before the operation
*/
-#if defined __powerpc__ && !defined __powerpc64__
-static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr,
- uint64_t value)
-{
- return __sync_fetch_and_sub((odp_atomic_u32_t *)ptr,
- (uint32_t)value);
-}
-#else
-static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr,
- uint64_t value)
-{
- return __sync_fetch_and_sub(ptr, value);
-}
-#endif
+uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr, uint64_t value);
/**
+ * @anchor odp_atomic_fetch_inc_u64
+ *
* Fetch and increment atomic uint64 by 1
*
* @param ptr An atomic variable
*
* @return Value of the variable before the operation
*/
-static inline uint64_t odp_atomic_fetch_inc_u64(odp_atomic_u64_t *ptr)
-{
- return odp_atomic_fetch_add_u64(ptr, 1);
-}
+uint64_t odp_atomic_fetch_inc_u64(odp_atomic_u64_t *ptr);
/**
+ * @anchor odp_atomic_inc_u64
+ *
* Increment atomic uint64 by 1
*
* @param ptr An atomic variable
*
*/
-static inline void odp_atomic_inc_u64(odp_atomic_u64_t *ptr)
-{
- odp_atomic_fetch_add_u64(ptr, 1);
-}
+void odp_atomic_inc_u64(odp_atomic_u64_t *ptr);
/**
+ * @anchor odp_atomic_fetch_dec_u64
+ *
* Fetch and decrement atomic uint64 by 1
*
* @param ptr An atomic variable
*
* @return Value of the variable before the operation
*/
-static inline uint64_t odp_atomic_fetch_dec_u64(odp_atomic_u64_t *ptr)
-{
- return odp_atomic_fetch_sub_u64(ptr, 1);
-}
+uint64_t odp_atomic_fetch_dec_u64(odp_atomic_u64_t *ptr);
/**
+ * @anchor odp_atomic_dec_u64
+ *
* Decrement atomic uint64 by 1
*
* @param ptr An atomic variable
*
*/
-static inline void odp_atomic_dec_u64(odp_atomic_u64_t *ptr)
-{
- odp_atomic_fetch_sub_u64(ptr, 1);
-}
+void odp_atomic_dec_u64(odp_atomic_u64_t *ptr);
/**
+ * @anchor odp_atomic_cmpset_u64
+ *
* Atomic compare and set for 64bit
*
* @param dst destination location into which the value will be written.
@@ -457,11 +375,7 @@ static inline void odp_atomic_dec_u64(odp_atomic_u64_t *ptr)
* @param src new value.
* @return Non-zero on success; 0 on failure.
*/
-static inline int
-odp_atomic_cmpset_u64(odp_atomic_u64_t *dst, uint64_t exp, uint64_t src)
-{
- return __sync_bool_compare_and_swap(dst, exp, src);
-}
+int odp_atomic_cmpset_u64(odp_atomic_u64_t *dst, uint64_t exp, uint64_t src);
#ifdef __cplusplus
}
@@ -22,102 +22,34 @@ extern "C" {
#include <odp_std_types.h>
#include <odp_compiler.h>
-#ifndef __BYTE_ORDER
-#error __BYTE_ORDER not defined!
-#endif
-
-#ifndef __BIG_ENDIAN
-#error __BIG_ENDIAN not defined!
-#endif
-
-#ifndef __LITTLE_ENDIAN
-#error __LITTLE_ENDIAN not defined!
-#endif
-
-/** Big endian byte order */
-#define ODP_BIG_ENDIAN __BIG_ENDIAN
-
-/** Little endian byte order */
-#define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
-
-/** Selected byte order */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define ODP_BYTE_ORDER ODP_BIG_ENDIAN
-#endif
-
-
-/* for use with type checkers such as sparse */
-#ifdef __CHECKER__
-/** @internal bitwise attribute */
-#define __odp_bitwise __attribute__((bitwise))
-/** @internal force attribute */
-#define __odp_force __attribute__((force))
-#else
-/** @internal bitwise attribute */
-#define __odp_bitwise
-/** @internal force attribute */
-#define __odp_force
-#endif
-
-
-typedef uint16_t __odp_bitwise uint16le_t; /**< unsigned 16bit little endian */
-typedef uint16_t __odp_bitwise uint16be_t; /**< unsigned 16bit big endian */
-
-typedef uint32_t __odp_bitwise uint32le_t; /**< unsigned 32bit little endian */
-typedef uint32_t __odp_bitwise uint32be_t; /**< unsigned 32bit big endian */
-
-typedef uint64_t __odp_bitwise uint64le_t; /**< unsigned 64bit little endian */
-typedef uint64_t __odp_bitwise uint64be_t; /**< unsigned 64bit big endian */
-
-typedef uint16_t __odp_bitwise uint16sum_t; /**< unsigned 16bit bitwise */
-typedef uint32_t __odp_bitwise uint32sum_t; /**< unsigned 32bit bitwise */
-/*
- * Big Endian -> CPU byte order:
- */
+#include <odp_platform_defines.h>
/**
+ * @anchor odp_be_to_cpu_16
+ *
* Convert 16bit big endian to cpu native uint16_t
* @param be16 big endian 16bit
* @return cpu native uint16_t
*/
-static inline uint16_t odp_be_to_cpu_16(uint16be_t be16)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return __odp_builtin_bswap16((__odp_force uint16_t)be16);
-#else
- return (__odp_force uint16_t)be16;
-#endif
-}
+uint16_t odp_be_to_cpu_16(uint16be_t be16);
/**
+ * @anchor odp_be_to_cpu_32
+ *
* Convert 32bit big endian to cpu native uint32_t
* @param be32 big endian 32bit
* @return cpu native uint32_t
*/
-static inline uint32_t odp_be_to_cpu_32(uint32be_t be32)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return __builtin_bswap32((__odp_force uint32_t)be32);
-#else
- return (__odp_force uint32_t)be32;
-#endif
-}
+uint32_t odp_be_to_cpu_32(uint32be_t be32);
/**
+ * @anchor odp_be_to_cpu_64
+ *
* Convert 64bit big endian to cpu native uint64_t
* @param be64 big endian 64bit
* @return cpu native uint64_t
*/
-static inline uint64_t odp_be_to_cpu_64(uint64be_t be64)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return __builtin_bswap64((__odp_force uint64_t)be64);
-#else
- return (__odp_force uint64_t)be64;
-#endif
-}
+uint64_t odp_be_to_cpu_64(uint64be_t be64);
/*
@@ -125,46 +57,31 @@ static inline uint64_t odp_be_to_cpu_64(uint64be_t be64)
*/
/**
+ * @anchor odp_cpu_to_be_16
+ *
* Convert cpu native uint16_t to 16bit big endian
* @param cpu16 uint16_t in cpu native format
* @return big endian 16bit
*/
-static inline uint16be_t odp_cpu_to_be_16(uint16_t cpu16)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint16be_t)__odp_builtin_bswap16(cpu16);
-#else
- return (__odp_force uint16be_t)cpu16;
-#endif
-}
+uint16be_t odp_cpu_to_be_16(uint16_t cpu16);
/**
+ * @anchor odp_cpu_to_be_32
+ *
* Convert cpu native uint32_t to 32bit big endian
* @param cpu32 uint32_t in cpu native format
* @return big endian 32bit
*/
-static inline uint32be_t odp_cpu_to_be_32(uint32_t cpu32)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint32be_t)__builtin_bswap32(cpu32);
-#else
- return (__odp_force uint32be_t)cpu32;
-#endif
-}
+uint32be_t odp_cpu_to_be_32(uint32_t cpu32);
/**
+ * @anchor odp_cpu_to_be_64
+ *
* Convert cpu native uint64_t to 64bit big endian
* @param cpu64 uint64_t in cpu native format
* @return big endian 64bit
*/
-static inline uint64be_t odp_cpu_to_be_64(uint64_t cpu64)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint64be_t)__builtin_bswap64(cpu64);
-#else
- return (__odp_force uint64be_t)cpu64;
-#endif
-}
+uint64be_t odp_cpu_to_be_64(uint64_t cpu64);
/*
@@ -172,46 +89,31 @@ static inline uint64be_t odp_cpu_to_be_64(uint64_t cpu64)
*/
/**
+ * @anchor odp_le_to_cpu_16
+ *
* Convert 16bit little endian to cpu native uint16_t
* @param le16 little endian 16bit
* @return cpu native uint16_t
*/
-static inline uint16_t odp_le_to_cpu_16(uint16le_t le16)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint16_t)le16;
-#else
- return __odp_builtin_bswap16((__odp_force uint16_t)le16);
-#endif
-}
+uint16_t odp_le_to_cpu_16(uint16le_t le16);
/**
+ * @anchor odp_le_to_cpu_32
+ *
* Convert 32bit little endian to cpu native uint32_t
* @param le32 little endian 32bit
* @return cpu native uint32_t
*/
-static inline uint32_t odp_le_to_cpu_32(uint32le_t le32)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint32_t)le32;
-#else
- return __builtin_bswap32((__odp_force uint32_t)le32);
-#endif
-}
+uint32_t odp_le_to_cpu_32(uint32le_t le32);
/**
+ * @anchor odp_le_to_cpu_64
+ *
* Convert 64bit little endian to cpu native uint64_t
* @param le64 little endian 64bit
* @return cpu native uint64_t
*/
-static inline uint64_t odp_le_to_cpu_64(uint64le_t le64)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint64_t)le64;
-#else
- return __builtin_bswap64((__odp_force uint64_t)le64);
-#endif
-}
+uint64_t odp_le_to_cpu_64(uint64le_t le64);
/*
@@ -219,46 +121,31 @@ static inline uint64_t odp_le_to_cpu_64(uint64le_t le64)
*/
/**
+ * @anchor odp_cpu_to_le_16
+ *
* Convert cpu native uint16_t to 16bit little endian
* @param cpu16 uint16_t in cpu native format
* @return little endian 16bit
*/
-static inline uint16le_t odp_cpu_to_le_16(uint16_t cpu16)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint16le_t)cpu16;
-#else
- return (__odp_force uint16le_t)__odp_builtin_bswap16(cpu16);
-#endif
-}
+uint16le_t odp_cpu_to_le_16(uint16_t cpu16);
/**
+ * @anchor odp_cpu_to_le_32
+ *
* Convert cpu native uint32_t to 32bit little endian
* @param cpu32 uint32_t in cpu native format
* @return little endian 32bit
*/
-static inline uint32le_t odp_cpu_to_le_32(uint32_t cpu32)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint32le_t)cpu32;
-#else
- return (__odp_force uint32le_t)__builtin_bswap32(cpu32);
-#endif
-}
+uint32le_t odp_cpu_to_le_32(uint32_t cpu32);
/**
+ * @anchor odp_cpu_to_le_64
+ *
* Convert cpu native uint64_t to 64bit little endian
* @param cpu64 uint64_t in cpu native format
* @return little endian 64bit
*/
-static inline uint64le_t odp_cpu_to_le_64(uint64_t cpu64)
-{
-#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
- return (__odp_force uint64le_t)cpu64;
-#else
- return (__odp_force uint64le_t)__builtin_bswap64(cpu64);
-#endif
-}
+uint64le_t odp_cpu_to_le_64(uint64_t cpu64);
#ifdef __cplusplus
@@ -22,20 +22,6 @@ extern "C" {
#include <odp_std_types.h>
-/** @internal */
-#define ODP_COREMASK_SIZE_U64 1
-
-/**
- * Core mask
- *
- * Don't access directly, use access functions.
- */
-typedef struct odp_coremask_t {
- uint64_t _u64[ODP_COREMASK_SIZE_U64]; /**< @private Mask*/
-
-} odp_coremask_t;
-
-
/**
* Add core mask bits from a string
@@ -86,10 +72,7 @@ void odp_coremask_from_u64(const uint64_t *u64, int num, odp_coremask_t *mask);
* Clear entire mask
* @param mask Core mask to flush with zero value
*/
-static inline void odp_coremask_zero(odp_coremask_t *mask)
-{
- mask->_u64[0] = 0;
-}
+void odp_coremask_zero(odp_coremask_t *mask);
/**
* Add core to mask
@@ -129,11 +112,8 @@ int odp_coremask_count(const odp_coremask_t *mask);
* @param src1 Source mask 1
* @param src2 Source mask 2
*/
-static inline void odp_coremask_and(odp_coremask_t *dest, odp_coremask_t *src1,
- odp_coremask_t *src2)
-{
- dest->_u64[0] = src1->_u64[0] & src2->_u64[0];
-}
+void odp_coremask_and(odp_coremask_t *dest, odp_coremask_t *src1,
+ odp_coremask_t *src2);
/**
* Logical OR over two source masks.
@@ -142,11 +122,8 @@ static inline void odp_coremask_and(odp_coremask_t *dest, odp_coremask_t *src1,
* @param src1 Source mask 1
* @param src2 Source mask 2
*/
-static inline void odp_coremask_or(odp_coremask_t *dest, odp_coremask_t *src1,
- odp_coremask_t *src2)
-{
- dest->_u64[0] = src1->_u64[0] | src2->_u64[0];
-}
+void odp_coremask_or(odp_coremask_t *dest, odp_coremask_t *src1,
+ odp_coremask_t *src2);
/**
* Logical XOR over two source masks.
@@ -155,20 +132,14 @@ static inline void odp_coremask_or(odp_coremask_t *dest, odp_coremask_t *src1,
* @param src1 Source mask 1
* @param src2 Source mask 2
*/
-static inline void odp_coremask_xor(odp_coremask_t *dest, odp_coremask_t *src1,
- odp_coremask_t *src2)
-{
- dest->_u64[0] = src1->_u64[0] ^ src2->_u64[0];
-}
+void odp_coremask_xor(odp_coremask_t *dest, odp_coremask_t *src1,
+ odp_coremask_t *src2);
/**
* Test if two masks contain the same cores
*/
-static inline int odp_coremask_equal(odp_coremask_t *mask1,
- odp_coremask_t *mask2)
-{
- return (mask1->_u64[0] == mask2->_u64[0]);
-}
+int odp_coremask_equal(odp_coremask_t *mask1,
+ odp_coremask_t *mask2);
#ifdef __cplusplus
}
new file mode 100644
@@ -0,0 +1,152 @@
+/**
+ * @file
+ *
+ * ODP platform defines and typedefs
+ */
+
+/******************************************************************************
+ * odp_version.h
+*******************************************************************************/
+
+#ifndef ODP_PLATFORM_DEFINES_H_
+#define ODP_PLATFORM_DEFINES_H_
+/**
+ * ODP API main version
+ *
+ * Introduction of major new features or changes. APIs with different major
+ * versions are likely not backward compatible.
+ */
+#define ODP_VERSION_API_MAIN 0
+
+/**
+ * ODP API sub version
+ *
+ * Introduction of additional features or minor changes. APIs with common
+ * major version and different sub versions may be backward compatible (if only
+ * additions).
+ */
+#define ODP_VERSION_API_SUB 0
+
+/**
+ * ODP API bug correction version
+ *
+ * Bug corrections to the API files. APIs with the same major and sub
+ * versions, but different bug correction versions are backward compatible.
+ */
+#define ODP_VERSION_API_BUG 1
+
+
+/** @internal Version string expand */
+#define ODP_VERSION_STR_EXPAND(x) #x
+
+/** @internal Version to string */
+#define ODP_VERSION_TO_STR(x) ODP_VERSION_STR_EXPAND(x)
+
+/** @internal API version string */
+#define ODP_VERSION_API_STR \
+ODP_VERSION_TO_STR(ODP_VERSION_API_MAIN) "."\
+ODP_VERSION_TO_STR(ODP_VERSION_API_SUB) "."\
+ODP_VERSION_TO_STR(ODP_VERSION_API_BUG)
+
+
+/******************************************************************************
+ * odp_byte_order.h
+*******************************************************************************/
+
+#include <endian.h>
+#include <odp_std_types.h>
+#include <odp_compiler.h>
+
+#ifndef __BYTE_ORDER
+#error __BYTE_ORDER not defined!
+#endif
+
+#ifndef __BIG_ENDIAN
+#error __BIG_ENDIAN not defined!
+#endif
+
+#ifndef __LITTLE_ENDIAN
+#error __LITTLE_ENDIAN not defined!
+#endif
+
+/** Big endian byte order */
+#define ODP_BIG_ENDIAN __BIG_ENDIAN
+
+/** Little endian byte order */
+#define ODP_LITTLE_ENDIAN __LITTLE_ENDIAN
+
+/** Selected byte order */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define ODP_BYTE_ORDER ODP_BIG_ENDIAN
+#endif
+
+/* for use with type checkers such as sparse */
+#ifdef __CHECKER__
+/** @internal bitwise attribute */
+#define __odp_bitwise __attribute__((bitwise))
+/** @internal force attribute */
+#define __odp_force __attribute__((force))
+#else
+/** @internal bitwise attribute */
+#define __odp_bitwise
+/** @internal force attribute */
+#define __odp_force
+#endif
+
+
+typedef uint16_t __odp_bitwise uint16le_t; /**< unsigned 16bit little endian */
+typedef uint16_t __odp_bitwise uint16be_t; /**< unsigned 16bit big endian */
+
+typedef uint32_t __odp_bitwise uint32le_t; /**< unsigned 32bit little endian */
+typedef uint32_t __odp_bitwise uint32be_t; /**< unsigned 32bit big endian */
+
+typedef uint64_t __odp_bitwise uint64le_t; /**< unsigned 64bit little endian */
+typedef uint64_t __odp_bitwise uint64be_t; /**< unsigned 64bit big endian */
+
+typedef uint16_t __odp_bitwise uint16sum_t; /**< unsigned 16bit bitwise */
+typedef uint32_t __odp_bitwise uint32sum_t; /**< unsigned 32bit bitwise */
+/*
+ * Big Endian -> CPU byte order:
+ */
+
+/******************************************************************************
+ * odp_coremask.h
+*******************************************************************************/
+
+/** @internal */
+#define ODP_COREMASK_SIZE_U64 1
+
+/**
+ * Core mask
+ *
+ * Don't access directly, use access functions.
+ */
+typedef struct odp_coremask_t {
+ uint64_t _u64[ODP_COREMASK_SIZE_U64]; /**< @private Mask*/
+
+} odp_coremask_t;
+
+
+/******************************************************************************
+ * odp_atomic.h
+*******************************************************************************/
+
+/**
+ * Atomic integer
+ */
+typedef volatile int32_t odp_atomic_int_t;
+
+/**
+ * Atomic unsigned integer 64 bits
+ */
+typedef volatile uint64_t odp_atomic_u64_t;
+
+/**
+ * Atomic unsigned integer 32 bits
+ */
+typedef volatile uint32_t odp_atomic_u32_t;
+
+
+#endif
new file mode 100644
@@ -0,0 +1,527 @@
+/**
+ * @file
+ *
+ * ODP platform inline implementations
+ */
+
+#ifndef ODP_PLATFORM_INLINES_H_
+#define ODP_PLATFORM_INLINES_H_
+
+#include <odp_std_types.h>
+#include <odp_compiler.h>
+#include <odp_platform_defines.h>
+
+/******************************************************************************
+ * odp_version.h
+*******************************************************************************/
+/**
+ * odp_version_api_str
+ */
+static inline const char *odp_version_api_str(void)
+{
+ return ODP_VERSION_API_STR;
+}
+
+
+/******************************************************************************
+ * odp_byte_order.h
+*******************************************************************************/
+
+/**
+ * Platform specific inline implementation of @ref odp_be_to_cpu_16
+ */
+static inline uint16_t odp_be_to_cpu_16(uint16be_t be16)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return __odp_builtin_bswap16((__odp_force uint16_t)be16);
+#else
+ return (__odp_force uint16_t)be16;
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_be_to_cpu_32
+ */
+static inline uint32_t odp_be_to_cpu_32(uint32be_t be32)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return __builtin_bswap32((__odp_force uint32_t)be32);
+#else
+ return (__odp_force uint32_t)be32;
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_be_to_cpu_64
+ */
+static inline uint64_t odp_be_to_cpu_64(uint64be_t be64)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return __builtin_bswap64((__odp_force uint64_t)be64);
+#else
+ return (__odp_force uint64_t)be64;
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_cpu_to_be_16
+ */
+static inline uint16be_t odp_cpu_to_be_16(uint16_t cpu16)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint16be_t)__odp_builtin_bswap16(cpu16);
+#else
+ return (__odp_force uint16be_t)cpu16;
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_cpu_to_be_32
+ */
+static inline uint32be_t odp_cpu_to_be_32(uint32_t cpu32)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint32be_t)__builtin_bswap32(cpu32);
+#else
+ return (__odp_force uint32be_t)cpu32;
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_cpu_to_be_64
+ */
+static inline uint64be_t odp_cpu_to_be_64(uint64_t cpu64)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint64be_t)__builtin_bswap64(cpu64);
+#else
+ return (__odp_force uint64be_t)cpu64;
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_le_to_cpu_16
+ */
+static inline uint16_t odp_le_to_cpu_16(uint16le_t le16)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint16_t)le16;
+#else
+ return __odp_builtin_bswap16((__odp_force uint16_t)le16);
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_le_to_cpu_32
+ */
+static inline uint32_t odp_le_to_cpu_32(uint32le_t le32)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint32_t)le32;
+#else
+ return __builtin_bswap32((__odp_force uint32_t)le32);
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_le_to_cpu_64
+ */
+static inline uint64_t odp_le_to_cpu_64(uint64le_t le64)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint64_t)le64;
+#else
+ return __builtin_bswap64((__odp_force uint64_t)le64);
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_cpu_to_le_16
+ */
+static inline uint16le_t odp_cpu_to_le_16(uint16_t cpu16)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint16le_t)cpu16;
+#else
+ return (__odp_force uint16le_t)__odp_builtin_bswap16(cpu16);
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_cpu_to_le_32
+ */
+static inline uint32le_t odp_cpu_to_le_32(uint32_t cpu32)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint32le_t)cpu32;
+#else
+ return (__odp_force uint32le_t)__builtin_bswap32(cpu32);
+#endif
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_cpu_to_le_64
+ */
+static inline uint64le_t odp_cpu_to_le_64(uint64_t cpu64)
+{
+#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN
+ return (__odp_force uint64le_t)cpu64;
+#else
+ return (__odp_force uint64le_t)__builtin_bswap64(cpu64);
+#endif
+}
+
+
+/******************************************************************************
+ * odp_coremask.h
+*******************************************************************************/
+
+/**
+ * Platform specific inline implementation of @ref odp_coremask_zero
+ */
+static inline void odp_coremask_zero(odp_coremask_t *mask)
+{
+ mask->_u64[0] = 0;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_coremask_and
+ */
+static inline void odp_coremask_and(odp_coremask_t *dest, odp_coremask_t *src1,
+ odp_coremask_t *src2)
+{
+ dest->_u64[0] = src1->_u64[0] & src2->_u64[0];
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_coremask_or
+ */
+static inline void odp_coremask_or(odp_coremask_t *dest, odp_coremask_t *src1,
+ odp_coremask_t *src2)
+{
+ dest->_u64[0] = src1->_u64[0] | src2->_u64[0];
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_coremask_xor
+ */
+static inline void odp_coremask_xor(odp_coremask_t *dest, odp_coremask_t *src1,
+ odp_coremask_t *src2)
+{
+ dest->_u64[0] = src1->_u64[0] ^ src2->_u64[0];
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_coremask_equal
+ */
+static inline int odp_coremask_equal(odp_coremask_t *mask1,
+ odp_coremask_t *mask2)
+{
+ return (mask1->_u64[0] == mask2->_u64[0]);
+}
+
+/******************************************************************************
+ * odp_atomic.h
+*******************************************************************************/
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_init_int
+ */
+static inline void odp_atomic_init_int(odp_atomic_int_t *ptr)
+{
+ *ptr = 0;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_store_int
+ */
+static inline void odp_atomic_store_int(odp_atomic_int_t *ptr, int new_value)
+{
+ *ptr = new_value;
+}
+/**
+ * Platform specific inline implementation of @ref odp_atomic_load_int
+ */
+static inline int odp_atomic_load_int(odp_atomic_int_t *ptr)
+{
+ return *ptr;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_add_int
+ */
+static inline int odp_atomic_fetch_add_int(odp_atomic_int_t *ptr, int value)
+{
+ return __sync_fetch_and_add(ptr, value);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_sub_int
+ */
+static inline int odp_atomic_fetch_sub_int(odp_atomic_int_t *ptr, int value)
+{
+ return __sync_fetch_and_sub(ptr, value);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_inc_int
+ */
+static inline int odp_atomic_fetch_inc_int(odp_atomic_int_t *ptr)
+{
+ return odp_atomic_fetch_add_int(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_inc_int
+ */
+static inline void odp_atomic_inc_int(odp_atomic_int_t *ptr)
+{
+ odp_atomic_fetch_add_int(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_dec_int
+ */
+static inline int odp_atomic_fetch_dec_int(odp_atomic_int_t *ptr)
+{
+ return odp_atomic_fetch_sub_int(ptr, 1);
+}
+
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_dec_int
+ */
+static inline void odp_atomic_dec_int(odp_atomic_int_t *ptr)
+{
+ odp_atomic_fetch_sub_int(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_init_u32
+ */
+static inline void odp_atomic_init_u32(odp_atomic_u32_t *ptr)
+{
+ *ptr = 0;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_load_u32
+ */
+static inline uint32_t odp_atomic_load_u32(odp_atomic_u32_t *ptr)
+{
+ return *ptr;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_store_u32
+ */
+static inline void odp_atomic_store_u32(odp_atomic_u32_t *ptr,
+ uint32_t new_value)
+{
+ *ptr = new_value;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_add_u32
+ */
+static inline uint32_t odp_atomic_fetch_add_u32(odp_atomic_u32_t *ptr,
+ uint32_t value)
+{
+ return __sync_fetch_and_add(ptr, value);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_sub_u32
+ */
+static inline uint32_t odp_atomic_fetch_sub_u32(odp_atomic_u32_t *ptr,
+ uint32_t value)
+{
+ return __sync_fetch_and_sub(ptr, value);
+}
+
+#if defined __OCTEON__
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_inc_u32
+ */
+static inline uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *ptr)
+{
+ uint32_t ret;
+
+ __asm__ __volatile__ ("syncws");
+ __asm__ __volatile__ ("lai %0,(%2)" : "=r" (ret), "+m" (ptr) :
+ "r" (ptr));
+
+ return ret;
+}
+
+#else
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_inc_u32
+ */
+static inline uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *ptr)
+{
+ return odp_atomic_fetch_add_u32(ptr, 1);
+}
+
+#endif
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_inc_u32
+ */
+static inline void odp_atomic_inc_u32(odp_atomic_u32_t *ptr)
+{
+ odp_atomic_fetch_add_u32(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_dec_u32
+ */
+static inline uint32_t odp_atomic_fetch_dec_u32(odp_atomic_u32_t *ptr)
+{
+ return odp_atomic_fetch_sub_u32(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_dec_u32
+ */
+static inline void odp_atomic_dec_u32(odp_atomic_u32_t *ptr)
+{
+ odp_atomic_fetch_sub_u32(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_cmpset_u32
+ */
+static inline int
+odp_atomic_cmpset_u32(odp_atomic_u32_t *dst, uint32_t exp, uint32_t src)
+{
+ return __sync_bool_compare_and_swap(dst, exp, src);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_init_u64
+ */
+static inline void odp_atomic_init_u64(odp_atomic_u64_t *ptr)
+{
+ *ptr = 0;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_load_u64
+ */
+static inline uint64_t odp_atomic_load_u64(odp_atomic_u64_t *ptr)
+{
+ return *ptr;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_store_u64
+ */
+static inline void odp_atomic_store_u64(odp_atomic_u64_t *ptr,
+ uint64_t new_value)
+{
+ *ptr = new_value;
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_add_u64
+ */
+static inline void odp_atomic_add_u64(odp_atomic_u64_t *ptr, uint64_t value)
+{
+ __sync_fetch_and_add(ptr, value);
+}
+
+#if defined __powerpc__ && !defined __powerpc64__
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_add_u64
+ */
+static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr,
+ uint64_t value)
+{
+ return __sync_fetch_and_add((odp_atomic_u32_t *)ptr,
+ (uint32_t)value);
+}
+#else
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_add_u64
+ */
+static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr,
+ uint64_t value)
+{
+ return __sync_fetch_and_add(ptr, value);
+}
+#endif
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_sub_u64
+ */
+static inline void odp_atomic_sub_u64(odp_atomic_u64_t *ptr, uint64_t value)
+{
+ __sync_fetch_and_sub(ptr, value);
+}
+
+#if defined __powerpc__ && !defined __powerpc64__
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_sub_u64
+ */
+static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr,
+ uint64_t value)
+{
+ return __sync_fetch_and_sub((odp_atomic_u32_t *)ptr,
+ (uint32_t)value);
+}
+#else
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_sub_u64
+ */
+static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr,
+ uint64_t value)
+{
+ return __sync_fetch_and_sub(ptr, value);
+}
+#endif
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_inc_u64
+ */
+static inline uint64_t odp_atomic_fetch_inc_u64(odp_atomic_u64_t *ptr)
+{
+ return odp_atomic_fetch_add_u64(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_inc_u64
+ */
+static inline void odp_atomic_inc_u64(odp_atomic_u64_t *ptr)
+{
+ odp_atomic_fetch_add_u64(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_fetch_dec_u64
+ */
+static inline uint64_t odp_atomic_fetch_dec_u64(odp_atomic_u64_t *ptr)
+{
+ return odp_atomic_fetch_sub_u64(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_dec_u64
+ */
+static inline void odp_atomic_dec_u64(odp_atomic_u64_t *ptr)
+{
+ odp_atomic_fetch_sub_u64(ptr, 1);
+}
+
+/**
+ * Platform specific inline implementation of @ref odp_atomic_cmpset_u64
+ */
+static inline int
+odp_atomic_cmpset_u64(odp_atomic_u64_t *dst, uint64_t exp, uint64_t src)
+{
+ return __sync_bool_compare_and_swap(dst, exp, src);
+}
+
+#endif
@@ -20,51 +20,11 @@ extern "C" {
/**
- * ODP API main version
+ * @anchor odp_version_api_str
*
- * Introduction of major new features or changes. APIs with different major
- * versions are likely not backward compatible.
- */
-#define ODP_VERSION_API_MAIN 0
-
-/**
- * ODP API sub version
- *
- * Introduction of additional features or minor changes. APIs with common
- * major version and different sub versions may be backward compatible (if only
- * additions).
- */
-#define ODP_VERSION_API_SUB 0
-
-/**
- * ODP API bug correction version
- *
- * Bug corrections to the API files. APIs with the same major and sub
- * versions, but different bug correction versions are backward compatible.
- */
-#define ODP_VERSION_API_BUG 1
-
-
-/** @internal Version string expand */
-#define ODP_VERSION_STR_EXPAND(x) #x
-
-/** @internal Version to string */
-#define ODP_VERSION_TO_STR(x) ODP_VERSION_STR_EXPAND(x)
-
-/** @internal API version string */
-#define ODP_VERSION_API_STR \
-ODP_VERSION_TO_STR(ODP_VERSION_API_MAIN) "."\
-ODP_VERSION_TO_STR(ODP_VERSION_API_SUB) "."\
-ODP_VERSION_TO_STR(ODP_VERSION_API_BUG)
-
-
-/**
* Returns ODP API version string
*/
-static inline const char *odp_version_api_str(void)
-{
- return ODP_VERSION_API_STR;
-}
+const char *odp_version_api_str(void);
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_barrier.h>
-#include <odp_sync.h>
+#include <odp.h>
#include <odp_spin_internal.h>
void odp_barrier_init_count(odp_barrier_t *barrier, int count)
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_buffer.h>
+#include <odp.h>
#include <odp_buffer_internal.h>
#include <odp_buffer_pool_internal.h>
@@ -4,18 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_std_types.h>
-#include <odp_buffer_pool.h>
+#include <odp.h>
#include <odp_buffer_pool_internal.h>
#include <odp_buffer_internal.h>
#include <odp_packet_internal.h>
#include <odp_timer_internal.h>
-#include <odp_shared_memory.h>
-#include <odp_align.h>
#include <odp_internal.h>
-#include <odp_config.h>
-#include <odp_hints.h>
-#include <odp_debug.h>
#include <string.h>
#include <stdlib.h>
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_coremask.h>
-#include <odp_debug.h>
+#include <odp.h>
#include <stdlib.h>
#include <string.h>
@@ -4,16 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_crypto.h>
+#include <odp.h>
#include <odp_internal.h>
-#include <odp_atomic.h>
-#include <odp_spinlock.h>
-#include <odp_sync.h>
-#include <odp_debug.h>
-#include <odp_align.h>
-#include <odp_shared_memory.h>
#include <odp_crypto_internal.h>
-#include <odp_hints.h>
#include <odph_packet.h>
#include <string.h>
@@ -4,10 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_packet.h>
+#include <odp.h>
#include <odp_packet_internal.h>
-#include <odp_hints.h>
-#include <odp_byteorder.h>
#include <odph_eth.h>
#include <odph_ip.h>
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_packet_flags.h>
+#include <odp.h>
#include <odp_packet_internal.h>
@@ -4,20 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_packet_io.h>
+#include <odp.h>
#include <odp_packet_io_internal.h>
-#include <odp_packet_io_queue.h>
-#include <odp_packet.h>
#include <odp_packet_internal.h>
+/** XXX: This should probably be odp_packet_io_queue_internal.h> */
+#include <odp_packet_io_queue.h>
#include <odp_internal.h>
-#include <odp_spinlock.h>
-#include <odp_shared_memory.h>
#include <odp_packet_socket.h>
-#include <odp_hints.h>
-#include <odp_config.h>
#include <odp_queue_internal.h>
#include <odp_schedule_internal.h>
-#include <odp_debug.h>
#include <string.h>
@@ -34,9 +34,9 @@
#include <errno.h>
#include <sys/syscall.h>
+#include <odp.h>
#include <odp_packet_socket.h>
#include <odp_packet_internal.h>
-#include <odp_hints.h>
#include <odph_eth.h>
#include <odph_ip.h>
@@ -4,22 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_queue.h>
+#include <odp.h>
#include <odp_queue_internal.h>
-#include <odp_std_types.h>
-#include <odp_align.h>
-#include <odp_buffer.h>
#include <odp_buffer_internal.h>
#include <odp_buffer_pool_internal.h>
#include <odp_internal.h>
-#include <odp_shared_memory.h>
#include <odp_schedule_internal.h>
-#include <odp_config.h>
#include <odp_packet_io_internal.h>
#include <odp_packet_io_queue.h>
-#include <odp_debug.h>
-#include <odp_hints.h>
-#include <odp_sync.h>
#ifdef USE_TICKETLOCK
#include <odp_ticketlock.h>
@@ -69,17 +69,13 @@
*
***************************************************************************/
-#include <odp_shared_memory.h>
+#include <odp.h>
#include <odp_internal.h>
#include <odp_spin_internal.h>
-#include <odp_spinlock.h>
-#include <odp_align.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
-#include <odp_debug.h>
-#include <odp_rwlock.h>
#include <odph_ring.h>
static TAILQ_HEAD(, odph_ring) odp_ring_list;
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_atomic.h>
-#include <odp_rwlock.h>
+#include <odp.h>
#include <odp_spin_internal.h>
@@ -4,20 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_schedule.h>
+#include <odp.h>
#include <odp_schedule_internal.h>
-#include <odp_align.h>
-#include <odp_queue.h>
-#include <odp_shared_memory.h>
-#include <odp_buffer.h>
-#include <odp_buffer_pool.h>
#include <odp_internal.h>
-#include <odp_config.h>
-#include <odp_debug.h>
#include <odp_thread.h>
#include <odp_time.h>
-#include <odp_spinlock.h>
-#include <odp_hints.h>
#include <odp_queue_internal.h>
@@ -9,13 +9,8 @@
#endif
#include <sched.h>
-#include <odp_thread.h>
+#include <odp.h>
#include <odp_internal.h>
-#include <odp_atomic.h>
-#include <odp_config.h>
-#include <odp_debug.h>
-#include <odp_shared_memory.h>
-#include <odp_align.h>
#include <string.h>
#include <stdio.h>
@@ -4,9 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_ticketlock.h>
-#include <odp_atomic.h>
-#include <odp_sync.h>
+#include <odp.h>
#include <odp_spin_internal.h>
@@ -4,15 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <odp_timer.h>
+#include <odp.h>
#include <odp_timer_internal.h>
-#include <odp_time.h>
#include <odp_buffer_pool_internal.h>
#include <odp_internal.h>
-#include <odp_atomic.h>
-#include <odp_spinlock.h>
-#include <odp_sync.h>
-#include <odp_debug.h>
#include <signal.h>
#include <time.h>