Fix a whole bunch of #includes that were either wrong or redundant.

The first rule of portability for us is 'thou shalt have no other gods
before c.h', and a whole lot of these files were either not including
c.h at all, or including random system headers beforehand, either of
which sins can mess up largefile support nicely.  Once you have
included c.h, there is no need to re-include what it includes, either.
This commit is contained in:
Tom Lane 2005-07-28 04:03:14 +00:00
parent 420cfd0366
commit 06e1d62689
19 changed files with 44 additions and 57 deletions

View File

@ -43,10 +43,7 @@ __RCSID("$NetBSD: crypt.c,v 1.18 2001/03/01 14:37:35 wiz Exp $");
#include "c.h" #include "c.h"
#include <stddef.h>
#include <sys/types.h>
#include <limits.h> #include <limits.h>
#include <stdlib.h>
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/fseeko.c,v 1.17 2004/12/31 22:03:53 pgsql Exp $ * $PostgreSQL: pgsql/src/port/fseeko.c,v 1.18 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -24,10 +24,8 @@
#ifdef bsdi #ifdef bsdi
#include <pthread.h> #include <pthread.h>
#endif #endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
/* /*
* On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards * On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards

View File

@ -12,7 +12,7 @@
* Copyright (c) 2003-2005, PostgreSQL Global Development Group * Copyright (c) 2003-2005, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.16 2005/01/01 20:44:33 tgl Exp $ * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.17 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -21,7 +21,6 @@
#include "c.h" #include "c.h"
#ifndef WIN32_CLIENT_ONLY #ifndef WIN32_CLIENT_ONLY
#include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>

View File

@ -7,15 +7,13 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/gethostname.c,v 1.6 2004/12/31 22:03:53 pgsql Exp $ * $PostgreSQL: pgsql/src/port/gethostname.c,v 1.7 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "c.h" #include "c.h"
#include <string.h>
#include <sys/utsname.h> #include <sys/utsname.h>
int int

View File

@ -34,14 +34,10 @@
#include "c.h" #include "c.h"
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int opterr = 1, /* if error message should be printed */ int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */ optind = 1, /* index into parent argv vector */

View File

