Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d2a386d

Browse files
committed
MOre univel port patches/files from:
"Michael P. Snyder" <msnyder@hawkeye.huntersmoon.com>
1 parent 52ab652 commit d2a386d

File tree

7 files changed

+342
-0
lines changed

7 files changed

+342
-0
lines changed

src/backend/port/univel/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile--
4+
# Makefile for port/univel
5+
#
6+
# IDENTIFICATION
7+
# $Header: /cvsroot/pgsql/src/backend/port/univel/Attic/Makefile,v 1.1 1997/03/25 07:54:31 scrappy Exp $
8+
#
9+
#-------------------------------------------------------------------------
10+
11+
SRCDIR = ../../..
12+
include ../../../Makefile.global
13+
14+
INCLUDE_OPT = -I../.. \
15+
-I../../../include
16+
17+
CFLAGS+=$(INCLUDE_OPT)
18+
19+
OBJS = port.o #tas.o
20+
21+
all: SUBSYS.o
22+
23+
SUBSYS.o: $(OBJS)
24+
$(LD) -r -o SUBSYS.o $(OBJS)
25+
26+
depend dep:
27+
$(CC) -MM $(INCLUDE_OPT) *.c >depend
28+
29+
clean:
30+
rm -f SUBSYS.o $(OBJS)
31+
32+
ifeq (depend,$(wildcard depend))
33+
include depend
34+
endif
35+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* port-protos.h--
4+
* port-specific prototypes for Intel x86/Intel SVR4
5+
*
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
* port-protos.h,v 1.2 1995/03/17 06:40:18 andrew Exp
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef FPORT_PROTOS_H
14+
#define FPORT_PROTOS_H
15+
16+
/* port.c */
17+
extern long random(void);
18+
extern void srandom(int seed);
19+
extern int strcasecmp(char *s1,char *s2);
20+
extern int gethostname(char *name,int namelen);
21+
22+
#endif /* FPORT_PROTOS_H */

src/backend/port/univel/port-protos.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* port-protos.h--
4+
* port-specific prototypes for Intel x86/Intel SVR4
5+
*
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
* port-protos.h,v 1.2 1995/03/17 06:40:18 andrew Exp
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef PORT_PROTOS_H
14+
#define PORT_PROTOS_H
15+
16+
#include <dlfcn.h>
17+
#include "fmgr.h" /* for func_ptr */
18+
#include "utils/dynamic_loader.h"
19+
20+
/* dynloader.c */
21+
/*
22+
* Dynamic Loader on Intel x86/Intel SVR4.
23+
*
24+
* this dynamic loader uses the system dynamic loading interface for shared
25+
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
26+
* library as the file to be dynamically loaded.
27+
*
28+
*/
29+
#define pg_dlopen(f) dlopen(f,RTLD_LAZY)
30+
#define pg_dlsym dlsym
31+
#define pg_dlclose dlclose
32+
#define pg_dlerror dlerror
33+
34+
/* port.c */
35+
extern long random(void);
36+
extern void srandom(int seed);
37+
extern int strcasecmp(char *s1,char *s2);
38+
extern int gethostname(char *name,int namelen);
39+
40+
#endif /* PORT_PROTOS_H */

