From: Randy Kunkee Date: Mon, 20 May 1996 18:16:19 -0500 (CDT) Subject: [PG95]: Feedback on postgres95/patches for i386_solaris Here's some patch format files for a port to i386_solaris. This includes a file NEOSOFT-PORT, which you may want exclude, since it is only notes on the obvious. Also needed is to add a line in Makefile.global for i386_solaris. Thanks, it has been a nice experience working on this. We have plugged it into our web browser, via a Tcl interface. Randy Kunkee NeoSoft. Index: NEOSOFT/postgres95/NEOSOFT-PORT diff -c /dev/null NEOSOFT/postgres95/NEOSOFT-PORT:1.1 *** /dev/null Mon May 20 18:09:08 1996 - --- NEOSOFT/postgres95/NEOSOFT-PORT Mon May 20 18:08:04 1996 *************** *** 0 **** - --- 1,43 ---- + Postgres95 was seen by NeoSoft as an economical way to get access + to a relational database (via the Tcl interface provided). In the + process of getting it running, we have built postgres95 on the following + platforms: + sparc_solaris + i386_solaris (added by us) + Freebsd2.1 + BSD/386 + + + In the process of porting Postgres95 to new platforms, we have run into + the following: + + i386_solaris: + + This is the "PORTNAME" we gave to the software for Solaris 2.5 running + under an Intel processor. This was built using GNU tools, we made the + following changes to the source to make it compile: + + 1. Removed definition of HAS_TEST_AND_SET in backend/storage/ipc.h. + This is an optimization for in-core spin locks, and probably is a + performance hit, but it was the easy way to make it work. + + 2. Borrowed from various PORTNAME_bsdi'isms to make other things work. + Files affected were + backend/storage/ipc/ipc.c + backend/storage/lmgr/proc.c + backend/utils/adt/float.c + backend/utils/adt/nabstime.c + + 3. Created a backend/port directory containing + port/i386_solaris/Makefile.inc + port/i386_solaris/machine.h + port/i386_solaris/port-protos.h + port/i386_solaris/port.c + port/i386_solaris/rusagestub.h + + For another port, I had to change several // style comments to /* */ style + to get it to compile. Don't know why, because this was gcc in both cases, + but that's the way it was. + + Randy Kunkee + NeoSoft, Inc. Index: NEOSOFT/postgres95/src/backend/port/i386_solaris/Makefile.inc diff -c /dev/null NEOSOFT/postgres95/src/backend/port/i386_solaris/Makefile.inc:1.1 *** /dev/null Mon May 20 18:09:56 1996 - --- NEOSOFT/postgres95/src/backend/port/i386_solaris/Makefile.inc Mon May 20 17:37:13 1996 *************** *** 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: /usr/cvs/NEOSOFT/postgres95/src/backend/port/i386_solaris/Makefile.inc,v 1.1 1996/05/20 22:37:13 kunkee 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 Index: NEOSOFT/postgres95/src/backend/port/i386_solaris/machine.h diff -c /dev/null NEOSOFT/postgres95/src/backend/port/i386_solaris/machine.h:1.1 *** /dev/null Mon May 20 18:09:57 1996 - --- NEOSOFT/postgres95/src/backend/port/i386_solaris/machine.h Mon May 20 17:37:14 1996 *************** *** 0 **** - --- 1,19 ---- + /*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1 1996/05/20 22:37:14 kunkee Exp $ + * + *------------------------------------------------------------------------- + */ + #ifndef MACHINE_H + #define MACHINE_H + + #define BLCKSZ 8192 + + #endif + Index: NEOSOFT/postgres95/src/backend/port/i386_solaris/port-protos.h diff -c /dev/null NEOSOFT/postgres95/src/backend/port/i386_solaris/port-protos.h:1.1 *** /dev/null Mon May 20 18:09:58 1996 - --- NEOSOFT/postgres95/src/backend/port/i386_solaris/port-protos.h Mon May 20 17:37:16 1996 *************** *** 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/05/20 22:37:16 kunkee 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 */ Index: NEOSOFT/postgres95/src/backend/port/i386_solaris/port.c diff -c /dev/null NEOSOFT/postgres95/src/backend/port/i386_solaris/port.c:1.1 *** /dev/null Mon May 20 18:09:59 1996 - --- NEOSOFT/postgres95/src/backend/port/i386_solaris/port.c Mon May 20 17:37:17 1996 *************** *** 0 **** - --- 1,66 ---- + /*------------------------------------------------------------------------- + * + * port.c-- + * SunOS5-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/port/i386_solaris/port.c,v 1.1 1996/05/20 22:37:17 kunkee 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); + } Index: NEOSOFT/postgres95/src/backend/port/i386_solaris/rusagestub.h diff -c /dev/null NEOSOFT/postgres95/src/backend/port/i386_solaris/rusagestub.h:1.1 *** /dev/null Mon May 20 18:10:01 1996 - --- NEOSOFT/postgres95/src/backend/port/i386_solaris/rusagestub.h Mon May 20 17:37:18 1996 *************** *** 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/05/20 22:37:18 kunkee 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 */ Index: NEOSOFT/postgres95/src/backend/storage/ipc.h diff -c NEOSOFT/postgres95/src/backend/storage/ipc.h:1.1.1.1 NEOSOFT/postgres95/src/backend/storage/ipc.h:1.2 *** NEOSOFT/postgres95/src/backend/storage/ipc.h:1.1.1.1 Fri Apr 19 05:29:01 1996 - --- NEOSOFT/postgres95/src/backend/storage/ipc.h Mon May 20 17:37:22 1996 *************** *** 6,12 **** * * Copyright (c) 1994, Regents of the University of California * ! * $Id: ipc.h,v 1.1.1.1 1996/04/19 10:29:01 karl Exp $ * * NOTES * This file is very architecture-specific. This stuff should actually - --- 6,12 ---- * * Copyright (c) 1994, Regents of the University of California * ! * $Id: ipc.h,v 1.2 1996/05/20 22:37:22 kunkee Exp $ * * NOTES * This file is very architecture-specific. This stuff should actually *************** *** 30,43 **** * atomic test-and-set instruction). However, we have only written * spinlock code for the architectures listed. */ ! #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__)) #define HAS_TEST_AND_SET #endif - --- 30,44 ---- * atomic test-and-set instruction). However, we have only written * spinlock code for the architectures listed. */ ! #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(PORTNAME_i386_solaris) #define HAS_TEST_AND_SET #endif Index: NEOSOFT/postgres95/src/backend/storage/ipc/ipc.c diff -c NEOSOFT/postgres95/src/backend/storage/ipc/ipc.c:1.1.1.1 NEOSOFT/postgres95/src/backend/storage/ipc/ipc.c:1.2 *** NEOSOFT/postgres95/src/backend/storage/ipc/ipc.c:1.1.1.1 Fri Apr 19 05:29:03 1996 - --- NEOSOFT/postgres95/src/backend/storage/ipc/ipc.c Mon May 20 17:37:24 1996 *************** *** 7,13 **** * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/storage/ipc/ipc.c,v 1.1.1.1 1996/04/19 10:29:03 karl Exp $ * * NOTES * - --- 7,13 ---- * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/storage/ipc/ipc.c,v 1.2 1996/05/20 22:37:24 kunkee Exp $ * * NOTES * *************** *** 47,53 **** int UsePrivateMemory = 0; #endif ! #if defined(PORTNAME_bsdi) /* hacka, hacka, hacka (XXX) */ union semun { int val; /* value for SETVAL */ - --- 47,53 ---- int UsePrivateMemory = 0; #endif ! #if defined(PORTNAME_bsdi)||defined(PORTNAME_i386_solaris) /* hacka, hacka, hacka (XXX) */ union semun { int val; /* value for SETVAL */ Index: NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c diff -c NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c:1.1.1.1 NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c:1.2 *** NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c:1.1.1.1 Fri Apr 19 05:29:07 1996 - --- NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c Mon May 20 17:37:26 1996 *************** *** 7,13 **** * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c,v 1.1.1.1 1996/04/19 10:29:07 karl Exp $ * *------------------------------------------------------------------------- */ - --- 7,13 ---- * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c,v 1.2 1996/05/20 22:37:26 kunkee Exp $ * *------------------------------------------------------------------------- */ *************** *** 46,52 **** * This is so that we can support more backends. (system-wide semaphore * sets run out pretty fast.) -ay 4/95 * ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c,v 1.1.1.1 1996/04/19 10:29:07 karl Exp $ */ #include #ifndef WIN32 - --- 46,52 ---- * This is so that we can support more backends. (system-wide semaphore * sets run out pretty fast.) -ay 4/95 * ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/storage/lmgr/proc.c,v 1.2 1996/05/20 22:37:26 kunkee Exp $ */ #include #ifndef WIN32 *************** *** 56,62 **** #include #include "libpq/pqsignal.h" /* substitute for */ ! #if defined(PORTNAME_bsdi) /* hacka, hacka, hacka (XXX) */ union semun { int val; /* value for SETVAL */ - --- 56,62 ---- #include #include "libpq/pqsignal.h" /* substitute for */ ! #if defined(PORTNAME_bsdi)||defined(PORTNAME_i386_solaris) /* hacka, hacka, hacka (XXX) */ union semun { int val; /* value for SETVAL */ Index: NEOSOFT/postgres95/src/backend/utils/adt/float.c diff -c NEOSOFT/postgres95/src/backend/utils/adt/float.c:1.1.1.1 NEOSOFT/postgres95/src/backend/utils/adt/float.c:1.2 *** NEOSOFT/postgres95/src/backend/utils/adt/float.c:1.1.1.1 Fri Apr 19 05:29:15 1996 - --- NEOSOFT/postgres95/src/backend/utils/adt/float.c Mon May 20 17:37:28 1996 *************** *** 7,13 **** * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/utils/adt/float.c,v 1.1.1.1 1996/04/19 10:29:15 karl Exp $ * *------------------------------------------------------------------------- */ - --- 7,13 ---- * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/utils/adt/float.c,v 1.2 1996/05/20 22:37:28 kunkee Exp $ * *------------------------------------------------------------------------- */ *************** *** 1275,1281 **** } #endif /* PORTNAME_alpha */ ! #if defined(PORTNAME_sparc_solaris) #include static int isinf(d) - --- 1275,1281 ---- } #endif /* PORTNAME_alpha */ ! #if defined(PORTNAME_sparc_solaris)||defined(PORTNAME_i386_solaris) #include static int isinf(d) Index: NEOSOFT/postgres95/src/backend/utils/adt/nabstime.c diff -c NEOSOFT/postgres95/src/backend/utils/adt/nabstime.c:1.1.1.1 NEOSOFT/postgres95/src/backend/utils/adt/nabstime.c:1.2 *** NEOSOFT/postgres95/src/backend/utils/adt/nabstime.c:1.1.1.1 Fri Apr 19 05:29:16 1996 - --- NEOSOFT/postgres95/src/backend/utils/adt/nabstime.c Mon May 20 17:37:30 1996 *************** *** 7,13 **** * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/utils/adt/nabstime.c,v 1.1.1.1 1996/04/19 10:29:16 karl Exp $ * *------------------------------------------------------------------------- */ - --- 7,13 ---- * * * IDENTIFICATION ! * $Header: /usr/cvs/NEOSOFT/postgres95/src/backend/utils/adt/nabstime.c,v 1.2 1996/05/20 22:37:30 kunkee Exp $ * *------------------------------------------------------------------------- */ *************** *** 295,301 **** defined(PORTNAME_aix) || \ defined(PORTNAME_irix5) || \ defined(WIN32) || \ ! defined(PORTNAME_sparc_solaris) tzset(); #ifndef WIN32 *tzp = timezone / 60; /* this is an X/Open-ism */ - --- 295,301 ---- defined(PORTNAME_aix) || \ defined(PORTNAME_irix5) || \ defined(WIN32) || \ ! defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i386_solaris) tzset(); #ifndef WIN32 *tzp = timezone / 60; /* this is an X/Open-ism */ Index: NEOSOFT/postgres95/src/mk/port/postgres.mk.i386_solaris diff -c /dev/null NEOSOFT/postgres95/src/mk/port/postgres.mk.i386_solaris:1.1 *** /dev/null Mon May 20 18:10:45 1996 - --- NEOSOFT/postgres95/src/mk/port/postgres.mk.i386_solaris Mon May 20 18:05:20 1996 *************** *** 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/05/20 23:05:20 kunkee 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)/$(