@ -35,19 +35,22 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.3 2003/11/29 19:52:13 pgsql Exp $ * $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.4 2005/07/28 04:03:14 tgl Exp $
*/ */
#include <stdio.h> #include "c.h"
#include <stdlib.h>
#include <string.h>
#include "getopt_long.h" #include "getopt_long.h"
#ifndef HAVE_INT_OPTRESET
int optreset;
#endif
#define BADCH '?' #define BADCH '?'
#define BADARG ':' #define BADARG ':'
#define EMSG "" #define EMSG ""
int int
getopt_long(int argc, char *const argv[], getopt_long(int argc, char *const argv[],
const char *optstring, const char *optstring,

View File

@ -8,15 +8,13 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/getrusage.c,v 1.9 2005/05/16 05:52:13 neilc Exp $ * $PostgreSQL: pgsql/src/port/getrusage.c,v 1.10 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include <stdio.h>
#include <errno.h>
#include "c.h" #include "c.h"
#include "rusagestub.h" #include "rusagestub.h"
/* This code works on: /* This code works on:

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/memcmp.c,v 1.7 2004/12/31 22:03:53 pgsql Exp $ * $PostgreSQL: pgsql/src/port/memcmp.c,v 1.8 2005/07/28 04:03:14 tgl Exp $
* *
* This file was taken from NetBSD and is used by SunOS because memcmp * This file was taken from NetBSD and is used by SunOS because memcmp
* on that platform does not properly compare negative bytes. The * on that platform does not properly compare negative bytes. The
@ -46,7 +46,8 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <string.h> #include "c.h"
/* /*
* Compare memory regions. * Compare memory regions.

View File

@ -7,16 +7,16 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/noblock.c,v 1.6 2005/03/25 00:34:31 tgl Exp $ * $PostgreSQL: pgsql/src/port/noblock.c,v 1.7 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "c.h" #include "c.h"
#include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
bool bool
pg_set_noblock(int sock) pg_set_noblock(int sock)
{ {

View File

@ -6,17 +6,17 @@
* *
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/port/open.c,v 1.9 2005/03/24 04:36:20 momjian Exp $ * $PostgreSQL: pgsql/src/port/open.c,v 1.10 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifdef WIN32 #ifdef WIN32
#include <postgres.h> #include "c.h"
#include <windows.h> #include <windows.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#include <assert.h> #include <assert.h>
int win32_open(const char *fileName, int fileFlags, ...); int win32_open(const char *fileName, int fileFlags, ...);

View File

@ -3,7 +3,7 @@
* Add do ... while() macro fix * Add do ... while() macro fix
* Remove __inline, _DIAGASSERTs, __P * Remove __inline, _DIAGASSERTs, __P
* *
* $PostgreSQL: pgsql/src/port/qsort.c,v 1.6 2005/05/25 21:40:43 momjian Exp $ * $PostgreSQL: pgsql/src/port/qsort.c,v 1.7 2005/07/28 04:03:14 tgl Exp $
*/ */
/* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */ /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */
@ -37,9 +37,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <stdlib.h> #include "c.h"
#include <errno.h>
#include <sys/types.h>
static char *med3(char *, char *, char *, static char *med3(char *, char *, char *,

View File

@ -8,16 +8,15 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/random.c,v 1.5 2004/12/31 22:03:53 pgsql Exp $ * $PostgreSQL: pgsql/src/port/random.c,v 1.6 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "c.h" #include "c.h"
#include <stdlib.h>
#include <math.h> #include <math.h>
#include <errno.h>
long long
random() random()

View File

@ -32,7 +32,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include "postgres.h" #include "c.h"
#ifndef WIN32 #ifndef WIN32
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -62,7 +62,7 @@
* causing nasty effects. * causing nasty effects.
**************************************************************/ **************************************************************/
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.27 2005/04/14 20:53:09 tgl Exp $";*/ /*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.28 2005/07/28 04:03:14 tgl Exp $";*/
static void dopr(char *buffer, const char *format, va_list args, char *end); static void dopr(char *buffer, const char *format, va_list args, char *end);

View File

@ -8,16 +8,15 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/srandom.c,v 1.5 2004/12/31 22:03:53 pgsql Exp $ * $PostgreSQL: pgsql/src/port/srandom.c,v 1.6 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "c.h" #include "c.h"
#include <stdlib.h>
#include <math.h> #include <math.h>
#include <errno.h>
void void
srandom(unsigned int seed) srandom(unsigned int seed)

View File

@ -8,15 +8,16 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/strdup.c,v 1.6 2004/12/31 22:03:53 pgsql Exp $ * $PostgreSQL: pgsql/src/port/strdup.c,v 1.7 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include <string.h> #include "c.h"
#include <stdlib.h>
#include "strdup.h" #include "strdup.h"
char * char *
strdup(char const * string) strdup(char const * string)
{ {

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/port/strerror.c,v 1.4 2005/02/22 04:43:16 momjian Exp $ */ /* $PostgreSQL: pgsql/src/port/strerror.c,v 1.5 2005/07/28 04:03:14 tgl Exp $ */
/* /*
* strerror - map error number to descriptive string * strerror - map error number to descriptive string
@ -9,9 +9,8 @@
* modified for ANSI by D'Arcy J.M. Cain * modified for ANSI by D'Arcy J.M. Cain
*/ */
#include <string.h> #include "c.h"
#include <stdio.h>
#include <errno.h>
extern const char *const sys_errlist[]; extern const char *const sys_errlist[];
extern int sys_nerr; extern int sys_nerr;

View File

@ -36,10 +36,11 @@
static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include "c.h"
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#define const #define const

View File

@ -35,10 +35,11 @@
static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93"; static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include "c.h"
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include <stdlib.h>
/* /*
* Convert a string to an unsigned long integer. * Convert a string to an unsigned long integer.

View File

@ -7,15 +7,13 @@
* *
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/port/thread.c,v 1.29 2004/12/31 22:03:53 pgsql Exp $ * $PostgreSQL: pgsql/src/port/thread.c,v 1.30 2005/07/28 04:03:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "c.h" #include "c.h"
#include <sys/types.h>
#include <errno.h>
#ifdef WIN32_CLIENT_ONLY #ifdef WIN32_CLIENT_ONLY
#undef ERROR #undef ERROR
#else #else
@ -25,6 +23,7 @@
#include <pthread.h> #include <pthread.h>
#endif #endif
/* /*
* Threading sometimes requires specially-named versions of functions * Threading sometimes requires specially-named versions of functions
* that return data in static buffers, like strerror_r() instead of * that return data in static buffers, like strerror_r() instead of