aboutsummaryrefslogtreecommitdiff
path: root/src/backend/port
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/port')
-rw-r--r--src/backend/port/BSD44_derived/dl.c56
-rw-r--r--src/backend/port/BSD44_derived/port-protos.h26
-rw-r--r--src/backend/port/aix/dlfcn.c393
-rw-r--r--src/backend/port/aix/dlfcn.h37
-rw-r--r--src/backend/port/aix/port-protos.h8
-rw-r--r--src/backend/port/alpha/port-protos.h14
-rw-r--r--src/backend/port/alpha/port.c23
-rw-r--r--src/backend/port/bsdi/dynloader.c123
-rw-r--r--src/backend/port/bsdi/port-protos.h24
-rw-r--r--src/backend/port/dgux/dynloader.c120
-rw-r--r--src/backend/port/dgux/port-protos.h18
-rw-r--r--src/backend/port/dgux/port.c4
-rw-r--r--src/backend/port/hpux/dynloader.c36
-rw-r--r--src/backend/port/hpux/fixade.h63
-rw-r--r--src/backend/port/hpux/port-protos.h20
-rw-r--r--src/backend/port/hpux/port.c32
-rw-r--r--src/backend/port/hpux/rusagestub.h23
-rw-r--r--src/backend/port/i386_solaris/port-protos.h20
-rw-r--r--src/backend/port/i386_solaris/port.c76
-rw-r--r--src/backend/port/i386_solaris/rusagestub.h25
-rw-r--r--src/backend/port/inet_aton.c96
-rw-r--r--src/backend/port/inet_aton.h2
-rw-r--r--src/backend/port/irix5/port-protos.h16
-rw-r--r--src/backend/port/irix5/port.c6
-rw-r--r--src/backend/port/linux/dynloader.c128
-rw-r--r--src/backend/port/linux/port-protos.h32
-rw-r--r--src/backend/port/linux/port.c4
-rw-r--r--src/backend/port/linuxalpha/machine.h4
-rw-r--r--src/backend/port/linuxalpha/port-protos.h16
-rw-r--r--src/backend/port/linuxalpha/port.c4
-rw-r--r--src/backend/port/nextstep/dynloader.c97
-rw-r--r--src/backend/port/nextstep/port-protos.h24
-rw-r--r--src/backend/port/nextstep/port.c75
-rw-r--r--src/backend/port/sco/port-protos.h16
-rw-r--r--src/backend/port/sco/port.c73
-rw-r--r--src/backend/port/sco/rusagestub.h23
-rw-r--r--src/backend/port/sparc_solaris/port-protos.h28
-rw-r--r--src/backend/port/sparc_solaris/port.c81
-rw-r--r--src/backend/port/sparc_solaris/rusagestub.h25
-rw-r--r--src/backend/port/strerror.c27
-rw-r--r--src/backend/port/sunos4/float.h26
-rw-r--r--src/backend/port/sunos4/port-protos.h18
-rw-r--r--src/backend/port/sunos4/strtol.c96
-rw-r--r--src/backend/port/svr4/port-protos.h18
-rw-r--r--src/backend/port/svr4/port.c98
-rw-r--r--src/backend/port/svr4/rusagestub.h23
-rw-r--r--src/backend/port/ultrix4/dl.h143
-rw-r--r--src/backend/port/ultrix4/dynloader.c85
-rw-r--r--src/backend/port/ultrix4/port-protos.h24
-rw-r--r--src/backend/port/ultrix4/port.c8
-rw-r--r--src/backend/port/ultrix4/strdup.c14
-rw-r--r--src/backend/port/univel/frontend-port-protos.h12
-rw-r--r--src/backend/port/univel/port-protos.h22
-rw-r--r--src/backend/port/univel/port.c111
-rw-r--r--src/backend/port/univel/rusagestub.h23
55 files changed, 1421 insertions, 1218 deletions
diff --git a/src/backend/port/BSD44_derived/dl.c b/src/backend/port/BSD44_derived/dl.c
index 0a6525c8ac8..091507204b4 100644
--- a/src/backend/port/BSD44_derived/dl.c
+++ b/src/backend/port/BSD44_derived/dl.c
@@ -6,22 +6,22 @@
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -32,8 +32,9 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
-#endif /* LIBC_SCCS and not lint */
+static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
+
+#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <nlist.h>
@@ -45,52 +46,55 @@ static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
#include "port-protos.h"
-static char error_message[BUFSIZ];
+static char error_message[BUFSIZ];
-char *
+char *
BSD44_derived_dlerror(void)
{
- static char ret[BUFSIZ];
+ static char ret[BUFSIZ];
strcpy(ret, error_message);
error_message[0] = 0;
- return((ret[0] == 0) ? (char *) NULL : ret);
+ return ((ret[0] == 0) ? (char *) NULL : ret);
}
-void *
+void *
BSD44_derived_dlopen(const char *file, int num)
{
#ifdef __mips__
- sprintf(error_message, "dlopen (%s) not supported", file);
+ sprintf(error_message, "dlopen (%s) not supported", file);
return NULL;
#else
- void *vp;
+ void *vp;
- if ((vp = dlopen((char *) file, num)) == (void *) NULL) {
+ if ((vp = dlopen((char *) file, num)) == (void *) NULL)
+ {
sprintf(error_message, "dlopen (%s) failed", file);
}
- return(vp);
+ return (vp);
#endif
}
-void *
+void *
BSD44_derived_dlsym(void *handle, const char *name)
{
#ifdef __mips__
sprintf(error_message, "dlsym (%s) failed", name);
return NULL;
#else
- void *vp;
- char buf[BUFSIZ];
+ void *vp;
+ char buf[BUFSIZ];
- if (*name != '_') {
+ if (*name != '_')
+ {
sprintf(buf, "_%s", name);
name = buf;
}
- if ((vp = dlsym(handle, (char *) name)) == (void *) NULL) {
+ if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
+ {
sprintf(error_message, "dlsym (%s) failed", name);
}
- return(vp);
+ return (vp);
#endif
}
diff --git a/src/backend/port/BSD44_derived/port-protos.h b/src/backend/port/BSD44_derived/port-protos.h
index e1f52bbdd63..2452355d29d 100644
--- a/src/backend/port/BSD44_derived/port-protos.h
+++ b/src/backend/port/BSD44_derived/port-protos.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for NetBSD 1.0
+ * port-specific prototypes for NetBSD 1.0
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.6 1997/03/19 03:56:50 scrappy Exp $
+ * $Id: port-protos.h,v 1.7 1997/09/07 04:45:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,14 +19,14 @@
#include "postgres.h"
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on NetBSD 1.0.
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
@@ -35,14 +35,14 @@
* begin with an underscore is fairly tricky, and some versions of
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
*/
-# define pg_dlopen(f) BSD44_derived_dlopen(f, 1)
-# define pg_dlsym BSD44_derived_dlsym
-# define pg_dlclose BSD44_derived_dlclose
-# define pg_dlerror BSD44_derived_dlerror
+#define pg_dlopen(f) BSD44_derived_dlopen(f, 1)
+#define pg_dlsym BSD44_derived_dlsym
+#define pg_dlclose BSD44_derived_dlclose
+#define pg_dlerror BSD44_derived_dlerror
-char * BSD44_derived_dlerror(void);
-void * BSD44_derived_dlopen(const char *filename, int num);
-void * BSD44_derived_dlsym(void *handle, const char *name);
-void BSD44_derived_dlclose(void *handle);
+char *BSD44_derived_dlerror(void);
+void *BSD44_derived_dlopen(const char *filename, int num);
+void *BSD44_derived_dlsym(void *handle, const char *name);
+void BSD44_derived_dlclose(void *handle);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/aix/dlfcn.c b/src/backend/port/aix/dlfcn.c
index 4e95271e098..58a3dea3c12 100644
--- a/src/backend/port/aix/dlfcn.c
+++ b/src/backend/port/aix/dlfcn.c
@@ -22,33 +22,36 @@
* address.
*/
-typedef struct {
- char *name; /* the symbols's name */
- void *addr; /* its relocated virtual address */
-} Export, *ExportPtr;
+typedef struct
+{
+ char *name; /* the symbols's name */
+ void *addr; /* its relocated virtual address */
+} Export, *ExportPtr;
/*
* xlC uses the following structure to list its constructors and
* destructors. This is gleaned from the output of munch.
*/
-typedef struct {
- void (*init)(void); /* call static constructors */
- void (*term)(void); /* call static destructors */
-} Cdtor, *CdtorPtr;
+typedef struct
+{
+ void (*init) (void); /* call static constructors */
+ void (*term) (void); /* call static destructors */
+} Cdtor, *CdtorPtr;
/*
* The void * handle returned from dlopen is actually a ModulePtr.
*/
-typedef struct Module {
- struct Module *next;
- char *name; /* module name for refcounting */
- int refCnt; /* the number of references */
- void *entry; /* entry point from load */
- struct dl_info *info; /* optional init/terminate functions */
- CdtorPtr cdtors; /* optional C++ constructors */
- int nExports; /* the number of exports found */
- ExportPtr exports; /* the array of exports */
-} Module, *ModulePtr;
+typedef struct Module
+{
+ struct Module *next;
+ char *name; /* module name for refcounting */
+ int refCnt; /* the number of references */
+ void *entry; /* entry point from load */
+ struct dl_info *info; /* optional init/terminate functions */
+ CdtorPtr cdtors; /* optional C++ constructors */
+ int nExports; /* the number of exports found */
+ ExportPtr exports; /* the array of exports */
+} Module, *ModulePtr;
/*
* We keep a list of all loaded modules to be able to call the fini
@@ -60,98 +63,116 @@ static ModulePtr modList;
* The last error from one of the dl* routines is kept in static
* variables here. Each error is returned only once to the caller.
*/
-static char errbuf[BUFSIZ];
-static int errvalid;
+static char errbuf[BUFSIZ];
+static int errvalid;
-extern char *strdup(const char *);
-static void caterr(char *);
-static int readExports(ModulePtr);
-static void terminate(void);
-static void *findMain(void);
+extern char *strdup(const char *);
+static void caterr(char *);
+static int readExports(ModulePtr);
+static void terminate(void);
+static void *findMain(void);
-void *dlopen(const char *path, int mode)
+void *
+dlopen(const char *path, int mode)
{
register ModulePtr mp;
- static void *mainModule;
+ static void *mainModule;
/*
- * Upon the first call register a terminate handler that will
- * close all libraries. Also get a reference to the main module
- * for use with loadbind.
+ * Upon the first call register a terminate handler that will close
+ * all libraries. Also get a reference to the main module for use with
+ * loadbind.
*/
- if (!mainModule) {
+ if (!mainModule)
+ {
if ((mainModule = findMain()) == NULL)
return NULL;
atexit(terminate);
}
+
/*
* Scan the list of modules if we have the module already loaded.
*/
for (mp = modList; mp; mp = mp->next)
- if (strcmp(mp->name, path) == 0) {
+ if (strcmp(mp->name, path) == 0)
+ {
mp->refCnt++;
return mp;
}
- if ((mp = (ModulePtr)calloc(1, sizeof(*mp))) == NULL) {
+ if ((mp = (ModulePtr) calloc(1, sizeof(*mp))) == NULL)
+ {
errvalid++;
strcpy(errbuf, "calloc: ");
strcat(errbuf, strerror(errno));
return NULL;
}
- if ((mp->name = strdup(path)) == NULL) {
+ if ((mp->name = strdup(path)) == NULL)
+ {
errvalid++;
strcpy(errbuf, "strdup: ");
strcat(errbuf, strerror(errno));
free(mp);
return NULL;
}
+
/*
- * load should be declared load(const char *...). Thus we
- * cast the path to a normal char *. Ugly.
+ * load should be declared load(const char *...). Thus we cast the
+ * path to a normal char *. Ugly.
*/
- if ((mp->entry = (void *)load((char *)path, L_NOAUTODEFER, NULL)) == NULL) {
+ if ((mp->entry = (void *) load((char *) path, L_NOAUTODEFER, NULL)) == NULL)
+ {
free(mp->name);
free(mp);
errvalid++;
strcpy(errbuf, "dlopen: ");
strcat(errbuf, path);
strcat(errbuf, ": ");
+
/*
- * If AIX says the file is not executable, the error
- * can be further described by querying the loader about
- * the last error.
+ * If AIX says the file is not executable, the error can be
+ * further described by querying the loader about the last error.
*/
- if (errno == ENOEXEC) {
- char *tmp[BUFSIZ/sizeof(char *)];
+ if (errno == ENOEXEC)
+ {
+ char *tmp[BUFSIZ / sizeof(char *)];
+
if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1)
strcpy(errbuf, strerror(errno));
- else {
- char **p;
+ else
+ {
+ char **p;
+
for (p = tmp; *p; p++)
caterr(*p);
}
- } else
+ }
+ else
strcat(errbuf, strerror(errno));
return NULL;
}
mp->refCnt = 1;
mp->next = modList;
modList = mp;
- if (loadbind(0, mainModule, mp->entry) == -1) {
+ if (loadbind(0, mainModule, mp->entry) == -1)
+ {
dlclose(mp);
errvalid++;
strcpy(errbuf, "loadbind: ");
strcat(errbuf, strerror(errno));
return NULL;
}
+
/*
- * If the user wants global binding, loadbind against all other
- * loaded modules.
+ * If the user wants global binding, loadbind against all other loaded
+ * modules.
*/
- if (mode & RTLD_GLOBAL) {
+ if (mode & RTLD_GLOBAL)
+ {
register ModulePtr mp1;
+
for (mp1 = mp->next; mp1; mp1 = mp1->next)
- if (loadbind(0, mp1->entry, mp->entry) == -1) {
+ if (loadbind(0, mp1->entry, mp->entry) == -1)
+ {
dlclose(mp);
errvalid++;
strcpy(errbuf, "loadbind: ");
@@ -159,28 +180,36 @@ void *dlopen(const char *path, int mode)
return NULL;
}
}
- if (readExports(mp) == -1) {
+ if (readExports(mp) == -1)
+ {
dlclose(mp);
return NULL;
}
+
/*
* If there is a dl_info structure, call the init function.
*/
- if (mp->info = (struct dl_info *)dlsym(mp, "dl_info")) {
+ if (mp->info = (struct dl_info *) dlsym(mp, "dl_info"))
+ {
if (mp->info->init)
- (*mp->info->init)();
- } else
+ (*mp->info->init) ();
+ }
+ else
errvalid = 0;
+
/*
- * If the shared object was compiled using xlC we will need
- * to call static constructors (and later on dlclose destructors).
+ * If the shared object was compiled using xlC we will need to call
+ * static constructors (and later on dlclose destructors).
*/
- if (mp->cdtors = (CdtorPtr)dlsym(mp, "__cdtors")) {
- while (mp->cdtors->init) {
- (*mp->cdtors->init)();
+ if (mp->cdtors = (CdtorPtr) dlsym(mp, "__cdtors"))
+ {
+ while (mp->cdtors->init)
+ {
+ (*mp->cdtors->init) ();
mp->cdtors++;
}
- } else
+ }
+ else
errvalid = 0;
return mp;
}
@@ -189,13 +218,15 @@ void *dlopen(const char *path, int mode)
* Attempt to decipher an AIX loader error message and append it
* to our static error message buffer.
*/
-static void caterr(char *s)
+static void
+caterr(char *s)
{
- register char *p = s;
+ register char *p = s;
while (*p >= '0' && *p <= '9')
p++;
- switch(atoi(s)) {
+ switch (atoi(s))
+ {
case L_ERROR_TOOMANY:
strcat(errbuf, "to many errors");
break;
@@ -224,15 +255,16 @@ static void caterr(char *s)
}
}
-void *dlsym(void *handle, const char *symbol)
+void *
+dlsym(void *handle, const char *symbol)
{
- register ModulePtr mp = (ModulePtr)handle;
+ register ModulePtr mp = (ModulePtr) handle;
register ExportPtr ep;
- register int i;
+ register int i;
/*
- * Could speed up the search, but I assume that one assigns
- * the result to function pointers anyways.
+ * Could speed up the search, but I assume that one assigns the result
+ * to function pointers anyways.
*/
for (ep = mp->exports, i = mp->nExports; i; i--, ep++)
if (strcmp(ep->name, symbol) == 0)
@@ -243,38 +275,45 @@ void *dlsym(void *handle, const char *symbol)
return NULL;
}
-char *dlerror(void)
+char *
+dlerror(void)
{
- if (errvalid) {
+ if (errvalid)
+ {
errvalid = 0;
return errbuf;
}
return NULL;
}
-int dlclose(void *handle)
+int
+dlclose(void *handle)
{
- register ModulePtr mp = (ModulePtr)handle;
- int result;
+ register ModulePtr mp = (ModulePtr) handle;
+ int result;
register ModulePtr mp1;
if (--mp->refCnt > 0)
return 0;
if (mp->info && mp->info->fini)
- (*mp->info->fini)();
+ (*mp->info->fini) ();
if (mp->cdtors)
- while (mp->cdtors->term) {
- (*mp->cdtors->term)();
+ while (mp->cdtors->term)
+ {
+ (*mp->cdtors->term) ();
mp->cdtors++;
}
result = unload(mp->entry);
- if (result == -1) {
+ if (result == -1)
+ {
errvalid++;
strcpy(errbuf, strerror(errno));
}
- if (mp->exports) {
+ if (mp->exports)
+ {
register ExportPtr ep;
- register int i;
+ register int i;
+
for (ep = mp->exports, i = mp->nExports; i; i--, ep++)
if (ep->name)
free(ep->name);
@@ -282,9 +321,11 @@ int dlclose(void *handle)
}
if (mp == modList)
modList = mp->next;
- else {
+ else
+ {
for (mp1 = modList; mp1; mp1 = mp1->next)
- if (mp1->next == mp) {
+ if (mp1->next == mp)
+ {
mp1->next = mp->next;
break;
}
@@ -294,7 +335,8 @@ int dlclose(void *handle)
return result;
}
-static void terminate(void)
+static void
+terminate(void)
{
while (modList)
dlclose(modList);
@@ -303,180 +345,208 @@ static void terminate(void)
/*
* Build the export table from the XCOFF .loader section.
*/
-static int readExports(ModulePtr mp)
+static int
+readExports(ModulePtr mp)
{
- LDFILE *ldp = NULL;
- SCNHDR sh, shdata;
- LDHDR *lhp;
- char *ldbuf;
- LDSYM *ls;
- int i;
- ExportPtr ep;
-
- if ((ldp = ldopen(mp->name, ldp)) == NULL) {
+ LDFILE *ldp = NULL;
+ SCNHDR sh,
+ shdata;
+ LDHDR *lhp;
+ char *ldbuf;
+ LDSYM *ls;
+ int i;
+ ExportPtr ep;
+
+ if ((ldp = ldopen(mp->name, ldp)) == NULL)
+ {
struct ld_info *lp;
- char *buf;
- int size = 4*1024;
- if (errno != ENOENT) {
+ char *buf;
+ int size = 4 * 1024;
+
+ if (errno != ENOENT)
+ {
errvalid++;
strcpy(errbuf, "readExports: ");
strcat(errbuf, strerror(errno));
return -1;
}
+
/*
- * The module might be loaded due to the LIBPATH
- * environment variable. Search for the loaded
- * module using L_GETINFO.
+ * The module might be loaded due to the LIBPATH environment
+ * variable. Search for the loaded module using L_GETINFO.
*/
- if ((buf = malloc(size)) == NULL) {
+ if ((buf = malloc(size)) == NULL)
+ {
errvalid++;
strcpy(errbuf, "readExports: ");
strcat(errbuf, strerror(errno));
return -1;
}
- while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
+ while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM)
+ {
free(buf);
- size += 4*1024;
- if ((buf = malloc(size)) == NULL) {
+ size += 4 * 1024;
+ if ((buf = malloc(size)) == NULL)
+ {
errvalid++;
strcpy(errbuf, "readExports: ");
strcat(errbuf, strerror(errno));
return -1;
}
}
- if (i == -1) {
+ if (i == -1)
+ {
errvalid++;
strcpy(errbuf, "readExports: ");
strcat(errbuf, strerror(errno));
free(buf);
return -1;
}
+
/*
- * Traverse the list of loaded modules. The entry point
- * returned by load() does actually point to the data
- * segment origin.
+ * Traverse the list of loaded modules. The entry point returned
+ * by load() does actually point to the data segment origin.
*/
- lp = (struct ld_info *)buf;
- while (lp) {
- if (lp->ldinfo_dataorg == mp->entry) {
+ lp = (struct ld_info *) buf;
+ while (lp)
+ {
+ if (lp->ldinfo_dataorg == mp->entry)
+ {
ldp = ldopen(lp->ldinfo_filename, ldp);
break;
}
if (lp->ldinfo_next == 0)
lp = NULL;
else
- lp = (struct ld_info *)((char *)lp + lp->ldinfo_next);
+ lp = (struct ld_info *) ((char *) lp + lp->ldinfo_next);
}
free(buf);
- if (!ldp) {
+ if (!ldp)
+ {
errvalid++;
strcpy(errbuf, "readExports: ");
strcat(errbuf, strerror(errno));
return -1;
}
}
- if (TYPE(ldp) != U802TOCMAGIC) {
+ if (TYPE(ldp) != U802TOCMAGIC)
+ {
errvalid++;
strcpy(errbuf, "readExports: bad magic");
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return -1;
}
+
/*
- * Get the padding for the data section. This is needed for
- * AIX 4.1 compilers. This is used when building the final
- * function pointer to the exported symbol.
+ * Get the padding for the data section. This is needed for AIX 4.1
+ * compilers. This is used when building the final function pointer to
+ * the exported symbol.
*/
- if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) {
+ if (ldnshread(ldp, _DATA, &shdata) != SUCCESS)
+ {
errvalid++;
strcpy(errbuf, "readExports: cannot read data section header");
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return -1;
}
- if (ldnshread(ldp, _LOADER, &sh) != SUCCESS) {
+ if (ldnshread(ldp, _LOADER, &sh) != SUCCESS)
+ {
errvalid++;
strcpy(errbuf, "readExports: cannot read loader section header");
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return -1;
}
+
/*
* We read the complete loader section in one chunk, this makes
* finding long symbol names residing in the string table easier.
*/
- if ((ldbuf = (char *)malloc(sh.s_size)) == NULL) {
+ if ((ldbuf = (char *) malloc(sh.s_size)) == NULL)
+ {
errvalid++;
strcpy(errbuf, "readExports: ");
strcat(errbuf, strerror(errno));
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return -1;
}
- if (FSEEK(ldp, sh.s_scnptr, BEGINNING) != OKFSEEK) {
+ if (FSEEK(ldp, sh.s_scnptr, BEGINNING) != OKFSEEK)
+ {
errvalid++;
strcpy(errbuf, "readExports: cannot seek to loader section");
free(ldbuf);
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return -1;
}
- if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1) {
+ if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1)
+ {
errvalid++;
strcpy(errbuf, "readExports: cannot read loader section");
free(ldbuf);
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return -1;
}
- lhp = (LDHDR *)ldbuf;
- ls = (LDSYM *)(ldbuf+LDHDRSZ);
+ lhp = (LDHDR *) ldbuf;
+ ls = (LDSYM *) (ldbuf + LDHDRSZ);
+
/*
* Count the number of exports to include in our export table.
*/
- for (i = lhp->l_nsyms; i; i--, ls++) {
+ for (i = lhp->l_nsyms; i; i--, ls++)
+ {
if (!LDR_EXPORT(*ls))
continue;
mp->nExports++;
}
- if ((mp->exports = (ExportPtr)calloc(mp->nExports, sizeof(*mp->exports))) == NULL) {
+ if ((mp->exports = (ExportPtr) calloc(mp->nExports, sizeof(*mp->exports))) == NULL)
+ {
errvalid++;
strcpy(errbuf, "readExports: ");
strcat(errbuf, strerror(errno));
free(ldbuf);
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return -1;
}
+
/*
- * Fill in the export table. All entries are relative to
- * the entry point we got from load.
+ * Fill in the export table. All entries are relative to the entry
+ * point we got from load.
*/
ep = mp->exports;
- ls = (LDSYM *)(ldbuf+LDHDRSZ);
- for (i = lhp->l_nsyms; i; i--, ls++) {
- char *symname;
- char tmpsym[SYMNMLEN+1];
+ ls = (LDSYM *) (ldbuf + LDHDRSZ);
+ for (i = lhp->l_nsyms; i; i--, ls++)
+ {
+ char *symname;
+ char tmpsym[SYMNMLEN + 1];
+
if (!LDR_EXPORT(*ls))
continue;
if (ls->l_zeroes == 0)
- symname = ls->l_offset+lhp->l_stoff+ldbuf;
- else {
+ symname = ls->l_offset + lhp->l_stoff + ldbuf;
+ else
+ {
+
/*
- * The l_name member is not zero terminated, we
- * must copy the first SYMNMLEN chars and make
- * sure we have a zero byte at the end.
+ * The l_name member is not zero terminated, we must copy the
+ * first SYMNMLEN chars and make sure we have a zero byte at
+ * the end.
*/
strNcpy(tmpsym, ls->l_name, SYMNMLEN);
symname = tmpsym;
}
ep->name = strdup(symname);
- ep->addr = (void *)((unsigned long)mp->entry +
- ls->l_value - shdata.s_vaddr);
+ ep->addr = (void *) ((unsigned long) mp->entry +
+ ls->l_value - shdata.s_vaddr);
ep++;
}
free(ldbuf);
- while(ldclose(ldp) == FAILURE)
+ while (ldclose(ldp) == FAILURE)
;
return 0;
}
@@ -485,43 +555,48 @@ static int readExports(ModulePtr mp)
* Find the main modules entry point. This is used as export pointer
* for loadbind() to be able to resolve references to the main part.
*/
-static void * findMain(void)
+static void *
+findMain(void)
{
struct ld_info *lp;
- char *buf;
- int size = 4*1024;
- int i;
- void *ret;
+ char *buf;
+ int size = 4 * 1024;
+ int i;
+ void *ret;
- if ((buf = malloc(size)) == NULL) {
+ if ((buf = malloc(size)) == NULL)
+ {
errvalid++;
strcpy(errbuf, "findMain: ");
strcat(errbuf, strerror(errno));
return NULL;
}
- while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
+ while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM)
+ {
free(buf);
- size += 4*1024;
- if ((buf = malloc(size)) == NULL) {
+ size += 4 * 1024;
+ if ((buf = malloc(size)) == NULL)
+ {
errvalid++;
strcpy(errbuf, "findMain: ");
strcat(errbuf, strerror(errno));
return NULL;
}
}
- if (i == -1) {
+ if (i == -1)
+ {
errvalid++;
strcpy(errbuf, "findMain: ");
strcat(errbuf, strerror(errno));
free(buf);
return NULL;
}
+
/*
- * The first entry is the main module. The entry point
- * returned by load() does actually point to the data
- * segment origin.
+ * The first entry is the main module. The entry point returned by
+ * load() does actually point to the data segment origin.
*/
- lp = (struct ld_info *)buf;
+ lp = (struct ld_info *) buf;
ret = lp->ldinfo_dataorg;
free(buf);
return ret;
diff --git a/src/backend/port/aix/dlfcn.h b/src/backend/port/aix/dlfcn.h
index 5671e9caa3a..1e874d96559 100644
--- a/src/backend/port/aix/dlfcn.h
+++ b/src/backend/port/aix/dlfcn.h
@@ -8,39 +8,42 @@
#define __dlfcn_h__
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
/*
* Mode flags for the dlopen routine.
*/
-#define RTLD_LAZY 1 /* lazy function call binding */
-#define RTLD_NOW 2 /* immediate function call binding */
-#define RTLD_GLOBAL 0x100 /* allow symbols to be global */
+#define RTLD_LAZY 1 /* lazy function call binding */
+#define RTLD_NOW 2 /* immediate function call binding */
+#define RTLD_GLOBAL 0x100 /* allow symbols to be global */
/*
* To be able to intialize, a library may provide a dl_info structure
* that contains functions to be called to initialize and terminate.
*/
-struct dl_info {
- void (*init)(void);
- void (*fini)(void);
-};
+ struct dl_info
+ {
+ void (*init) (void);
+ void (*fini) (void);
+ };
#if __STDC__ || defined(_IBMR2)
-void *dlopen(const char *path, int mode);
-void *dlsym(void *handle, const char *symbol);
-char *dlerror(void);
-int dlclose(void *handle);
+ void *dlopen(const char *path, int mode);
+ void *dlsym(void *handle, const char *symbol);
+ char *dlerror(void);
+ int dlclose(void *handle);
#else
-void *dlopen();
-void *dlsym();
-char *dlerror();
-int dlclose();
+ void *dlopen();
+ void *dlsym();
+ char *dlerror();
+ int dlclose();
#endif
#ifdef __cplusplus
}
+
#endif
-#endif /* __dlfcn_h__ */
+#endif /* __dlfcn_h__ */
diff --git a/src/backend/port/aix/port-protos.h b/src/backend/port/aix/port-protos.h
index 986e5bd7d48..6429dc26c04 100644
--- a/src/backend/port/aix/port-protos.h
+++ b/src/backend/port/aix/port-protos.h
@@ -1,19 +1,19 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for AIX
+ * port-specific prototypes for AIX
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:41 scrappy Exp $
+ * $Id: port-protos.h,v 1.2 1997/09/07 04:45:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-#include "dlfcn.h" /* this is from jum's libdl package */
+#include "dlfcn.h" /* this is from jum's libdl package */
/* dynloader.c */
@@ -22,4 +22,4 @@
#define pg_dlclose(h) dlclose(h)
#define pg_dlerror() dlerror()
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/alpha/port-protos.h b/src/backend/port/alpha/port-protos.h
index 3bd8d454a5e..3b5cb47adea 100644
--- a/src/backend/port/alpha/port-protos.h
+++ b/src/backend/port/alpha/port-protos.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * prototypes for OSF/1-specific routines
+ * prototypes for OSF/1-specific routines
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $
+ * $Id: port-protos.h,v 1.2 1997/09/07 04:45:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,18 +22,18 @@
/*
* Dynamic Loader on Alpha OSF/1.x
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
#define pg_dlopen(f) dlopen(f, RTLD_LAZY)
-#define pg_dlsym(h, f) ((func_ptr)dlsym(h, f))
-#define pg_dlclose(h) dlclose(h)
+#define pg_dlsym(h, f) ((func_ptr)dlsym(h, f))
+#define pg_dlclose(h) dlclose(h)
#define pg_dlerror() dlerror()
/* port.c */
-extern void init_address_fixup(void);
+extern void init_address_fixup(void);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/alpha/port.c b/src/backend/port/alpha/port.c
index d7c17b0a5ba..80b03088a43 100644
--- a/src/backend/port/alpha/port.c
+++ b/src/backend/port/alpha/port.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * OSF/1-specific routines
+ * OSF/1-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/alpha/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:42 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/alpha/Attic/port.c,v 1.2 1997/09/07 04:45:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,14 +21,17 @@ void
init_address_fixup()
{
#ifdef NOFIXADE
- int buffer[] = { SSIN_UACPROC, UAC_SIGBUS };
-#endif /* NOFIXADE */
+ int buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
+
+#endif /* NOFIXADE */
#ifdef NOPRINTADE
- int buffer[] = { SSIN_UACPROC, UAC_NOPRINT };
-#endif /* NOPRINTADE */
+ int buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
+
+#endif /* NOPRINTADE */
- if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
- (unsigned long) NULL) < 0) {
- elog(NOTICE, "setsysinfo failed: %d\n", errno);
- }
+ if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
+ (unsigned long) NULL) < 0)
+ {
+ elog(NOTICE, "setsysinfo failed: %d\n", errno);
+ }
}
diff --git a/src/backend/port/bsdi/dynloader.c b/src/backend/port/bsdi/dynloader.c
index f9b2180f03a..cfaeec0c200 100644
--- a/src/backend/port/bsdi/dynloader.c
+++ b/src/backend/port/bsdi/dynloader.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
*
* dynloader.c--
- * Dynamic Loader for Postgres for Linux, generated from those for
- * Ultrix.
+ * Dynamic Loader for Postgres for Linux, generated from those for
+ * Ultrix.
*
- * You need to install the dld library on your Linux system!
+ * You need to install the dld library on your Linux system!
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * /usr/local/devel/pglite/cvs/src/backend/port/linux/dynloader.c,v 1.1.1.1 1994/11/07 05:19:37 andrew Exp
+ * /usr/local/devel/pglite/cvs/src/backend/port/linux/dynloader.c,v 1.1.1.1 1994/11/07 05:19:37 andrew Exp
*
*-------------------------------------------------------------------------
*/
@@ -22,74 +22,85 @@
#include "utils/elog.h"
#include "fmgr.h"
-extern char pg_pathname[];
+extern char pg_pathname[];
-void *
+void *
pg_dlopen(char *filename)
{
- static int dl_initialized= 0;
+ static int dl_initialized = 0;
- /*
- * initializes the dynamic loader with the executable's pathname.
- * (only needs to do this the first time pg_dlopen is called.)
- */
- if (!dl_initialized) {
- if (dld_init (dld_find_executable (pg_pathname))) {
- return NULL;
- }
/*
- * if there are undefined symbols, we want dl to search from the
- * following libraries also.
+ * initializes the dynamic loader with the executable's pathname.
+ * (only needs to do this the first time pg_dlopen is called.)
*/
- dl_initialized= 1;
- }
-
- /*
- * link the file, then check for undefined symbols!
- */
- if (dld_link(filename)) {
- return NULL;
- }
+ if (!dl_initialized)
+ {
+ if (dld_init(dld_find_executable(pg_pathname)))
+ {
+ return NULL;
+ }
- /*
- * If undefined symbols: try to link with the C and math libraries!
- * This could be smarter, if the dynamic linker was able to handle
- * shared libs!
- */
- if(dld_undefined_sym_count > 0) {
- if (dld_link("/usr/lib/libc.a")) {
- elog(NOTICE, "dld: Cannot link C library!");
- return NULL;
+ /*
+ * if there are undefined symbols, we want dl to search from the
+ * following libraries also.
+ */
+ dl_initialized = 1;
}
- if(dld_undefined_sym_count > 0) {
- if (dld_link("/usr/lib/libm.a")) {
- elog(NOTICE, "dld: Cannot link math library!");
+
+ /*
+ * link the file, then check for undefined symbols!
+ */
+ if (dld_link(filename))
+ {
return NULL;
- }
- if(dld_undefined_sym_count > 0) {
- int count = dld_undefined_sym_count;
- char **list= dld_list_undefined_sym();
+ }
- /* list the undefined symbols, if any */
- elog(NOTICE, "dld: Undefined:");
- do {
- elog(NOTICE, " %s", *list);
- list++;
- count--;
- } while(count > 0);
+ /*
+ * If undefined symbols: try to link with the C and math libraries!
+ * This could be smarter, if the dynamic linker was able to handle
+ * shared libs!
+ */
+ if (dld_undefined_sym_count > 0)
+ {
+ if (dld_link("/usr/lib/libc.a"))
+ {
+ elog(NOTICE, "dld: Cannot link C library!");
+ return NULL;
+ }
+ if (dld_undefined_sym_count > 0)
+ {
+ if (dld_link("/usr/lib/libm.a"))
+ {
+ elog(NOTICE, "dld: Cannot link math library!");
+ return NULL;
+ }
+ if (dld_undefined_sym_count > 0)
+ {
+ int count = dld_undefined_sym_count;
+ char **list = dld_list_undefined_sym();
- dld_unlink_by_file(filename, 1);
- return NULL;
- }
+ /* list the undefined symbols, if any */
+ elog(NOTICE, "dld: Undefined:");
+ do
+ {
+ elog(NOTICE, " %s", *list);
+ list++;
+ count--;
+ } while (count > 0);
+
+ dld_unlink_by_file(filename, 1);
+ return NULL;
+ }
+ }
}
- }
- return (void *) strdup(filename);
+ return (void *) strdup(filename);
}
-char *
+char *
pg_dlerror()
{
- return dld_strerror(dld_errno);
+ return dld_strerror(dld_errno);
}
+
#endif
diff --git a/src/backend/port/bsdi/port-protos.h b/src/backend/port/bsdi/port-protos.h
index 9d21bb15115..acd0e85a49b 100644
--- a/src/backend/port/bsdi/port-protos.h
+++ b/src/backend/port/bsdi/port-protos.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SunOS 4
+ * port-specific prototypes for SunOS 4
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -17,26 +17,26 @@
* Externals in libc that need prototypes (or at least declarations)
*/
-extern char *ecvt(double, int, int*, int*);
-extern char *fcvt(double, int, int*, int*);
+extern char *ecvt(double, int, int *, int *);
+extern char *fcvt(double, int, int *, int *);
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
#ifndef PRE_BSDI_2_1
-# include <dlfcn.h>
-# define pg_dlopen(f) dlopen(f, 1)
-# define pg_dlsym dlsym
-# define pg_dlclose dlclose
-# define pg_dlerror dlerror
+#include <dlfcn.h>
+#define pg_dlopen(f) dlopen(f, 1)
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
#else
-# define pg_dlsym(handle, funcname) ((func_ptr) dld_get_func((funcname)))
-# define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
+#define pg_dlsym(handle, funcname) ((func_ptr) dld_get_func((funcname)))
+#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
#endif
/* port.c */
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/dgux/dynloader.c b/src/backend/port/dgux/dynloader.c
index 7ec648fb44b..0f7d38bc092 100644
--- a/src/backend/port/dgux/dynloader.c
+++ b/src/backend/port/dgux/dynloader.c
@@ -1,14 +1,14 @@
/*-------------------------------------------------------------------------
*
* dynloader.c--
- * Dynamic Loader for Postgres for DG/UX, generated from those for
- * Linux.
+ * Dynamic Loader for Postgres for DG/UX, generated from those for
+ * Linux.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/dynloader.c,v 1.1 1996/07/25 20:43:58 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/dynloader.c,v 1.2 1997/09/07 04:45:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,73 +19,83 @@
#include "utils/elog.h"
#include "fmgr.h"
-extern char pg_pathname[];
+extern char pg_pathname[];
-void *
+void *
pg_dlopen(char *filename)
{
- static int dl_initialized= 0;
+ static int dl_initialized = 0;
- /*
- * initializes the dynamic loader with the executable's pathname.
- * (only needs to do this the first time pg_dlopen is called.)
- */
- if (!dl_initialized) {
- if (dld_init (dld_find_executable (pg_pathname))) {
- return NULL;
- }
/*
- * if there are undefined symbols, we want dl to search from the
- * following libraries also.
+ * initializes the dynamic loader with the executable's pathname.
+ * (only needs to do this the first time pg_dlopen is called.)
*/
- dl_initialized= 1;
- }
-
- /*
- * link the file, then check for undefined symbols!
- */
- if (dld_link(filename)) {
- return NULL;
- }
+ if (!dl_initialized)
+ {
+ if (dld_init(dld_find_executable(pg_pathname)))
+ {
+ return NULL;
+ }
- /*
- * If undefined symbols: try to link with the C and math libraries!
- * This could be smarter, if the dynamic linker was able to handle
- * shared libs!
- */
- if(dld_undefined_sym_count > 0) {
- if (dld_link("/usr/lib/libc.a")) {
- elog(NOTICE, "dld: Cannot link C library!");
- return NULL;
+ /*
+ * if there are undefined symbols, we want dl to search from the
+ * following libraries also.
+ */
+ dl_initialized = 1;
}
- if(dld_undefined_sym_count > 0) {
- if (dld_link("/usr/lib/libm.a")) {
- elog(NOTICE, "dld: Cannot link math library!");
+
+ /*
+ * link the file, then check for undefined symbols!
+ */
+ if (dld_link(filename))
+ {
return NULL;
- }
- if(dld_undefined_sym_count > 0) {
- int count = dld_undefined_sym_count;
- char **list= dld_list_undefined_sym();
+ }
- /* list the undefined symbols, if any */
- elog(NOTICE, "dld: Undefined:");
- do {
- elog(NOTICE, " %s", *list);
- list++;
- count--;
- } while(count > 0);
+ /*
+ * If undefined symbols: try to link with the C and math libraries!
+ * This could be smarter, if the dynamic linker was able to handle
+ * shared libs!
+ */
+ if (dld_undefined_sym_count > 0)
+ {
+ if (dld_link("/usr/lib/libc.a"))
+ {
+ elog(NOTICE, "dld: Cannot link C library!");
+ return NULL;
+ }
+ if (dld_undefined_sym_count > 0)
+ {
+ if (dld_link("/usr/lib/libm.a"))
+ {
+ elog(NOTICE, "dld: Cannot link math library!");
+ return NULL;
+ }
+ if (dld_undefined_sym_count > 0)
+ {
+ int count = dld_undefined_sym_count;
+ char **list = dld_list_undefined_sym();
- dld_unlink_by_file(filename, 1);
- return NULL;
- }
+ /* list the undefined symbols, if any */
+ elog(NOTICE, "dld: Undefined:");
+ do
+ {
+ elog(NOTICE, " %s", *list);
+ list++;
+ count--;
+ } while (count > 0);
+
+ dld_unlink_by_file(filename, 1);
+ return NULL;
+ }
+ }
}
- }
- return (void *) strdup(filename);
+ return (void *) strdup(filename);
}
-char *
+char *
pg_dlerror()
{
- return dld_strerror(dld_errno);
+ return dld_strerror(dld_errno);
}
diff --git a/src/backend/port/dgux/port-protos.h b/src/backend/port/dgux/port-protos.h
index 13862f9a007..9ca45ba234a 100644
--- a/src/backend/port/dgux/port-protos.h
+++ b/src/backend/port/dgux/port-protos.h
@@ -1,30 +1,30 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SunOS 4
+ * port-specific prototypes for SunOS 4
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.1 1996/07/25 20:44:00 scrappy Exp $
+ * $Id: port-protos.h,v 1.2 1997/09/07 04:45:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
#include "dlfcn.h"
/* dynloader.c */
-/* #define pg_dlopen(f) dlopen(f, 1) */
-#define pg_dlopen(f) dlopen(f, 2)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+/* #define pg_dlopen(f) dlopen(f, 1) */
+#define pg_dlopen(f) dlopen(f, 2)
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
/* port.c */
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/dgux/port.c b/src/backend/port/dgux/port.c
index 46fe71db568..1cc325c0db0 100644
--- a/src/backend/port/dgux/port.c
+++ b/src/backend/port/dgux/port.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * Linux-specific routines
+ * Linux-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/port.c,v 1.1 1996/07/25 20:44:00 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/port.c,v 1.2 1997/09/07 04:45:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
diff --git a/src/backend/port/hpux/dynloader.c b/src/backend/port/hpux/dynloader.c
index deea2e1dc29..3c7a8acaa7a 100644
--- a/src/backend/port/hpux/dynloader.c
+++ b/src/backend/port/hpux/dynloader.c
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
*
* dynloader.c--
- * dynamic loader for HP-UX using the shared library mechanism
+ * dynamic loader for HP-UX using the shared library mechanism
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/dynloader.c,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/dynloader.c,v 1.2 1997/09/07 04:45:44 momjian Exp $
*
- * NOTES
- * all functions are defined here -- it's impossible to trace the
- * shl_* routines from the bundled HP-UX debugger.
+ * NOTES
+ * all functions are defined here -- it's impossible to trace the
+ * shl_* routines from the bundled HP-UX debugger.
*
*-------------------------------------------------------------------------
*/
@@ -24,34 +24,36 @@
#include "utils/dynamic_loader.h"
#include "port-protos.h"
-void *
+void *
pg_dlopen(char *filename)
{
- shl_t handle = shl_load(filename, BIND_DEFERRED, 0);
+ shl_t handle = shl_load(filename, BIND_DEFERRED, 0);
- return((void *) handle);
+ return ((void *) handle);
}
func_ptr
pg_dlsym(void *handle, char *funcname)
{
- func_ptr f;
+ func_ptr f;
- if (shl_findsym((shl_t *) &handle, funcname, TYPE_PROCEDURE, &f) == -1) {
- f = (func_ptr) NULL;
- }
- return(f);
+ if (shl_findsym((shl_t *) & handle, funcname, TYPE_PROCEDURE, &f) == -1)
+ {
+ f = (func_ptr) NULL;
+ }
+ return (f);
}
void
pg_dlclose(void *handle)
{
- shl_unload((shl_t) handle);
+ shl_unload((shl_t) handle);
}
-char *
+char *
pg_dlerror()
{
- static char errmsg[]= "shl_load failed";
- return errmsg;
+ static char errmsg[] = "shl_load failed";
+
+ return errmsg;
}
diff --git a/src/backend/port/hpux/fixade.h b/src/backend/port/hpux/fixade.h
index 62324eb05d7..094cd13ca83 100644
--- a/src/backend/port/hpux/fixade.h
+++ b/src/backend/port/hpux/fixade.h
@@ -1,63 +1,66 @@
/*-------------------------------------------------------------------------
*
* fixade.h--
- * compiler tricks to make things work while POSTGRES does non-native
- * dereferences on PA-RISC.
+ * compiler tricks to make things work while POSTGRES does non-native
+ * dereferences on PA-RISC.
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: fixade.h,v 1.1.1.1 1996/07/09 06:21:43 scrappy Exp $
+ * $Id: fixade.h,v 1.2 1997/09/07 04:45:48 momjian Exp $
*
- * NOTES
- * This must be included in EVERY source file.
+ * NOTES
+ * This must be included in EVERY source file.
*
*-------------------------------------------------------------------------
*/
-#ifndef FIXADE_H
+#ifndef FIXADE_H
#define FIXADE_H
#if !defined(NOFIXADE)
#if defined(HP_S500_ALIGN)
/* ----------------
- * This cheesy hack turns ON unaligned-access fixup on H-P PA-RISC;
- * the resulting object files contain code that explicitly handles
- * realignment on reference, so it slows memory access down by a
- * considerable factor. It must be used in conjunction with the +u
- * flag to cc. The #pragma is included in c.h to be safe since EVERY
- * source file that performs unaligned access must contain the #pragma.
+ * This cheesy hack turns ON unaligned-access fixup on H-P PA-RISC;
+ * the resulting object files contain code that explicitly handles
+ * realignment on reference, so it slows memory access down by a
+ * considerable factor. It must be used in conjunction with the +u
+ * flag to cc. The #pragma is included in c.h to be safe since EVERY
+ * source file that performs unaligned access must contain the #pragma.
* ----------------
*/
#pragma HP_ALIGN HPUX_NATURAL_S500
#if defined(BROKEN_STRUCT_INIT)
/* ----------------
- * This is so bogus. The HP-UX 9.01 compiler has totally broken
- * struct initialization code. It actually length-checks ALL
- * array initializations within structs against the FIRST one that
- * it sees (when #pragma HP_ALIGN HPUX_NATURAL_S500 is defined)..
- * we have to throw in this unused structure before struct varlena
- * is defined.
+ * This is so bogus. The HP-UX 9.01 compiler has totally broken
+ * struct initialization code. It actually length-checks ALL
+ * array initializations within structs against the FIRST one that
+ * it sees (when #pragma HP_ALIGN HPUX_NATURAL_S500 is defined)..
+ * we have to throw in this unused structure before struct varlena
+ * is defined.
*
- * XXX guess you don't need the #pragma anymore after all :-)
- * since no one looks at this except me i think i'll just leave
- * this here for now..
+ * XXX guess you don't need the #pragma anymore after all :-)
+ * since no one looks at this except me i think i'll just leave
+ * this here for now..
* ----------------
*/
-struct HP_WAY_BOGUS {
- char hpwb_bogus[8192];
+struct HP_WAY_BOGUS
+{
+ char hpwb_bogus[8192];
};
-struct HP_TOO_BOGUS {
- int hptb_bogus[8192];
+struct HP_TOO_BOGUS
+{
+ int hptb_bogus[8192];
};
-#endif /* BROKEN_STRUCT_INIT */
-#endif /* HP_S500_ALIGN */
+
+#endif /* BROKEN_STRUCT_INIT */
+#endif /* HP_S500_ALIGN */
#if defined(WEAK_C_OPTIMIZER)
#pragma OPT_LEVEL 1
-#endif /* WEAK_C_OPTIMIZER */
+#endif /* WEAK_C_OPTIMIZER */
-#endif /* !NOFIXADE */
+#endif /* !NOFIXADE */
-#endif /* FIXADE_H */
+#endif /* FIXADE_H */
diff --git a/src/backend/port/hpux/port-protos.h b/src/backend/port/hpux/port-protos.h
index 33d2dd66def..76b336aae22 100644
--- a/src/backend/port/hpux/port-protos.h
+++ b/src/backend/port/hpux/port-protos.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for HP-UX
+ * port-specific prototypes for HP-UX
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.2 1997/07/27 18:51:57 momjian Exp $
+ * $Id: port-protos.h,v 1.3 1997/09/07 04:45:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,7 +14,7 @@
#define PORT_PROTOS_H
#include <sys/resource.h> /* for struct rusage */
-#include <dl.h> /* for shl_t */
+#include <dl.h> /* for shl_t */
#include "utils/dynamic_loader.h"
@@ -24,11 +24,11 @@
/* port.c */
-extern int init_address_fixup(void);
-extern double rint(double x);
-extern double cbrt(double x);
-extern long random(void);
-extern void srandom(unsigned seed);
-extern int getrusage(int who, struct rusage *ru);
+extern int init_address_fixup(void);
+extern double rint(double x);
+extern double cbrt(double x);
+extern long random(void);
+extern void srandom(unsigned seed);
+extern int getrusage(int who, struct rusage * ru);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/hpux/port.c b/src/backend/port/hpux/port.c
index 205a3178267..8f37cd44484 100644
--- a/src/backend/port/hpux/port.c
+++ b/src/backend/port/hpux/port.c
@@ -1,47 +1,49 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * port-specific routines for HP-UX
+ * port-specific routines for HP-UX
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/port.c,v 1.2 1997/07/27 18:52:05 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/port.c,v 1.3 1997/09/07 04:45:52 momjian Exp $
*
* NOTES
- * For the most part, this file gets around some non-POSIX calls
- * in POSTGRES.
+ * For the most part, this file gets around some non-POSIX calls
+ * in POSTGRES.
*
*-------------------------------------------------------------------------
*/
-#include <unistd.h> /* for rand()/srand() prototypes */
-#include <math.h> /* for pow() prototype */
-#include <sys/syscall.h> /* for syscall #defines */
+#include <unistd.h> /* for rand()/srand() prototypes */
+#include <math.h> /* for pow() prototype */
+#include <sys/syscall.h> /* for syscall #defines */
#include "c.h"
void
init_address_fixup()
{
- /*
- * On PA-RISC, unaligned access fixup is handled by the compiler,
- * not by the kernel.
- */
+
+ /*
+ * On PA-RISC, unaligned access fixup is handled by the compiler, not
+ * by the kernel.
+ */
}
long
random()
{
- return(lrand48());
+ return (lrand48());
}
-void srandom(unsigned seed)
+void
+srandom(unsigned seed)
{
srand48((long int) seed);
}
-getrusage(int who, struct rusage *ru)
+getrusage(int who, struct rusage * ru)
{
- return(syscall(SYS_GETRUSAGE, who, ru));
+ return (syscall(SYS_GETRUSAGE, who, ru));
}
diff --git a/src/backend/port/hpux/rusagestub.h b/src/backend/port/hpux/rusagestub.h
index d2393eb792d..5eda998802e 100644
--- a/src/backend/port/hpux/rusagestub.h
+++ b/src/backend/port/hpux/rusagestub.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* rusagestub.h--
- * Stubs for getrusage(3).
+ * Stubs for getrusage(3).
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -13,18 +13,19 @@
#ifndef RUSAGESTUB_H
#define RUSAGESTUB_H
-#include <sys/time.h> /* for struct timeval */
-#include <sys/times.h> /* for struct tms */
-#include <limits.h> /* for CLK_TCK */
+#include <sys/time.h> /* for struct timeval */
+#include <sys/times.h> /* for struct tms */
+#include <limits.h> /* for CLK_TCK */
-#define RUSAGE_SELF 0
-#define RUSAGE_CHILDREN -1
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
};
-extern int getrusage(int who, struct rusage *rusage);
+extern int getrusage(int who, struct rusage * rusage);
-#endif /* RUSAGESTUB_H */
+#endif /* RUSAGESTUB_H */
diff --git a/src/backend/port/i386_solaris/port-protos.h b/src/backend/port/i386_solaris/port-protos.h
index 45e56ad1e75..6118a650460 100644
--- a/src/backend/port/i386_solaris/port-protos.h
+++ b/src/backend/port/i386_solaris/port-protos.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SunOS 4
+ * port-specific prototypes for SunOS 4
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.1 1996/07/20 08:34:33 scrappy Exp $
+ * $Id: port-protos.h,v 1.2 1997/09/07 04:45:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,25 +14,25 @@
#define PORT_PROTOS_H
#include <dlfcn.h>
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on SunOS 4.
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
#define pg_dlopen(f) dlopen(f,1)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
/* port.c */
-extern long random(void);
-extern void srandom(int seed);
+extern long random(void);
+extern void srandom(int seed);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/i386_solaris/port.c b/src/backend/port/i386_solaris/port.c
index c6fcdab98e7..119163a1869 100644
--- a/src/backend/port/i386_solaris/port.c
+++ b/src/backend/port/i386_solaris/port.c
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * SunOS5-specific routines
+ * SunOS5-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/i386_solaris/Attic/port.c,v 1.1 1996/07/20 08:34:34 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/i386_solaris/Attic/port.c,v 1.2 1997/09/07 04:45:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
-#include <math.h> /* for pow() prototype */
+#include <math.h> /* for pow() prototype */
#include <errno.h>
#include "rusagestub.h"
@@ -19,48 +19,52 @@
long
random()
{
- return(lrand48());
+ return (lrand48());
}
void
srandom(int seed)
{
- srand48((long int) seed);
+ srand48((long int) seed);
}
int
-getrusage(int who, struct rusage *rusage)
+getrusage(int who, struct rusage * rusage)
{
- struct tms tms;
- register int tick_rate = CLK_TCK; /* ticks per second */
- clock_t u, s;
+ struct tms tms;
+ register int tick_rate = CLK_TCK; /* ticks per second */
+ clock_t u,
+ s;
- if (rusage == (struct rusage *) NULL) {
- errno = EFAULT;
- return(-1);
- }
- if (times(&tms) < 0) {
- /* errno set by times */
- return(-1);
- }
- switch (who) {
- case RUSAGE_SELF:
- u = tms.tms_utime;
- s = tms.tms_stime;
- break;
- case RUSAGE_CHILDREN:
- u = tms.tms_cutime;
- s = tms.tms_cstime;
- break;
- default:
- errno = EINVAL;
- return(-1);
- }
+ if (rusage == (struct rusage *) NULL)
+ {
+ errno = EFAULT;
+ return (-1);
+ }
+ if (times(&tms) < 0)
+ {
+ /* errno set by times */
+ return (-1);
+ }
+ switch (who)
+ {
+ case RUSAGE_SELF:
+ u = tms.tms_utime;
+ s = tms.tms_stime;
+ break;
+ case RUSAGE_CHILDREN:
+ u = tms.tms_cutime;
+ s = tms.tms_cstime;
+ break;
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
-#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
- rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
- rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
- rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
- rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
- return(0);
+#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
+ rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
+ rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
+ rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ return (0);
}
diff --git a/src/backend/port/i386_solaris/rusagestub.h b/src/backend/port/i386_solaris/rusagestub.h
index 0ad45fafaad..c6e2ceae453 100644
--- a/src/backend/port/i386_solaris/rusagestub.h
+++ b/src/backend/port/i386_solaris/rusagestub.h
@@ -1,30 +1,31 @@
/*-------------------------------------------------------------------------
*
* rusagestub.h--
- * Stubs for getrusage(3).
+ * Stubs for getrusage(3).
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: rusagestub.h,v 1.1 1996/07/20 08:34:34 scrappy Exp $
+ * $Id: rusagestub.h,v 1.2 1997/09/07 04:46:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef RUSAGESTUB_H
#define RUSAGESTUB_H
-#include <sys/time.h> /* for struct timeval */
-#include <sys/times.h> /* for struct tms */
-#include <limits.h> /* for CLK_TCK */
+#include <sys/time.h> /* for struct timeval */
+#include <sys/times.h> /* for struct tms */
+#include <limits.h> /* for CLK_TCK */
-#define RUSAGE_SELF 0
-#define RUSAGE_CHILDREN -1
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
};
-extern int getrusage(int who, struct rusage *rusage);
+extern int getrusage(int who, struct rusage * rusage);
-#endif /* RUSAGESTUB_H */
+#endif /* RUSAGESTUB_H */
diff --git a/src/backend/port/inet_aton.c b/src/backend/port/inet_aton.c
index 37c11b621b7..122875eda3b 100644
--- a/src/backend/port/inet_aton.c
+++ b/src/backend/port/inet_aton.c
@@ -1,39 +1,39 @@
/*
*
- * This inet_aton() function was taken from the GNU C library and
- * incorporated into Postgres for those systems which do not have this
- * routine in their standard C libraries.
+ * This inet_aton() function was taken from the GNU C library and
+ * incorporated into Postgres for those systems which do not have this
+ * routine in their standard C libraries.
*
- * The function was been extracted whole from the file inet_aton.c in
- * Release 5.3.12 of the Linux C library, which is derived from the
- * GNU C library, by Bryan Henderson in October 1996. The copyright
- * notice from that file is below.
+ * The function was been extracted whole from the file inet_aton.c in
+ * Release 5.3.12 of the Linux C library, which is derived from the
+ * GNU C library, by Bryan Henderson in October 1996. The copyright
+ * notice from that file is below.
*/
/*
* Copyright (c) 1983, 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -55,82 +55,92 @@
* cannot distinguish between failure and a local broadcast address.
*/
int
-inet_aton(const char *cp, struct in_addr *addr)
+inet_aton(const char *cp, struct in_addr * addr)
{
register u_long val;
- register int base, n;
- register char c;
- u_int parts[4];
+ register int base,
+ n;
+ register char c;
+ u_int parts[4];
register u_int *pp = parts;
- for (;;) {
+ for (;;)
+ {
+
/*
- * Collect number up to ``.''.
- * Values are specified as for C:
+ * Collect number up to ``.''. Values are specified as for C:
* 0x=hex, 0=octal, other=decimal.
*/
- val = 0; base = 10;
- if (*cp == '0') {
+ val = 0;
+ base = 10;
+ if (*cp == '0')
+ {
if (*++cp == 'x' || *cp == 'X')
base = 16, cp++;
else
base = 8;
}
- while ((c = *cp) != '\0') {
- if (isascii(c) && isdigit(c)) {
+ while ((c = *cp) != '\0')
+ {
+ if (isascii(c) && isdigit(c))
+ {
val = (val * base) + (c - '0');
cp++;
continue;
}
- if (base == 16 && isascii(c) && isxdigit(c)) {
- val = (val << 4) +
+ if (base == 16 && isascii(c) && isxdigit(c))
+ {
+ val = (val << 4) +
(c + 10 - (islower(c) ? 'a' : 'A'));
cp++;
continue;
}
break;
}
- if (*cp == '.') {
+ if (*cp == '.')
+ {
+
/*
- * Internet format:
- * a.b.c.d
- * a.b.c (with c treated as 16-bits)
- * a.b (with b treated as 24 bits)
+ * Internet format: a.b.c.d a.b.c (with c treated as
+ * 16-bits) a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3 || val > 0xff)
return (0);
*pp++ = val, cp++;
- } else
+ }
+ else
break;
}
+
/*
* Check for trailing characters.
*/
if (*cp && (!isascii(*cp) || !isspace(*cp)))
return (0);
+
/*
- * Concoct the address according to
- * the number of parts specified.
+ * Concoct the address according to the number of parts specified.
*/
n = pp - parts + 1;
- switch (n) {
+ switch (n)
+ {
- case 1: /* a -- 32 bits */
+ case 1: /* a -- 32 bits */
break;
- case 2: /* a.b -- 8.24 bits */
+ case 2: /* a.b -- 8.24 bits */
if (val > 0xffffff)
return (0);
val |= parts[0] << 24;
break;
- case 3: /* a.b.c -- 8.8.16 bits */
+ case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16);
break;
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
+ case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
diff --git a/src/backend/port/inet_aton.h b/src/backend/port/inet_aton.h
index 6909bd2b12d..b1df9a8ff3d 100644
--- a/src/backend/port/inet_aton.h
+++ b/src/backend/port/inet_aton.h
@@ -1,2 +1,2 @@
int
-inet_aton(const char *cp, struct in_addr *addr);
+ inet_aton(const char *cp, struct in_addr * addr);
diff --git a/src/backend/port/irix5/port-protos.h b/src/backend/port/irix5/port-protos.h
index 3f580758416..be894ed5b12 100644
--- a/src/backend/port/irix5/port-protos.h
+++ b/src/backend/port/irix5/port-protos.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for Irix 5
+ * port-specific prototypes for Irix 5
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -14,24 +14,24 @@
#define PORT_PROTOS_H
#include <dlfcn.h>
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on SunOS 4.
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
#define pg_dlopen(f) dlopen(f,1)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
/* port.c */
-extern long random(void);
+extern long random(void);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/irix5/port.c b/src/backend/port/irix5/port.c
index 82303ed7fcb..6c60ade72f9 100644
--- a/src/backend/port/irix5/port.c
+++ b/src/backend/port/irix5/port.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * Irix5-specific routines
+ * Irix5-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * /usr/local/devel/pglite/cvs/src/backend/port/sparc_solaris/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
+ * /usr/local/devel/pglite/cvs/src/backend/port/sparc_solaris/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
*
*-------------------------------------------------------------------------
*/
-#include <math.h> /* for pow() prototype */
+#include <math.h> /* for pow() prototype */
#include <errno.h>
diff --git a/src/backend/port/linux/dynloader.c b/src/backend/port/linux/dynloader.c
index a3b551b6f95..adb13b40194 100644
--- a/src/backend/port/linux/dynloader.c
+++ b/src/backend/port/linux/dynloader.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
*
* dynloader.c--
- * Dynamic Loader for Postgres for Linux, generated from those for
- * Ultrix.
+ * Dynamic Loader for Postgres for Linux, generated from those for
+ * Ultrix.
*
- * You need to install the dld library on your Linux system!
+ * You need to install the dld library on your Linux system!
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/dynloader.c,v 1.2 1997/02/06 08:39:40 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/dynloader.c,v 1.3 1997/09/07 04:46:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,82 +23,92 @@
#include "utils/elog.h"
#include "fmgr.h"
-extern char pg_pathname[];
+extern char pg_pathname[];
-void *
+void *
pg_dlopen(char *filename)
{
#ifndef HAVE_DLD_H
- elog(WARN, "dynamic load not supported");
- return(NULL);
+ elog(WARN, "dynamic load not supported");
+ return (NULL);
#else
- static int dl_initialized= 0;
+ static int dl_initialized = 0;
- /*
- * initializes the dynamic loader with the executable's pathname.
- * (only needs to do this the first time pg_dlopen is called.)
- */
- if (!dl_initialized) {
- if (dld_init (dld_find_executable (pg_pathname))) {
- return NULL;
- }
/*
- * if there are undefined symbols, we want dl to search from the
- * following libraries also.
+ * initializes the dynamic loader with the executable's pathname.
+ * (only needs to do this the first time pg_dlopen is called.)
*/
- dl_initialized= 1;
- }
-
- /*
- * link the file, then check for undefined symbols!
- */
- if (dld_link(filename)) {
- return NULL;
- }
+ if (!dl_initialized)
+ {
+ if (dld_init(dld_find_executable(pg_pathname)))
+ {
+ return NULL;
+ }
- /*
- * If undefined symbols: try to link with the C and math libraries!
- * This could be smarter, if the dynamic linker was able to handle
- * shared libs!
- */
- if(dld_undefined_sym_count > 0) {
- if (dld_link("/usr/lib/libc.a")) {
- elog(NOTICE, "dld: Cannot link C library!");
- return NULL;
+ /*
+ * if there are undefined symbols, we want dl to search from the
+ * following libraries also.
+ */
+ dl_initialized = 1;
}
- if(dld_undefined_sym_count > 0) {
- if (dld_link("/usr/lib/libm.a")) {
- elog(NOTICE, "dld: Cannot link math library!");
+
+ /*
+ * link the file, then check for undefined symbols!
+ */
+ if (dld_link(filename))
+ {
return NULL;
- }
- if(dld_undefined_sym_count > 0) {
- int count = dld_undefined_sym_count;
- char **list= dld_list_undefined_sym();
+ }
- /* list the undefined symbols, if any */
- elog(NOTICE, "dld: Undefined:");
- do {
- elog(NOTICE, " %s", *list);
- list++;
- count--;
- } while(count > 0);
+ /*
+ * If undefined symbols: try to link with the C and math libraries!
+ * This could be smarter, if the dynamic linker was able to handle
+ * shared libs!
+ */
+ if (dld_undefined_sym_count > 0)
+ {
+ if (dld_link("/usr/lib/libc.a"))
+ {
+ elog(NOTICE, "dld: Cannot link C library!");
+ return NULL;
+ }
+ if (dld_undefined_sym_count > 0)
+ {
+ if (dld_link("/usr/lib/libm.a"))
+ {
+ elog(NOTICE, "dld: Cannot link math library!");
+ return NULL;
+ }
+ if (dld_undefined_sym_count > 0)
+ {
+ int count = dld_undefined_sym_count;
+ char **list = dld_list_undefined_sym();
- dld_unlink_by_file(filename, 1);
- return NULL;
- }
+ /* list the undefined symbols, if any */
+ elog(NOTICE, "dld: Undefined:");
+ do
+ {
+ elog(NOTICE, " %s", *list);
+ list++;
+ count--;
+ } while (count > 0);
+
+ dld_unlink_by_file(filename, 1);
+ return NULL;
+ }
+ }
}
- }
- return (void *) strdup(filename);
+ return (void *) strdup(filename);
#endif
}
-char *
+char *
pg_dlerror()
{
#ifndef HAVE_DLD_H
- return("dynaloader unspported");
+ return ("dynaloader unspported");
#else
- return dld_strerror(dld_errno);
+ return dld_strerror(dld_errno);
#endif
}
diff --git a/src/backend/port/linux/port-protos.h b/src/backend/port/linux/port-protos.h
index 76f02b48fe9..f5af9beecee 100644
--- a/src/backend/port/linux/port-protos.h
+++ b/src/backend/port/linux/port-protos.h
@@ -1,19 +1,19 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SunOS 4
+ * port-specific prototypes for SunOS 4
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.2 1997/02/06 08:39:53 scrappy Exp $
+ * $Id: port-protos.h,v 1.3 1997/09/07 04:46:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
#ifdef LINUX_ELF
#include "dlfcn.h"
@@ -22,21 +22,21 @@
/* dynloader.c */
#ifndef LINUX_ELF
-# ifndef HAVE_DLD_H
-#define pg_dlsym(handle, funcname) (NULL)
-# define pg_dlclose(handle) ({})
-# else
-#define pg_dlsym(handle, funcname) ((func_ptr) dld_get_func((funcname)))
-# define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
-# endif
+#ifndef HAVE_DLD_H
+#define pg_dlsym(handle, funcname) (NULL)
+#define pg_dlclose(handle) ({})
#else
-/* #define pg_dlopen(f) dlopen(f, 1) */
-#define pg_dlopen(f) dlopen(f, 2)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlsym(handle, funcname) ((func_ptr) dld_get_func((funcname)))
+#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
+#endif
+#else
+/* #define pg_dlopen(f) dlopen(f, 1) */
+#define pg_dlopen(f) dlopen(f, 2)
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
#endif
/* port.c */
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/linux/port.c b/src/backend/port/linux/port.c
index e4c5edfb9e5..942340f40fd 100644
--- a/src/backend/port/linux/port.c
+++ b/src/backend/port/linux/port.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * Linux-specific routines
+ * Linux-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:44 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/port.c,v 1.2 1997/09/07 04:46:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
diff --git a/src/backend/port/linuxalpha/machine.h b/src/backend/port/linuxalpha/machine.h
index 78d45d41ba9..eee148e390c 100644
--- a/src/backend/port/linuxalpha/machine.h
+++ b/src/backend/port/linuxalpha/machine.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* machine.h--
- *
+ *
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: machine.h,v 1.1 1997/03/14 06:01:21 scrappy Exp $
+ * $Id: machine.h,v 1.2 1997/09/07 04:46:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
diff --git a/src/backend/port/linuxalpha/port-protos.h b/src/backend/port/linuxalpha/port-protos.h
index 7bcbaf020d1..350c0c52809 100644
--- a/src/backend/port/linuxalpha/port-protos.h
+++ b/src/backend/port/linuxalpha/port-protos.h
@@ -1,25 +1,25 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SunOS 4
+ * port-specific prototypes for SunOS 4
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.1 1997/03/14 06:01:33 scrappy Exp $
+ * $Id: port-protos.h,v 1.2 1997/09/07 04:46:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
#include "dlfcn.h"
-#define pg_dlopen(f) dlopen(f, 2)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlopen(f) dlopen(f, 2)
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/linuxalpha/port.c b/src/backend/port/linuxalpha/port.c
index a9886814449..8ddc6ddc1e3 100644
--- a/src/backend/port/linuxalpha/port.c
+++ b/src/backend/port/linuxalpha/port.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * Linux-specific routines
+ * Linux-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/linuxalpha/Attic/port.c,v 1.1 1997/03/14 06:01:40 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/linuxalpha/Attic/port.c,v 1.2 1997/09/07 04:46:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
diff --git a/src/backend/port/nextstep/dynloader.c b/src/backend/port/nextstep/dynloader.c
index af183d436de..c37508f7f19 100644
--- a/src/backend/port/nextstep/dynloader.c
+++ b/src/backend/port/nextstep/dynloader.c
@@ -2,71 +2,80 @@
#include <streams/streams.h>
#include <stdlib.h>
-static char* lastError = NULL;
+static char *lastError = NULL;
-static NXStream* OpenError()
+static NXStream *
+OpenError()
{
- return NXOpenMemory(NULL, 0, NX_WRITEONLY);
+ return NXOpenMemory(NULL, 0, NX_WRITEONLY);
}
-static void CloseError(NXStream* s)
+static void
+CloseError(NXStream * s)
{
- if (s)
- NXCloseMemory (s, NX_FREEBUFFER);
+ if (s)
+ NXCloseMemory(s, NX_FREEBUFFER);
}
-static void TransferError(NXStream* s)
+static void
+TransferError(NXStream * s)
{
- char *buffer;
- int len, maxlen;
+ char *buffer;
+ int len,
+ maxlen;
- if (lastError)
- free (lastError);
- NXGetMemoryBuffer (s, &buffer, &len, &maxlen);
- lastError = malloc (len + 1);
- strcpy (lastError, buffer);
+ if (lastError)
+ free(lastError);
+ NXGetMemoryBuffer(s, &buffer, &len, &maxlen);
+ lastError = malloc(len + 1);
+ strcpy(lastError, buffer);
}
-void* next_dlopen(char* name)
+void *
+next_dlopen(char *name)
{
- int rld_success;
- NXStream* errorStream;
- char* result = NULL;
- char **p;
-
- errorStream = OpenError();
- p = calloc (2, sizeof(void*));
- p[0] = name;
- rld_success = rld_load(errorStream, NULL, p, NULL);
- free (p);
+ int rld_success;
+ NXStream *errorStream;
+ char *result = NULL;
+ char **p;
- if (!rld_success) {
- TransferError (errorStream);
- result = (char*)1;
- }
- CloseError (errorStream);
- return result;
+ errorStream = OpenError();
+ p = calloc(2, sizeof(void *));
+ p[0] = name;
+ rld_success = rld_load(errorStream, NULL, p, NULL);
+ free(p);
+
+ if (!rld_success)
+ {
+ TransferError(errorStream);
+ result = (char *) 1;
+ }
+ CloseError(errorStream);
+ return result;
}
-int next_dlclose(void* handle)
+int
+next_dlclose(void *handle)
{
- return 0;
+ return 0;
}
-void* next_dlsym (void *handle, char *symbol)
+void *
+next_dlsym(void *handle, char *symbol)
{
- NXStream* errorStream = OpenError();
- char symbuf[1024];
- unsigned long symref = 0;
+ NXStream *errorStream = OpenError();
+ char symbuf[1024];
+ unsigned long symref = 0;
- sprintf(symbuf, "_%s", symbol);
- if (!rld_lookup (errorStream, symbuf, &symref))
- TransferError(errorStream);
- CloseError(errorStream);
- return (void*) symref;
+ sprintf(symbuf, "_%s", symbol);
+ if (!rld_lookup(errorStream, symbuf, &symref))
+ TransferError(errorStream);
+ CloseError(errorStream);
+ return (void *) symref;
}
-char* next_dlerror(void)
+char *
+next_dlerror(void)
{
- return lastError;
+ return lastError;
}
diff --git a/src/backend/port/nextstep/port-protos.h b/src/backend/port/nextstep/port-protos.h
index 93fec7642f0..ce17beb69a6 100644
--- a/src/backend/port/nextstep/port-protos.h
+++ b/src/backend/port/nextstep/port-protos.h
@@ -1,27 +1,27 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for NeXT
+ * port-specific prototypes for NeXT
*
-
+
-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
-void* next_dlopen(char* name);
-int next_dlclose(void* handle);
-void* next_dlsym (void *handle, char *symbol);
-char* next_dlerror(void);
+void *next_dlopen(char *name);
+int next_dlclose(void *handle);
+void *next_dlsym(void *handle, char *symbol);
+char *next_dlerror(void);
-#define pg_dlopen(f) next_dlopen
-#define pg_dlsym next_dlsym
-#define pg_dlclose next_dlclose
-#define pg_dlerror next_dlerror
+#define pg_dlopen(f) next_dlopen
+#define pg_dlsym next_dlsym
+#define pg_dlclose next_dlclose
+#define pg_dlerror next_dlerror
/* port.c */
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/nextstep/port.c b/src/backend/port/nextstep/port.c
index 3da87b32eb8..baf026d5d1d 100644
--- a/src/backend/port/nextstep/port.c
+++ b/src/backend/port/nextstep/port.c
@@ -1,58 +1,65 @@
#ifndef _POSIX_SOURCE
-# include <libc.h>
+#include <libc.h>
#else
-# include <unistd.h>
-# include <stdlib.h>
+#include <unistd.h>
+#include <stdlib.h>
#endif
#include <string.h>
#include <sys/signal.h>
-void putenv(char* name)
+void
+putenv(char *name)
{
- extern char** environ;
- static int was_mallocated = 0;
- int size;
-
- /* Compute the size of environ array including the final NULL */
- for (size = 1; environ[size++];)
- /* nothing */;
-
- if (!was_mallocated) {
- char** tmp = environ;
- int i;
-
- was_mallocated = 1;
- environ = malloc (size * sizeof(char*));
- for (i = 0; i < size; i++)
- environ[i] = tmp[i];
- }
-
- environ = realloc (environ, (size + 1) * sizeof (char*));
- environ[size - 1] = strcpy (malloc (strlen (name) + 1), name);
- environ[size] = NULL;
+ extern char **environ;
+ static int was_mallocated = 0;
+ int size;
+
+ /* Compute the size of environ array including the final NULL */
+ for (size = 1; environ[size++];)
+ /* nothing */ ;
+
+ if (!was_mallocated)
+ {
+ char **tmp = environ;
+ int i;
+
+ was_mallocated = 1;
+ environ = malloc(size * sizeof(char *));
+ for (i = 0; i < size; i++)
+ environ[i] = tmp[i];
+ }
+
+ environ = realloc(environ, (size + 1) * sizeof(char *));
+ environ[size - 1] = strcpy(malloc(strlen(name) + 1), name);
+ environ[size] = NULL;
}
-char* strdup (const char* string)
+char *
+strdup(const char *string)
{
- return strcpy (malloc (strlen (string) + 1), string);
+ return strcpy(malloc(strlen(string) + 1), string);
}
#ifndef _POSIX_SOURCE
-int sigaddset(int *set, int signo)
+int
+sigaddset(int *set, int signo)
{
- *set |= sigmask(signo);
- return *set;
+ *set |= sigmask(signo);
+ return *set;
}
-int sigemptyset(int *set)
+int
+sigemptyset(int *set)
{
- return (*set = 0);
+ return (*set = 0);
}
-char *getcwd(char *buf, size_t size)
+char *
+getcwd(char *buf, size_t size)
{
- return getwd (buf);
+ return getwd(buf);
}
+
#endif
diff --git a/src/backend/port/sco/port-protos.h b/src/backend/port/sco/port-protos.h
index 17e3b02a265..9526f7c747d 100644
--- a/src/backend/port/sco/port-protos.h
+++ b/src/backend/port/sco/port-protos.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SCO 3.2v5.2
+ * port-specific prototypes for SCO 3.2v5.2
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.1 1997/07/28 01:33:55 momjian Exp $
+ * $Id: port-protos.h,v 1.2 1997/09/07 04:46:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,23 +14,23 @@
#define PORT_PROTOS_H
#include <dlfcn.h>
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on SCO 3.2v5.0.2
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
#define pg_dlopen(f) dlopen(f,1)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
/* port.c */
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/sco/port.c b/src/backend/port/sco/port.c
index 3f1b84d6189..d1c868e8426 100644
--- a/src/backend/port/sco/port.c
+++ b/src/backend/port/sco/port.c
@@ -1,57 +1,60 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * SCO 3.2v5.0.2 specific routines
+ * SCO 3.2v5.0.2 specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * /usr/local/devel/pglite/cvs/src/backend/port/svr4/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
+ * /usr/local/devel/pglite/cvs/src/backend/port/svr4/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
*
*-------------------------------------------------------------------------
*/
#include <unistd.h>
-#include <math.h> /* for pow() prototype */
+#include <math.h> /* for pow() prototype */
#include <errno.h>
#include "rusagestub.h"
int
-getrusage(int who, struct rusage *rusage)
+getrusage(int who, struct rusage * rusage)
{
- struct tms tms;
- register int tick_rate = CLK_TCK; /* ticks per second */
- clock_t u, s;
+ struct tms tms;
+ register int tick_rate = CLK_TCK; /* ticks per second */
+ clock_t u,
+ s;
- if (rusage == (struct rusage *) NULL) {
- errno = EFAULT;
- return(-1);
- }
- if (times(&tms) < 0) {
- /* errno set by times */
- return(-1);
- }
- switch (who) {
- case RUSAGE_SELF:
- u = tms.tms_utime;
- s = tms.tms_stime;
- break;
- case RUSAGE_CHILDREN:
- u = tms.tms_cutime;
- s = tms.tms_cstime;
- break;
- default:
- errno = EINVAL;
- return(-1);
- }
+ if (rusage == (struct rusage *) NULL)
+ {
+ errno = EFAULT;
+ return (-1);
+ }
+ if (times(&tms) < 0)
+ {
+ /* errno set by times */
+ return (-1);
+ }
+ switch (who)
+ {
+ case RUSAGE_SELF:
+ u = tms.tms_utime;
+ s = tms.tms_stime;
+ break;
+ case RUSAGE_CHILDREN:
+ u = tms.tms_cutime;
+ s = tms.tms_cstime;
+ break;
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
-#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
- rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
- rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
- rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
- rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
- return(0);
+#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
+ rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
+ rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
+ rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ return (0);
}
-
diff --git a/src/backend/port/sco/rusagestub.h b/src/backend/port/sco/rusagestub.h
index d2393eb792d..5eda998802e 100644
--- a/src/backend/port/sco/rusagestub.h
+++ b/src/backend/port/sco/rusagestub.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* rusagestub.h--
- * Stubs for getrusage(3).
+ * Stubs for getrusage(3).
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -13,18 +13,19 @@
#ifndef RUSAGESTUB_H
#define RUSAGESTUB_H
-#include <sys/time.h> /* for struct timeval */
-#include <sys/times.h> /* for struct tms */
-#include <limits.h> /* for CLK_TCK */
+#include <sys/time.h> /* for struct timeval */
+#include <sys/times.h> /* for struct tms */
+#include <limits.h> /* for CLK_TCK */
-#define RUSAGE_SELF 0
-#define RUSAGE_CHILDREN -1
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
};
-extern int getrusage(int who, struct rusage *rusage);
+extern int getrusage(int who, struct rusage * rusage);
-#endif /* RUSAGESTUB_H */
+#endif /* RUSAGESTUB_H */
diff --git a/src/backend/port/sparc_solaris/port-protos.h b/src/backend/port/sparc_solaris/port-protos.h
index c2cbf5803b5..95239173462 100644
--- a/src/backend/port/sparc_solaris/port-protos.h
+++ b/src/backend/port/sparc_solaris/port-protos.h
@@ -1,52 +1,52 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SunOS 4
+ * port-specific prototypes for SunOS 4
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.4 1997/04/15 18:18:33 scrappy Exp $
+ * $Id: port-protos.h,v 1.5 1997/09/07 04:46:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
-#include <netinet/in.h> /* For struct in_addr */
+#include <netinet/in.h> /* For struct in_addr */
#include <arpa/inet.h>
#include <dlfcn.h>
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on SunOS 4.
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
#define pg_dlopen(f) dlopen(f,1)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
/* port.c */
-extern long random(void);
-extern void srandom(int seed);
+extern long random(void);
+extern void srandom(int seed);
/* inet_aton.c in backend/port directory */
-extern int inet_aton(const char *cp, struct in_addr *addr);
+extern int inet_aton(const char *cp, struct in_addr * addr);
/* In system library, but can't find prototype in system library .h files */
-extern int gethostname(char *name, int namelen);
+extern int gethostname(char *name, int namelen);
/* In system library, but can't find prototype in system library .h files */
#include <sys/resource.h>
-extern int getrusage(int who, struct rusage *rusage);
+extern int getrusage(int who, struct rusage * rusage);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/sparc_solaris/port.c b/src/backend/port/sparc_solaris/port.c
index 8710ec95451..7f19a1ae237 100644
--- a/src/backend/port/sparc_solaris/port.c
+++ b/src/backend/port/sparc_solaris/port.c
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * SunOS5-specific routines
+ * SunOS5-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/port.c,v 1.4 1997/04/15 18:18:45 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/port.c,v 1.5 1997/09/07 04:46:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
-#include <math.h> /* for pow() prototype */
+#include <math.h> /* for pow() prototype */
#include <stdlib.h>
#include <errno.h>
@@ -20,55 +20,60 @@
#include "port-protos.h"
#ifndef HAVE_GETRUSAGE
#include "rusagestub.h"
-#endif /* HAVE_GETRUSAGE */
+#endif /* HAVE_GETRUSAGE */
long
random()
{
- return(lrand48());
+ return (lrand48());
}
void
srandom(int seed)
{
- srand48((long int) seed);
+ srand48((long int) seed);
}
#ifndef HAVE_GETRUSAGE
int
-getrusage(int who, struct rusage *rusage)
+getrusage(int who, struct rusage * rusage)
{
- struct tms tms;
- register int tick_rate = CLK_TCK; /* ticks per second */
- clock_t u, s;
+ struct tms tms;
+ register int tick_rate = CLK_TCK; /* ticks per second */
+ clock_t u,
+ s;
- if (rusage == (struct rusage *) NULL) {
- errno = EFAULT;
- return(-1);
- }
- if (times(&tms) < 0) {
- /* errno set by times */
- return(-1);
- }
- switch (who) {
- case RUSAGE_SELF:
- u = tms.tms_utime;
- s = tms.tms_stime;
- break;
- case RUSAGE_CHILDREN:
- u = tms.tms_cutime;
- s = tms.tms_cstime;
- break;
- default:
- errno = EINVAL;
- return(-1);
- }
+ if (rusage == (struct rusage *) NULL)
+ {
+ errno = EFAULT;
+ return (-1);
+ }
+ if (times(&tms) < 0)
+ {
+ /* errno set by times */
+ return (-1);
+ }
+ switch (who)
+ {
+ case RUSAGE_SELF:
+ u = tms.tms_utime;
+ s = tms.tms_stime;
+ break;
+ case RUSAGE_CHILDREN:
+ u = tms.tms_cutime;
+ s = tms.tms_cstime;
+ break;
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
-#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
- rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
- rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
- rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
- rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
- return(0);
+#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
+ rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
+ rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
+ rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ return (0);
}
-#endif /* HAVE_GETRUSAGE */
+
+#endif /* HAVE_GETRUSAGE */
diff --git a/src/backend/port/sparc_solaris/rusagestub.h b/src/backend/port/sparc_solaris/rusagestub.h
index 5e413bd0d9a..87957a45eac 100644
--- a/src/backend/port/sparc_solaris/rusagestub.h
+++ b/src/backend/port/sparc_solaris/rusagestub.h
@@ -1,30 +1,31 @@
/*-------------------------------------------------------------------------
*
* rusagestub.h--
- * Stubs for getrusage(3).
+ * Stubs for getrusage(3).
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: rusagestub.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $
+ * $Id: rusagestub.h,v 1.2 1997/09/07 04:46:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef RUSAGESTUB_H
#define RUSAGESTUB_H
-#include <sys/time.h> /* for struct timeval */
-#include <sys/times.h> /* for struct tms */
-#include <limits.h> /* for CLK_TCK */
+#include <sys/time.h> /* for struct timeval */
+#include <sys/times.h> /* for struct tms */
+#include <limits.h> /* for CLK_TCK */
-#define RUSAGE_SELF 0
-#define RUSAGE_CHILDREN -1
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
};
-extern int getrusage(int who, struct rusage *rusage);
+extern int getrusage(int who, struct rusage * rusage);
-#endif /* RUSAGESTUB_H */
+#endif /* RUSAGESTUB_H */
diff --git a/src/backend/port/strerror.c b/src/backend/port/strerror.c
index 7ec842e366e..5bcd3cb4527 100644
--- a/src/backend/port/strerror.c
+++ b/src/backend/port/strerror.c
@@ -7,24 +7,23 @@
* modified for ANSI by D'Arcy J.M. Cain
*/
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
-extern const char * const sys_errlist[];
-extern int sys_nerr;
+extern const char *const sys_errlist[];
+extern int sys_nerr;
-const char *
+const char *
strerror(int errnum)
{
- static char buf[24];
+ static char buf[24];
- if (errnum < 0 || errnum > sys_nerr)
- {
- sprintf(buf, "unknown error %d", errnum);
- return(buf);
- }
+ if (errnum < 0 || errnum > sys_nerr)
+ {
+ sprintf(buf, "unknown error %d", errnum);
+ return (buf);
+ }
- return(sys_errlist[errnum]);
+ return (sys_errlist[errnum]);
}
-
diff --git a/src/backend/port/sunos4/float.h b/src/backend/port/sunos4/float.h
index eb9ec5c2a2e..e81d29557fe 100644
--- a/src/backend/port/sunos4/float.h
+++ b/src/backend/port/sunos4/float.h
@@ -1,30 +1,30 @@
/*-------------------------------------------------------------------------
*
* float.h--
- * definitions for ANSI floating point
+ * definitions for ANSI floating point
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: float.h,v 1.1 1997/07/28 00:08:35 momjian Exp $
+ * $Id: float.h,v 1.2 1997/09/07 04:46:58 momjian Exp $
*
* NOTES
- * These come straight out of ANSI X3.159-1989 (p.18) and
- * would be unnecessary if SunOS 4 were ANSI-compliant.
+ * These come straight out of ANSI X3.159-1989 (p.18) and
+ * would be unnecessary if SunOS 4 were ANSI-compliant.
*
- * This is only a partial listing because I'm lazy to type
- * the whole thing in.
+ * This is only a partial listing because I'm lazy to type
+ * the whole thing in.
*
*-------------------------------------------------------------------------
*/
#ifndef FLOAT_H
#define FLOAT_H
-#define FLT_DIG 6
-#define FLT_MIN ((float) 1.17549435e-38)
-#define FLT_MAX ((float) 3.40282347e+38)
-#define DBL_DIG 15
-#define DBL_MIN 2.2250738585072014e-308
-#define DBL_MAX 1.7976931348623157e+308
+#define FLT_DIG 6
+#define FLT_MIN ((float) 1.17549435e-38)
+#define FLT_MAX ((float) 3.40282347e+38)
+#define DBL_DIG 15
+#define DBL_MIN 2.2250738585072014e-308
+#define DBL_MAX 1.7976931348623157e+308
-#endif /* FLOAT_H */
+#endif /* FLOAT_H */
diff --git a/src/backend/port/sunos4/port-protos.h b/src/backend/port/sunos4/port-protos.h
index ce1de05aa02..33ec1e40e93 100644
--- a/src/backend/port/sunos4/port-protos.h
+++ b/src/backend/port/sunos4/port-protos.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for SunOS 4
+ * port-specific prototypes for SunOS 4
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.1 1997/07/28 00:08:39 momjian Exp $
+ * $Id: port-protos.h,v 1.2 1997/09/07 04:47:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,21 +14,21 @@
#define PORT_PROTOS_H
#include <dlfcn.h>
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on SunOS 4.
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
-#define pg_dlopen(f) dlopen(f, 1)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlopen(f) dlopen(f, 1)
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/sunos4/strtol.c b/src/backend/port/sunos4/strtol.c
index 5850848e66a..c788d94bd50 100644
--- a/src/backend/port/sunos4/strtol.c
+++ b/src/backend/port/sunos4/strtol.c
@@ -6,22 +6,22 @@
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -32,8 +32,9 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91";
-#endif /* LIBC_SCCS and not lint */
+static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91";
+
+#endif /* LIBC_SCCS and not lint */
#include <limits.h>
#include <ctype.h>
@@ -50,31 +51,37 @@ static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91";
*/
long
strtol(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- register int base;
+const char *nptr;
+char **endptr;
+register int base;
{
register const char *s = nptr;
register unsigned long acc;
- register int c;
+ register int c;
register unsigned long cutoff;
- register int neg = 0, any, cutlim;
+ register int neg = 0,
+ any,
+ cutlim;
/*
- * Skip white space and pick up leading +/- sign if any.
- * If base is 0, allow 0x for hex and 0 for octal, else
- * assume decimal; if base is already 16, allow 0x.
+ * Skip white space and pick up leading +/- sign if any. If base is 0,
+ * allow 0x for hex and 0 for octal, else assume decimal; if base is
+ * already 16, allow 0x.
*/
- do {
+ do
+ {
c = *s++;
} while (isspace(c));
- if (c == '-') {
+ if (c == '-')
+ {
neg = 1;
c = *s++;
- } else if (c == '+')
+ }
+ else if (c == '+')
c = *s++;
if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
+ c == '0' && (*s == 'x' || *s == 'X'))
+ {
c = s[1];
s += 2;
base = 16;
@@ -83,26 +90,26 @@ strtol(nptr, endptr, base)
base = c == '0' ? 8 : 10;
/*
- * Compute the cutoff value between legal numbers and illegal
- * numbers. That is the largest legal value, divided by the
- * base. An input number that is greater than this value, if
- * followed by a legal input character, is too big. One that
- * is equal to this value may be valid or not; the limit
- * between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for longs is
- * [-2147483648..2147483647] and the input base is 10,
- * cutoff will be set to 214748364 and cutlim to either
- * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
- * a value > 214748364, or equal but the next digit is > 7 (or 8),
- * the number is too big, and we will return a range error.
+ * Compute the cutoff value between legal numbers and illegal numbers.
+ * That is the largest legal value, divided by the base. An input
+ * number that is greater than this value, if followed by a legal
+ * input character, is too big. One that is equal to this value may
+ * be valid or not; the limit between valid and invalid numbers is
+ * then based on the last digit. For instance, if the range for longs
+ * is [-2147483648..2147483647] and the input base is 10, cutoff will
+ * be set to 214748364 and cutlim to either 7 (neg==0) or 8 (neg==1),
+ * meaning that if we have accumulated a value > 214748364, or equal
+ * but the next digit is > 7 (or 8), the number is too big, and we
+ * will return a range error.
*
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
- cutlim = cutoff % (unsigned long)base;
- cutoff /= (unsigned long)base;
- for (acc = 0, any = 0;; c = *s++) {
+ cutoff = neg ? -(unsigned long) LONG_MIN : LONG_MAX;
+ cutlim = cutoff % (unsigned long) base;
+ cutoff /= (unsigned long) base;
+ for (acc = 0, any = 0;; c = *s++)
+ {
if (isdigit(c))
c -= '0';
else if (isalpha(c))
@@ -113,18 +120,21 @@ strtol(nptr, endptr, base)
break;
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
any = -1;
- else {
+ else
+ {
any = 1;
acc *= base;
acc += c;
}
}
- if (any < 0) {
+ if (any < 0)
+ {
acc = neg ? LONG_MIN : LONG_MAX;
errno = ERANGE;
- } else if (neg)
+ }
+ else if (neg)
acc = -acc;
if (endptr != 0)
- *endptr = any ? s - 1 : (char *)nptr;
+ *endptr = any ? s - 1 : (char *) nptr;
return (acc);
}
diff --git a/src/backend/port/svr4/port-protos.h b/src/backend/port/svr4/port-protos.h
index 4b992570acd..1baff088769 100644
--- a/src/backend/port/svr4/port-protos.h
+++ b/src/backend/port/svr4/port-protos.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for Intel x86/Intel SVR4
+ * port-specific prototypes for Intel x86/Intel SVR4
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -14,25 +14,25 @@
#define PORT_PROTOS_H
#include <dlfcn.h>
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on Intel x86/Intel SVR4.
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
#define pg_dlopen(f) dlopen(f,RTLD_LAZY)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
/* port.c */
-extern long random(void);
-extern void srandom(int seed);
+extern long random(void);
+extern void srandom(int seed);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/svr4/port.c b/src/backend/port/svr4/port.c
index 137cebbcbe3..0b38e2c4acd 100644
--- a/src/backend/port/svr4/port.c
+++ b/src/backend/port/svr4/port.c
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * Intel x86/Intel SVR4-specific routines
+ * Intel x86/Intel SVR4-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * /usr/local/devel/pglite/cvs/src/backend/port/svr4/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
+ * /usr/local/devel/pglite/cvs/src/backend/port/svr4/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
*
*-------------------------------------------------------------------------
*/
-#include <math.h> /* for pow() prototype */
+#include <math.h> /* for pow() prototype */
#include <errno.h>
#include "rusagestub.h"
@@ -19,50 +19,54 @@
long
random()
{
- return(lrand48());
+ return (lrand48());
}
void
srandom(int seed)
{
- srand48((long int) seed);
+ srand48((long int) seed);
}
int
-getrusage(int who, struct rusage *rusage)
+getrusage(int who, struct rusage * rusage)
{
- struct tms tms;
- register int tick_rate = CLK_TCK; /* ticks per second */
- clock_t u, s;
+ struct tms tms;
+ register int tick_rate = CLK_TCK; /* ticks per second */
+ clock_t u,
+ s;
- if (rusage == (struct rusage *) NULL) {
- errno = EFAULT;
- return(-1);
- }
- if (times(&tms) < 0) {
- /* errno set by times */
- return(-1);
- }
- switch (who) {
- case RUSAGE_SELF:
- u = tms.tms_utime;
- s = tms.tms_stime;
- break;
- case RUSAGE_CHILDREN:
- u = tms.tms_cutime;
- s = tms.tms_cstime;
- break;
- default:
- errno = EINVAL;
- return(-1);
- }
+ if (rusage == (struct rusage *) NULL)
+ {
+ errno = EFAULT;
+ return (-1);
+ }
+ if (times(&tms) < 0)
+ {
+ /* errno set by times */
+ return (-1);
+ }
+ switch (who)
+ {
+ case RUSAGE_SELF:
+ u = tms.tms_utime;
+ s = tms.tms_stime;
+ break;
+ case RUSAGE_CHILDREN:
+ u = tms.tms_cutime;
+ s = tms.tms_cstime;
+ break;
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
-#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
- rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
- rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
- rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
- rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
- return(0);
+#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
+ rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
+ rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
+ rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ return (0);
}
/*
@@ -78,15 +82,16 @@ getrusage(int who, struct rusage *rusage)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
-#endif /* LIBC_SCCS and not lint */
+static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
+
+#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <string.h>
/*
* This array is designed for mapping upper and lower case letter
- * together for a case independent comparison. The mappings are
+ * together for a case independent comparison. The mappings are
p * based upon ascii character sequences.
*/
static unsigned char charmap[] = {
@@ -127,17 +132,20 @@ static unsigned char charmap[] = {
int
strcasecmp(char *s1, char *s2)
{
- register unsigned char u1, u2;
+ register unsigned char u1,
+ u2;
- for (;;) {
+ for (;;)
+ {
u1 = (unsigned char) *s1++;
u2 = (unsigned char) *s2++;
- if (charmap[u1] != charmap[u2]) {
+ if (charmap[u1] != charmap[u2])
+ {
return charmap[u1] - charmap[u2];
}
- if (u1 == '\0') {
+ if (u1 == '\0')
+ {
return 0;
}
- }
+ }
}
-
diff --git a/src/backend/port/svr4/rusagestub.h b/src/backend/port/svr4/rusagestub.h
index d2393eb792d..5eda998802e 100644
--- a/src/backend/port/svr4/rusagestub.h
+++ b/src/backend/port/svr4/rusagestub.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* rusagestub.h--
- * Stubs for getrusage(3).
+ * Stubs for getrusage(3).
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -13,18 +13,19 @@
#ifndef RUSAGESTUB_H
#define RUSAGESTUB_H
-#include <sys/time.h> /* for struct timeval */
-#include <sys/times.h> /* for struct tms */
-#include <limits.h> /* for CLK_TCK */
+#include <sys/time.h> /* for struct timeval */
+#include <sys/times.h> /* for struct tms */
+#include <limits.h> /* for CLK_TCK */
-#define RUSAGE_SELF 0
-#define RUSAGE_CHILDREN -1
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
};
-extern int getrusage(int who, struct rusage *rusage);
+extern int getrusage(int who, struct rusage * rusage);
-#endif /* RUSAGESTUB_H */
+#endif /* RUSAGESTUB_H */
diff --git a/src/backend/port/ultrix4/dl.h b/src/backend/port/ultrix4/dl.h
index 7855db38f30..56eab754bf4 100644
--- a/src/backend/port/ultrix4/dl.h
+++ b/src/backend/port/ultrix4/dl.h
@@ -1,40 +1,40 @@
/*-------------------------------------------------------------------------
*
* dl.h--
- *
+ *
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: dl.h,v 1.3 1996/11/26 03:18:46 bryanh Exp $
+ * $Id: dl.h,v 1.4 1997/09/07 04:47:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
- * Ultrix 4.x Dynamic Loader Library Version 1.0
+ * Ultrix 4.x Dynamic Loader Library Version 1.0
*
- * dl.h--
- * header file for the Dynamic Loader Library
+ * dl.h--
+ * header file for the Dynamic Loader Library
*
*
- * Copyright (c) 1993 Andrew K. Yu, University of California at Berkeley
- * All rights reserved.
+ * Copyright (c) 1993 Andrew K. Yu, University of California at Berkeley
+ * All rights reserved.
*
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for educational, research, and non-profit purposes and
- * without fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation. Permission
- * to incorporate this software into commercial products can be obtained
- * from the author. The University of California and the author make
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for educational, research, and non-profit purposes and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation. Permission
+ * to incorporate this software into commercial products can be obtained
+ * from the author. The University of California and the author make
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
*
*/
#ifndef _DL_HEADER_
#define _DL_HEADER_
-#include <stdio.h> /* needed to declare FILE for ldfcn.h */
+#include <stdio.h> /* needed to declare FILE for ldfcn.h */
#include <filehdr.h>
#include <syms.h>
#include <ldfcn.h>
@@ -42,77 +42,82 @@
#include <scnhdr.h>
-typedef long CoreAddr;
+typedef long CoreAddr;
-typedef struct ScnInfo {
- CoreAddr addr; /* starting address of the section */
- SCNHDR hdr; /* section header */
- RELOC *relocEntries; /* relocation entries */
-} ScnInfo;
+typedef struct ScnInfo
+{
+ CoreAddr addr; /* starting address of the section */
+ SCNHDR hdr; /* section header */
+ RELOC *relocEntries; /* relocation entries */
+} ScnInfo;
-typedef enum {
- DL_NEEDRELOC, /* still need relocation */
- DL_RELOCATED, /* no relocation necessary */
- DL_INPROG /* relocation in progress */
-} dlRStatus;
+typedef enum
+{
+ DL_NEEDRELOC, /* still need relocation */
+ DL_RELOCATED, /* no relocation necessary */
+ DL_INPROG /* relocation in progress */
+} dlRStatus;
-typedef struct JmpTbl {
- char *block; /* the jump table memory block */
- struct JmpTbl *next; /* next block */
-} JmpTbl;
+typedef struct JmpTbl
+{
+ char *block; /* the jump table memory block */
+ struct JmpTbl *next; /* next block */
+} JmpTbl;
-typedef struct dlFile {
- char *filename; /* file name of the object file */
+typedef struct dlFile
+{
+ char *filename; /* file name of the object file */
- int textSize; /* used by mprotect */
- CoreAddr textAddress; /* start addr of text section */
- long textVaddr; /* vaddr of text section in obj file */
- CoreAddr rdataAddress; /* start addr of rdata section */
- long rdataVaddr; /* vaddr of text section in obj file */
- CoreAddr dataAddress; /* start addr of data section */
- long dataVaddr; /* vaddr of text section in obj file */
- CoreAddr bssAddress; /* start addr of bss section */
- long bssVaddr; /* vaddr of text section in obj file */
+ int textSize; /* used by mprotect */
+ CoreAddr textAddress;/* start addr of text section */
+ long textVaddr; /* vaddr of text section in obj file */
+ CoreAddr rdataAddress; /* start addr of rdata section */
+ long rdataVaddr; /* vaddr of text section in obj file */
+ CoreAddr dataAddress;/* start addr of data section */
+ long dataVaddr; /* vaddr of text section in obj file */
+ CoreAddr bssAddress; /* start addr of bss section */
+ long bssVaddr; /* vaddr of text section in obj file */
- int nsect; /* number of sections */
- ScnInfo *sect; /* details of each section (array) */
+ int nsect; /* number of sections */
+ ScnInfo *sect; /* details of each section (array) */
- int issExtMax; /* size of string space */
- char *extss; /* extern sym string space (in core) */
- int iextMax; /* maximum number of Symbols */
- pEXTR extsyms; /* extern syms */
+ int issExtMax; /* size of string space */
+ char *extss; /* extern sym string space (in core) */
+ int iextMax; /* maximum number of Symbols */
+ pEXTR extsyms; /* extern syms */
- dlRStatus relocStatus; /* what relocation needed? */
- int needReloc;
+ dlRStatus relocStatus;/* what relocation needed? */
+ int needReloc;
- JmpTbl *jmptable; /* the jump table for R_JMPADDR */
+ JmpTbl *jmptable; /* the jump table for R_JMPADDR */
- struct dlFile *next; /* next member of the archive */
-} dlFile;
+ struct dlFile *next; /* next member of the archive */
+} dlFile;
-typedef struct dlSymbol {
- char *name; /* name of the symbol */
- long addr; /* address of the symbol */
- dlFile *objFile; /* from which file */
-} dlSymbol;
+typedef struct dlSymbol
+{
+ char *name; /* name of the symbol */
+ long addr; /* address of the symbol */
+ dlFile *objFile; /* from which file */
+} dlSymbol;
/*
* prototypes for the dl* interface
*/
-extern void *dl_open(/* char *filename, int mode */);
-extern void *dl_sym(/* void *handle, char *name */);
-extern void dl_close(/* void *handle */);
-extern char *dl_error(/* void */);
+extern void *dl_open( /* char *filename, int mode */ );
+extern void *dl_sym( /* void *handle, char *name */ );
+extern void dl_close( /* void *handle */ );
+extern char *dl_error( /* void */ );
-#define DL_LAZY 0 /* lazy resolution */
-#define DL_NOW 1 /* immediate resolution */
+#define DL_LAZY 0 /* lazy resolution */
+#define DL_NOW 1 /* immediate resolution */
/*
* Miscellaneous utility routines:
*/
-extern char **dl_undefinedSymbols(/* int *count */);
-extern void dl_printAllSymbols(/* void *handle */);
-extern void dl_setLibraries(/* char *libs */);
+extern char **dl_undefinedSymbols( /* int *count */ );
+extern void dl_printAllSymbols( /* void *handle */ );
+extern void dl_setLibraries( /* char *libs */ );
-#endif /* _DL_HEADER_ */
+#endif /* _DL_HEADER_ */
diff --git a/src/backend/port/ultrix4/dynloader.c b/src/backend/port/ultrix4/dynloader.c
index 1acc54260a1..d896eebf901 100644
--- a/src/backend/port/ultrix4/dynloader.c
+++ b/src/backend/port/ultrix4/dynloader.c
@@ -1,15 +1,15 @@
/*-------------------------------------------------------------------------
*
* dynloader.c--
- * This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x.
- * (Note that pg_dlsym and pg_dlclose are actually macros defined in
- * "port-protos.h".)
- *
+ * This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x.
+ * (Note that pg_dlsym and pg_dlclose are actually macros defined in
+ * "port-protos.h".)
+ *
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.3 1996/11/26 03:18:50 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.4 1997/09/07 04:47:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,49 +22,54 @@
#include "port-protos.h"
#include "utils/elog.h"
-extern char pg_pathname[];
+extern char pg_pathname[];
-void *
+void *
pg_dlopen(char *filename)
{
- static int dl_initialized= 0;
- void *handle;
+ static int dl_initialized = 0;
+ void *handle;
- /*
- * initializes the dynamic loader with the executable's pathname.
- * (only needs to do this the first time pg_dlopen is called.)
- */
- if (!dl_initialized) {
- if (!dl_init(pg_pathname)) {
- return NULL;
- }
/*
- * if there are undefined symbols, we want dl to search from the
- * following libraries also.
+ * initializes the dynamic loader with the executable's pathname.
+ * (only needs to do this the first time pg_dlopen is called.)
*/
- dl_setLibraries("/usr/lib/libm_G0.a:/usr/lib/libc_G0.a");
- dl_initialized= 1;
- }
+ if (!dl_initialized)
+ {
+ if (!dl_init(pg_pathname))
+ {
+ return NULL;
+ }
- /*
- * open the file. We do the symbol resolution right away so that we
- * will know if there are undefined symbols. (This is in fact the
- * same semantics as "ld -A". ie. you cannot have undefined symbols.
- */
- if ((handle=dl_open(filename, DL_NOW))==NULL) {
- int count;
- char **list= dl_undefinedSymbols(&count);
+ /*
+ * if there are undefined symbols, we want dl to search from the
+ * following libraries also.
+ */
+ dl_setLibraries("/usr/lib/libm_G0.a:/usr/lib/libc_G0.a");
+ dl_initialized = 1;
+ }
- /* list the undefined symbols, if any */
- if(count) {
- elog(NOTICE, "dl: Undefined:");
- while(*list) {
- elog(NOTICE, " %s", *list);
- list++;
- }
+ /*
+ * open the file. We do the symbol resolution right away so that we
+ * will know if there are undefined symbols. (This is in fact the same
+ * semantics as "ld -A". ie. you cannot have undefined symbols.
+ */
+ if ((handle = dl_open(filename, DL_NOW)) == NULL)
+ {
+ int count;
+ char **list = dl_undefinedSymbols(&count);
+
+ /* list the undefined symbols, if any */
+ if (count)
+ {
+ elog(NOTICE, "dl: Undefined:");
+ while (*list)
+ {
+ elog(NOTICE, " %s", *list);
+ list++;
+ }
+ }
}
- }
- return (void *)handle;
+ return (void *) handle;
}
-
diff --git a/src/backend/port/ultrix4/port-protos.h b/src/backend/port/ultrix4/port-protos.h
index 4d4346f16b5..25f49db393d 100644
--- a/src/backend/port/ultrix4/port-protos.h
+++ b/src/backend/port/ultrix4/port-protos.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * prototypes for Ultrix-specific routines
+ * prototypes for Ultrix-specific routines
*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: port-protos.h,v 1.5 1997/02/13 09:53:57 scrappy Exp $
+ * $Id: port-protos.h,v 1.6 1997/09/07 04:47:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,8 +17,8 @@
* Externals in libc that need prototypes (or at least declarations)
*/
-extern char *ecvt(double, int, int*, int*);
-extern char *fcvt(double, int, int*, int*);
+extern char *ecvt(double, int, int *, int *);
+extern char *fcvt(double, int, int *, int *);
/* dynloader.c */
/*
@@ -27,21 +27,21 @@ extern char *fcvt(double, int, int*, int*);
* This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x.
* (Note that pg_dlsym and pg_dlclose are actually macros defined in
* "port-protos.h".)
- */
+ */
#define pg_dlsym(h, f) ((func_ptr)dl_sym(h, f))
#define pg_dlclose(h) dl_close(h)
-#define pg_dlerror() dl_error()
-extern int dl_init(char *);
+#define pg_dlerror() dl_error()
+extern int dl_init(char *);
/* port.c */
-extern int syscall();
+extern int syscall();
-extern void init_address_fixup(void);
+extern void init_address_fixup(void);
/* strdup.c: strdup() is not part of libc on Ultrix */
-extern char* strdup(char const*);
+extern char *strdup(char const *);
/* inet_aton() is not part of libc on Ultrix. The following is from
backend/port/inet_aton.h
@@ -49,6 +49,6 @@ extern char* strdup(char const*);
struct in_addr;
int
-inet_aton(const char *cp, struct in_addr *addr);
+ inet_aton(const char *cp, struct in_addr * addr);
-#endif /* PORT_PORTOS_H */
+#endif /* PORT_PORTOS_H */
diff --git a/src/backend/port/ultrix4/port.c b/src/backend/port/ultrix4/port.c
index 4e6e19bdd0d..b009073f788 100644
--- a/src/backend/port/ultrix4/port.c
+++ b/src/backend/port/ultrix4/port.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * Ultrix-specific routines
+ * Ultrix-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/port.c,v 1.2 1997/02/13 09:53:59 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/port.c,v 1.3 1997/09/07 04:47:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,6 +21,6 @@ void
init_address_fixup()
{
#ifdef NOFIXADE
- syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
-#endif /* NOFIXADE */
+ syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
+#endif /* NOFIXADE */
}
diff --git a/src/backend/port/ultrix4/strdup.c b/src/backend/port/ultrix4/strdup.c
index 882f0047e63..a738e1611ef 100644
--- a/src/backend/port/ultrix4/strdup.c
+++ b/src/backend/port/ultrix4/strdup.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* strdup.c--
- * copies a null-terminated string.
+ * copies a null-terminated string.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/strdup.c,v 1.2 1996/11/26 03:19:04 bryanh Exp $
+ * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/strdup.c,v 1.3 1997/09/07 04:47:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,11 +17,11 @@
#include "port-protos.h"
-char *
-strdup(char const *string)
+char *
+strdup(char const * string)
{
- char *nstr;
+ char *nstr;
- nstr = strcpy((char *)palloc(strlen(string)+1), string);
- return nstr;
+ nstr = strcpy((char *) palloc(strlen(string) + 1), string);
+ return nstr;
}
diff --git a/src/backend/port/univel/frontend-port-protos.h b/src/backend/port/univel/frontend-port-protos.h
index b76feb9d6ca..9ca0100cb90 100644
--- a/src/backend/port/univel/frontend-port-protos.h
+++ b/src/backend/port/univel/frontend-port-protos.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for Intel x86/Intel SVR4
+ * port-specific prototypes for Intel x86/Intel SVR4
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -14,9 +14,9 @@
#define FPORT_PROTOS_H
/* port.c */
-extern long random(void);
-extern void srandom(int seed);
-extern int strcasecmp(char *s1,char *s2);
-extern int gethostname(char *name,int namelen);
+extern long random(void);
+extern void srandom(int seed);
+extern int strcasecmp(char *s1, char *s2);
+extern int gethostname(char *name, int namelen);
-#endif /* FPORT_PROTOS_H */
+#endif /* FPORT_PROTOS_H */
diff --git a/src/backend/port/univel/port-protos.h b/src/backend/port/univel/port-protos.h
index 8c5cfb0f019..c181edfc9ec 100644
--- a/src/backend/port/univel/port-protos.h
+++ b/src/backend/port/univel/port-protos.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
- * port-specific prototypes for Intel x86/Intel SVR4
+ * port-specific prototypes for Intel x86/Intel SVR4
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -14,27 +14,27 @@
#define PORT_PROTOS_H
#include <dlfcn.h>
-#include "fmgr.h" /* for func_ptr */
+#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
/* dynloader.c */
/*
* Dynamic Loader on Intel x86/Intel SVR4.
*
- * this dynamic loader uses the system dynamic loading interface for shared
+ * this dynamic loader uses the system dynamic loading interface for shared
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
* library as the file to be dynamically loaded.
*
*/
#define pg_dlopen(f) dlopen(f,RTLD_LAZY)
-#define pg_dlsym dlsym
-#define pg_dlclose dlclose
-#define pg_dlerror dlerror
+#define pg_dlsym dlsym
+#define pg_dlclose dlclose
+#define pg_dlerror dlerror
/* port.c */
-extern long random(void);
-extern void srandom(int seed);
-extern int strcasecmp(char *s1,char *s2);
-extern int gethostname(char *name,int namelen);
+extern long random(void);
+extern void srandom(int seed);
+extern int strcasecmp(char *s1, char *s2);
+extern int gethostname(char *name, int namelen);
-#endif /* PORT_PROTOS_H */
+#endif /* PORT_PROTOS_H */
diff --git a/src/backend/port/univel/port.c b/src/backend/port/univel/port.c
index 07daeba62c6..d4c7658859e 100644
--- a/src/backend/port/univel/port.c
+++ b/src/backend/port/univel/port.c
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
*
* port.c--
- * Intel x86/Intel SVR4-specific routines
+ * Intel x86/Intel SVR4-specific routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * /usr/local/devel/pglite/cvs/src/backend/port/svr4/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
+ * /usr/local/devel/pglite/cvs/src/backend/port/svr4/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
*
*-------------------------------------------------------------------------
*/
-#include <math.h> /* for pow() prototype */
+#include <math.h> /* for pow() prototype */
#include <errno.h>
#include "rusagestub.h"
@@ -20,50 +20,54 @@
long
random()
{
- return(lrand48());
+ return (lrand48());
}
void
srandom(int seed)
{
- srand48((long int) seed);
+ srand48((long int) seed);
}
int
-getrusage(int who, struct rusage *rusage)
+getrusage(int who, struct rusage * rusage)
{
- struct tms tms;
- register int tick_rate = CLK_TCK; /* ticks per second */
- clock_t u, s;
-
- if (rusage == (struct rusage *) NULL) {
- errno = EFAULT;
- return(-1);
- }
- if (times(&tms) < 0) {
- /* errno set by times */
- return(-1);
- }
- switch (who) {
- case RUSAGE_SELF:
- u = tms.tms_utime;
- s = tms.tms_stime;
- break;
- case RUSAGE_CHILDREN:
- u = tms.tms_cutime;
- s = tms.tms_cstime;
- break;
- default:
- errno = EINVAL;
- return(-1);
- }
+ struct tms tms;
+ register int tick_rate = CLK_TCK; /* ticks per second */
+ clock_t u,
+ s;
+
+ if (rusage == (struct rusage *) NULL)
+ {
+ errno = EFAULT;
+ return (-1);
+ }
+ if (times(&tms) < 0)
+ {
+ /* errno set by times */
+ return (-1);
+ }
+ switch (who)
+ {
+ case RUSAGE_SELF:
+ u = tms.tms_utime;
+ s = tms.tms_stime;
+ break;
+ case RUSAGE_CHILDREN:
+ u = tms.tms_cutime;
+ s = tms.tms_cstime;
+ break;
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
-#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
- rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
- rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
- rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
- rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
- return(0);
+#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
+ rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
+ rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
+ rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
+ return (0);
}
/*
@@ -79,15 +83,16 @@ getrusage(int who, struct rusage *rusage)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
-#endif /* LIBC_SCCS and not lint */
+static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
+
+#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <string.h>
/*
* This array is designed for mapping upper and lower case letter
- * together for a case independent comparison. The mappings are
+ * together for a case independent comparison. The mappings are
p * based upon ascii character sequences.
*/
static unsigned char charmap[] = {
@@ -128,34 +133,38 @@ static unsigned char charmap[] = {
int
strcasecmp(char *s1, char *s2)
{
- register unsigned char u1, u2;
+ register unsigned char u1,
+ u2;
- for (;;) {
+ for (;;)
+ {
u1 = (unsigned char) *s1++;
u2 = (unsigned char) *s2++;
- if (charmap[u1] != charmap[u2]) {
+ if (charmap[u1] != charmap[u2])
+ {
return charmap[u1] - charmap[u2];
}
- if (u1 == '\0') {
+ if (u1 == '\0')
+ {
return 0;
}
- }
+ }
}
#include <sys/utsname.h>
-int gethostname(char *name, int namelen)
+int
+gethostname(char *name, int namelen)
{
static struct utsname mname;
- static int called=0;
+ static int called = 0;
- if(!called)
+ if (!called)
{
called++;
uname(&mname);
}
- strncpy(name,mname.nodename,(SYS_NMLN<namelen?SYS_NMLN:namelen));
+ strncpy(name, mname.nodename, (SYS_NMLN < namelen ? SYS_NMLN : namelen));
- return(0);
+ return (0);
}
-
diff --git a/src/backend/port/univel/rusagestub.h b/src/backend/port/univel/rusagestub.h
index d2393eb792d..5eda998802e 100644
--- a/src/backend/port/univel/rusagestub.h
+++ b/src/backend/port/univel/rusagestub.h
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* rusagestub.h--
- * Stubs for getrusage(3).
+ * Stubs for getrusage(3).
*
*
* Copyright (c) 1994, Regents of the University of California
@@ -13,18 +13,19 @@
#ifndef RUSAGESTUB_H
#define RUSAGESTUB_H
-#include <sys/time.h> /* for struct timeval */
-#include <sys/times.h> /* for struct tms */
-#include <limits.h> /* for CLK_TCK */
+#include <sys/time.h> /* for struct timeval */
+#include <sys/times.h> /* for struct tms */
+#include <limits.h> /* for CLK_TCK */
-#define RUSAGE_SELF 0
-#define RUSAGE_CHILDREN -1
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
};
-extern int getrusage(int who, struct rusage *rusage);
+extern int getrusage(int who, struct rusage * rusage);
-#endif /* RUSAGESTUB_H */
+#endif /* RUSAGESTUB_H */