From 8470374cba7df0e70653d95c4f336a4082c68d82 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 25 Feb 2012 02:38:52 +0100 Subject: [PATCH] Cleanup after non-Linux code removal. Conditions such as defined(LINUX) are always true now, defined(FREEBSD) etc are always false. When if directive has them as subexpressions, it can be simplified. Another trivial changes here are fixes for directive indentation. Signed-off-by: Denys Vlasenko --- defs.h | 10 +-- desc.c | 4 +- file.c | 259 +++++++++++++++++++++++++---------------------------- io.c | 2 +- ipc.c | 6 +- mem.c | 23 +++-- net.c | 12 +-- process.c | 62 +++++++------ resource.c | 6 +- signal.c | 52 +++++------ strace.c | 2 +- stream.c | 4 +- syscall.c | 12 +-- time.c | 6 +- util.c | 14 +-- 15 files changed, 227 insertions(+), 247 deletions(-) diff --git a/defs.h b/defs.h index 6cf37830..84b7d74f 100644 --- a/defs.h +++ b/defs.h @@ -48,7 +48,7 @@ /* Configuration section */ #ifndef MAX_QUALS -#if defined(LINUX) && defined(MIPS) +#if defined(MIPS) #define MAX_QUALS 7000 /* maximum number of syscalls, signals, etc. */ #else #define MAX_QUALS 2048 /* maximum number of syscalls, signals, etc. */ @@ -67,11 +67,6 @@ * Make sure that all entries in all syscallent.h files * have nargs <= MAX_ARGS! * linux//syscallent.h: all have nargs <= 6. - * freebsd/i386/syscallent.h: one syscall with nargs = 8 - * (sys_sendfile, looks legitimate) - * and one with nargs = 7 (sys_mmap, maybe it should have 6?). - * sunos4/syscallent.h: all are <= 6. - * svr4/syscallent.h: all are MA (MAX_ARGS), it's unclear what the real max is. */ #ifndef MAX_ARGS # define MAX_ARGS 6 @@ -578,8 +573,7 @@ extern void tv_div(struct timeval *, struct timeval *, int); extern char *stpcpy(char *dst, const char *src); #endif -#if !(defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(IA64) \ - && !defined(SH)) +#if defined(SPARC) || defined(SPARC64) || defined(IA64) || defined(SH) extern long getrval2(struct tcb *); #endif diff --git a/desc.c b/desc.c index 2d5ac5d3..be327eb4 100644 --- a/desc.c +++ b/desc.c @@ -465,13 +465,13 @@ sys_dup3(struct tcb *tcp) return do_dup2(tcp, 2); } -#if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) +#if defined(ALPHA) int sys_getdtablesize(struct tcb *tcp) { return 0; } -#endif /* ALPHA || FREEBSD || SUNOS4 */ +#endif static int decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) diff --git a/file.c b/file.c index a1d30b3f..7e3e3fbd 100644 --- a/file.c +++ b/file.c @@ -41,7 +41,7 @@ struct kernel_dirent { char d_name[1]; }; -# ifdef LINUXSPARC +#ifdef LINUXSPARC struct stat { unsigned short st_dev; unsigned int st_ino; @@ -61,7 +61,7 @@ struct stat { int st_blocks; unsigned int __unused4[2]; }; -#if defined(SPARC64) +# if defined(SPARC64) struct stat_sparc64 { unsigned int st_dev; unsigned long st_ino; @@ -78,81 +78,82 @@ struct stat_sparc64 { long st_blocks; unsigned long __unused4[2]; }; -#endif /* SPARC64 */ -# define stat kernel_stat -# include -# undef stat -# else -# undef dev_t -# undef ino_t -# undef mode_t -# undef nlink_t -# undef uid_t -# undef gid_t -# undef off_t -# undef loff_t - -# define dev_t __kernel_dev_t -# define ino_t __kernel_ino_t -# define mode_t __kernel_mode_t -# define nlink_t __kernel_nlink_t -# define uid_t __kernel_uid_t -# define gid_t __kernel_gid_t -# define off_t __kernel_off_t -# define loff_t __kernel_loff_t - -# include - -# undef dev_t -# undef ino_t -# undef mode_t -# undef nlink_t -# undef uid_t -# undef gid_t -# undef off_t -# undef loff_t - -# define dev_t dev_t -# define ino_t ino_t -# define mode_t mode_t -# define nlink_t nlink_t -# define uid_t uid_t -# define gid_t gid_t -# define off_t off_t -# define loff_t loff_t -# endif -# ifdef HPPA /* asm-parisc/stat.h defines stat64 */ -# undef stat64 -# endif -# define stat libc_stat -# define stat64 libc_stat64 -# include -# undef stat -# undef stat64 - /* These might be macros. */ -# undef st_atime -# undef st_mtime -# undef st_ctime -# ifdef HPPA -# define stat64 hpux_stat64 -# endif +# endif /* SPARC64 */ +# define stat kernel_stat +# include +# undef stat +#else +# undef dev_t +# undef ino_t +# undef mode_t +# undef nlink_t +# undef uid_t +# undef gid_t +# undef off_t +# undef loff_t + +# define dev_t __kernel_dev_t +# define ino_t __kernel_ino_t +# define mode_t __kernel_mode_t +# define nlink_t __kernel_nlink_t +# define uid_t __kernel_uid_t +# define gid_t __kernel_gid_t +# define off_t __kernel_off_t +# define loff_t __kernel_loff_t + +# include + +# undef dev_t +# undef ino_t +# undef mode_t +# undef nlink_t +# undef uid_t +# undef gid_t +# undef off_t +# undef loff_t + +# define dev_t dev_t +# define ino_t ino_t +# define mode_t mode_t +# define nlink_t nlink_t +# define uid_t uid_t +# define gid_t gid_t +# define off_t off_t +# define loff_t loff_t +#endif + +#ifdef HPPA /* asm-parisc/stat.h defines stat64 */ +# undef stat64 +#endif +#define stat libc_stat +#define stat64 libc_stat64 +#include +#undef stat +#undef stat64 + /* These might be macros. */ +#undef st_atime +#undef st_mtime +#undef st_ctime +#ifdef HPPA +# define stat64 hpux_stat64 +#endif #include #ifdef HAVE_SYS_VFS_H -#include +# include #endif #ifdef HAVE_LINUX_XATTR_H -#include +# include #else -#define XATTR_CREATE 1 -#define XATTR_REPLACE 2 +# define XATTR_CREATE 1 +# define XATTR_REPLACE 2 #endif -#if _LFS64_LARGEFILE && (defined(LINUX) || defined(SVR4)) +#if _LFS64_LARGEFILE # ifdef HAVE_INTTYPES_H # include # else @@ -166,27 +167,27 @@ struct stat_sparc64 { * Ugly hacks for systems that have typedef long long off_t */ -#define stat64 stat -#define HAVE_STAT64 1 /* Ugly hack */ +# define stat64 stat +# define HAVE_STAT64 1 /* Ugly hack */ -#define sys_stat64 sys_stat -#define sys_fstat64 sys_fstat -#define sys_lstat64 sys_lstat -#define sys_lseek64 sys_lseek -#define sys_truncate64 sys_truncate -#define sys_ftruncate64 sys_ftruncate +# define sys_stat64 sys_stat +# define sys_fstat64 sys_fstat +# define sys_lstat64 sys_lstat +# define sys_lseek64 sys_lseek +# define sys_truncate64 sys_truncate +# define sys_ftruncate64 sys_ftruncate #endif #ifdef MAJOR_IN_SYSMACROS -#include +# include #endif #ifdef MAJOR_IN_MKDEV -#include +# include #endif #ifdef HAVE_SYS_ASYNCH_H -#include +# include #endif @@ -830,7 +831,7 @@ printstat_sparc64(struct tcb *tcp, long addr) #endif /* SPARC64 */ #endif /* LINUXSPARC */ -#if defined LINUX && defined POWERPC64 +#if defined POWERPC64 struct stat_powerpc32 { unsigned int st_dev; unsigned int st_ino; @@ -893,7 +894,7 @@ printstat_powerpc32(struct tcb *tcp, long addr) else tprints("...}"); } -#endif /* LINUX && POWERPC64 */ +#endif /* POWERPC64 */ static const struct xlat fileflags[] = { { 0, NULL }, @@ -994,7 +995,7 @@ printstat(struct tcb *tcp, long addr) #endif #endif /* LINUXSPARC */ -#if defined LINUX && defined POWERPC64 +#if defined POWERPC64 if (current_personality == 1) { printstat_powerpc32(tcp, addr); return; @@ -1010,7 +1011,7 @@ printstat(struct tcb *tcp, long addr) } #endif /* !HAVE_LONG_LONG_OFF_T */ -#if !defined HAVE_STAT64 && defined LINUX && defined X86_64 +#if !defined HAVE_STAT64 && defined X86_64 /* * Linux x86_64 has unified `struct stat' but its i386 biarch needs * `struct stat64'. Its definition expects 32-bit `long'. @@ -1074,7 +1075,7 @@ printstat64(struct tcb *tcp, long addr) # endif #endif /* LINUXSPARC */ -#if defined LINUX && defined X86_64 +#if defined X86_64 if (current_personality == 0) { printstat(tcp, addr); return; @@ -1162,8 +1163,7 @@ printstat64(struct tcb *tcp, long addr) } #endif /* HAVE_STAT64 */ -#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \ - && !defined(HAVE_LONG_LONG_OFF_T) +#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T) static void convertoldstat(const struct __old_kernel_stat *oldbuf, struct stat *newbuf) { @@ -1198,12 +1198,12 @@ printoldstat(struct tcb *tcp, long addr) return; } -#ifdef LINUXSPARC +# ifdef LINUXSPARC if (current_personality == 1) { printstatsol(tcp, addr); return; } -#endif /* LINUXSPARC */ +# endif if (umove(tcp, addr, &statbuf) < 0) { tprints("{...}"); @@ -1213,7 +1213,7 @@ printoldstat(struct tcb *tcp, long addr) convertoldstat(&statbuf, &newstatbuf); realprintstat(tcp, &newstatbuf); } -#endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */ +#endif #ifndef HAVE_LONG_LONG_OFF_T int @@ -1278,8 +1278,7 @@ sys_newfstatat(struct tcb *tcp) return 0; } -#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \ - && !defined(HAVE_LONG_LONG_OFF_T) +#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T) int sys_oldstat(struct tcb *tcp) { @@ -1291,7 +1290,7 @@ sys_oldstat(struct tcb *tcp) } return 0; } -#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */ +#endif #ifndef HAVE_LONG_LONG_OFF_T int @@ -1323,8 +1322,7 @@ sys_fstat64(struct tcb *tcp) #endif } -#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \ - && !defined(HAVE_LONG_LONG_OFF_T) +#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T) int sys_oldfstat(struct tcb *tcp) { @@ -1336,7 +1334,7 @@ sys_oldfstat(struct tcb *tcp) } return 0; } -#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */ +#endif #ifndef HAVE_LONG_LONG_OFF_T int @@ -1368,8 +1366,7 @@ sys_lstat64(struct tcb *tcp) #endif } -#if defined(LINUX) && defined(HAVE_STRUCT___OLD_KERNEL_STAT) \ - && !defined(HAVE_LONG_LONG_OFF_T) +#if defined(HAVE_STRUCT___OLD_KERNEL_STAT) && !defined(HAVE_LONG_LONG_OFF_T) int sys_oldlstat(struct tcb *tcp) { @@ -1381,10 +1378,10 @@ sys_oldlstat(struct tcb *tcp) } return 0; } -#endif /* LINUX && HAVE_STRUCT___OLD_KERNEL_STAT */ +#endif -#if defined(SVR4) || defined(LINUXSPARC) +#if defined(LINUXSPARC) int sys_xstat(struct tcb *tcp) @@ -1394,11 +1391,11 @@ sys_xstat(struct tcb *tcp) printpath(tcp, tcp->u_arg[1]); tprints(", "); } else { -#ifdef _STAT64_VER +# ifdef _STAT64_VER if (tcp->u_arg[0] == _STAT64_VER) printstat64 (tcp, tcp->u_arg[2]); else -#endif +# endif printstat(tcp, tcp->u_arg[2]); } return 0; @@ -1410,11 +1407,11 @@ sys_fxstat(struct tcb *tcp) if (entering(tcp)) tprintf("%ld, %ld, ", tcp->u_arg[0], tcp->u_arg[1]); else { -#ifdef _STAT64_VER +# ifdef _STAT64_VER if (tcp->u_arg[0] == _STAT64_VER) printstat64 (tcp, tcp->u_arg[2]); else -#endif +# endif printstat(tcp, tcp->u_arg[2]); } return 0; @@ -1428,11 +1425,11 @@ sys_lxstat(struct tcb *tcp) printpath(tcp, tcp->u_arg[1]); tprints(", "); } else { -#ifdef _STAT64_VER +# ifdef _STAT64_VER if (tcp->u_arg[0] == _STAT64_VER) printstat64 (tcp, tcp->u_arg[2]); else -#endif +# endif printstat(tcp, tcp->u_arg[2]); } return 0; @@ -1449,15 +1446,9 @@ sys_xmknod(struct tcb *tcp) tprintf(", %s", sprintmode(mode)); switch (mode & S_IFMT) { case S_IFCHR: case S_IFBLK: -#ifdef LINUXSPARC tprintf(", makedev(%lu, %lu)", (unsigned long) ((tcp->u_arg[3] >> 18) & 0x3fff), (unsigned long) (tcp->u_arg[3] & 0x3ffff)); -#else - tprintf(", makedev(%lu, %lu)", - (unsigned long) major(tcp->u_arg[3]), - (unsigned long) minor(tcp->u_arg[3])); -#endif break; default: break; @@ -1466,29 +1457,29 @@ sys_xmknod(struct tcb *tcp) return 0; } -#ifdef HAVE_SYS_ACL_H +# ifdef HAVE_SYS_ACL_H -#include +# include static const struct xlat aclcmds[] = { -#ifdef SETACL +# ifdef SETACL { SETACL, "SETACL" }, -#endif -#ifdef GETACL +# endif +# ifdef GETACL { GETACL, "GETACL" }, -#endif -#ifdef GETACLCNT +# endif +# ifdef GETACLCNT { GETACLCNT, "GETACLCNT" }, -#endif -#ifdef ACL_GET +# endif +# ifdef ACL_GET { ACL_GET, "ACL_GET" }, -#endif -#ifdef ACL_SET +# endif +# ifdef ACL_SET { ACL_SET, "ACL_SET" }, -#endif -#ifdef ACL_CNT +# endif +# ifdef ACL_CNT { ACL_CNT, "ACL_CNT" }, -#endif +# endif { 0, NULL }, }; @@ -1534,15 +1525,15 @@ sys_facl(struct tcb *tcp) static const struct xlat aclipc[] = { -#ifdef IPC_SHM +# ifdef IPC_SHM { IPC_SHM, "IPC_SHM" }, -#endif -#ifdef IPC_SEM +# endif +# ifdef IPC_SEM { IPC_SEM, "IPC_SEM" }, -#endif -#ifdef IPC_MSG +# endif +# ifdef IPC_MSG { IPC_MSG, "IPC_MSG" }, -#endif +# endif { 0, NULL }, }; @@ -1567,9 +1558,9 @@ sys_aclipc(struct tcb *tcp) return 0; } -#endif /* HAVE_SYS_ACL_H */ +# endif /* HAVE_SYS_ACL_H */ -#endif /* SVR4 || LINUXSPARC */ +#endif /* LINUXSPARC */ static const struct xlat fsmagic[] = { @@ -1687,7 +1678,7 @@ sys_fstatfs(struct tcb *tcp) return 0; } -#if defined LINUX && defined HAVE_STATFS64 +#if defined HAVE_STATFS64 static void printstatfs64(struct tcb *tcp, long addr) { @@ -1804,8 +1795,7 @@ sys_fstatfs64(struct tcb *tcp) } #endif -#if defined(LINUX) && defined(__alpha) - +#if defined(__alpha) int osf_statfs(struct tcb *tcp) { @@ -1830,8 +1820,7 @@ osf_fstatfs(struct tcb *tcp) } return 0; } -#endif /* LINUX && __alpha */ - +#endif /* directory */ diff --git a/io.c b/io.c index 9aa0ddd0..7dff4e63 100644 --- a/io.c +++ b/io.c @@ -69,7 +69,7 @@ sys_write(struct tcb *tcp) void tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr, int decode_iov) { -#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 +#if SUPPORTED_PERSONALITIES > 1 union { struct { u_int32_t base; u_int32_t len; } iov32; struct { u_int64_t base; u_int64_t len; } iov64; diff --git a/ipc.c b/ipc.c index 963537e2..d8757c1f 100644 --- a/ipc.c +++ b/ipc.c @@ -62,7 +62,7 @@ #define SEM_INFO 19 #endif -#if defined LINUX && !defined IPC_64 +#if !defined IPC_64 # define IPC_64 0x100 #endif @@ -421,11 +421,11 @@ int sys_shmat(struct tcb *tcp) if (syserror(tcp)) return 0; /* HPPA does not use an IPC multiplexer on Linux. */ -#if defined(LINUX) && !defined(HPPA) +#if !defined(HPPA) if (umove(tcp, tcp->u_arg[2], &raddr) < 0) return RVAL_NONE; tcp->u_rval = raddr; -#endif /* LINUX */ +#endif return RVAL_HEX; } return 0; diff --git a/mem.c b/mem.c index e8bad07d..252486ad 100644 --- a/mem.c +++ b/mem.c @@ -37,13 +37,13 @@ #include #include -#if defined(LINUX) && defined(I386) +#if defined(I386) # include # ifdef HAVE_STRUCT_USER_DESC # define modify_ldt_ldt_s user_desc # endif #endif -#if defined(LINUX) && defined(SH64) +#if defined(SH64) # include /* for PAGE_SHIFT */ #endif @@ -299,7 +299,7 @@ sys_mmap(struct tcb *tcp) * from pages to bytes. See test/mmap_offset_decode.c * Why SH64 and i386 are handled differently? */ -#if defined(LINUX) && defined(SH64) +#if defined(SH64) /* * Old mmap differs from new mmap in specifying the * offset in units of bytes rather than pages. We @@ -325,7 +325,7 @@ int sys_mmap64(struct tcb *tcp) { if (entering(tcp)) { -#if !defined(LINUX) || defined(ALPHA) +#if defined(ALPHA) long *u_arg = tcp->u_arg; #else long u_arg[7]; @@ -354,7 +354,7 @@ sys_mmap64(struct tcb *tcp) tprints(", "); printfd(tcp, u_arg[4]); /* offset */ -#if !defined(LINUX) || defined(ALPHA) +#if defined(ALPHA) printllval(tcp, ", %#llx", 5); #else /* NOTE: not verified that [5] and [6] should be used. @@ -574,7 +574,7 @@ sys_mincore(struct tcb *tcp) return 0; } -#if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64) +#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64) int sys_getpagesize(struct tcb *tcp) { @@ -582,9 +582,9 @@ sys_getpagesize(struct tcb *tcp) return RVAL_HEX; return 0; } -#endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */ +#endif -#if defined(LINUX) && defined(__i386__) +#if defined(__i386__) void print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry) { @@ -676,10 +676,9 @@ sys_get_thread_area(struct tcb *tcp) return 0; } -#endif /* LINUX && __i386__ */ - -#if defined(LINUX) && defined(M68K) +#endif /* __i386__ */ +#if defined(M68K) int sys_set_thread_area(struct tcb *tcp) { @@ -910,7 +909,7 @@ sys_move_pages(struct tcb *tcp) return 0; } -#if defined(LINUX) && defined(POWERPC) +#if defined(POWERPC) int sys_subpage_prot(struct tcb *tcp) { diff --git a/net.c b/net.c index e7d2a07f..3955f168 100644 --- a/net.c +++ b/net.c @@ -1218,7 +1218,7 @@ printsock(struct tcb *tcp, long addr, int addrlen) #ifdef HAVE_INET_NTOP struct sockaddr_in6 sa6; #endif -#if defined(LINUX) && defined(AF_IPX) +#if defined(AF_IPX) struct sockaddr_ipx sipx; #endif #ifdef AF_PACKET @@ -1297,7 +1297,7 @@ printsock(struct tcb *tcp, long addr, int addrlen) #endif break; #endif -#if defined(AF_IPX) && defined(linux) +#if defined(AF_IPX) case AF_IPX: { int i; @@ -1315,7 +1315,7 @@ printsock(struct tcb *tcp, long addr, int addrlen) tprintf("/[%02x]", addrbuf.sipx.sipx_type); } break; -#endif /* AF_IPX && linux */ +#endif /* AF_IPX */ #ifdef AF_PACKET case AF_PACKET: { @@ -1332,7 +1332,7 @@ printsock(struct tcb *tcp, long addr, int addrlen) } break; -#endif /* AF_APACKET */ +#endif /* AF_PACKET */ #ifdef AF_NETLINK case AF_NETLINK: tprintf("pid=%d, groups=%08x", addrbuf.nl.nl_pid, addrbuf.nl.nl_groups); @@ -1800,14 +1800,14 @@ do_pipe(struct tcb *tcp, int flags_arg) if (syserror(tcp)) { tprintf("%#lx", tcp->u_arg[0]); } else { -#if defined(LINUX) && !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) +#if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) int fds[2]; if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) tprints("[...]"); else tprintf("[%u, %u]", fds[0], fds[1]); -#elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(SVR4) || defined(FREEBSD) || defined(IA64) +#elif defined(SPARC) || defined(SPARC64) || defined(SH) || defined(IA64) tprintf("[%lu, %lu]", tcp->u_rval, getrval2(tcp)); #else tprintf("%#lx", tcp->u_arg[0]); diff --git a/process.c b/process.c index 699355bf..20cfe206 100644 --- a/process.c +++ b/process.c @@ -52,50 +52,50 @@ #ifdef HAVE_SYS_REG_H # include -#ifndef PTRACE_PEEKUSR -# define PTRACE_PEEKUSR PTRACE_PEEKUSER -#endif -#ifndef PTRACE_POKEUSR -# define PTRACE_POKEUSR PTRACE_POKEUSER -#endif +# ifndef PTRACE_PEEKUSR +# define PTRACE_PEEKUSR PTRACE_PEEKUSER +# endif +# ifndef PTRACE_POKEUSR +# define PTRACE_POKEUSR PTRACE_POKEUSER +# endif #endif #ifdef HAVE_LINUX_PTRACE_H -#undef PTRACE_SYSCALL +# undef PTRACE_SYSCALL # ifdef HAVE_STRUCT_IA64_FPREG # define ia64_fpreg XXX_ia64_fpreg # endif # ifdef HAVE_STRUCT_PT_ALL_USER_REGS # define pt_all_user_regs XXX_pt_all_user_regs # endif -#include +# include # undef ia64_fpreg # undef pt_all_user_regs #endif -#if defined (LINUX) && defined (SPARC64) +#if defined(SPARC64) # define r_pc r_tpc # undef PTRACE_GETREGS # define PTRACE_GETREGS PTRACE_GETREGS64 # undef PTRACE_SETREGS # define PTRACE_SETREGS PTRACE_SETREGS64 -#endif /* LINUX && SPARC64 */ +#endif #ifdef HAVE_LINUX_FUTEX_H # include #endif -# ifndef FUTEX_WAIT -# define FUTEX_WAIT 0 -# endif -# ifndef FUTEX_WAKE -# define FUTEX_WAKE 1 -# endif -# ifndef FUTEX_FD -# define FUTEX_FD 2 -# endif -# ifndef FUTEX_REQUEUE -# define FUTEX_REQUEUE 3 -# endif +#ifndef FUTEX_WAIT +# define FUTEX_WAIT 0 +#endif +#ifndef FUTEX_WAKE +# define FUTEX_WAKE 1 +#endif +#ifndef FUTEX_FD +# define FUTEX_FD 2 +#endif +#ifndef FUTEX_REQUEUE +# define FUTEX_REQUEUE 3 +#endif #include #include @@ -104,7 +104,7 @@ #undef GETGROUPS32_T #define GETGROUPS32_T __kernel_gid32_t -#if defined(LINUX) && defined(IA64) +#if defined(IA64) # include # include #endif @@ -360,7 +360,7 @@ sys_sethostname(struct tcb *tcp) return 0; } -#if defined(ALPHA) || defined(FREEBSD) || defined(SUNOS4) || defined(SVR4) +#if defined(ALPHA) int sys_gethostname(struct tcb *tcp) { @@ -373,7 +373,7 @@ sys_gethostname(struct tcb *tcp) } return 0; } -#endif /* ALPHA || FREEBSD || SUNOS4 || SVR4 */ +#endif int sys_setdomainname(struct tcb *tcp) @@ -1068,7 +1068,7 @@ sys_getgroups32(struct tcb *tcp) return 0; } -#if defined(ALPHA) || defined(SUNOS4) || defined(SVR4) +#if defined(ALPHA) int sys_setpgrp(struct tcb *tcp) { @@ -1077,7 +1077,7 @@ sys_setpgrp(struct tcb *tcp) } return 0; } -#endif /* ALPHA || SUNOS4 || SVR4 */ +#endif int sys_getpgrp(struct tcb *tcp) @@ -1165,7 +1165,7 @@ printargc(const char *fmt, struct tcb *tcp, long addr) tprintf(fmt, count, count == 1 ? "" : "s"); } -#if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) +#if defined(SPARC) || defined(SPARC64) int sys_execv(struct tcb *tcp) { @@ -1181,7 +1181,7 @@ sys_execv(struct tcb *tcp) } return 0; } -#endif /* SPARC || SPARC64 || SUNOS4 */ +#endif int sys_execve(struct tcb *tcp) @@ -1209,11 +1209,10 @@ sys_execve(struct tcb *tcp) } -#if defined SUNOS4 || (defined LINUX && defined TCB_WAITEXECVE) +#if defined(TCB_WAITEXECVE) int internal_exec(struct tcb *tcp) { -# if defined LINUX && defined TCB_WAITEXECVE if (exiting(tcp) && syserror(tcp)) tcp->flags &= ~TCB_WAITEXECVE; else { @@ -1221,7 +1220,6 @@ internal_exec(struct tcb *tcp) if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC)) tcp->flags |= TCB_WAITEXECVE; /* no */ } -# endif return 0; } #endif diff --git a/resource.c b/resource.c index b340ccd1..9040b052 100644 --- a/resource.c +++ b/resource.c @@ -118,7 +118,7 @@ sprintrlim(long lim) return buf; } -# if defined LINUX && (defined POWERPC64 || defined X86_64) +# if defined POWERPC64 || defined X86_64 static void print_rlimit32(struct tcb *tcp) { @@ -152,7 +152,7 @@ sys_getrlimit(struct tcb *tcp) else { if (syserror(tcp) || !verbose(tcp)) tprintf("%#lx", tcp->u_arg[1]); -# if defined LINUX && (defined POWERPC64 || defined X86_64) +# if defined POWERPC64 || defined X86_64 else if (current_personality == 1) print_rlimit32(tcp); # endif @@ -176,7 +176,7 @@ sys_setrlimit(struct tcb *tcp) tprints(", "); if (!verbose(tcp)) tprintf("%#lx", tcp->u_arg[1]); -# if defined LINUX && (defined POWERPC64 || defined X86_64) +# if defined POWERPC64 || defined X86_64 else if (current_personality == 1) print_rlimit32(tcp); # endif diff --git a/signal.c b/signal.c index f9e826c8..eab5c522 100644 --- a/signal.c +++ b/signal.c @@ -43,21 +43,21 @@ #ifdef HAVE_SYS_REG_H # include -#ifndef PTRACE_PEEKUSR -# define PTRACE_PEEKUSR PTRACE_PEEKUSER -#endif -#ifndef PTRACE_POKEUSR -# define PTRACE_POKEUSR PTRACE_POKEUSER -#endif +# ifndef PTRACE_PEEKUSR +# define PTRACE_PEEKUSR PTRACE_PEEKUSER +# endif +# ifndef PTRACE_POKEUSR +# define PTRACE_POKEUSR PTRACE_POKEUSER +# endif #elif defined(HAVE_LINUX_PTRACE_H) -#undef PTRACE_SYSCALL +# undef PTRACE_SYSCALL # ifdef HAVE_STRUCT_IA64_FPREG # define ia64_fpreg XXX_ia64_fpreg # endif # ifdef HAVE_STRUCT_PT_ALL_USER_REGS # define pt_all_user_regs XXX_pt_all_user_regs # endif -#include +# include # undef ia64_fpreg # undef pt_all_user_regs #endif @@ -68,24 +68,24 @@ # include #endif -#if defined (LINUX) && defined (SPARC64) +#if defined(SPARC64) # undef PTRACE_GETREGS # define PTRACE_GETREGS PTRACE_GETREGS64 # undef PTRACE_SETREGS # define PTRACE_SETREGS PTRACE_SETREGS64 -#endif /* LINUX && SPARC64 */ +#endif -#if defined (SPARC) || defined (SPARC64) || defined (MIPS) +#if defined(SPARC) || defined(SPARC64) || defined(MIPS) typedef struct { struct pt_regs si_regs; int si_mask; } m_siginfo_t; #elif defined HAVE_ASM_SIGCONTEXT_H -#if !defined(IA64) && !defined(X86_64) -#include -#endif /* !IA64 && !X86_64 */ +# if !defined(IA64) && !defined(X86_64) +# include +# endif /* !IA64 && !X86_64 */ #else /* !HAVE_ASM_SIGCONTEXT_H */ -#if defined I386 && !defined HAVE_STRUCT_SIGCONTEXT_STRUCT +# if defined I386 && !defined HAVE_STRUCT_SIGCONTEXT_STRUCT struct sigcontext_struct { unsigned short gs, __gsh; unsigned short fs, __fsh; @@ -110,8 +110,8 @@ struct sigcontext_struct { unsigned long oldmask; unsigned long cr2; }; -#else /* !I386 */ -#if defined M68K && !defined HAVE_STRUCT_SIGCONTEXT +# else /* !I386 */ +# if defined M68K && !defined HAVE_STRUCT_SIGCONTEXT struct sigcontext { unsigned long sc_mask; @@ -124,25 +124,25 @@ struct sigcontext unsigned long sc_pc; unsigned short sc_formatvec; }; -#endif /* M68K */ -#endif /* !I386 */ +# endif /* M68K */ +# endif /* !I386 */ #endif /* !HAVE_ASM_SIGCONTEXT_H */ #ifndef NSIG -#warning: NSIG is not defined, using 32 -#define NSIG 32 +# warning: NSIG is not defined, using 32 +# define NSIG 32 #endif #ifdef ARM /* Ugh. Is this really correct? ARM has no RT signals?! */ -#undef NSIG -#define NSIG 32 +# undef NSIG +# define NSIG 32 #endif #ifdef HAVE_SIGACTION -#if defined LINUX && (defined I386 || defined X86_64) +#if defined I386 || defined X86_64 /* The libc headers do not define this constant since it should only be used by the implementation. So we define it here. */ # ifndef SA_RESTORER @@ -427,7 +427,7 @@ print_sigset(struct tcb *tcp, long addr, int rt) #define SI_FROMUSER(sip) ((sip)->si_code <= 0) -#endif /* LINUX */ +#endif #if __GLIBC_MINOR__ < 1 /* Type for data associated with a signal. */ @@ -1141,7 +1141,7 @@ sys_sigsuspend(struct tcb *tcp) -#if defined LINUX && !defined SS_ONSTACK +#if !defined SS_ONSTACK #define SS_ONSTACK 1 #define SS_DISABLE 2 #if __GLIBC_MINOR__ == 0 diff --git a/strace.c b/strace.c index bda091ed..66dee5f8 100644 --- a/strace.c +++ b/strace.c @@ -58,7 +58,7 @@ # define my_tkill(tid, sig) kill((tid), (sig)) # endif -#if defined(IA64) && defined(LINUX) +#if defined(IA64) # include #endif diff --git a/stream.c b/stream.c index a5bd8318..3eb7dde5 100644 --- a/stream.c +++ b/stream.c @@ -120,7 +120,7 @@ sys_putmsg(struct tcb *tcp) return 0; } -#if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) || defined(SVR4) +#if defined(SPARC) || defined(SPARC64) int sys_getmsg(struct tcb *tcp) { @@ -166,7 +166,7 @@ sys_getmsg(struct tcb *tcp) } return RVAL_HEX | RVAL_STR; } -#endif /* SPARC || SPARC64 || SUNOS4 || SVR4 */ +#endif #if defined SYS_putpmsg || defined SYS_getpmsg static const struct xlat pmsgflags[] = { diff --git a/syscall.c b/syscall.c index 978c65a4..b94ad651 100644 --- a/syscall.c +++ b/syscall.c @@ -60,14 +60,14 @@ # undef pt_all_user_regs #endif -#if defined (LINUX) && defined (SPARC64) +#if defined(SPARC64) # undef PTRACE_GETREGS # define PTRACE_GETREGS PTRACE_GETREGS64 # undef PTRACE_SETREGS # define PTRACE_SETREGS PTRACE_SETREGS64 -#endif /* LINUX && SPARC64 */ +#endif -#if defined(LINUX) && defined(IA64) +#if defined(IA64) # include # include #endif @@ -523,7 +523,7 @@ qualify(const char *s) enum subcall_style { shift_style, deref_style, mask_style, door_style }; -#if !(defined(LINUX) && ( defined(ALPHA) || defined(MIPS) || defined(__ARM_EABI__) )) +#if !(defined(ALPHA) || defined(MIPS) || defined(__ARM_EABI__)) static void decode_subcall(struct tcb *tcp, int subcall, int nsubcalls, enum subcall_style style) @@ -1206,9 +1206,9 @@ internal_syscall(struct tcb *tcp) ) return internal_fork(tcp); -#if defined SUNOS4 || (defined LINUX && defined TCB_WAITEXECVE) +#if defined(TCB_WAITEXECVE) if ( sys_execve == func -# if defined(SPARC) || defined(SPARC64) || defined(SUNOS4) +# if defined(SPARC) || defined(SPARC64) || sys_execv == func # endif ) diff --git a/time.c b/time.c index 86f102e0..4cc9c591 100644 --- a/time.c +++ b/time.c @@ -81,7 +81,7 @@ sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int spec return buf + sprintf(buf, "%#lx", addr); if (bitness == BITNESS_32 -#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 +#if SUPPORTED_PERSONALITIES > 1 || personality_wordsize[current_personality] == 4 #endif ) @@ -137,7 +137,7 @@ sprint_timespec(char *buf, struct tcb *tcp, long addr) else { int rc; -#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 +#if SUPPORTED_PERSONALITIES > 1 if (personality_wordsize[current_personality] == 4) { struct timeval32 tv; @@ -291,7 +291,7 @@ printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness) int rc; if (bitness == BITNESS_32 -#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 +#if SUPPORTED_PERSONALITIES > 1 || personality_wordsize[current_personality] == 4 #endif ) diff --git a/util.c b/util.c index b7ba283b..80acc133 100644 --- a/util.c +++ b/util.c @@ -44,27 +44,27 @@ #include #endif -#if defined(linux) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)) +#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) #include #endif -#if defined(LINUX) && defined(IA64) +#if defined(IA64) # include # include #endif #ifdef HAVE_SYS_REG_H -#include +# include # define PTRACE_PEEKUSR PTRACE_PEEKUSER #elif defined(HAVE_LINUX_PTRACE_H) -#undef PTRACE_SYSCALL +# undef PTRACE_SYSCALL # ifdef HAVE_STRUCT_IA64_FPREG # define ia64_fpreg XXX_ia64_fpreg # endif # ifdef HAVE_STRUCT_PT_ALL_USER_REGS # define pt_all_user_regs XXX_pt_all_user_regs # endif -#include +# include # undef ia64_fpreg # undef pt_all_user_regs #endif @@ -246,7 +246,7 @@ printxval(const struct xlat *xlat, int val, const char *dflt) int printllval(struct tcb *tcp, const char *format, int llarg) { -# if defined LINUX && (defined X86_64 || defined POWERPC64) +# if defined X86_64 || defined POWERPC64 if (current_personality == 0) { tprintf(format, tcp->u_arg[llarg]); llarg++; @@ -655,7 +655,7 @@ printstr(struct tcb *tcp, long addr, int len) void dumpiov(struct tcb *tcp, int len, long addr) { -#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 +#if SUPPORTED_PERSONALITIES > 1 union { struct { u_int32_t base; u_int32_t len; } *iov32; struct { u_int64_t base; u_int64_t len; } *iov64; -- 2.40.0