bpo-40268: Reformat posixmodule.c includes (GH-19536)

This commit is contained in:
Victor Stinner 2020-04-15 15:07:31 +02:00 committed by GitHub
parent 455df97798
commit 5eca75df03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 165 additions and 171 deletions

View File

@ -1,4 +1,3 @@
/* POSIX module implementation */ /* POSIX module implementation */
/* This file is also used for Windows NT/MS-Win. In that case the /* 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 of the compiler used. Different compilers define their own feature
test macro, e.g. '_MSC_VER'. */ test macro, e.g. '_MSC_VER'. */
#ifdef __APPLE__ #ifdef __APPLE__
/* /*
* Step 1 of support for weak-linking a number of symbols existing on * 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 /* On android API level 21, 'AT_EACCESS' is not declared although
* HAVE_FACCESSAT is defined. */ * HAVE_FACCESSAT is defined. */
#ifdef __ANDROID__ #ifdef __ANDROID__
#undef HAVE_FACCESSAT # undef HAVE_FACCESSAT
#endif #endif
#include <stdio.h> /* needed for ctermid() */ #include <stdio.h> /* needed for ctermid() */
@ -65,89 +62,89 @@ corresponding Unix manual entries for more information on calls.");
#ifdef HAVE_SYS_UIO_H #ifdef HAVE_SYS_UIO_H
#include <sys/uio.h> # include <sys/uio.h>
#endif #endif
#ifdef HAVE_SYS_SYSMACROS_H #ifdef HAVE_SYS_SYSMACROS_H
/* GNU C Library: major(), minor(), makedev() */ /* GNU C Library: major(), minor(), makedev() */
#include <sys/sysmacros.h> # include <sys/sysmacros.h>
#endif #endif
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> # include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */ #endif /* HAVE_SYS_TYPES_H */
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> # include <sys/stat.h>
#endif /* HAVE_SYS_STAT_H */ #endif /* HAVE_SYS_STAT_H */
#ifdef HAVE_SYS_WAIT_H #ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h> /* For WNOHANG */ # include <sys/wait.h> // WNOHANG
#endif #endif
#ifdef HAVE_LINUX_WAIT_H #ifdef HAVE_LINUX_WAIT_H
#include <linux/wait.h> // For P_PIDFD # include <linux/wait.h> // P_PIDFD
#endif #endif
#ifdef HAVE_SIGNAL_H #ifdef HAVE_SIGNAL_H
#include <signal.h> # include <signal.h>
#endif #endif
#ifdef HAVE_FCNTL_H #ifdef HAVE_FCNTL_H
#include <fcntl.h> # include <fcntl.h>
#endif /* HAVE_FCNTL_H */ #endif
#ifdef HAVE_GRP_H #ifdef HAVE_GRP_H
#include <grp.h> # include <grp.h>
#endif #endif
#ifdef HAVE_SYSEXITS_H #ifdef HAVE_SYSEXITS_H
#include <sysexits.h> # include <sysexits.h>
#endif /* HAVE_SYSEXITS_H */ #endif
#ifdef HAVE_SYS_LOADAVG_H #ifdef HAVE_SYS_LOADAVG_H
#include <sys/loadavg.h> # include <sys/loadavg.h>
#endif #endif
#ifdef HAVE_SYS_SENDFILE_H #ifdef HAVE_SYS_SENDFILE_H
#include <sys/sendfile.h> # include <sys/sendfile.h>
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
#include <copyfile.h> # include <copyfile.h>
#endif #endif
#ifdef HAVE_SCHED_H #ifdef HAVE_SCHED_H
#include <sched.h> # include <sched.h>
#endif #endif
#ifdef HAVE_COPY_FILE_RANGE #ifdef HAVE_COPY_FILE_RANGE
#include <unistd.h> # include <unistd.h>
#endif #endif
#if !defined(CPU_ALLOC) && defined(HAVE_SCHED_SETAFFINITY) #if !defined(CPU_ALLOC) && defined(HAVE_SCHED_SETAFFINITY)
#undef HAVE_SCHED_SETAFFINITY # undef HAVE_SCHED_SETAFFINITY
#endif #endif
#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) #if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
#define USE_XATTRS # define USE_XATTRS
#endif #endif
#ifdef USE_XATTRS #ifdef USE_XATTRS
#include <sys/xattr.h> # include <sys/xattr.h>
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__)
#ifdef HAVE_SYS_SOCKET_H # ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> # include <sys/socket.h>
#endif # endif
#endif #endif
#ifdef HAVE_DLFCN_H #ifdef HAVE_DLFCN_H
#include <dlfcn.h> # include <dlfcn.h>
#endif #endif
#ifdef __hpux #ifdef __hpux
#include <sys/mpctl.h> # include <sys/mpctl.h>
#endif #endif
#if defined(__DragonFly__) || \ #if defined(__DragonFly__) || \
@ -155,7 +152,7 @@ corresponding Unix manual entries for more information on calls.");
defined(__FreeBSD__) || \ defined(__FreeBSD__) || \
defined(__NetBSD__) || \ defined(__NetBSD__) || \
defined(__APPLE__) defined(__APPLE__)
#include <sys/sysctl.h> # include <sys/sysctl.h>
#endif #endif
#ifdef HAVE_LINUX_RANDOM_H #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 */ /* Various compilers have only certain posix functions */
/* XXX Gosh I wish these were all moved into pyconfig.h */ /* XXX Gosh I wish these were all moved into pyconfig.h */
#if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */ #if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */
#define HAVE_OPENDIR 1 # define HAVE_OPENDIR 1
#define HAVE_SYSTEM 1 # define HAVE_SYSTEM 1
#include <process.h> # include <process.h>
#else #else
#ifdef _MSC_VER /* Microsoft compiler */ # ifdef _MSC_VER
#define HAVE_GETPPID 1 /* Microsoft compiler */
#define HAVE_GETLOGIN 1 # define HAVE_GETPPID 1
#define HAVE_SPAWNV 1 # define HAVE_GETLOGIN 1
#define HAVE_EXECV 1 # define HAVE_SPAWNV 1
#define HAVE_WSPAWNV 1 # define HAVE_EXECV 1
#define HAVE_WEXECV 1 # define HAVE_WSPAWNV 1
#define HAVE_PIPE 1 # define HAVE_WEXECV 1
#define HAVE_SYSTEM 1 # define HAVE_PIPE 1
#define HAVE_CWAIT 1 # define HAVE_SYSTEM 1
#define HAVE_FSYNC 1 # define HAVE_CWAIT 1
#define fsync _commit # define HAVE_FSYNC 1
#else # define fsync _commit
/* Unix functions that the configure script doesn't check for */ # else
#ifndef __VXWORKS__ /* Unix functions that the configure script doesn't check for */
#define HAVE_EXECV 1 # ifndef __VXWORKS__
#define HAVE_FORK 1 # define HAVE_EXECV 1
#if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */ # define HAVE_FORK 1
#define HAVE_FORK1 1 # if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */
#endif # define HAVE_FORK1 1
#endif # endif
#define HAVE_GETEGID 1 # endif
#define HAVE_GETEUID 1 # define HAVE_GETEGID 1
#define HAVE_GETGID 1 # define HAVE_GETEUID 1
#define HAVE_GETPPID 1 # define HAVE_GETGID 1
#define HAVE_GETUID 1 # define HAVE_GETPPID 1
#define HAVE_KILL 1 # define HAVE_GETUID 1
#define HAVE_OPENDIR 1 # define HAVE_KILL 1
#define HAVE_PIPE 1 # define HAVE_OPENDIR 1
#define HAVE_SYSTEM 1 # define HAVE_PIPE 1
#define HAVE_WAIT 1 # define HAVE_SYSTEM 1
#define HAVE_TTYNAME 1 # define HAVE_WAIT 1
#endif /* _MSC_VER */ # define HAVE_TTYNAME 1
# endif /* _MSC_VER */
#endif /* ! __WATCOMC__ || __QNX__ */ #endif /* ! __WATCOMC__ || __QNX__ */
_Py_IDENTIFIER(__fspath__); _Py_IDENTIFIER(__fspath__);
@ -238,123 +236,119 @@ extern char *ctermid_r(char *);
#endif /* !_MSC_VER */ #endif /* !_MSC_VER */
#if defined(__VXWORKS__) #if defined(__VXWORKS__)
#include <vxCpuLib.h> # include <vxCpuLib.h>
#include <rtpLib.h> # include <rtpLib.h>
#include <wait.h> # include <wait.h>
#include <taskLib.h> # include <taskLib.h>
#ifndef _P_WAIT # ifndef _P_WAIT
#define _P_WAIT 0 # define _P_WAIT 0
#define _P_NOWAIT 1 # define _P_NOWAIT 1
#define _P_NOWAITO 1 # define _P_NOWAITO 1
#endif # endif
#endif /* __VXWORKS__ */ #endif /* __VXWORKS__ */
#ifdef HAVE_POSIX_SPAWN #ifdef HAVE_POSIX_SPAWN
#include <spawn.h> # include <spawn.h>
#endif #endif
#ifdef HAVE_UTIME_H #ifdef HAVE_UTIME_H
#include <utime.h> # include <utime.h>
#endif /* HAVE_UTIME_H */ #endif /* HAVE_UTIME_H */
#ifdef HAVE_SYS_UTIME_H #ifdef HAVE_SYS_UTIME_H
#include <sys/utime.h> # include <sys/utime.h>
#define HAVE_UTIME_H /* pretend we do for the rest of this file */ # define HAVE_UTIME_H /* pretend we do for the rest of this file */
#endif /* HAVE_SYS_UTIME_H */ #endif /* HAVE_SYS_UTIME_H */
#ifdef HAVE_SYS_TIMES_H #ifdef HAVE_SYS_TIMES_H
#include <sys/times.h> # include <sys/times.h>
#endif /* HAVE_SYS_TIMES_H */ #endif /* HAVE_SYS_TIMES_H */
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> # include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */ #endif /* HAVE_SYS_PARAM_H */
#ifdef HAVE_SYS_UTSNAME_H #ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h> # include <sys/utsname.h>
#endif /* HAVE_SYS_UTSNAME_H */ #endif /* HAVE_SYS_UTSNAME_H */
#ifdef HAVE_DIRENT_H #ifdef HAVE_DIRENT_H
#include <dirent.h> # include <dirent.h>
#define NAMLEN(dirent) strlen((dirent)->d_name) # define NAMLEN(dirent) strlen((dirent)->d_name)
#else #else
#if defined(__WATCOMC__) && !defined(__QNX__) # if defined(__WATCOMC__) && !defined(__QNX__)
#include <direct.h> # include <direct.h>
#define NAMLEN(dirent) strlen((dirent)->d_name) # define NAMLEN(dirent) strlen((dirent)->d_name)
#else # else
#define dirent direct # define dirent direct
#define NAMLEN(dirent) (dirent)->d_namlen # define NAMLEN(dirent) (dirent)->d_namlen
#endif # endif
#ifdef HAVE_SYS_NDIR_H # ifdef HAVE_SYS_NDIR_H
#include <sys/ndir.h> # include <sys/ndir.h>
#endif # endif
#ifdef HAVE_SYS_DIR_H # ifdef HAVE_SYS_DIR_H
#include <sys/dir.h> # include <sys/dir.h>
#endif # endif
#ifdef HAVE_NDIR_H # ifdef HAVE_NDIR_H
#include <ndir.h> # include <ndir.h>
#endif # endif
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#ifdef HAVE_DIRECT_H # ifdef HAVE_DIRECT_H
#include <direct.h> # include <direct.h>
#endif # endif
#ifdef HAVE_IO_H # ifdef HAVE_IO_H
#include <io.h> # include <io.h>
#endif # endif
#ifdef HAVE_PROCESS_H # ifdef HAVE_PROCESS_H
#include <process.h> # include <process.h>
#endif # endif
#ifndef IO_REPARSE_TAG_SYMLINK # ifndef IO_REPARSE_TAG_SYMLINK
#define IO_REPARSE_TAG_SYMLINK (0xA000000CL) # define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
#endif # endif
#ifndef IO_REPARSE_TAG_MOUNT_POINT # ifndef IO_REPARSE_TAG_MOUNT_POINT
#define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) # define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L)
#endif # endif
#include "osdefs.h" // SEP # include "osdefs.h" // SEP
#include <malloc.h> # include <malloc.h>
#include <windows.h> # include <windows.h>
#include <shellapi.h> // ShellExecute() # include <shellapi.h> // ShellExecute()
#include <lmcons.h> // UNLEN # include <lmcons.h> // UNLEN
#define HAVE_SYMLINK # define HAVE_SYMLINK
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#ifndef MAXPATHLEN #ifndef MAXPATHLEN
#if defined(PATH_MAX) && PATH_MAX > 1024 # if defined(PATH_MAX) && PATH_MAX > 1024
#define MAXPATHLEN PATH_MAX # define MAXPATHLEN PATH_MAX
#else # else
#define MAXPATHLEN 1024 # define MAXPATHLEN 1024
#endif # endif
#endif /* MAXPATHLEN */ #endif /* MAXPATHLEN */
#ifdef UNION_WAIT #ifdef UNION_WAIT
/* Emulate some macros on systems that have a union instead of macros */ /* Emulate some macros on systems that have a union instead of macros */
# ifndef WIFEXITED
#ifndef WIFEXITED # define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump)
#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump) # endif
#endif # ifndef WEXITSTATUS
# define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1)
#ifndef WEXITSTATUS # endif
#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1) # ifndef WTERMSIG
#endif # define WTERMSIG(u_wait) ((u_wait).w_termsig)
# endif
#ifndef WTERMSIG # define WAIT_TYPE union wait
#define WTERMSIG(u_wait) ((u_wait).w_termsig) # define WAIT_STATUS_INT(s) (s.w_status)
#endif #else
/* !UNION_WAIT */
#define WAIT_TYPE union wait # define WAIT_TYPE int
#define WAIT_STATUS_INT(s) (s.w_status) # define WAIT_STATUS_INT(s) (s)
#else /* !UNION_WAIT */
#define WAIT_TYPE int
#define WAIT_STATUS_INT(s) (s)
#endif /* UNION_WAIT */ #endif /* UNION_WAIT */
/* Don't use the "_r" form if we don't need it (also, won't have a /* 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?). */ prototype for it, at least on Solaris -- maybe others as well?). */
#if defined(HAVE_CTERMID_R) #if defined(HAVE_CTERMID_R)
#define USE_CTERMID_R # define USE_CTERMID_R
#endif #endif
/* choose the appropriate stat and fstat functions and return structs */ /* choose the appropriate stat and fstat functions and return structs */
@ -362,56 +356,56 @@ extern char *ctermid_r(char *);
#undef FSTAT #undef FSTAT
#undef STRUCT_STAT #undef STRUCT_STAT
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
# define STAT win32_stat # define STAT win32_stat
# define LSTAT win32_lstat # define LSTAT win32_lstat
# define FSTAT _Py_fstat_noraise # define FSTAT _Py_fstat_noraise
# define STRUCT_STAT struct _Py_stat_struct # define STRUCT_STAT struct _Py_stat_struct
#else #else
# define STAT stat # define STAT stat
# define LSTAT lstat # define LSTAT lstat
# define FSTAT fstat # define FSTAT fstat
# define STRUCT_STAT struct stat # define STRUCT_STAT struct stat
#endif #endif
#if defined(MAJOR_IN_MKDEV) #if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h> # include <sys/mkdev.h>
#else #else
#if defined(MAJOR_IN_SYSMACROS) # if defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h> # include <sys/sysmacros.h>
#endif # endif
#if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H) # if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H)
#include <sys/mkdev.h> # include <sys/mkdev.h>
#endif # endif
#endif #endif
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
#define INITFUNC PyInit_nt # define INITFUNC PyInit_nt
#define MODNAME "nt" # define MODNAME "nt"
#else #else
#define INITFUNC PyInit_posix # define INITFUNC PyInit_posix
#define MODNAME "posix" # define MODNAME "posix"
#endif #endif
#if defined(__sun) #if defined(__sun)
/* Something to implement in autoconf, not present in autoconf 2.69 */ /* 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 #endif
/* memfd_create is either defined in sys/mman.h or sys/memfd.h /* memfd_create is either defined in sys/mman.h or sys/memfd.h
* linux/memfd.h defines additional flags * linux/memfd.h defines additional flags
*/ */
#ifdef HAVE_SYS_MMAN_H #ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h> # include <sys/mman.h>
#endif #endif
#ifdef HAVE_SYS_MEMFD_H #ifdef HAVE_SYS_MEMFD_H
#include <sys/memfd.h> # include <sys/memfd.h>
#endif #endif
#ifdef HAVE_LINUX_MEMFD_H #ifdef HAVE_LINUX_MEMFD_H
#include <linux/memfd.h> # include <linux/memfd.h>
#endif #endif
#ifdef _Py_MEMORY_SANITIZER #ifdef _Py_MEMORY_SANITIZER
# include <sanitizer/msan_interface.h> # include <sanitizer/msan_interface.h>
#endif #endif
#ifdef HAVE_FORK #ifdef HAVE_FORK