Skip to content

Commit b02d3aa

Browse files
committed
Move substitute extern declarations to end of file, so that they are
not read until after we've read the port-specific header file. In particular this should make it safer to #include system headers for inet_aton; in general it seems that the port header file ought to be in a position to set definitions before we do stuff based on having a definition or not.
1 parent 3a4b3ac commit b02d3aa

File tree

1 file changed

+79
-60
lines changed

1 file changed

+79
-60
lines changed

src/include/pg_config.h.in

Lines changed: 79 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
99
* changes will be overwritten the next time you run configure.
1010
*
11-
* $Id: pg_config.h.in,v 1.32 2002/09/05 00:43:07 tgl Exp $
11+
* $Id: pg_config.h.in,v 1.33 2002/11/07 22:08:30 tgl Exp $
1212
*/
1313

1414
#ifndef PG_CONFIG_H
@@ -332,11 +332,6 @@
332332
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
333333
#undef HAVE_FSEEKO
334334

335-
#ifndef HAVE_FSEEKO
336-
#define fseeko(a, b, c) fseek((a), (b), (c))
337-
#define ftello(a) ftell((a))
338-
#endif
339-
340335
/* Define if your cpp understands the ANSI stringizing operators in macros */
341336
#undef HAVE_STRINGIZE
342337

@@ -423,6 +418,7 @@
423418

424419
/* Set to 1 if you have gettimeofday(a) instead of gettimeofday(a,b) */
425420
#undef GETTIMEOFDAY_1ARG
421+
426422
#ifdef GETTIMEOFDAY_1ARG
427423
# define gettimeofday(a,b) gettimeofday(a)
428424
#endif
@@ -444,9 +440,6 @@
444440

445441
/* Set to 1 if you have isinf() */
446442
#undef HAVE_ISINF
447-
#ifndef HAVE_ISINF
448-
extern int isinf(double x);
449-
#endif
450443

451444
/*
452445
* These are all related to port/isinf.c
@@ -459,9 +452,6 @@ extern int isinf(double x);
459452

460453
/* Set to 1 if you have gethostname() */
461454
#undef HAVE_GETHOSTNAME
462-
#ifndef HAVE_GETHOSTNAME
463-
extern int gethostname(char *name, int namelen);
464-
#endif
465455

466456
/* Set to 1 if struct tm has a tm_zone member */
467457
#undef HAVE_TM_ZONE
@@ -479,13 +469,6 @@ extern int gethostname(char *name, int namelen);
479469
/* Set to 1 if you have inet_aton() */
480470
#undef HAVE_INET_ATON
481471

482-
#ifndef HAVE_INET_ATON
483-
# include <sys/types.h>
484-
# include <netinet/in.h>
485-
# include <arpa/inet.h>
486-
extern int inet_aton(const char *cp, struct in_addr * addr);
487-
#endif
488-
489472
/* Set to 1 if you have fcvt() */
490473
#undef HAVE_FCVT
491474

@@ -501,17 +484,6 @@ extern int inet_aton(const char *cp, struct in_addr * addr);
501484
/* Set to 1 if you have sigsetjmp() */
502485
#undef HAVE_SIGSETJMP
503486

504-
/*
505-
* When there is no sigsetjmp, its functionality is provided by plain
506-
* setjmp. Incidentally, nothing provides setjmp's functionality in
507-
* that case.
508-
*/
509-
#ifndef HAVE_SIGSETJMP
510-
# define sigjmp_buf jmp_buf
511-
# define sigsetjmp(x,y) setjmp(x)
512-
# define siglongjmp longjmp
513-
#endif
514-
515487
/* Set to 1 if you have sysconf() */
516488
#undef HAVE_SYSCONF
517489

@@ -529,9 +501,6 @@ extern int inet_aton(const char *cp, struct in_addr * addr);
529501

530502
/* Set to 1 if you have sigprocmask() */
531503
#undef HAVE_STRCASECMP
532-
#ifndef HAVE_STRCASECMP
533-
extern int strcasecmp(char *s1, char *s2);
534-
#endif
535504

536505
/* Set to 1 if you have strtol() */
537506
#undef HAVE_STRTOL
@@ -541,21 +510,12 @@ extern int strcasecmp(char *s1, char *s2);
541510

542511
/* Set to 1 if you have strdup() */
543512
#undef HAVE_STRDUP
544-
#ifndef HAVE_STRDUP
545-
extern char *strdup(char const *);
546-
#endif
547513

548514
/* Set to 1 if you have random() */
549515
#undef HAVE_RANDOM
550-
#ifndef HAVE_RANDOM
551-
extern long random(void);
552-
#endif
553516

554517
/* Set to 1 if you have srandom() */
555518
#undef HAVE_SRANDOM
556-
#ifndef HAVE_SRANDOM
557-
extern void srandom(unsigned int seed);
558-
#endif
559519

