Skip to content

Commit

Permalink
Fix mmapmodule.c
Browse files Browse the repository at this point in the history
Cleanup also other <unistd.h> includes.
  • Loading branch information
vstinner committed Sep 1, 2023
1 parent dddca41 commit 28c89b0
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 24 deletions.
13 changes: 7 additions & 6 deletions Modules/_ctypes/malloc_closure.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include <Python.h>
#include <ffi.h>
#ifdef MS_WIN32
#include <windows.h>
# include <windows.h>
#else
#include <sys/mman.h>
#include <unistd.h>
# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
# define MAP_ANONYMOUS MAP_ANON
# endif
# include <sys/mman.h>
# include <unistd.h>
# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
# define MAP_ANONYMOUS MAP_ANON
# endif
#endif
#include "ctypes.h"

Expand Down
4 changes: 2 additions & 2 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include "pycore_pystate.h"
#include "pycore_signal.h" // _Py_RestoreSignals()
#if defined(HAVE_PIPE2) && !defined(_GNU_SOURCE)
# define _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <unistd.h>
#include <unistd.h> // close()
#include <fcntl.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down
3 changes: 0 additions & 3 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
#include <float.h> // FLT_MAX
#include <signal.h>
#include <stddef.h> // offsetof()
#ifndef MS_WINDOWS
# include <unistd.h>
#endif

#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h> // W_STOPCODE
Expand Down
4 changes: 3 additions & 1 deletion Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "pycore_fileutils.h" // _Py_stat_struct

#include <stddef.h> // offsetof()
#include <unistd.h> // close()
#ifndef MS_WINDOWS
# include <unistd.h> // close()
#endif

// to support MS_WINDOWS_SYSTEM OpenFileMappingA / CreateFileMappingA
// need to be replaced with OpenFileMappingW / CreateFileMappingW
Expand Down
2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ corresponding Unix manual entries for more information on calls.");
#endif

#ifdef HAVE_COPY_FILE_RANGE
# include <unistd.h>
# include <unistd.h> // copy_file_range()
#endif

#if !defined(CPU_ALLOC) && defined(HAVE_SCHED_SETAFFINITY)
Expand Down
1 change: 0 additions & 1 deletion Modules/pwdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <pwd.h> // getpwuid()
#include <unistd.h> // sysconf()


#include "clinic/pwdmodule.c.h"
/*[clinic input]
module pwd
Expand Down
9 changes: 4 additions & 5 deletions Modules/resource.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

#include "Python.h"
#include <sys/resource.h>
#include <errno.h> // errno
#include <string.h>
#include <sys/resource.h> // getrusage()
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
# include <sys/time.h>
#endif
#include <time.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

/* On some systems, these aren't in any header file.
Expand Down
2 changes: 1 addition & 1 deletion Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ shutdown(how) -- shut down traffic in one or both directions\n\
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
# include <unistd.h>
#include <unistd.h> // close()

/* Headers needed for inet_ntoa() and inet_addr() */
# include <arpa/inet.h>
Expand Down
2 changes: 1 addition & 1 deletion Programs/_freeze_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifndef MS_WINDOWS
#include <unistd.h>
# include <unistd.h>
#endif

uint32_t _Py_next_func_version = 1;
Expand Down
6 changes: 3 additions & 3 deletions Python/dup2.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* Return fd2 if all went well; return BADEXIT otherwise.
*/

#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h> // errno
#include <fcntl.h> // fcntl()
#include <unistd.h> // close()

#define BADEXIT -1

Expand Down

0 comments on commit 28c89b0

Please sign in to comment.