Skip to content

Commit 79a2109

Browse files
committed
Address comments
1 parent 735736f commit 79a2109

File tree

6 files changed

+115
-47
lines changed

6 files changed

+115
-47
lines changed

compiler-rt/cmake/base-config-ix.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ include(CompilerRTDarwinUtils)
1414
check_include_file(unwind.h HAVE_UNWIND_H)
1515

1616
# Used by sanitizer_common and tests.
17-
check_include_file(rpc/xdr.h HAVE_RPC_XDR_H)
17+
if (${CMAKE_SYSTEM_NAME} MATCHES AIX)
18+
check_include_file(tirpc/rpc/xdr.h HAVE_RPC_XDR_H)
19+
else()
20+
check_include_file(rpc/xdr.h HAVE_RPC_XDR_H)
21+
endif()
1822
if (NOT HAVE_RPC_XDR_H)
1923
set(HAVE_RPC_XDR_H 0)
2024
endif()

compiler-rt/lib/sanitizer_common/sanitizer_errno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
# define __errno_location _errno
3232
#elif SANITIZER_HAIKU
3333
# define __errno_location _errnop
34+
#elif SANITIZER_AIX
35+
# define __errno_location _Errno
3436
#endif
3537

3638
extern "C" int *__errno_location();

compiler-rt/lib/sanitizer_common/sanitizer_platform.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
1616
!defined(__APPLE__) && !defined(_WIN32) && !defined(__Fuchsia__) && \
1717
!(defined(__sun__) && defined(__svr4__)) && !defined(__HAIKU__) && \
18-
!defined(__wasi__)
18+
!defined(__wasi__) && !defined(_AIX)
1919
# error "This operating system is not supported"
2020
#endif
2121

@@ -32,6 +32,12 @@
3232
# define SANITIZER_LINUX 0
3333
#endif
3434

35+
#if defined(_AIX)
36+
# define SANITIZER_AIX 1
37+
#else
38+
# define SANITIZER_AIX 0
39+
#endif
40+
3541
#if defined(__GLIBC__)
3642
# define SANITIZER_GLIBC 1
3743
#else
@@ -151,7 +157,7 @@
151157

152158
#define SANITIZER_POSIX \
153159
(SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_APPLE || \
154-
SANITIZER_NETBSD || SANITIZER_SOLARIS || SANITIZER_HAIKU)
160+
SANITIZER_NETBSD || SANITIZER_SOLARIS || SANITIZER_HAIKU || SANITIZER_AIX)
155161

156162
#if __LP64__ || defined(_WIN64)
157163
# define SANITIZER_WORDSIZE 64

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// Must go after undef _FILE_OFFSET_BITS.
2525
#include "sanitizer_platform.h"
2626

27-
#if SANITIZER_LINUX || SANITIZER_APPLE || SANITIZER_HAIKU
27+
#if SANITIZER_LINUX || SANITIZER_APPLE || SANITIZER_HAIKU || SANITIZER_AIX
2828
// Must go after undef _FILE_OFFSET_BITS.
2929
#include "sanitizer_glibc_version.h"
3030

@@ -61,7 +61,7 @@
6161
#endif
6262

6363
#if !SANITIZER_ANDROID
64-
#if !SANITIZER_HAIKU
64+
#if !SANITIZER_HAIKU && !SANITIZER_AIX
6565
#include <sys/mount.h>
6666
#endif
6767
#include <sys/timeb.h>
@@ -112,11 +112,15 @@ typedef struct user_fpregs elf_fpregset_t;
112112
#endif
113113

114114
#if !SANITIZER_ANDROID
115-
#include <ifaddrs.h>
116-
#if !SANITIZER_HAIKU
117-
#include <sys/ucontext.h>
118-
#include <wordexp.h>
119-
#endif
115+
# if !SANITIZER_AIX
116+
# include <ifaddrs.h>
117+
# else
118+
# include <netinet/in.h>
119+
# endif
120+
# if !SANITIZER_HAIKU
121+
# include <sys/ucontext.h>
122+
# include <wordexp.h>
123+
# endif
120124
#endif
121125

122126
#if SANITIZER_LINUX
@@ -182,6 +186,17 @@ typedef struct user_fpregs elf_fpregset_t;
182186
#include <sys/ioctl.h>
183187
#endif
184188

189+
# if SANITIZER_AIX
190+
# include <netinet/ip_mroute.h>
191+
# include <stropts.h>
192+
# include <sys/ioctl.h>
193+
# include <sys/statfs.h>
194+
# include <unistd.h>
195+
# if HAVE_RPC_XDR_H
196+
# include <tirpc/rpc/xdr.h>
197+
# endif
198+
# endif
199+
185200
// Include these after system headers to avoid name clashes and ambiguities.
186201
# include "sanitizer_common.h"
187202
# include "sanitizer_internal_defs.h"
@@ -557,13 +572,20 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
557572

558573
const unsigned IOCTL_NOT_PRESENT = 0;
559574

