Skip to content

Commit c2ec174

Browse files
authored
gh-108765: Move stat() fiddling from pyport.h to fileutils.h (#108854)
1 parent 0c369d6 commit c2ec174

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

Include/fileutils.h

+36
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
#ifndef Py_FILEUTILS_H
22
#define Py_FILEUTILS_H
3+
4+
/*******************************
5+
* stat() and fstat() fiddling *
6+
*******************************/
7+
8+
#ifdef HAVE_SYS_STAT_H
9+
# include <sys/stat.h> // S_ISREG()
10+
#elif defined(HAVE_STAT_H)
11+
# include <stat.h> // S_ISREG()
12+
#endif
13+
14+
#ifndef S_IFMT
15+
// VisualAge C/C++ Failed to Define MountType Field in sys/stat.h.
16+
# define S_IFMT 0170000
17+
#endif
18+
#ifndef S_IFLNK
19+
// Windows doesn't define S_IFLNK, but posixmodule.c maps
20+
// IO_REPARSE_TAG_SYMLINK to S_IFLNK.
21+
# define S_IFLNK 0120000
22+
#endif
23+
#ifndef S_ISREG
24+
# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
25+
#endif
26+
#ifndef S_ISDIR
27+
# define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
28+
#endif
29+
#ifndef S_ISCHR
30+
# define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
31+
#endif
32+
#ifndef S_ISLNK
33+
# define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
34+
#endif
35+
36+
37+
// Move this down here since some C++ #include's don't like to be included
38+
// inside an extern "C".
339
#ifdef __cplusplus
440
extern "C" {
541
#endif

Include/pyport.h

-37
Original file line numberDiff line numberDiff line change
@@ -184,43 +184,6 @@ typedef Py_ssize_t Py_ssize_clean_t;
184184
# define Py_MEMCPY memcpy
185185
#endif
186186

187-
/*******************************
188-
* stat() and fstat() fiddling *
189-
*******************************/
190-
191-
#ifdef HAVE_SYS_STAT_H
192-
#include <sys/stat.h>
193-
#elif defined(HAVE_STAT_H)
194-
#include <stat.h>
195-
#endif
196-
197-
#ifndef S_IFMT
198-
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
199-
#define S_IFMT 0170000
200-
#endif
201-
202-
#ifndef S_IFLNK
203-
/* Windows doesn't define S_IFLNK but posixmodule.c maps
204-
* IO_REPARSE_TAG_SYMLINK to S_IFLNK */
205-
# define S_IFLNK 0120000
206-
#endif
207-
208-
#ifndef S_ISREG
209-
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
210-
#endif
211-
212-
#ifndef S_ISDIR
213-
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
214-
#endif
215-
216-
#ifndef S_ISCHR
217-
#define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
218-
#endif
219-
220-
#ifndef S_ISLNK
221-
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
222-
#endif
223-
224187
#ifdef __cplusplus
225188
/* Move this down here since some C++ #include's don't like to be included
226189
inside an extern "C" */

0 commit comments

Comments
 (0)