From 5eca75df031d3cbe577c75dd87734b48c787e7f6 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 15 Apr 2020 15:07:31 +0200 Subject: [PATCH] bpo-40268: Reformat posixmodule.c includes (GH-19536) --- Modules/posixmodule.c | 336 +++++++++++++++++++++--------------------- 1 file changed, 165 insertions(+), 171 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 89f9757c515..4085b922a7c 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1,4 +1,3 @@ - /* POSIX module implementation */ /* This file is also used for Windows NT/MS-Win. In that case the @@ -8,8 +7,6 @@ of the compiler used. Different compilers define their own feature test macro, e.g. '_MSC_VER'. */ - - #ifdef __APPLE__ /* * Step 1 of support for weak-linking a number of symbols existing on @@ -48,7 +45,7 @@ /* On android API level 21, 'AT_EACCESS' is not declared although * HAVE_FACCESSAT is defined. */ #ifdef __ANDROID__ -#undef HAVE_FACCESSAT +# undef HAVE_FACCESSAT #endif #include /* needed for ctermid() */ @@ -65,89 +62,89 @@ corresponding Unix manual entries for more information on calls."); #ifdef HAVE_SYS_UIO_H -#include +# include #endif #ifdef HAVE_SYS_SYSMACROS_H /* GNU C Library: major(), minor(), makedev() */ -#include +# include #endif #ifdef HAVE_SYS_TYPES_H -#include +# include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_STAT_H -#include +# include #endif /* HAVE_SYS_STAT_H */ #ifdef HAVE_SYS_WAIT_H -#include /* For WNOHANG */ +# include // WNOHANG #endif #ifdef HAVE_LINUX_WAIT_H -#include // For P_PIDFD +# include // P_PIDFD #endif #ifdef HAVE_SIGNAL_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ +# include +#endif #ifdef HAVE_GRP_H -#include +# include #endif #ifdef HAVE_SYSEXITS_H -#include -#endif /* HAVE_SYSEXITS_H */ +# include +#endif #ifdef HAVE_SYS_LOADAVG_H -#include +# include #endif #ifdef HAVE_SYS_SENDFILE_H -#include +# include #endif #if defined(__APPLE__) -#include +# include #endif #ifdef HAVE_SCHED_H -#include +# include #endif #ifdef HAVE_COPY_FILE_RANGE -#include +# include #endif #if !defined(CPU_ALLOC) && defined(HAVE_SCHED_SETAFFINITY) -#undef HAVE_SCHED_SETAFFINITY +# undef HAVE_SCHED_SETAFFINITY #endif #if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) -#define USE_XATTRS +# define USE_XATTRS #endif #ifdef USE_XATTRS -#include +# include #endif #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__) -#ifdef HAVE_SYS_SOCKET_H -#include -#endif +# ifdef HAVE_SYS_SOCKET_H +# include +# endif #endif #ifdef HAVE_DLFCN_H -#include +# include #endif #ifdef __hpux -#include +# include #endif #if defined(__DragonFly__) || \ @@ -155,7 +152,7 @@ corresponding Unix manual entries for more information on calls."); defined(__FreeBSD__) || \ defined(__NetBSD__) || \ defined(__APPLE__) -#include +# include #endif #ifdef HAVE_LINUX_RANDOM_H @@ -180,43 +177,44 @@ corresponding Unix manual entries for more information on calls."); /* Various compilers have only certain posix functions */ /* XXX Gosh I wish these were all moved into pyconfig.h */ #if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */ -#define HAVE_OPENDIR 1 -#define HAVE_SYSTEM 1 -#include +# define HAVE_OPENDIR 1 +# define HAVE_SYSTEM 1 +# include #else -#ifdef _MSC_VER /* Microsoft compiler */ -#define HAVE_GETPPID 1 -#define HAVE_GETLOGIN 1 -#define HAVE_SPAWNV 1 -#define HAVE_EXECV 1 -#define HAVE_WSPAWNV 1 -#define HAVE_WEXECV 1 -#define HAVE_PIPE 1 -#define HAVE_SYSTEM 1 -#define HAVE_CWAIT 1 -#define HAVE_FSYNC 1 -#define fsync _commit -#else -/* Unix functions that the configure script doesn't check for */ -#ifndef __VXWORKS__ -#define HAVE_EXECV 1 -#define HAVE_FORK 1 -#if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */ -#define HAVE_FORK1 1 -#endif -#endif -#define HAVE_GETEGID 1 -#define HAVE_GETEUID 1 -#define HAVE_GETGID 1 -#define HAVE_GETPPID 1 -#define HAVE_GETUID 1 -#define HAVE_KILL 1 -#define HAVE_OPENDIR 1 -#define HAVE_PIPE 1 -#define HAVE_SYSTEM 1 -#define HAVE_WAIT 1 -#define HAVE_TTYNAME 1 -#endif /* _MSC_VER */ +# ifdef _MSC_VER + /* Microsoft compiler */ +# define HAVE_GETPPID 1 +# define HAVE_GETLOGIN 1 +# define HAVE_SPAWNV 1 +# define HAVE_EXECV 1 +# define HAVE_WSPAWNV 1 +# define HAVE_WEXECV 1 +# define HAVE_PIPE 1 +# define HAVE_SYSTEM 1 +# define HAVE_CWAIT 1 +# define HAVE_FSYNC 1 +# define fsync _commit +# else + /* Unix functions that the configure script doesn't check for */ +# ifndef __VXWORKS__ +# define HAVE_EXECV 1 +# define HAVE_FORK 1 +# if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */ +# define HAVE_FORK1 1 +# endif +# endif +# define HAVE_GETEGID 1 +# define HAVE_GETEUID 1 +# define HAVE_GETGID 1 +# define HAVE_GETPPID 1 +# define HAVE_GETUID 1 +# define HAVE_KILL 1 +# define HAVE_OPENDIR 1 +# define HAVE_PIPE 1 +# define HAVE_SYSTEM 1 +# define HAVE_WAIT 1 +# define HAVE_TTYNAME 1 +# endif /* _MSC_VER */ #endif /* ! __WATCOMC__ || __QNX__ */ _Py_IDENTIFIER(__fspath__); @@ -238,123 +236,119 @@ extern char *ctermid_r(char *); #endif /* !_MSC_VER */ #if defined(__VXWORKS__) -#include -#include -#include -#include -#ifndef _P_WAIT -#define _P_WAIT 0 -#define _P_NOWAIT 1 -#define _P_NOWAITO 1 -#endif +# include +# include +# include +# include +# ifndef _P_WAIT +# define _P_WAIT 0 +# define _P_NOWAIT 1 +# define _P_NOWAITO 1 +# endif #endif /* __VXWORKS__ */ #ifdef HAVE_POSIX_SPAWN -#include +# include #endif #ifdef HAVE_UTIME_H -#include +# include #endif /* HAVE_UTIME_H */ #ifdef HAVE_SYS_UTIME_H -#include -#define HAVE_UTIME_H /* pretend we do for the rest of this file */ +# include +# define HAVE_UTIME_H /* pretend we do for the rest of this file */ #endif /* HAVE_SYS_UTIME_H */ #ifdef HAVE_SYS_TIMES_H -#include +# include #endif /* HAVE_SYS_TIMES_H */ #ifdef HAVE_SYS_PARAM_H -#include +# include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_UTSNAME_H -#include +# include #endif /* HAVE_SYS_UTSNAME_H */ #ifdef HAVE_DIRENT_H -#include -#define NAMLEN(dirent) strlen((dirent)->d_name) +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) #else -#if defined(__WATCOMC__) && !defined(__QNX__) -#include -#define NAMLEN(dirent) strlen((dirent)->d_name) -#else -#define dirent direct -#define NAMLEN(dirent) (dirent)->d_namlen -#endif -#ifdef HAVE_SYS_NDIR_H -#include -#endif -#ifdef HAVE_SYS_DIR_H -#include -#endif -#ifdef HAVE_NDIR_H -#include -#endif +# if defined(__WATCOMC__) && !defined(__QNX__) +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) +# else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# endif +# ifdef HAVE_SYS_NDIR_H +# include +# endif +# ifdef HAVE_SYS_DIR_H +# include +# endif +# ifdef HAVE_NDIR_H +# include +# endif #endif #ifdef _MSC_VER -#ifdef HAVE_DIRECT_H -#include -#endif -#ifdef HAVE_IO_H -#include -#endif -#ifdef HAVE_PROCESS_H -#include -#endif -#ifndef IO_REPARSE_TAG_SYMLINK -#define IO_REPARSE_TAG_SYMLINK (0xA000000CL) -#endif -#ifndef IO_REPARSE_TAG_MOUNT_POINT -#define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) -#endif -#include "osdefs.h" // SEP -#include -#include -#include // ShellExecute() -#include // UNLEN -#define HAVE_SYMLINK +# ifdef HAVE_DIRECT_H +# include +# endif +# ifdef HAVE_IO_H +# include +# endif +# ifdef HAVE_PROCESS_H +# include +# endif +# ifndef IO_REPARSE_TAG_SYMLINK +# define IO_REPARSE_TAG_SYMLINK (0xA000000CL) +# endif +# ifndef IO_REPARSE_TAG_MOUNT_POINT +# define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) +# endif +# include "osdefs.h" // SEP +# include +# include +# include // ShellExecute() +# include // UNLEN +# define HAVE_SYMLINK #endif /* _MSC_VER */ #ifndef MAXPATHLEN -#if defined(PATH_MAX) && PATH_MAX > 1024 -#define MAXPATHLEN PATH_MAX -#else -#define MAXPATHLEN 1024 -#endif +# if defined(PATH_MAX) && PATH_MAX > 1024 +# define MAXPATHLEN PATH_MAX +# else +# define MAXPATHLEN 1024 +# endif #endif /* MAXPATHLEN */ #ifdef UNION_WAIT -/* Emulate some macros on systems that have a union instead of macros */ - -#ifndef WIFEXITED -#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump) -#endif - -#ifndef WEXITSTATUS -#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1) -#endif - -#ifndef WTERMSIG -#define WTERMSIG(u_wait) ((u_wait).w_termsig) -#endif - -#define WAIT_TYPE union wait -#define WAIT_STATUS_INT(s) (s.w_status) - -#else /* !UNION_WAIT */ -#define WAIT_TYPE int -#define WAIT_STATUS_INT(s) (s) + /* Emulate some macros on systems that have a union instead of macros */ +# ifndef WIFEXITED +# define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump) +# endif +# ifndef WEXITSTATUS +# define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1) +# endif +# ifndef WTERMSIG +# define WTERMSIG(u_wait) ((u_wait).w_termsig) +# endif +# define WAIT_TYPE union wait +# define WAIT_STATUS_INT(s) (s.w_status) +#else + /* !UNION_WAIT */ +# define WAIT_TYPE int +# define WAIT_STATUS_INT(s) (s) #endif /* UNION_WAIT */ /* Don't use the "_r" form if we don't need it (also, won't have a prototype for it, at least on Solaris -- maybe others as well?). */ #if defined(HAVE_CTERMID_R) -#define USE_CTERMID_R +# define USE_CTERMID_R #endif /* choose the appropriate stat and fstat functions and return structs */ @@ -362,56 +356,56 @@ extern char *ctermid_r(char *); #undef FSTAT #undef STRUCT_STAT #ifdef MS_WINDOWS -# define STAT win32_stat -# define LSTAT win32_lstat -# define FSTAT _Py_fstat_noraise -# define STRUCT_STAT struct _Py_stat_struct +# define STAT win32_stat +# define LSTAT win32_lstat +# define FSTAT _Py_fstat_noraise +# define STRUCT_STAT struct _Py_stat_struct #else -# define STAT stat -# define LSTAT lstat -# define FSTAT fstat -# define STRUCT_STAT struct stat +# define STAT stat +# define LSTAT lstat +# define FSTAT fstat +# define STRUCT_STAT struct stat #endif #if defined(MAJOR_IN_MKDEV) -#include +# include #else -#if defined(MAJOR_IN_SYSMACROS) -#include -#endif -#if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H) -#include -#endif +# if defined(MAJOR_IN_SYSMACROS) +# include +# endif +# if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H) +# include +# endif #endif #ifdef MS_WINDOWS -#define INITFUNC PyInit_nt -#define MODNAME "nt" +# define INITFUNC PyInit_nt +# define MODNAME "nt" #else -#define INITFUNC PyInit_posix -#define MODNAME "posix" +# define INITFUNC PyInit_posix +# define MODNAME "posix" #endif #if defined(__sun) /* Something to implement in autoconf, not present in autoconf 2.69 */ -#define HAVE_STRUCT_STAT_ST_FSTYPE 1 +# define HAVE_STRUCT_STAT_ST_FSTYPE 1 #endif /* memfd_create is either defined in sys/mman.h or sys/memfd.h * linux/memfd.h defines additional flags */ #ifdef HAVE_SYS_MMAN_H -#include +# include #endif #ifdef HAVE_SYS_MEMFD_H -#include +# include #endif #ifdef HAVE_LINUX_MEMFD_H -#include +# include #endif #ifdef _Py_MEMORY_SANITIZER -# include +# include #endif #ifdef HAVE_FORK