560-
unsigned IOCTL_FIONBIO = FIONBIO;
575+
// On AIX, some variables are unsigned long types.
576+
#if SANITIZER_AIX
577+
using ioctl_alttype = uptr;
578+
#else
579+
using ioctl_alttype = unsigned;
580+
#endif
581+
582+
ioctl_alttype IOCTL_FIONBIO = FIONBIO;
561583
#if !SANITIZER_HAIKU
562-
unsigned IOCTL_FIOASYNC = FIOASYNC;
584+
ioctl_alttype IOCTL_FIOASYNC = FIOASYNC;
563585
unsigned IOCTL_FIOCLEX = FIOCLEX;
564586
unsigned IOCTL_FIOGETOWN = FIOGETOWN;
565587
unsigned IOCTL_FIONCLEX = FIONCLEX;
566-
unsigned IOCTL_FIOSETOWN = FIOSETOWN;
588+
ioctl_alttype IOCTL_FIOSETOWN = FIOSETOWN;
567589
#endif
568590
unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI;
569591
unsigned IOCTL_SIOCATMARK = SIOCATMARK;
@@ -584,29 +606,31 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
584606
unsigned IOCTL_SIOCSIFMETRIC = SIOCSIFMETRIC;
585607
unsigned IOCTL_SIOCSIFMTU = SIOCSIFMTU;
586608
unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK;
587-
unsigned IOCTL_SIOCSPGRP = SIOCSPGRP;
609+
ioctl_alttype IOCTL_SIOCSPGRP = SIOCSPGRP;
588610

589611
#if !SANITIZER_HAIKU
590-
unsigned IOCTL_TIOCCONS = TIOCCONS;
612+
ioctl_alttype IOCTL_TIOCCONS = TIOCCONS;
591613
unsigned IOCTL_TIOCGETD = TIOCGETD;
592614
unsigned IOCTL_TIOCNOTTY = TIOCNOTTY;
593-
unsigned IOCTL_TIOCPKT = TIOCPKT;
594-
unsigned IOCTL_TIOCSETD = TIOCSETD;
595-
unsigned IOCTL_TIOCSTI = TIOCSTI;
615+
ioctl_alttype IOCTL_TIOCPKT = TIOCPKT;
616+
ioctl_alttype IOCTL_TIOCSETD = TIOCSETD;
617+
ioctl_alttype IOCTL_TIOCSTI = TIOCSTI;
596618
#endif
597619

598620
unsigned IOCTL_TIOCEXCL = TIOCEXCL;
599621
unsigned IOCTL_TIOCGPGRP = TIOCGPGRP;
600622
unsigned IOCTL_TIOCGWINSZ = TIOCGWINSZ;
601-
unsigned IOCTL_TIOCMBIC = TIOCMBIC;
602-
unsigned IOCTL_TIOCMBIS = TIOCMBIS;
623+
ioctl_alttype IOCTL_TIOCMBIC = TIOCMBIC;
624+
ioctl_alttype IOCTL_TIOCMBIS = TIOCMBIS;
603625
unsigned IOCTL_TIOCMGET = TIOCMGET;
604-
unsigned IOCTL_TIOCMSET = TIOCMSET;
626+
ioctl_alttype IOCTL_TIOCMSET = TIOCMSET;
605627
unsigned IOCTL_TIOCNXCL = TIOCNXCL;
606628
unsigned IOCTL_TIOCOUTQ = TIOCOUTQ;
629+
# if !SANITIZER_AIX
607630
unsigned IOCTL_TIOCSCTTY = TIOCSCTTY;
608-
unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
609-
unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
631+
# endif
632+
ioctl_alttype IOCTL_TIOCSPGRP = TIOCSPGRP;
633+
ioctl_alttype IOCTL_TIOCSWINSZ = TIOCSWINSZ;
610634
#if SANITIZER_LINUX && !SANITIZER_ANDROID
611635
unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
612636
unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
@@ -1115,6 +1139,8 @@ COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
11151139
CHECK_SIZE_AND_OFFSET(dirent, d_ino);
11161140
#if SANITIZER_APPLE
11171141
CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
1142+
#elif SANITIZER_AIX
1143+
CHECK_SIZE_AND_OFFSET(dirent, d_offset);
11181144
#elif SANITIZER_FREEBSD || SANITIZER_HAIKU
11191145
// There is no 'd_off' field on FreeBSD.
11201146
#else
@@ -1205,8 +1231,10 @@ CHECK_SIZE_AND_OFFSET(tm, tm_year);
12051231
CHECK_SIZE_AND_OFFSET(tm, tm_wday);
12061232
CHECK_SIZE_AND_OFFSET(tm, tm_yday);
12071233
CHECK_SIZE_AND_OFFSET(tm, tm_isdst);
1234+
# if !SANITIZER_AIX
12081235
CHECK_SIZE_AND_OFFSET(tm, tm_gmtoff);
12091236
CHECK_SIZE_AND_OFFSET(tm, tm_zone);
1237+
# endif
12101238

12111239
#if SANITIZER_LINUX
12121240
CHECK_TYPE_SIZE(mntent);
@@ -1258,7 +1286,7 @@ CHECK_TYPE_SIZE(clock_t);
12581286
CHECK_TYPE_SIZE(clockid_t);
12591287
#endif
12601288

1261-
#if !SANITIZER_ANDROID && !SANITIZER_HAIKU
1289+
#if !SANITIZER_ANDROID && !SANITIZER_HAIKU && !SANITIZER_AIX
12621290
CHECK_TYPE_SIZE(ifaddrs);
12631291
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next);
12641292
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name);

0 commit comments

Comments
 (0)