Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60f42b5

Browse files
committed
Move distributed and duplicated config for stat() and fstat() into pyport.h.
1 parent d2bf3b7 commit 60f42b5

4 files changed

Lines changed: 34 additions & 51 deletions

File tree

Include/pyport.h

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,38 @@ typedef unsigned LONG_LONG Py_uintptr_t;
118118

119119
#endif /* !HAVE_SYS_SELECT_H */
120120

121+
/*******************************
122+
* stat() and fstat() fiddling *
123+
*******************************/
124+
125+
/* We expect that stat and fstat exist on most systems.
126+
* It's confirmed on Unix, Mac and Windows.
127+
* If you don't have them, add
128+
* #define DONT_HAVE_STAT
129+
* and/or
130+
* #define DONT_HAVE_FSTAT
131+
* to your config.h. Python code beyond this should check HAVE_STAT and
132+
* HAVE_FSTAT instead.
133+
* Also
134+
* #define DONT_HAVE_SYS_STAT_H
135+
* if <sys/stat.h> doesn't exist on your platform, and
136+
* #define HAVE_STAT_H
137+
* if <stat.h> does (don't look at me -- ths mess is inherited).
138+
*/
139+
#ifndef DONT_HAVE_STAT
140+
#define HAVE_STAT
141+
#endif
142+
143+
#ifndef DONT_HAVE_FSTAT
144+
#define HAVE_FSTAT
145+
#endif
146+
147+
#ifndef DONT_HAVE_SYS_STAT_H
148+
#include <sys/stat.h>
149+
#elif defined(HAVE_STAT_H)
150+
#include <stat.h>
151+
#endif
152+
121153

122154
#ifdef __cplusplus
123155
/* Move this down here since some C++ #include's don't like to be included
@@ -192,7 +224,7 @@ extern int gethostname(char *, int);
192224
#ifdef __BEOS__
193225
/* Unchecked */
194226
/* It's in the libs, but not the headers... - [cjh] */
195-
int shutdown( int, int );
227+
int shutdown( int, int );
196228
#endif
197229

198230
#ifdef HAVE__GETPTY
@@ -305,7 +337,7 @@ extern double hypot(double, double);
305337
#define sqrt sqrtd
306338
#define tan tand
307339
#define tanh tanhd
308-
#endif
340+
#endif
309341

310342

311343
/************************************

Objects/fileobject.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@
88
#include <sys/types.h>
99
#endif /* DONT_HAVE_SYS_TYPES_H */
1010

11-
/* We expect that fstat exists on most systems.
12-
It's confirmed on Unix, Mac and Windows.
13-
If you don't have it, add #define DONT_HAVE_FSTAT to your config.h. */
14-
#ifndef DONT_HAVE_FSTAT
15-
#define HAVE_FSTAT
16-
17-
#ifndef DONT_HAVE_SYS_TYPES_H
18-
#include <sys/types.h>
19-
#endif
20-
21-
#ifndef DONT_HAVE_SYS_STAT_H
22-
#include <sys/stat.h>
23-
#else
24-
#ifdef HAVE_STAT_H
25-
#include <stat.h>
26-
#endif
27-
#endif
28-
29-
#endif /* DONT_HAVE_FSTAT */
30-
3111
#ifdef HAVE_UNISTD_H
3212
#include <unistd.h>
3313
#endif

Python/getmtime.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66
#include "Python.h"
77
#include "config.h"
88

9-
#include <stdio.h>
10-
#ifndef DONT_HAVE_SYS_TYPES_H
11-
#include <sys/types.h>
12-
#endif
13-
#ifndef DONT_HAVE_SYS_STAT_H
14-
#include <sys/stat.h>
15-
#elif defined(HAVE_STAT_H)
16-
#include <stat.h>
17-
#endif
18-
199
time_t
2010
PyOS_GetLastModificationTime(char *path, FILE *fp)
2111
{

Python/import.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,6 @@
1919
#include <unistd.h>
2020
#endif
2121

22-
/* We expect that stat exists on most systems.
23-
It's confirmed on Unix, Mac and Windows.
24-
If you don't have it, add #define DONT_HAVE_STAT to your config.h. */
25-
#ifndef DONT_HAVE_STAT
26-
#define HAVE_STAT
27-
28-
#ifndef DONT_HAVE_SYS_TYPES_H
29-
#include <sys/types.h>
30-
#endif
31-
32-
#ifndef DONT_HAVE_SYS_STAT_H
33-
#include <sys/stat.h>
34-
#elif defined(HAVE_STAT_H)
35-
#include <stat.h>
36-
#endif
37-
3822
#ifdef HAVE_FCNTL_H
3923
#include <fcntl.h>
4024
#endif
@@ -48,9 +32,6 @@
4832
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
4933
#endif
5034

51-
#endif
52-
53-
5435
extern time_t PyOS_GetLastModificationTime(char *, FILE *);
5536
/* In getmtime.c */
5637

0 commit comments

Comments
 (0)