From 60f42b50d894d3c9798c50e063ae758a1a5987a2 Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Thu, 18 Jan 2001 03:03:16 +0000 Subject: Move distributed and duplicated config for stat() and fstat() into pyport.h. --- Include/pyport.h | 36 ++++++++++++++++++++++++++++++++++-- Objects/fileobject.c | 20 -------------------- Python/getmtime.c | 10 ---------- Python/import.c | 19 ------------------- 4 files changed, 34 insertions(+), 51 deletions(-) diff --git a/Include/pyport.h b/Include/pyport.h index bf79012..852efb8 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -118,6 +118,38 @@ typedef unsigned LONG_LONG Py_uintptr_t; #endif /* !HAVE_SYS_SELECT_H */ +/******************************* + * stat() and fstat() fiddling * + *******************************/ + +/* We expect that stat and fstat exist on most systems. + * It's confirmed on Unix, Mac and Windows. + * If you don't have them, add + * #define DONT_HAVE_STAT + * and/or + * #define DONT_HAVE_FSTAT + * to your config.h. Python code beyond this should check HAVE_STAT and + * HAVE_FSTAT instead. + * Also + * #define DONT_HAVE_SYS_STAT_H + * if doesn't exist on your platform, and + * #define HAVE_STAT_H + * if does (don't look at me -- ths mess is inherited). + */ +#ifndef DONT_HAVE_STAT +#define HAVE_STAT +#endif + +#ifndef DONT_HAVE_FSTAT +#define HAVE_FSTAT +#endif + +#ifndef DONT_HAVE_SYS_STAT_H +#include +#elif defined(HAVE_STAT_H) +#include +#endif + #ifdef __cplusplus /* Move this down here since some C++ #include's don't like to be included @@ -192,7 +224,7 @@ extern int gethostname(char *, int); #ifdef __BEOS__ /* Unchecked */ /* It's in the libs, but not the headers... - [cjh] */ -int shutdown( int, int ); +int shutdown( int, int ); #endif #ifdef HAVE__GETPTY @@ -305,7 +337,7 @@ extern double hypot(double, double); #define sqrt sqrtd #define tan tand #define tanh tanhd -#endif +#endif /************************************ diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 385d188..7d32879 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -8,26 +8,6 @@ #include #endif /* DONT_HAVE_SYS_TYPES_H */ -/* We expect that fstat exists on most systems. - It's confirmed on Unix, Mac and Windows. - If you don't have it, add #define DONT_HAVE_FSTAT to your config.h. */ -#ifndef DONT_HAVE_FSTAT -#define HAVE_FSTAT - -#ifndef DONT_HAVE_SYS_TYPES_H -#include -#endif - -#ifndef DONT_HAVE_SYS_STAT_H -#include -#else -#ifdef HAVE_STAT_H -#include -#endif -#endif - -#endif /* DONT_HAVE_FSTAT */ - #ifdef HAVE_UNISTD_H #include #endif diff --git a/Python/getmtime.c b/Python/getmtime.c index 4c7ecd6..c77782d 100644 --- a/Python/getmtime.c +++ b/Python/getmtime.c @@ -6,16 +6,6 @@ #include "Python.h" #include "config.h" -#include -#ifndef DONT_HAVE_SYS_TYPES_H -#include -#endif -#ifndef DONT_HAVE_SYS_STAT_H -#include -#elif defined(HAVE_STAT_H) -#include -#endif - time_t PyOS_GetLastModificationTime(char *path, FILE *fp) { diff --git a/Python/import.c b/Python/import.c index a97d0c6..da4015f 100644 --- a/Python/import.c +++ b/Python/import.c @@ -19,22 +19,6 @@ #include #endif -/* We expect that stat exists on most systems. - It's confirmed on Unix, Mac and Windows. - If you don't have it, add #define DONT_HAVE_STAT to your config.h. */ -#ifndef DONT_HAVE_STAT -#define HAVE_STAT - -#ifndef DONT_HAVE_SYS_TYPES_H -#include -#endif - -#ifndef DONT_HAVE_SYS_STAT_H -#include -#elif defined(HAVE_STAT_H) -#include -#endif - #ifdef HAVE_FCNTL_H #include #endif @@ -48,9 +32,6 @@ #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) #endif -#endif - - extern time_t PyOS_GetLastModificationTime(char *, FILE *); /* In getmtime.c */ -- cgit v0.12