From ffae4ebde91a894d381a4b7fa9671fe83f08db3f Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Sat, 20 Jul 1996 08:36:33 +0000 Subject: [PATCH] Brought in NEOSOFT's port to i386_solaris Submitted by: Randy Kunkee --- src/Makefile.global | 3 +- src/backend/port/i386_solaris/Makefile.inc | 20 +++++++ src/backend/port/i386_solaris/machine.h | 19 ++++++ src/backend/port/i386_solaris/port-protos.h | 38 ++++++++++++ src/backend/port/i386_solaris/port.c | 66 +++++++++++++++++++++ src/backend/port/i386_solaris/rusagestub.h | 30 ++++++++++ src/backend/storage/ipc.h | 7 ++- src/backend/storage/ipc/ipc.c | 4 +- src/backend/storage/lmgr/proc.c | 6 +- src/backend/utils/adt/float.c | 4 +- src/backend/utils/adt/nabstime.c | 4 +- src/mk/port/postgres.mk.i386_solaris | 57 ++++++++++++++++++ 12 files changed, 245 insertions(+), 13 deletions(-) create mode 100644 src/backend/port/i386_solaris/Makefile.inc create mode 100644 src/backend/port/i386_solaris/machine.h create mode 100644 src/backend/port/i386_solaris/port-protos.h create mode 100644 src/backend/port/i386_solaris/port.c create mode 100644 src/backend/port/i386_solaris/rusagestub.h create mode 100644 src/mk/port/postgres.mk.i386_solaris diff --git a/src/Makefile.global b/src/Makefile.global index b09925c6ab..e0fa0f29e2 100644 --- a/src/Makefile.global +++ b/src/Makefile.global @@ -7,7 +7,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/Attic/Makefile.global,v 1.7 1996/07/20 07:57:49 scrappy Exp $ +# $Header: /cvsroot/pgsql/src/Attic/Makefile.global,v 1.8 1996/07/20 08:34:08 scrappy Exp $ # # NOTES # This is seen by any Makefiles that include mk/postgres.mk. To @@ -35,6 +35,7 @@ # The name of the port. Valid choices are: # alpha - DEC Alpha AXP on OSF/1 2.0 # hpux - HP PA-RISC on HP-UX 9.0 +# i386_solaris - i386 Solaris # sparc_solaris - SUN SPARC on Solaris 2.4 # sparc - SUN SPARC on SunOS 4.1.3 # ultrix4 - DEC MIPS on Ultrix 4.4 diff --git a/src/backend/port/i386_solaris/Makefile.inc b/src/backend/port/i386_solaris/Makefile.inc new file mode 100644 index 0000000000..927010d611 --- /dev/null +++ b/src/backend/port/i386_solaris/Makefile.inc @@ -0,0 +1,20 @@ +#------------------------------------------------------------------------- +# +# Makefile.inc-- +# Makefile for port/sparc_solaris (SPARC/Solaris 2.x specific stuff) +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/port/i386_solaris/Attic/Makefile.inc,v 1.1 1996/07/20 08:34:32 scrappy Exp $ +# +#------------------------------------------------------------------------- + +CFLAGS+= -DUSE_POSIX_TIME -DNEED_ISINF -DNEED_RUSAGE -DNO_EMPTY_STMTS + +LDADD+= -ll -ldl + +SUBSRCS+= port.c + +HEADERS+= machine.h port-protos.h rusagestub.h diff --git a/src/backend/port/i386_solaris/machine.h b/src/backend/port/i386_solaris/machine.h new file mode 100644 index 0000000000..c8cc81b358 --- /dev/null +++ b/src/backend/port/i386_solaris/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1 1996/07/20 08:34:33 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/i386_solaris/port-protos.h b/src/backend/port/i386_solaris/port-protos.h new file mode 100644 index 0000000000..45e56ad1e7 --- /dev/null +++ b/src/backend/port/i386_solaris/port-protos.h @@ -0,0 +1,38 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * 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 $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include +#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 + * 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 + +/* port.c */ +extern long random(void); +extern void srandom(int seed); + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/i386_solaris/port.c b/src/backend/port/i386_solaris/port.c new file mode 100644 index 0000000000..c6fcdab98e --- /dev/null +++ b/src/backend/port/i386_solaris/port.c @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * 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 $ + * + *------------------------------------------------------------------------- + */ +#include /* for pow() prototype */ + +#include +#include "rusagestub.h" + +long +random() +{ + return(lrand48()); +} + +void +srandom(int seed) +{ + srand48((long int) seed); +} + +int +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); + } +#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); +} diff --git a/src/backend/port/i386_solaris/rusagestub.h b/src/backend/port/i386_solaris/rusagestub.h new file mode 100644 index 0000000000..0ad45fafaa --- /dev/null +++ b/src/backend/port/i386_solaris/rusagestub.h @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * + * rusagestub.h-- + * 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 $ + * + *------------------------------------------------------------------------- + */ +#ifndef RUSAGESTUB_H +#define RUSAGESTUB_H + +#include /* for struct timeval */ +#include /* for struct tms */ +#include /* for CLK_TCK */ + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN -1 + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ +}; + +extern int getrusage(int who, struct rusage *rusage); + +#endif /* RUSAGESTUB_H */ diff --git a/src/backend/storage/ipc.h b/src/backend/storage/ipc.h index 0da041bc9c..36cb3c8f62 100644 --- a/src/backend/storage/ipc.h +++ b/src/backend/storage/ipc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: ipc.h,v 1.1.1.1 1996/07/09 06:21:52 scrappy Exp $ + * $Id: ipc.h,v 1.2 1996/07/20 08:35:24 scrappy Exp $ * * NOTES * This file is very architecture-specific. This stuff should actually @@ -30,14 +30,15 @@ * atomic test-and-set instruction). However, we have only written * spinlock code for the architectures listed. */ -#if defined(PORTNAME_aix) || \ +#if (defined(PORTNAME_aix) || \ defined(PORTNAME_alpha) || \ defined(PORTNAME_hpux) || \ defined(PORTNAME_irix5) || \ defined(PORTNAME_next) || \ defined(PORTNAME_sparc) || \ defined(PORTNAME_sparc_solaris) || \ - (defined(__i386__) && defined(__GNUC__)) + (defined(__i386__) && defined(__GNUC__))) && \ + !defined(PORTNAME_i386_solaris) #define HAS_TEST_AND_SET #endif diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index 306300b90c..0ccccd78fc 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.1.1.1 1996/07/09 06:21:54 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.2 1996/07/20 08:35:52 scrappy Exp $ * * NOTES * @@ -47,7 +47,7 @@ int UsePrivateMemory = 1; int UsePrivateMemory = 0; #endif -#if defined(PORTNAME_bsdi) +#if defined(PORTNAME_bsdi)||defined(PORTNAME_i386_solaris) /* hacka, hacka, hacka (XXX) */ union semun { int val; /* value for SETVAL */ diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 0955cdfc2f..10dad600b5 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.1.1.1 1996/07/09 06:21:57 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.2 1996/07/20 08:35:58 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ * This is so that we can support more backends. (system-wide semaphore * sets run out pretty fast.) -ay 4/95 * - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.1.1.1 1996/07/09 06:21:57 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.2 1996/07/20 08:35:58 scrappy Exp $ */ #include #ifndef WIN32 @@ -56,7 +56,7 @@ #include #include "libpq/pqsignal.h" /* substitute for */ -#if defined(PORTNAME_bsdi) +#if defined(PORTNAME_bsdi)||defined(PORTNAME_i386_solaris) /* hacka, hacka, hacka (XXX) */ union semun { int val; /* value for SETVAL */ diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index ef962e7136..f4b3bef543 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.1.1.1 1996/07/09 06:22:04 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.2 1996/07/20 08:36:17 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -1275,7 +1275,7 @@ static int isinf(x) } #endif /* PORTNAME_alpha */ -#if defined(PORTNAME_sparc_solaris) +#if defined(PORTNAME_sparc_solaris)||defined(PORTNAME_i386_solaris) #include static int isinf(d) diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index fa66ff5fa4..8bf212bb19 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.1.1.1 1996/07/09 06:22:04 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.2 1996/07/20 08:36:19 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -295,7 +295,7 @@ tryabsdate(char *fields[], int nf, struct tm *tm, int *tzp) defined(PORTNAME_aix) || \ defined(PORTNAME_irix5) || \ defined(WIN32) || \ - defined(PORTNAME_sparc_solaris) + defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i386_solaris) tzset(); #ifndef WIN32 *tzp = timezone / 60; /* this is an X/Open-ism */ diff --git a/src/mk/port/postgres.mk.i386_solaris b/src/mk/port/postgres.mk.i386_solaris new file mode 100644 index 0000000000..f5c3dce7d7 --- /dev/null +++ b/src/mk/port/postgres.mk.i386_solaris @@ -0,0 +1,57 @@ +#------------------------------------------------------------------------- +# +# postgres.mk.sparc_solaris-- +# SUN SPARC/solaris specific rules and variables +# +# Copyright (c) 1994-5, Regents of the University of California +# +# $Id: postgres.mk.i386_solaris,v 1.1 1996/07/20 08:36:33 scrappy Exp $ +# +#------------------------------------------------------------------------- +ifndef MK_PORT +MK_PORT= i386_solaris + +# cc won't work! +CC= gcc + +# +# for postgres.mk +# +CFLAGS_BE+= -DUSE_POSIX_SIGNALS + +# RANLIB is not used on solaris +RANLIB=touch + +INSTALL=/usr/ucb/install + +# +# Random things that must be passed everywhere to enable +# everything to compile. :-/ +# +# The extra -I flag is to scoop up extra BSD-emulating headers. +CFLAGS_BE+= -DSYSV_DIRENT -I$(POSTGRESDIR)/src/backend/port/sparc_solaris +LDADD_BE+= -lsocket -lnsl + +LD_ADD+= $(LDADD_BE) + +# +# for postgres.user.mk +# +ifeq ($(CC), cc) +CFLAGS_SL= -K PIC +else +CFLAGS_SL= -fPIC +endif + +SLSUFF= .so + +%.so: %.o + $(LD) -G -Bdynamic -o $(objdir)/$(@F) $(objdir)/$(