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

Skip to content

Commit a3f6e91

Browse files
committed
This patch extends PC/config.h and configure.in as appropriate for
64-bit readiness (the config values are needed for patches that I will be submitting later today. The changes are as follows: - add SIZEOF_OFF_T #define's to PC/config.h (it was already in configure.in) - add SIZEOF_TIME_T #define to PC/config.h and configure Needed for some buffer overflow checking because sizeof(time_t) is different on Win64. - add SIZEOF_FPOS_T #define Needed for the Win64 large file support implementation. - add SIZEOF_HKEY in PC/config.h only Needed for proper Win32 vs. Win64 handling in PC/winreg.c - #define HAVE_LARGEFILE_SUPPORT for Win64 - typedef long intptr_t; for all Windows except Win64 (which defines it itself) This is a new ANSI (I think) type that is useful (and used by me) for proper handling in msvcrtmodule.c and posixmodule.c - indent the nested #ifdef's and #defines in PC/config.h This is *so* much more readable. There cannot be a compiler compatibilty issue here can there? Perl uses indented #defines and it compiles with everything.
1 parent d04038d commit a3f6e91

4 files changed

Lines changed: 61 additions & 10 deletions

File tree

PC/config.h

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,45 @@ typedef int pid_t;
241241

242242
/* End of compilers - finish up */
243243

244+
/* define the ANSI intptr_t type for portable use of a pointer sized
245+
integer */
246+
#include <basetsd.h>
247+
#if defined(MS_WINDOWS) && !defined(MS_WIN64)
248+
typedef long intptr_t;
249+
#endif
250+
244251
#if defined(MS_WIN64)
245252
/* maintain "win32" sys.platform for backward compatibility of Python code,
246253
the Win64 API should be close enough to the Win32 API to make this
247254
preferable */
248-
#define PLATFORM "win32"
249-
#define SIZEOF_VOID_P 8
255+
# define PLATFORM "win32"
256+
# define SIZEOF_VOID_P 8
257+
# define SIZEOF_TIME_T 8
258+
# define SIZEOF_OFF_T 4
259+
# define SIZEOF_FPOS_T 8
260+
# define SIZEOF_HKEY 8
261+
/* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG,
262+
sizeof(off_t) > sizeof(long), and sizeof(LONG_LONG) >= sizeof(off_t).
263+
On Win64 the second condition is not true, but if fpos_t replaces off_t
264+
then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64
265+
should define this. */
266+
# define HAVE_LARGEFILE_SUPPORT
250267
#elif defined(MS_WIN32)
251-
#define PLATFORM "win32"
252-
#ifdef _M_ALPHA
253-
#define SIZEOF_VOID_P 8
254-
#else
255-
#define SIZEOF_VOID_P 4
256-
#endif
268+
# define PLATFORM "win32"
269+
# ifdef _M_ALPHA
270+
# define SIZEOF_VOID_P 8
271+
# define SIZEOF_TIME_T 8
272+
# else
273+
# define SIZEOF_VOID_P 4
274+
# define SIZEOF_TIME_T 4
275+
# define SIZEOF_OFF_T 4
276+
# define SIZEOF_FPOS_T 8
277+
# define SIZEOF_HKEY 4
278+
# endif
257279
#elif defined(MS_WIN16)
258-
#define PLATFORM "win16"
280+
# define PLATFORM "win16"
259281
#else
260-
#define PLATFORM "dos"
282+
# define PLATFORM "dos"
261283
#endif
262284

263285

acconfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@
151151
/* The number of bytes in an off_t. */
152152
#undef SIZEOF_OFF_T
153153

154+
/* The number of bytes in a time_t. */
155+
#undef SIZEOF_TIME_T
156+
154157
/* Defined to enable large file support when an off_t is bigger than a long
155158
and long long is available and at least as big as an off_t. You may need
156159
to add some flags for configuration and compilation to enable this mode.

config.h.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@
213213
/* The number of bytes in an off_t. */
214214
#undef SIZEOF_OFF_T
215215

216+
/* The number of bytes in a time_t. */
217+
#undef SIZEOF_TIME_T
218+
216219
/* Defined to enable large file support when an off_t is bigger than a long
217220
and long long is available and at least as big as an off_t. You may need
218221
to add some flags for configuration and compilation to enable this mode.
@@ -234,6 +237,9 @@
234237
/* The number of bytes in a float. */
235238
#undef SIZEOF_FLOAT
236239

240+
/* The number of bytes in a fpos_t. */
241+
#undef SIZEOF_FPOS_T
242+
237243
/* The number of bytes in a int. */
238244
#undef SIZEOF_INT
239245

@@ -546,6 +552,9 @@
546552
/* Define if you have the <sys/socket.h> header file. */
547553
#undef HAVE_SYS_SOCKET_H
548554

555+
/* Define if you have the <sys/socket.h> header file. */
556+
#undef HAVE_SYS_SOCKET_H
557+
549558
/* Define if you have the <sys/time.h> header file. */
550559
#undef HAVE_SYS_TIME_H
551560

configure.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ AC_CHECK_SIZEOF(char)
389389
AC_CHECK_SIZEOF(short)
390390
AC_CHECK_SIZEOF(float)
391391
AC_CHECK_SIZEOF(double)
392+
AC_CHECK_SIZEOF(fpos_t)
392393

393394
AC_MSG_CHECKING(for long long support)
394395
have_long_long=no
@@ -424,6 +425,22 @@ else
424425
AC_MSG_RESULT(no)
425426
fi
426427

428+
# AC_CHECK_SIZEOF() doesn't include <time.h>.
429+
AC_MSG_CHECKING(size of time_t)
430+
AC_CACHE_VAL(ac_cv_sizeof_time_t,
431+
[AC_TRY_RUN([#include <stdio.h>
432+
#include <time.h>
433+
main()
434+
{
435+
FILE *f=fopen("conftestval", "w");
436+
if (!f) exit(1);
437+
fprintf(f, "%d\n", sizeof(time_t));
438+
exit(0);
439+
}], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
440+
])
441+
AC_MSG_RESULT($ac_cv_sizeof_time_t)
442+
AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
443+
427444

428445
# Minor variations in building a framework between NextStep versions 4 and 5
429446
AC_SUBST(LIBTOOL_CRUFT)

0 commit comments

Comments
 (0)