From: Dan McGuirk Date: Wed, 1 May 1996 13:12:30 -0700 (MST) Subject: [PG95]: postgres95 for Solaris x86 patch Here are the minor changes I had to make to postgres95-1.01 to create an 'i486-solaris' port type (Solaris x86 2.4 using gcc 2.6.3). Content-Description: diff -urN postgres95.orig/src/Makefile.global postgres95/src/Makefile.global --- postgres95.orig/src/Makefile.global Mon Feb 26 12:26:32 1996 +++ postgres95/src/Makefile.global Wed May 1 12:09:54 1996 @@ -36,6 +36,7 @@ # alpha - DEC Alpha AXP on OSF/1 2.0 # hpux - HP PA-RISC on HP-UX 9.0 # sparc_solaris - SUN SPARC on Solaris 2.4 +# i486_solaris - Solaris x86 2.4 with gcc # sparc - SUN SPARC on SunOS 4.1.3 # ultrix4 - DEC MIPS on Ultrix 4.4 # linux - Intel x86 on Linux 1.2 and Linux ELF @@ -56,7 +57,7 @@ # until after this file is processed! # make sure that you have no whitespaces after the PORTNAME setting # or the makefiles can get confused -PORTNAME= alpha +PORTNAME= i486_solaris # POSTGRESLOGIN is the login name of the user who gets special # privileges within the database. By default it is "postgres", but @@ -68,10 +69,10 @@ # For convenience, POSTGRESDIR is where DATADIR, BINDIR, and LIBDIR # and other target destinations are rooted. Of course, each of these is # changable separately. -POSTGRESDIR= /private/postgres95 +POSTGRESDIR= /export/home/postgres # SRCDIR specifies where the source files are. -SRCDIR= $(POSTGRESDIR)/src +SRCDIR= /export/home/djm/postgres95/src # DATADIR specifies where the postmaster expects to find its database. # This may be overridden by command line options or the PGDATA environment @@ -131,7 +132,7 @@ # Comment out CDEBUG to turn off debugging and sanity-checking. # # XXX on MIPS, use -g3 if you want to compile with -O -CDEBUG= -g +CDEBUG= -O2 # turn this on if you prefer European style dates instead of American # style dates diff -urN postgres95.orig/src/backend/port/i486_solaris/Makefile.inc postgres95/src/backend/port/i486_solaris/Makefile.inc --- postgres95.orig/src/backend/port/i486_solaris/Makefile.inc Wed Dec 31 17:00:00 1969 +++ postgres95/src/backend/port/i486_solaris/Makefile.inc Wed May 1 12:34:40 1996 @@ -0,0 +1,24 @@ +# i486_solaris Makefile.inc +# modified by Dan McGuirk + +#------------------------------------------------------------------------- +# +# 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/local/devel/pglite/cvs/src/backend/port/sparc_solaris/Makefile.inc,v 1.3 1995/03/21 06:51:21 andrew 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 -urN postgres95.orig/src/backend/port/i486_solaris/machine.h postgres95/src/backend/port/i486_solaris/machine.h --- postgres95.orig/src/backend/port/i486_solaris/machine.h Wed Dec 31 17:00:00 1969 +++ postgres95/src/backend/port/i486_solaris/machine.h Wed May 1 12:05:35 1996 @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1994/11/07 05:19:38 andrew Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff -urN postgres95.orig/src/backend/port/i486_solaris/port-protos.h postgres95/src/backend/port/i486_solaris/port-protos.h --- postgres95.orig/src/backend/port/i486_solaris/port-protos.h Wed Dec 31 17:00:00 1969 +++ postgres95/src/backend/port/i486_solaris/port-protos.h Wed May 1 12:05:35 1996 @@ -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.2 1995/03/17 06:40:18 andrew 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 -urN postgres95.orig/src/backend/port/i486_solaris/port.c postgres95/src/backend/port/i486_solaris/port.c --- postgres95.orig/src/backend/port/i486_solaris/port.c Wed Dec 31 17:00:00 1969 +++ postgres95/src/backend/port/i486_solaris/port.c Wed May 1 12:05:35 1996 @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- + * + * port.c-- + * SunOS5-specific routines + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /usr/local/devel/pglite/cvs/src/backend/port/sparc_solaris/port.c,v 1.2 1995/03/17 06:40:19 andrew 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 -urN postgres95.orig/src/backend/port/i486_solaris/rusagestub.h postgres95/src/backend/port/i486_solaris/rusagestub.h --- postgres95.orig/src/backend/port/i486_solaris/rusagestub.h Wed Dec 31 17:00:00 1969 +++ postgres95/src/backend/port/i486_solaris/rusagestub.h Wed May 1 12:05:35 1996 @@ -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.1.1 1994/11/07 05:19:39 andrew 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 -urN postgres95.orig/src/backend/storage/buf_internals.h postgres95/src/backend/storage/buf_internals.h --- postgres95.orig/src/backend/storage/buf_internals.h Fri Feb 23 17:40:43 1996 +++ postgres95/src/backend/storage/buf_internals.h Wed May 1 12:20:57 1996 @@ -138,7 +138,7 @@ #if defined(PORTNAME_ultrix4) char sb_pad[60]; /* no slock_t */ #endif /* mips */ -#if defined(PORTNAME_sparc) || defined(PORTNAME_sparc_solaris) || defined(PORTNAME_irix5) +#if defined(PORTNAME_sparc) || defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) || defined(PORTNAME_irix5) char sb_pad[56]; /* has slock_t */ #endif /* sparc || irix5 */ #if defined(PORTNAME_hpux) diff -urN postgres95.orig/src/backend/storage/ipc/s_lock.c postgres95/src/backend/storage/ipc/s_lock.c --- postgres95.orig/src/backend/storage/ipc/s_lock.c Mon Feb 26 12:24:03 1996 +++ postgres95/src/backend/storage/ipc/s_lock.c Wed May 1 12:21:39 1996 @@ -159,11 +159,27 @@ * Solaris 2 */ +#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) + #if defined(PORTNAME_sparc_solaris) +/* for sparc, this is... */ /* defined in port/.../tas.s */ extern int tas(slock_t *lock); +#else + +/* for intel, we can use the linux version of tas */ +int +tas(slock_t *m) +{ + slock_t res; + __asm__("xchgb %0,%1":"=q" (res),"=m" (*m):"0" (0x1)); + return(res); +} + +#endif + void S_LOCK(slock_t *lock) { @@ -266,7 +282,7 @@ * sun3 */ -#if (defined(sun) && ! defined(sparc)) +#if (defined(sun) && ! defined(sparc) && ! defined(__i386__)) void S_LOCK(slock_t *lock) diff -urN postgres95.orig/src/backend/storage/ipc.h postgres95/src/backend/storage/ipc.h --- postgres95.orig/src/backend/storage/ipc.h Fri Feb 23 17:40:45 1996 +++ postgres95/src/backend/storage/ipc.h Wed May 1 12:20:31 1996 @@ -37,6 +37,7 @@ defined(PORTNAME_next) || \ defined(PORTNAME_sparc) || \ defined(PORTNAME_sparc_solaris) || \ + defined(PORTNAME_i486_solaris) || \ (defined(__i386__) && defined(__GNUC__)) #define HAS_TEST_AND_SET #endif @@ -108,6 +109,7 @@ defined(PORTNAME_alpha) || \ defined(PORTNAME_hpux) || \ defined(PORTNAME_sparc_solaris) || \ + defined(PORTNAME_i486_solaris) || \ defined(WIN32) || \ defined(PORTNAME_ultrix4) union semun { diff -urN postgres95.orig/src/backend/utils/adt/float.c postgres95/src/backend/utils/adt/float.c --- postgres95.orig/src/backend/utils/adt/float.c Fri Feb 23 18:03:10 1996 +++ postgres95/src/backend/utils/adt/float.c Wed May 1 12:27:57 1996 @@ -1275,7 +1275,7 @@ } #endif /* PORTNAME_alpha */ -#if defined(PORTNAME_sparc_solaris) +#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) #include static int isinf(d) @@ -1294,7 +1294,7 @@ return (0); } -#endif /* PORTNAME_sparc_solaris */ +#endif /* PORTNAME_sparc_solaris || PORTNAME_i486_solaris */ #if defined(PORTNAME_irix5) #include diff -urN postgres95.orig/src/backend/utils/adt/nabstime.c postgres95/src/backend/utils/adt/nabstime.c --- postgres95.orig/src/backend/utils/adt/nabstime.c Fri Feb 23 18:03:14 1996 +++ postgres95/src/backend/utils/adt/nabstime.c Wed May 1 12:31:52 1996 @@ -295,14 +295,15 @@ defined(PORTNAME_aix) || \ defined(PORTNAME_irix5) || \ defined(WIN32) || \ - defined(PORTNAME_sparc_solaris) + defined(PORTNAME_sparc_solaris) || \ + defined(PORTNAME_i486_solaris) tzset(); #ifndef WIN32 *tzp = timezone / 60; /* this is an X/Open-ism */ #else *tzp = _timezone / 60; /* this is an X/Open-ism */ #endif /* WIN32 */ -#else /* PORTNAME_hpux || PORTNAME_aix || PORTNAME_sparc_solaris || PORTNAME_irix5 */ +#else /* PORTNAME_hpux || PORTNAME_aix || PORTNAME_sparc_solaris || PORTNAME_i486_solaris || PORTNAME_irix5 */ time_t now = time((time_t *) NULL); struct tm *tmnow = localtime(&now); diff -urN postgres95.orig/src/bin/monitor/monitor.c postgres95/src/bin/monitor/monitor.c --- postgres95.orig/src/bin/monitor/monitor.c Mon Feb 26 14:19:58 1996 +++ postgres95/src/bin/monitor/monitor.c Wed May 1 12:29:24 1996 @@ -20,7 +20,7 @@ #ifndef WIN32 #include #endif -#ifdef PORTNAME_sparc_solaris +#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) #include /* for MAXHOSTNAMELEN on some */ #endif #include diff -urN postgres95.orig/src/bin/pg4_dump/common.c postgres95/src/bin/pg4_dump/common.c --- postgres95.orig/src/bin/pg4_dump/common.c Mon Jul 24 17:29:46 1995 +++ postgres95/src/bin/pg4_dump/common.c Wed May 1 12:29:45 1996 @@ -16,7 +16,7 @@ #include #include #include /* for MAXHOSTNAMELEN on most */ -#ifdef PORTNAME_sparc_solaris +#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) #include /* for MAXHOSTNAMELEN on some */ #endif diff -urN postgres95.orig/src/bin/pg4_dump/pg4_dump.c postgres95/src/bin/pg4_dump/pg4_dump.c --- postgres95.orig/src/bin/pg4_dump/pg4_dump.c Mon Jul 24 17:29:47 1995 +++ postgres95/src/bin/pg4_dump/pg4_dump.c Wed May 1 12:30:03 1996 @@ -28,7 +28,7 @@ #include #include #include /* for MAXHOSTNAMELEN on most */ -#ifdef PORTNAME_sparc_solaris +#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) #include /* for MAXHOSTNAMELEN on some */ #endif diff -urN postgres95.orig/src/bin/pg_dump/common.c postgres95/src/bin/pg_dump/common.c --- postgres95.orig/src/bin/pg_dump/common.c Fri Feb 23 18:13:10 1996 +++ postgres95/src/bin/pg_dump/common.c Wed May 1 12:30:20 1996 @@ -16,7 +16,7 @@ #include #include #include /* for MAXHOSTNAMELEN on most */ -#ifdef PORTNAME_sparc_solaris +#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) #include /* for MAXHOSTNAMELEN on some */ #endif diff -urN postgres95.orig/src/bin/pg_dump/pg_dump.c postgres95/src/bin/pg_dump/pg_dump.c --- postgres95.orig/src/bin/pg_dump/pg_dump.c Fri Feb 23 18:09:39 1996 +++ postgres95/src/bin/pg_dump/pg_dump.c Wed May 1 12:30:31 1996 @@ -30,7 +30,7 @@ #include #include #include /* for MAXHOSTNAMELEN on most */ -#ifdef PORTNAME_sparc_solaris +#if defined(PORTNAME_sparc_solaris) || defined(PORTNAME_i486_solaris) #include /* for MAXHOSTNAMELEN on some */ #endif diff -urN postgres95.orig/src/mk/port/postgres.mk.i486_solaris postgres95/src/mk/port/postgres.mk.i486_solaris --- postgres95.orig/src/mk/port/postgres.mk.i486_solaris Wed Dec 31 17:00:00 1969 +++ postgres95/src/mk/port/postgres.mk.i486_solaris Wed May 1 12:35:07 1996 @@ -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.sparc_solaris,v 1.5 1995/04/30 07:51:21 andrew Exp $ +# +#------------------------------------------------------------------------- +ifndef MK_PORT +MK_PORT= sparc_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)/$(