560520
/* The random() function is expected to yield values 0 .. MAX_RANDOM_VALUE */
561521
/* Currently, all known implementations yield 0..2^31-1, so we just hardwire
@@ -575,10 +535,6 @@ extern void srandom(unsigned int seed);
575535
/* Define if the standard header unistd.h declares fdatasync() */
576536
#undef HAVE_DECL_FDATASYNC
577537

578-
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
579-
extern int fdatasync(int fildes);
580-
#endif
581-
582538
/* Set to 1 if you have libz.a */
583539
#undef HAVE_LIBZ
584540

@@ -669,24 +625,12 @@ extern int fdatasync(int fildes);
669625
/* Define if you have strtoq() */
670626
#undef HAVE_STRTOQ
671627

672-
/* If strtoq() exists, rename it to the more standard strtoll() */
673-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
674-
# define strtoll strtoq
675-
# define HAVE_STRTOLL 1
676-
#endif
677-
678628
/* Define if you have strtoull() */
679629
#undef HAVE_STRTOULL
680630

681631
/* Define if you have strtouq() */
682632
#undef HAVE_STRTOUQ
683633

684-
/* If strtouq() exists, rename it to the more standard strtoull() */
685-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
686-
# define strtoull strtouq
687-
# define HAVE_STRTOULL 1
688-
#endif
689-
690634
/* Define if you have atexit() */
691635
#undef HAVE_ATEXIT
692636

@@ -727,9 +671,17 @@ extern int fdatasync(int fildes);
727671

728672
#include "pg_config_os.h"
729673

674+
730675
/*
731-
* Provide default definitions for things that port-specific pg_config_os.h
732-
* files can set, but typically don't.
676+
*------------------------------------------------------------------------
677+
* Part 5: provide default declarations for various things that should be
678+
* provided by the system headers or the port-specific pg_config_os.h file,
679+
* but sometimes aren't.
680+
*
681+
* This must be last so that pg_config_os.h can override the defaults.
682+
* In particular, we must not pull in any system header files until we
683+
* have read pg_config_os.h (largefile support tends to break otherwise).
684+
*------------------------------------------------------------------------
733685
*/
734686

735687
#ifndef DLLIMPORT
@@ -749,5 +701,72 @@ extern int fdatasync(int fildes);
749701
#define SIGNAL_ARGS int postgres_signal_arg
750702
#endif
751703

704+
/*
705+
* Default "extern" declarations or macro substitutes for library routines.
706+
* When necessary, these routines are provided by files in src/port/.
707+
*/
708+
#ifndef HAVE_FSEEKO
709+
#define fseeko(a, b, c) fseek((a), (b), (c))
710+
#define ftello(a) ftell((a))
711+
#endif
712+
713+
#ifndef HAVE_ISINF
714+
extern int isinf(double x);
715+
#endif
716+
717+
#ifndef HAVE_GETHOSTNAME
718+
extern int gethostname(char *name, int namelen);
719+
#endif
720+
721+
#ifndef HAVE_INET_ATON
722+
# include <sys/types.h>
723+
# include <netinet/in.h>
724+
# include <arpa/inet.h>
725+
extern int inet_aton(const char *cp, struct in_addr * addr);
726+
#endif
727+
728+
/*
729+
* When there is no sigsetjmp, its functionality is provided by plain
730+
* setjmp. Incidentally, nothing provides setjmp's functionality in
731+
* that case.
732+
*/
733+
#ifndef HAVE_SIGSETJMP
734+
# define sigjmp_buf jmp_buf
735+
# define sigsetjmp(x,y) setjmp(x)
736+
# define siglongjmp longjmp
737+
#endif
738+
739+
#ifndef HAVE_STRCASECMP
740+
extern int strcasecmp(char *s1, char *s2);
741+
#endif
742+
743+
#ifndef HAVE_STRDUP
744+
extern char *strdup(char const *);
745+
#endif
746+
747+
#ifndef HAVE_RANDOM
748+
extern long random(void);
749+
#endif
750+
751+
#ifndef HAVE_SRANDOM
752+
extern void srandom(unsigned int seed);
753+
#endif
754+
755+
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
756+
extern int fdatasync(int fildes);
757+
#endif
758+
759+
/* If strtoq() exists, rename it to the more standard strtoll() */
760+
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
761+
# define strtoll strtoq
762+
# define HAVE_STRTOLL 1
763+
#endif
764+
765+
/* If strtouq() exists, rename it to the more standard strtoull() */
766+
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
767+
# define strtoull strtouq
768+
# define HAVE_STRTOULL 1
769+
#endif
770+
752771

753772
#endif /* PG_CONFIG_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy