diff options
author | Marc G. Fournier <scrappy@hub.org> | 1996-07-09 06:22:35 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1996-07-09 06:22:35 +0000 |
commit | d31084e9d1118b25fd16580d9d8c2924b5740dff (patch) | |
tree | 3179e66307d54df9c7b966543550e601eb55e668 /src/backend/port/sparc_solaris | |
download | postgresql-d31084e9d1118b25fd16580d9d8c2924b5740dff.tar.gz postgresql-d31084e9d1118b25fd16580d9d8c2924b5740dff.zip |
Postgres95 1.01 Distribution - Virgin SourcesPG95-1_01
Diffstat (limited to 'src/backend/port/sparc_solaris')
-rw-r--r-- | src/backend/port/sparc_solaris/Makefile.inc | 20 | ||||
-rw-r--r-- | src/backend/port/sparc_solaris/machine.h | 19 | ||||
-rw-r--r-- | src/backend/port/sparc_solaris/port-protos.h | 38 | ||||
-rw-r--r-- | src/backend/port/sparc_solaris/port.c | 66 | ||||
-rw-r--r-- | src/backend/port/sparc_solaris/rusagestub.h | 30 | ||||
-rw-r--r-- | src/backend/port/sparc_solaris/tas.s | 50 |
6 files changed, 223 insertions, 0 deletions
diff --git a/src/backend/port/sparc_solaris/Makefile.inc b/src/backend/port/sparc_solaris/Makefile.inc new file mode 100644 index 00000000000..ee4a8f82f02 --- /dev/null +++ b/src/backend/port/sparc_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/sparc_solaris/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ +# +#------------------------------------------------------------------------- + +CFLAGS+= -DUSE_POSIX_TIME -DNEED_ISINF -DNEED_RUSAGE -DNO_EMPTY_STMTS + +LDADD+= -ll -ldl + +SUBSRCS+= port.c tas.s + +HEADERS+= machine.h port-protos.h rusagestub.h diff --git a/src/backend/port/sparc_solaris/machine.h b/src/backend/port/sparc_solaris/machine.h new file mode 100644 index 00000000000..35fe7afe61e --- /dev/null +++ b/src/backend/port/sparc_solaris/machine.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------- + * + * machine.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: machine.h,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef MACHINE_H +#define MACHINE_H + +#define BLCKSZ 8192 + +#endif + diff --git a/src/backend/port/sparc_solaris/port-protos.h b/src/backend/port/sparc_solaris/port-protos.h new file mode 100644 index 00000000000..777e66310f4 --- /dev/null +++ b/src/backend/port/sparc_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.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include <dlfcn.h> +#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/sparc_solaris/port.c b/src/backend/port/sparc_solaris/port.c new file mode 100644 index 00000000000..f3c6b8a7943 --- /dev/null +++ b/src/backend/port/sparc_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/sparc_solaris/Attic/port.c,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include <math.h> /* for pow() prototype */ + +#include <errno.h> +#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/sparc_solaris/rusagestub.h b/src/backend/port/sparc_solaris/rusagestub.h new file mode 100644 index 00000000000..5e413bd0d9a --- /dev/null +++ b/src/backend/port/sparc_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.1.1 1996/07/09 06:21:45 scrappy 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 */ + +#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/port/sparc_solaris/tas.s b/src/backend/port/sparc_solaris/tas.s new file mode 100644 index 00000000000..e09c2d4ad3c --- /dev/null +++ b/src/backend/port/sparc_solaris/tas.s @@ -0,0 +1,50 @@ + !! + !! $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/tas.s,v 1.1.1.1 1996/07/09 06:21:45 scrappy Exp $ + !! + !! this would be a piece of inlined assembler but it appears + !! to be easier to just write the assembler than to try to + !! figure out how to make sure that in/out registers are kept + !! straight in the asm's. + !! + .file "tas.c" +.section ".text" + .align 4 + .global tas + .type tas,#function + .proc 04 +tas: + !! + !! this is a leaf procedure - no need to save windows and + !! diddle the CWP. + !! + !#PROLOGUE# 0 + !#PROLOGUE# 1 + + !! + !! write 0xFF into the lock address, saving the old value in %o0. + !! this is an atomic action, even on multiprocessors. + !! + ldstub [%o0],%o0 + + !! + !! if it was already set when we set it, somebody else already + !! owned the lock -- return 1. + !! + cmp %o0,0 + bne .LL2 + mov 1,%o0 + + !! + !! otherwise, it was clear and we now own the lock -- return 0. + !! + mov 0,%o0 +.LL2: + !! + !! this is a leaf procedure - no need to restore windows and + !! diddle the CWP. + !! + retl + nop +.LLfe1: + .size tas,.LLfe1-tas + .ident "GCC: (GNU) 2.5.8" |