Skip to content

Commit f3a4274

Browse files
authored
Initial support for AIX (#1021)
* Init support of AIX * make sysinfo change AIX specific * Relocate TBF * Add comments for .csect psudo op.
1 parent 020619c commit f3a4274

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

absl/base/attributes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,16 @@
318318
// `__start_ ## name` and `__stop_ ## name` symbols to bracket the section.
319319
// This functionality is supported by GNU linker.
320320
#ifndef ABSL_ATTRIBUTE_SECTION_VARIABLE
321+
#ifdef _AIX
322+
// __attribute__((section(#name))) on AIX is achived by using the `.csect` psudo
323+
// op which includes an additional integer as part of its syntax indcating
324+
// alignment. If data fall under different alignments then you might get a
325+
// compilation error indicating a `Section type conflict`.
326+
#define ABSL_ATTRIBUTE_SECTION_VARIABLE(name)
327+
#else
321328
#define ABSL_ATTRIBUTE_SECTION_VARIABLE(name) __attribute__((section(#name)))
322329
#endif
330+
#endif
323331

324332
// ABSL_DECLARE_ATTRIBUTE_SECTION_VARS
325333
//

absl/base/config.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
408408
// POSIX.1-2001.
409409
#ifdef ABSL_HAVE_MMAP
410410
#error ABSL_HAVE_MMAP cannot be directly set
411-
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
412-
defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \
413-
defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \
414-
defined(__ASYLO__) || defined(__myriad2__)
411+
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
412+
defined(_AIX) || defined(__ros__) || defined(__native_client__) || \
413+
defined(__asmjs__) || defined(__wasm__) || defined(__Fuchsia__) || \
414+
defined(__sun) || defined(__ASYLO__) || defined(__myriad2__)
415415
#define ABSL_HAVE_MMAP 1
416416
#endif
417417

@@ -422,7 +422,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
422422
#ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM
423423
#error ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
424424
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
425-
defined(__ros__)
425+
defined(_AIX) || defined(__ros__)
426426
#define ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
427427
#endif
428428

absl/base/internal/sysinfo.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ static int GetNumCPUs() {
131131
#elif defined(_WIN32)
132132
const unsigned hardware_concurrency = Win32NumCPUs();
133133
return hardware_concurrency ? hardware_concurrency : 1;
134+
#elif defined(_AIX)
135+
return sysconf(_SC_NPROCESSORS_ONLN);
134136
#else
135137
// Other possibilities:
136138
// - Read /sys/devices/system/cpu/online and use cpumask_parse()

absl/base/internal/unscaledcycleclock.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ int64_t UnscaledCycleClock::Now() {
8787
double UnscaledCycleClock::Frequency() {
8888
#ifdef __GLIBC__
8989
return __ppc_get_timebase_freq();
90+
#elif defined(_AIX)
91+
// This is the same constant value as returned by
92+
// __ppc_get_timebase_freq().
93+
return static_cast<double>(512000000);
9094
#elif defined(__FreeBSD__)
9195
static once_flag init_timebase_frequency_once;
9296
static double timebase_frequency = 0.0;

absl/time/clock_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#if defined(ABSL_HAVE_ALARM)
1919
#include <signal.h>
2020
#include <unistd.h>
21+
#elif defined(_AIX)
22+
typedef void (*sig_t)(int);
2123
#elif defined(__linux__) || defined(__APPLE__)
2224
#error all known Linux and Apple targets have alarm
2325
#endif

0 commit comments

Comments
 (0)