bpo-40268: Reformat posixmodule.c includes (GH-19536)
This commit is contained in:
parent
455df97798
commit
5eca75df03
|
@ -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 <stdio.h> /* needed for ctermid() */
|
||||
|
@ -65,89 +62,89 @@ corresponding Unix manual entries for more information on calls.");
|
|||
|
||||
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
#include <sys/uio.h>
|
||||
# include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SYSMACROS_H
|
||||
/* GNU C Library: major(), minor(), makedev() */
|
||||
#include <sys/sysmacros.h>
|
||||
# include <sys/sysmacros.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
# include <sys/types.h>
|
||||
#endif /* HAVE_SYS_TYPES_H */
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
# include <sys/stat.h>
|
||||
#endif /* HAVE_SYS_STAT_H */
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h> /* For WNOHANG */
|
||||
# include <sys/wait.h> // WNOHANG
|
||||
#endif
|
||||
#ifdef HAVE_LINUX_WAIT_H
|
||||
#include <linux/wait.h> // For P_PIDFD
|
||||
# include <linux/wait.h> // P_PIDFD
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif /* HAVE_FCNTL_H */
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
# include <grp.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSEXITS_H
|
||||
#include <sysexits.h>
|
||||
#endif /* HAVE_SYSEXITS_H */
|
||||
# include <sysexits.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_LOADAVG_H
|
||||
#include <sys/loadavg.h>
|
||||
# include <sys/loadavg.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SENDFILE_H
|
||||
#include <sys/sendfile.h>
|
||||
# include <sys/sendfile.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <copyfile.h>
|
||||
# include <copyfile.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SCHED_H
|
||||
#include <sched.h>
|
||||
# include <sched.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COPY_FILE_RANGE
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#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 <sys/xattr.h>
|
||||
# include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__)
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
# ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifdef __hpux
|
||||
#include <sys/mpctl.h>
|
||||
# include <sys/mpctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(__DragonFly__) || \
|
||||
|
@ -155,7 +152,7 @@ corresponding Unix manual entries for more information on calls.");
|
|||
defined(__FreeBSD__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__APPLE__)
|
||||
#include <sys/sysctl.h>
|
||||
# include <sys/sysctl.h>
|
||||
#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 <process.h>
|
||||
# define HAVE_OPENDIR 1
|
||||
# define HAVE_SYSTEM 1
|
||||
# include <process.h>
|
||||
#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 <vxCpuLib.h>
|
||||
#include <rtpLib.h>
|
||||
#include <wait.h>
|
||||
#include <taskLib.h>
|
||||
#ifndef _P_WAIT
|
||||
#define _P_WAIT 0
|
||||
#define _P_NOWAIT 1
|
||||
#define _P_NOWAITO 1
|
||||
#endif
|
||||
# include <vxCpuLib.h>
|
||||
# include <rtpLib.h>
|
||||
# include <wait.h>
|
||||
# include <taskLib.h>
|
||||
# ifndef _P_WAIT
|
||||
# define _P_WAIT 0
|
||||
# define _P_NOWAIT 1
|
||||
# define _P_NOWAITO 1
|
||||
# endif
|
||||
#endif /* __VXWORKS__ */
|
||||
|
||||
#ifdef HAVE_POSIX_SPAWN
|
||||
#include <spawn.h>
|
||||
# include <spawn.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UTIME_H
|
||||
#include <utime.h>
|
||||
# include <utime.h>
|
||||
#endif /* HAVE_UTIME_H */
|
||||
|
||||
#ifdef HAVE_SYS_UTIME_H
|
||||
#include <sys/utime.h>
|
||||
#define HAVE_UTIME_H /* pretend we do for the rest of this file */
|
||||
# include <sys/utime.h>
|
||||
# define HAVE_UTIME_H /* pretend we do for the rest of this file */
|
||||
#endif /* HAVE_SYS_UTIME_H */
|
||||
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
#include <sys/times.h>
|
||||
# include <sys/times.h>
|
||||
#endif /* HAVE_SYS_TIMES_H */
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
# include <sys/param.h>
|
||||
#endif /* HAVE_SYS_PARAM_H */
|
||||
|
||||
#ifdef HAVE_SYS_UTSNAME_H
|
||||
#include <sys/utsname.h>
|
||||
# include <sys/utsname.h>
|
||||
#endif /* HAVE_SYS_UTSNAME_H */
|
||||
|
||||
#ifdef HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
# include <dirent.h>
|
||||
# define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
#else
|
||||
#if defined(__WATCOMC__) && !defined(__QNX__)
|
||||
#include <direct.h>
|
||||
#define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
#else
|
||||
#define dirent direct
|
||||
#define NAMLEN(dirent) (dirent)->d_namlen
|
||||
#endif
|
||||
#ifdef HAVE_SYS_NDIR_H
|
||||
#include <sys/ndir.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_DIR_H
|
||||
#include <sys/dir.h>
|
||||
#endif
|
||||
#ifdef HAVE_NDIR_H
|
||||
#include <ndir.h>
|
||||
#endif
|
||||
# if defined(__WATCOMC__) && !defined(__QNX__)
|
||||
# include <direct.h>
|
||||
# define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
# else
|
||||
# define dirent direct
|
||||
# define NAMLEN(dirent) (dirent)->d_namlen
|
||||
# endif
|
||||
# ifdef HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# ifdef HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#ifdef HAVE_PROCESS_H
|
||||
#include <process.h>
|
||||
#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 <malloc.h>
|
||||
#include <windows.h>
|
||||
#include <shellapi.h> // ShellExecute()
|
||||
#include <lmcons.h> // UNLEN
|
||||
#define HAVE_SYMLINK
|
||||
# ifdef HAVE_DIRECT_H
|
||||
# include <direct.h>
|
||||
# endif
|
||||
# ifdef HAVE_IO_H
|
||||
# include <io.h>
|
||||
# endif
|
||||
# ifdef HAVE_PROCESS_H
|
||||
# include <process.h>
|
||||
# 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 <malloc.h>
|
||||
# include <windows.h>
|
||||
# include <shellapi.h> // ShellExecute()
|
||||
# include <lmcons.h> // 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 <sys/mkdev.h>
|
||||
# include <sys/mkdev.h>
|
||||
#else
|
||||
#if defined(MAJOR_IN_SYSMACROS)
|
||||
#include <sys/sysmacros.h>
|
||||
#endif
|
||||
#if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H)
|
||||
#include <sys/mkdev.h>
|
||||
#endif
|
||||
# if defined(MAJOR_IN_SYSMACROS)
|
||||
# include <sys/sysmacros.h>
|
||||
# endif
|
||||
# if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H)
|
||||
# include <sys/mkdev.h>
|
||||
# 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 <sys/mman.h>
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_MEMFD_H
|
||||
#include <sys/memfd.h>
|
||||
# include <sys/memfd.h>
|
||||
#endif
|
||||
#ifdef HAVE_LINUX_MEMFD_H
|
||||
#include <linux/memfd.h>
|
||||
# include <linux/memfd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
# include <sanitizer/msan_interface.h>
|
||||
# include <sanitizer/msan_interface.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FORK
|
||||
|
|
Loading…
Reference in New Issue