Skip to content

Commit c801ca0

Browse files
committed
Finish adding in svr4 port to v2.0
1 parent 926a066 commit c801ca0

File tree

5 files changed

+250
-0
lines changed

5 files changed

+250
-0
lines changed

src/backend/port/svr4/Makefile.inc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile.inc--
4+
# Makefile for port/svr4 (Intel x86/Intel SVR4 specific stuff)
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/Makefile.inc,v 1.3 1995/03/21 06:51:21 andrew Exp
11+
#
12+
#-------------------------------------------------------------------------
13+
14+
CFLAGS+= -DUSE_POSIX_TIME -DNEED_ISINF -DNEED_RUSAGE -DNO_EMPTY_STMTS
15+
16+
LDADD+= -ll -ldl
17+
18+
SUBSRCS+= port.c
19+
20+
HEADERS+= machine.h port-protos.h rusagestub.h

src/backend/port/svr4/machine.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* machine.h--
4+
*
5+
*
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
* machine.h,v 1.1.1.1 1994/11/07 05:19:38 andrew Exp
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndef MACHINE_H
14+
#define MACHINE_H
15+
16+
#define BLCKSZ 8192
17+
18+
#endif
19+

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
38+
#endif /* PORT_PROTOS_H */

src/backend/port/svr4/port.c

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

src/backend/port/svr4/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 */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy