Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-108765: Move stat() fiddling from pyport.h to fileutils.h #108854

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Include/fileutils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
#ifndef Py_FILEUTILS_H
#define Py_FILEUTILS_H

/*******************************
* stat() and fstat() fiddling *
*******************************/

#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h> // S_ISREG()
#elif defined(HAVE_STAT_H)
# include <stat.h> // S_ISREG()
#endif

#ifndef S_IFMT
// VisualAge C/C++ Failed to Define MountType Field in sys/stat.h.
# define S_IFMT 0170000
#endif
#ifndef S_IFLNK
// Windows doesn't define S_IFLNK, but posixmodule.c maps
// IO_REPARSE_TAG_SYMLINK to S_IFLNK.
# define S_IFLNK 0120000
#endif
#ifndef S_ISREG
# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
#endif
#ifndef S_ISDIR
# define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISCHR
# define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
#endif
#ifndef S_ISLNK
# define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
#endif


// Move this down here since some C++ #include's don't like to be included
// inside an extern "C".
#ifdef __cplusplus
extern "C" {
#endif
Expand Down
37 changes: 0 additions & 37 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,43 +184,6 @@ typedef Py_ssize_t Py_ssize_clean_t;
# define Py_MEMCPY memcpy
#endif

/*******************************
* stat() and fstat() fiddling *
*******************************/

#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#elif defined(HAVE_STAT_H)
#include <stat.h>
#endif

#ifndef S_IFMT
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
#define S_IFMT 0170000
#endif

#ifndef S_IFLNK
/* Windows doesn't define S_IFLNK but posixmodule.c maps
* IO_REPARSE_TAG_SYMLINK to S_IFLNK */
# define S_IFLNK 0120000
#endif

#ifndef S_ISREG
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
#endif

#ifndef S_ISDIR
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
#endif

#ifndef S_ISCHR
#define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
#endif

#ifndef S_ISLNK
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
#endif

#ifdef __cplusplus
/* Move this down here since some C++ #include's don't like to be included
inside an extern "C" */
Expand Down