@@ -42,6 +42,10 @@ extern "C" {
#define ODP_CACHE_LINE_SIZE 128
+#elif defined __powerpc__
+
+#define ODP_CACHE_LINE_SIZE 64
+
#else
#error GCC target not found
#endif
@@ -353,12 +353,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
/**
* Subtract atomic uint64
*
@@ -379,12 +388,20 @@ 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
/**
* Fetch and increment atomic uint64 by 1
*
b/platform/linux-generic/source/odp_shared_memory.c
@@ -13,6 +13,9 @@
#include <odp_debug.h>
#include <sys/mman.h>
+#ifdef __powerpc__
+#include <asm/mman.h>
+#endif
#include <fcntl.h>
#include <stdio.h>
@@ -97,7 +100,7 @@ void *odp_shm_reserve(const char *name, uint64_t size,
uint64_t align)
int i;
odp_shm_block_t *block;
void *addr;
- uint64_t huge_sz, page_sz;
+ uint64_t huge_sz ODP_UNUSED, page_sz ODP_UNUSED;
huge_sz = odp_sys_huge_page_size();
page_sz = odp_sys_page_size();
b/platform/linux-generic/source/odp_system_info.c
@@ -60,7 +60,8 @@ static int sysconf_core_count(void)
}
-#if defined __x86_64__ || defined __i386__ || defined __OCTEON__
+#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \
+defined __powerpc__
/*
* Analysis of /sys/devices/system/cpu/ files
*/
@@ -213,6 +214,46 @@ static int cpuinfo_octeon(FILE *file,
odp_system_info_t *sysinfo)
return 0;
}
+#elif defined __powerpc__
+static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo)
+{
+ char str[1024];
+ char *pos;
+ double mhz = 0.0;
+ int model = 0;
+ int count = 2;
+
+ while (fgets(str, sizeof(str), file) != NULL && count > 0) {
+ if (!mhz) {
+ pos = strstr(str, "clock");
+
+ if (pos) {
+ sscanf(pos, "clock : %lf", &mhz);
+ count--;
+ }
+ }
+
+ if (!model) {
+ pos = strstr(str, "cpu");
+
+ if (pos) {
+ int len;
+ pos = strchr(str, ':');
+ strncpy(sysinfo->model_str, pos+2,
+ sizeof(sysinfo->model_str));
+ len = strlen(sysinfo->model_str);
+ sysinfo->model_str[len - 1] = 0;
+ model = 1;
+ count--;
+ }
+ }
+
+ sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0);
+ }
+
+
+ return 0;
+}
#else