summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2005-07-28 04:03:14 +0000
committerTom Lane2005-07-28 04:03:14 +0000
commit01e6c66b97958ed88c2f2ad0672d0524250994ef (patch)
treee6efe7693585c223258d32eac06089097052aa20
parent771c57b3419b22eec69d639faf5f582bbdf6e551 (diff)
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.
-rw-r--r--src/port/crypt.c3
-rw-r--r--src/port/fseeko.c4
-rw-r--r--src/port/getaddrinfo.c1
-rw-r--r--src/port/gethostname.c2
-rw-r--r--src/port/getopt.c4
-rw-r--r--src/port/getopt_long.c9
-rw-r--r--src/port/getrusage.c4
-rw-r--r--src/port/memcmp.c3
-rw-r--r--src/port/noblock.c2
-rw-r--r--src/port/open.c4
-rw-r--r--src/port/qsort.c4
-rw-r--r--src/port/random.c3
-rw-r--r--src/port/snprintf.c2
-rw-r--r--src/port/srandom.c3
-rw-r--r--src/port/strdup.c5
-rw-r--r--src/port/strerror.c5
-rw-r--r--src/port/strtol.c5
-rw-r--r--src/port/strtoul.c5
-rw-r--r--src/port/thread.c3
19 files changed, 29 insertions, 42 deletions
diff --git a/src/port/crypt.c b/src/port/crypt.c
index bf68faa3bb..5f47143729 100644
--- a/src/port/crypt.c
+++ b/src/port/crypt.c
@@ -43,10 +43,7 @@ __RCSID("$NetBSD$");
#include "c.h"
-#include <stddef.h>
-#include <sys/types.h>
#include <limits.h>
-#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
diff --git a/src/port/fseeko.c b/src/port/fseeko.c
index ddd184ca3e..6e39c37044 100644
--- a/src/port/fseeko.c
+++ b/src/port/fseeko.c
@@ -24,10 +24,8 @@
#ifdef bsdi
#include <pthread.h>
#endif
-#include <stdio.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <errno.h>
+
/*
* On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards
diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c
index 4c08e75ead..37b410c871 100644
--- a/src/port/getaddrinfo.c
+++ b/src/port/getaddrinfo.c
@@ -21,7 +21,6 @@
#include "c.h"
#ifndef WIN32_CLIENT_ONLY
-#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
diff --git a/src/port/gethostname.c b/src/port/gethostname.c
index fcc5754283..55cf0e1801 100644
--- a/src/port/gethostname.c
+++ b/src/port/gethostname.c
@@ -14,8 +14,6 @@
#include "c.h"
-#include <string.h>
-
#include <sys/utsname.h>
int
diff --git a/src/port/getopt.c b/src/port/getopt.c
index 8451a872aa..48d10fb9ee 100644
--- a/src/port/getopt.c
+++ b/src/port/getopt.c
@@ -34,14 +34,10 @@
#include "c.h"
-
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
diff --git a/src/port/getopt_long.c b/src/port/getopt_long.c
index 950d468acc..08e4d5374a 100644
--- a/src/port/getopt_long.c
+++ b/src/port/getopt_long.c
@@ -38,16 +38,19 @@
* $PostgreSQL$
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "c.h"
#include "getopt_long.h"
+#ifndef HAVE_INT_OPTRESET
+int optreset;
+#endif
+
#define BADCH '?'
#define BADARG ':'
#define EMSG ""
+
int
getopt_long(int argc, char *const argv[],
const char *optstring,
diff --git a/src/port/getrusage.c b/src/port/getrusage.c
index 9819c3b866..fc5b95a5f4 100644
--- a/src/port/getrusage.c
+++ b/src/port/getrusage.c
@@ -13,10 +13,8 @@
*-------------------------------------------------------------------------
*/
-#include <stdio.h>
-#include <errno.h>
-
#include "c.h"
+
#include "rusagestub.h"
/* This code works on:
diff --git a/src/port/memcmp.c b/src/port/memcmp.c
index a61cf5f5c0..487623d3bc 100644
--- a/src/port/memcmp.c
+++ b/src/port/memcmp.c
@@ -46,7 +46,8 @@
* SUCH DAMAGE.
*/
-#include <string.h>
+#include "c.h"
+
/*
* Compare memory regions.
diff --git a/src/port/noblock.c b/src/port/noblock.c
index f51079b287..bbff97bec1 100644
--- a/src/port/noblock.c
+++ b/src/port/noblock.c
@@ -14,9 +14,9 @@
#include "c.h"
-#include <sys/types.h>
#include <fcntl.h>
+
bool
pg_set_noblock(int sock)
{
diff --git a/src/port/open.c b/src/port/open.c
index 6fd9ab1f6f..d293453833 100644
--- a/src/port/open.c
+++ b/src/port/open.c
@@ -13,10 +13,10 @@
#ifdef WIN32
-#include <postgres.h>
+#include "c.h"
+
#include <windows.h>
#include <fcntl.h>
-#include <errno.h>
#include <assert.h>
int win32_open(const char *fileName, int fileFlags, ...);
diff --git a/src/port/qsort.c b/src/port/qsort.c
index 00a92fe4dd..a1d57a506b 100644
--- a/src/port/qsort.c
+++ b/src/port/qsort.c
@@ -37,9 +37,7 @@
* SUCH DAMAGE.
*/
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
+#include "c.h"
static char *med3(char *, char *, char *,
diff --git a/src/port/random.c b/src/port/random.c
index 8c951e4e1e..96c2a3a187 100644
--- a/src/port/random.c
+++ b/src/port/random.c
@@ -15,9 +15,8 @@
#include "c.h"
-#include <stdlib.h>
#include <math.h>
-#include <errno.h>
+
long
random()
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 18f6afab59..b2ebe62956 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*/
-#include "postgres.h"
+#include "c.h"
#ifndef WIN32
#include <sys/ioctl.h>
diff --git a/src/port/srandom.c b/src/port/srandom.c
index ac2f6cbfaa..db8b4c08fd 100644
--- a/src/port/srandom.c
+++ b/src/port/srandom.c
@@ -15,9 +15,8 @@
#include "c.h"
-#include <stdlib.h>
#include <math.h>
-#include <errno.h>
+
void
srandom(unsigned int seed)
diff --git a/src/port/strdup.c b/src/port/strdup.c
index 6c831654af..70a9faf2ee 100644
--- a/src/port/strdup.c
+++ b/src/port/strdup.c
@@ -13,10 +13,11 @@
*-------------------------------------------------------------------------
*/
-#include <string.h>
-#include <stdlib.h>
+#include "c.h"
+
#include "strdup.h"
+
char *
strdup(char const * string)
{
diff --git a/src/port/strerror.c b/src/port/strerror.c
index 2252eef9aa..ffa4cee848 100644
--- a/src/port/strerror.c
+++ b/src/port/strerror.c
@@ -9,9 +9,8 @@
* modified for ANSI by D'Arcy J.M. Cain
*/
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
+#include "c.h"
+
extern const char *const sys_errlist[];
extern int sys_nerr;
diff --git a/src/port/strtol.c b/src/port/strtol.c
index 3e0a92f06f..6bf14c5ff6 100644
--- a/src/port/strtol.c
+++ b/src/port/strtol.c
@@ -36,10 +36,11 @@
static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91";
#endif /* LIBC_SCCS and not lint */
+#include "c.h"
+
#include <limits.h>
#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
+
#define const
diff --git a/src/port/strtoul.c b/src/port/strtoul.c
index 5cb7f7855a..9cfe4fa458 100644
--- a/src/port/strtoul.c
+++ b/src/port/strtoul.c
@@ -35,10 +35,11 @@
static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
+#include "c.h"
+
#include <limits.h>
#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
+
/*
* Convert a string to an unsigned long integer.
diff --git a/src/port/thread.c b/src/port/thread.c
index e725e1fc67..8c535fe207 100644
--- a/src/port/thread.c
+++ b/src/port/thread.c
@@ -14,8 +14,6 @@
#include "c.h"
-#include <sys/types.h>
-#include <errno.h>
#ifdef WIN32_CLIENT_ONLY
#undef ERROR
#else
@@ -25,6 +23,7 @@
#include <pthread.h>
#endif
+
/*
* Threading sometimes requires specially-named versions of functions
* that return data in static buffers, like strerror_r() instead of