summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Milad Fa <46688537+miladfarca@users.noreply.github.com>2021-09-23 16:23:02 -0400
committerGravatar GitHub <noreply@github.com>2021-09-23 16:23:02 -0400
commitf3a42743db4df4c98e1df690045577c775daf20b (patch)
treee63f48001f0d1e339d9c1b95fcdbf2c6da4edcd5
parent020619c4aa68d13dfbdd6107a373912bb5ea85af (diff)
Initial support for AIX (#1021)
* Init support of AIX * make sysinfo change AIX specific * Relocate TBF * Add comments for .csect psudo op.
-rw-r--r--absl/base/attributes.h8
-rw-r--r--absl/base/config.h10
-rw-r--r--absl/base/internal/sysinfo.cc2
-rw-r--r--absl/base/internal/unscaledcycleclock.cc4
-rw-r--r--absl/time/clock_test.cc2
5 files changed, 21 insertions, 5 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 2665d8f3..e3907827 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -318,8 +318,16 @@
// `__start_ ## name` and `__stop_ ## name` symbols to bracket the section.
// This functionality is supported by GNU linker.
#ifndef ABSL_ATTRIBUTE_SECTION_VARIABLE
+#ifdef _AIX
+// __attribute__((section(#name))) on AIX is achived by using the `.csect` psudo
+// op which includes an additional integer as part of its syntax indcating
+// alignment. If data fall under different alignments then you might get a
+// compilation error indicating a `Section type conflict`.
+#define ABSL_ATTRIBUTE_SECTION_VARIABLE(name)
+#else
#define ABSL_ATTRIBUTE_SECTION_VARIABLE(name) __attribute__((section(#name)))
#endif
+#endif
// ABSL_DECLARE_ATTRIBUTE_SECTION_VARS
//
diff --git a/absl/base/config.h b/absl/base/config.h
index c7b2e64d..5d3edcd2 100644
--- a/absl/base/config.h
+++ b/absl/base/config.h
@@ -408,10 +408,10 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
// POSIX.1-2001.
#ifdef ABSL_HAVE_MMAP
#error ABSL_HAVE_MMAP cannot be directly set
-#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
- defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \
- defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \
- defined(__ASYLO__) || defined(__myriad2__)
+#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
+ defined(_AIX) || defined(__ros__) || defined(__native_client__) || \
+ defined(__asmjs__) || defined(__wasm__) || defined(__Fuchsia__) || \
+ defined(__sun) || defined(__ASYLO__) || defined(__myriad2__)
#define ABSL_HAVE_MMAP 1
#endif
@@ -422,7 +422,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM
#error ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
- defined(__ros__)
+ defined(_AIX) || defined(__ros__)
#define ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
#endif
diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc
index 08a1e288..a7cfb461 100644
--- a/absl/base/internal/sysinfo.cc
+++ b/absl/base/internal/sysinfo.cc
@@ -131,6 +131,8 @@ static int GetNumCPUs() {
#elif defined(_WIN32)
const unsigned hardware_concurrency = Win32NumCPUs();
return hardware_concurrency ? hardware_concurrency : 1;
+#elif defined(_AIX)
+ return sysconf(_SC_NPROCESSORS_ONLN);
#else
// Other possibilities:
// - Read /sys/devices/system/cpu/online and use cpumask_parse()
diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc
index fc07e300..4d352bd1 100644
--- a/absl/base/internal/unscaledcycleclock.cc
+++ b/absl/base/internal/unscaledcycleclock.cc
@@ -87,6 +87,10 @@ int64_t UnscaledCycleClock::Now() {
double UnscaledCycleClock::Frequency() {
#ifdef __GLIBC__
return __ppc_get_timebase_freq();
+#elif defined(_AIX)
+ // This is the same constant value as returned by
+ // __ppc_get_timebase_freq().
+ return static_cast<double>(512000000);
#elif defined(__FreeBSD__)
static once_flag init_timebase_frequency_once;
static double timebase_frequency = 0.0;
diff --git a/absl/time/clock_test.cc b/absl/time/clock_test.cc
index 4bcfc6bc..e6f627b3 100644
--- a/absl/time/clock_test.cc
+++ b/absl/time/clock_test.cc
@@ -18,6 +18,8 @@
#if defined(ABSL_HAVE_ALARM)
#include <signal.h>
#include <unistd.h>
+#elif defined(_AIX)
+typedef void (*sig_t)(int);
#elif defined(__linux__) || defined(__APPLE__)
#error all known Linux and Apple targets have alarm
#endif