Skip to content

Commit 5cf6f54

Browse files
committed
feat: (almost) complete ppc64 support
1 parent ba923e8 commit 5cf6f54

File tree

55 files changed

+1736
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1736
-19
lines changed

abis/linux/auxv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#define AT_FPUCW 18
88
#define AT_SECURE 23
99
#define AT_RANDOM 25
10+
#define AT_HWCAP2 26
11+
#define AT_HWCAP3 29
12+
#define AT_HWCAP4 30
1013
#define AT_EXECFN 31
1114
#define AT_SYSINFO_EHDR 33
1215

abis/linux/ipc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ extern "C" {
2222

2323
#if defined(__aarch64__) || defined(__i386__) || defined(__m68k__)
2424
#define IPC_64 0x100
25-
#elif defined(__x86_64__) || (defined(__riscv) && __riscv_xlen == 64) || defined(__loongarch64)
25+
#elif defined(__x86_64__) || (defined(__riscv) && __riscv_xlen == 64) || defined(__loongarch64) \
26+
|| defined(__powerpc64__)
2627
#define IPC_64 0
2728
#else
2829
#error "Unsupported arch!"

abis/linux/shm.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ struct shmid_ds {
7777
unsigned long shm_nattch;
7878
unsigned long __unused[2];
7979
};
80+
#elif defined(__powerpc64__)
81+
struct shmid_ds {
82+
struct ipc_perm shm_perm;
83+
time_t shm_atime;
84+
time_t shm_dtime;
85+
time_t shm_ctime;
86+
size_t shm_segsz;
87+
pid_t shm_cpid;
88+
pid_t shm_lpid;
89+
unsigned long shm_nattch;
90+
unsigned long __unused[2];
91+
};
8092
#else
8193
#error "Missing architecture specific code."
8294
#endif

abis/linux/signal.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <abi-bits/pid_t.h>
55
#include <abi-bits/sigevent.h>
66
#include <abi-bits/uid_t.h>
7+
#include <asm/types.h>
78
#include <bits/size_t.h>
89
#include <stdint.h>
910
#include <time.h>
@@ -152,8 +153,14 @@ typedef struct {
152153
#define SIGUNUSED SIGSYS
153154
#define SIGCANCEL 32
154155

156+
#if defined(__powerpc64__)
157+
#define MINSIGSTKSZ 8192
158+
#define SIGSTKSZ 32768
159+
#else
155160
#define MINSIGSTKSZ 2048
156161
#define SIGSTKSZ 8192
162+
#endif
163+
157164
#define SS_ONSTACK 1
158165
#define SS_DISABLE 2
159166

@@ -621,6 +628,46 @@ typedef struct __ucontext {
621628
mcontext_t uc_mcontext;
622629
} ucontext_t;
623630

631+
#elif defined(__powerpc64__)
632+
633+
struct sigaltstack {
634+
void *ss_sp;
635+
int ss_flags;
636+
size_t ss_size;
637+
};
638+
639+
typedef unsigned long greg_t, gregset_t[48];
640+
typedef double fpreg_t, fpregset_t[33];
641+
642+
typedef __vector128 vrreg_t;
643+
typedef vrreg_t vrregset_t[34];
644+
645+
struct pt_regs {
646+
greg_t gpr[32];
647+
greg_t pc;
648+
};
649+
650+
struct sigcontext {
651+
unsigned long _unused[4];
652+
int signal;
653+
int _pad0;
654+
unsigned long handler;
655+
unsigned long oldmask;
656+
struct pt_regs *regs;
657+
gregset_t gp_regs;
658+
fpregset_t fp_regs;
659+
vrreg_t *v_regs;
660+
long vmx_reserve[101];
661+
};
662+
663+
typedef struct __ucontext {
664+
unsigned long uc_flags;
665+
struct ucontext *uc_link;
666+
stack_t uc_stack;
667+
sigset_t uc_sigmask;
668+
struct sigcontext uc_mcontext;
669+
} ucontext_t;
670+
624671
#else
625672
#error "Missing architecture specific code."
626673
#endif

abis/linux/stat.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,27 @@ struct stat {
137137
ino_t st_ino;
138138
};
139139

140+
#elif defined(__powerpc64__)
141+
142+
struct stat {
143+
unsigned long st_dev;
144+
unsigned long st_ino;
145+
unsigned long st_nlink;
146+
mode_t st_mode;
147+
uid_t st_uid;
148+
gid_t st_gid;
149+
unsigned long st_rdev;
150+
long st_size;
151+
unsigned long st_blksize;
152+
unsigned long st_blocks;
153+
struct timespec st_atim;
154+
struct timespec st_mtim;
155+
struct timespec st_ctim;
156+
unsigned long __unused4;
157+
unsigned long __unused5;
158+
unsigned long __unused6;
159+
};
160+
140161
#endif
141162

142163
#define stat64 stat

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ if default_library_paths.length() == 0
176176
'arm': 32,
177177
'm68k': 32,
178178
'loongarch64': 64,
179+
'powerpc64': 64
179180
}
180181
if target_word_size.get(target_machine.cpu_family()) == 64
181182
default_library_paths = ['/lib', '/lib64', '/usr/lib', '/usr/lib64']

options/ansi/include/bits/ansi/fenv.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@
8787
#define FE_UPWARD 0x200
8888
#define FE_DOWNWARD 0x300
8989

90+
#elif defined(__powerpc64__)
91+
92+
#define FE_DIVBYZERO 0x4000000
93+
#define FE_INEXACT 0x2000000
94+
#define FE_INVALID 0x20000000
95+
#define FE_OVERFLOW 0x10000000
96+
#define FE_UNDERFLOW 0x8000000
97+
98+
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
99+
100+
#define FE_TONEAREST 0
101+
#define FE_DOWNWARD 0b11
102+
#define FE_TOWARDZERO 0b01
103+
#define FE_UPWARD 0b10
104+
90105
#else
91106
#error Unknown architecture
92107
#endif

options/ansi/musl-generic-math/__fpclassifyl.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,22 @@ int __fpclassifyl(long double x) {
3434
return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE;
3535
return FP_NORMAL;
3636
}
37+
#elif LDBL_MANT_DIG == 106 && LDBL_MAX_EXP == 1024
38+
int __fpclassifyl(long double x) {
39+
union ldshape u = {x};
40+
41+
if (isnan(u.i.hi))
42+
return FP_NAN;
43+
if (isinf(u.i.hi))
44+
return FP_INFINITE;
45+
46+
if (u.i.hi == 0.0) {
47+
if (u.i.lo == 0.0)
48+
return FP_ZERO;
49+
else
50+
return fpclassify(u.i.lo);
51+
}
52+
53+
return fpclassify(u.i.hi);
54+
}
3755
#endif

options/ansi/musl-generic-math/exp10l.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ long double exp10l(long double x) {
2424
}
2525
return powl(10.0, x);
2626
}
27+
#elif LDBL_MANT_DIG == 106 && LDBL_MAX_EXP == 1024
28+
29+
#define M_LN10l 2.302585092994045684017991454684364208L
30+
31+
static const long double log10_high = 0x2.4d763776aaap+0L;
32+
static const long double log10_low = 0x2.b05ba95b58ae0b4c28a38a3fb4p-48L;
33+
34+
long double exp10l(long double x) {
35+
if (!isfinite(x))
36+
return expl(x);
37+
if (x < LDBL_MIN_10_EXP - LDBL_DIG - 10)
38+
return LDBL_MIN * LDBL_MIN;
39+
else if (x > LDBL_MAX_10_EXP + 1)
40+
return LDBL_MAX * LDBL_MAX;
41+
else if (fabsl(x) < 0x1p-109L)
42+
return 1.0L;
43+
44+
union ldshape u = {x};
45+
long double exp_hi = u.i.hi * log10_high;
46+
long double exp_lo = u.i.hi * log10_low + u.i.lo * M_LN10l;
47+
return expl(exp_hi) * expl(exp_lo);
48+
}
2749
#endif
2850

2951
weak_alias(exp10l, pow10l);

options/ansi/musl-generic-math/expl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ long double expl(long double x) {
113113
x = 1.0 + 2.0 * x;
114114
return scalbnl(x, k);
115115
}
116-
#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
116+
#elif (LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384) \
117+
|| (LDBL_MANT_DIG == 106 && LDBL_MAX_EXP == 1024)
117118
// TODO: broken implementation to make things compile
118119
long double expl(long double x) { return exp(x); }
119120
#endif

0 commit comments

Comments
 (0)