gh-110014: Include explicitly <unistd.h> header (#110155)

* Remove unused <locale.h> includes.
* Remove unused <fcntl.h> include in traceback.h.
* Remove redundant <assert.h> and <stddef.h> includes. They  are already
  included by "Python.h".
* Remove <object.h> include in faulthandler.c. Python.h already includes it.
* Add missing <stdbool.h> in pycore_pythread.h if HAVE_PTHREAD_STUBS
  is defined.
* Fix also warnings in pthread_stubs.h: don't redefine macros if they
  are already defined, like the __NEED_pthread_t macro.
This commit is contained in:
Victor Stinner 2023-09-30 22:06:45 +02:00 committed by GitHub
parent 0def8c712b
commit 7513994c92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 120 additions and 59 deletions

View file

@ -17,6 +17,11 @@
#include "clinic/bltinmodule.c.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h> // isatty()
#endif
static PyObject*
update_bases(PyObject *bases, PyObject *const *args, Py_ssize_t nargs)
{

View file

@ -4,22 +4,28 @@
#include "pycore_pylifecycle.h" // _PyOS_URandomNonblock()
#include "pycore_runtime.h" // _PyRuntime
#undef HAVE_GETRANDOM
#undef HAVE_GETENTROPY
#ifdef HAVE_UNISTD_H
# include <unistd.h> // close()
#endif
#ifdef MS_WINDOWS
# include <windows.h>
# include <bcrypt.h>
#else
# include <fcntl.h>
# include <fcntl.h> // O_RDONLY
# ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
# endif
# ifdef HAVE_LINUX_RANDOM_H
# include <linux/random.h>
# include <linux/random.h> // GRND_NONBLOCK
# endif
# if defined(HAVE_SYS_RANDOM_H) && (defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY))
# include <sys/random.h>
# include <sys/random.h> // getrandom()
# endif
# if !defined(HAVE_GETRANDOM) && defined(HAVE_GETRANDOM_SYSCALL)
# include <sys/syscall.h>
# include <sys/syscall.h> // SYS_getrandom
# endif
#endif

View file

@ -2,8 +2,11 @@
#include "pycore_fileutils.h" // fileutils definitions
#include "pycore_runtime.h" // _PyRuntime
#include "osdefs.h" // SEP
#include <locale.h>
#include <stdlib.h> // mbstowcs()
#ifdef HAVE_UNISTD_H
# include <unistd.h> // getcwd()
#endif
#ifdef MS_WINDOWS
# include <malloc.h>
@ -19,7 +22,7 @@ extern int winerror_to_errno(int);
#endif
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
# include <langinfo.h> // nl_langinfo(CODESET)
#endif
#ifdef HAVE_SYS_IOCTL_H
@ -27,12 +30,12 @@ extern int winerror_to_errno(int);
#endif
#ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
#include <iconv.h>
# include <iconv.h> // iconv_open()
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
# include <fcntl.h> // fcntl(F_GETFD)
#endif
#ifdef O_CLOEXEC
/* Does open() support the O_CLOEXEC flag? Possible values:

View file

@ -3,7 +3,11 @@
#include "Python.h"
#include "pycore_pystate.h" // _Py_GetConfig()
#include "pycore_runtime.h" // _PyRuntime_Initialize()
#include <locale.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> // isatty()
#endif
#ifdef MS_WINDOWS
extern void PyWinFreeze_ExeInit(void);

View file

@ -37,6 +37,9 @@
#include <locale.h> // setlocale()
#include <stdlib.h> // getenv()
#ifdef HAVE_UNISTD_H
# include <unistd.h> // isatty()
#endif
#if defined(__APPLE__)
# include <mach-o/loader.h>

View file

@ -40,7 +40,9 @@ Data members:
#include "osdefs.h" // DELIM
#include "stdlib_module_names.h" // _Py_stdlib_module_names
#include <locale.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> // getpid()
#endif
#ifdef MS_WINDOWS
# define WIN32_LEAN_AND_MEAN

View file

@ -20,13 +20,14 @@
#include "frameobject.h" // PyFrame_New()
#include "osdefs.h" // SEP
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> // lseek()
#endif
#define OFF(x) offsetof(PyTracebackObject, x)
#define OFF(x) offsetof(PyTracebackObject, x)
#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, (int)strlen(str))
#define MAX_STRING_LENGTH 500
#define MAX_FRAME_DEPTH 100
#define MAX_NTHREADS 100