src/backend/port/univel/port.c

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* port.c--
4+
* Intel x86/Intel SVR4-specific routines
5+
*
6+
* Copyright (c) 1994, Regents of the University of California
7+
*
8+
*
9+
* IDENTIFICATION
10+
* /usr/local/devel/pglite/cvs/src/backend/port/svr4/port.c,v 1.2 1995/03/17 06:40:19 andrew Exp
11+
*
12+
*-------------------------------------------------------------------------
13+
*/
14+
#include <math.h> /* for pow() prototype */
15+
16+
#include <errno.h>
17+
#include "rusagestub.h"
18+
#include "port-protos.h"
19+
20+
long
21+
random()
22+
{
23+
return(lrand48());
24+
}
25+
26+
void
27+
srandom(int seed)
28+
{
29+
srand48((long int) seed);
30+
}
31+
32+
int
33+
getrusage(int who, struct rusage *rusage)
34+
{
35+
struct tms tms;
36+
register int tick_rate = CLK_TCK; /* ticks per second */
37+
clock_t u, s;
38+
39+
if (rusage == (struct rusage *) NULL) {
40+
errno = EFAULT;
41+
return(-1);
42+
}
43+
if (times(&tms) < 0) {
44+
/* errno set by times */
45+
return(-1);
46+
}
47+
switch (who) {
48+
case RUSAGE_SELF:
49+
u = tms.tms_utime;
50+
s = tms.tms_stime;
51+
break;
52+
case RUSAGE_CHILDREN:
53+
u = tms.tms_cutime;
54+
s = tms.tms_cstime;
55+
break;
56+
default:
57+
errno = EINVAL;
58+
return(-1);
59+
}
60+
#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
61+
#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
62+
rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
63+
rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
64+
rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
65+
rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
66+
return(0);
67+
}
68+
69+
/*
70+
* Copyright (c) 1987 Regents of the University of California.
71+
* All rights reserved.
72+
*
73+
* Redistribution and use in source and binary forms are permitted
74+
* provided that this notice is preserved and that due credit is given
75+
* to the University of California at Berkeley. The name of the University
76+
* may not be used to endorse or promote products derived from this
77+
* software without specific written prior permission. This software
78+
* is provided ``as is'' without express or implied warranty.
79+
*/
80+
81+
#if defined(LIBC_SCCS) && !defined(lint)
82+
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
83+
#endif /* LIBC_SCCS and not lint */
84+
85+
#include <sys/types.h>
86+
#include <string.h>
87+
88+
/*
89+
* This array is designed for mapping upper and lower case letter
90+
* together for a case independent comparison. The mappings are
91+
p * based upon ascii character sequences.
92+
*/
93+
static unsigned char charmap[] = {
94+
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
95+
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
96+
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
97+
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
98+
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
99+
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
100+
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
101+
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
102+
'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
103+
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
104+
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
105+
'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
106+
'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
107+
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
108+
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
109+
'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
110+
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
111+
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
112+
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
113+
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
114+
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
115+
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
116+
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
117+
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
118+
'\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
119+
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
120+
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
121+
'\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
122+
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
123+
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
124+
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
125+
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
126+
};
127+
128+
int
129+
strcasecmp(char *s1, char *s2)
130+
{
131+
register unsigned char u1, u2;
132+
133+
for (;;) {
134+
u1 = (unsigned char) *s1++;
135+
u2 = (unsigned char) *s2++;
136+
if (charmap[u1] != charmap[u2]) {
137+
return charmap[u1] - charmap[u2];
138+
}
139+
if (u1 == '\0') {
140+
return 0;
141+
}
142+
}
143+
}
144+
145+
#include <sys/utsname.h>
146+
147+
int gethostname(char *name, int namelen)
148+
{
149+
static struct utsname mname;
150+
static int called=0;
151+
152+
if(!called)
153+
{
154+
called++;
155+
uname(&mname);
156+
}
157+
strncpy(name,mname.nodename,(SYS_NMLN<namelen?SYS_NMLN:namelen));
158+
159+
return(0);
160+
}
161+

src/backend/port/univel/rusagestub.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* rusagestub.h--
4+
* Stubs for getrusage(3).
5+
*
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
* rusagestub.h,v 1.1.1.1 1994/11/07 05:19:39 andrew Exp
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef RUSAGESTUB_H
14+
#define RUSAGESTUB_H
15+
16+
#include <sys/time.h> /* for struct timeval */
17+
#include <sys/times.h> /* for struct tms */
18+
#include <limits.h> /* for CLK_TCK */
19+
20+
#define RUSAGE_SELF 0
21+
#define RUSAGE_CHILDREN -1
22+
23+
struct rusage {
24+
struct timeval ru_utime; /* user time used */
25+
struct timeval ru_stime; /* system time used */
26+
};
27+
28+
extern int getrusage(int who, struct rusage *rusage);
29+
30+
#endif /* RUSAGESTUB_H */

src/backend/port/univel/tas.s

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/=============================================================================
2+
/ tas.s -- test and set lock for i386_solaris
3+
/=============================================================================
4+
5+
.file "tas.s"
6+
.text
7+
.align 16
8+
.L1.text:
9+
10+
.globl tas
11+
tas:
12+
pushl %ebp /save prev base pointer
13+
movl %esp,%ebp /new base pointer
14+
pushl %ebx /save prev bx
15+
movl 8(%ebp),%ebx /load bx with address of lock
16+
pushl %ebx /save prev bx
17+
movl 8(%ebp),%ebx /load bx with address of lock
18+
movl $255,%eax /put something in ax
19+
xchgb %al,(%ebx) /swap lock value with "0"
20+
cmpb $0,%al /did we get the lock?
21+
jne .Locked
22+
subl %eax,%eax /yes, we got it -- return 0
23+
jmp .Finish
24+
.align 4
25+
.Locked:
26+
movl $1,%eax /no, we didn't get it - return 1
27+
.Finish:
28+
popl %ebx /restore prev bx
29+
movl %ebp,%esp /restore stack state
30+
popl %ebp
31+
ret /return
32+
.align 4
33+
.type tas,@function
34+
.size tas,.-tas
35+

src/port/univel.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# define USE_POSIX_TIME
2+
# define NO_EMPTY_STMTS
3+
# define USE_POSIX_SIGNALS
4+
# define SYSV_DIRENT
5+
6+
#if 0
7+
# define HAS_TEST_AND_SET
8+
typedef unsigned char slock_t;
9+
#endif
10+
11+
extern long random(void);
12+
extern void srandom(int seed);
13+
extern int strcasecmp(char *s1,char *s2);
14+
extern int gethostname(char *name,int namelen);
15+
16+
#ifndef BYTE_ORDER
17+
#define BYTE_ORDER LITTLE_ENDIAN
18+
#endif
19+

0 commit comments

Comments
 (0)