Init
This commit is contained in:
36
lib/libc/compat/sys5/Makefile
Normal file
36
lib/libc/compat/sys5/Makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# @(#)Makefile 1.1 94/10/31 SMI
|
||||
#
|
||||
# Copyright (c) 1987 by Sun Microsystems, Inc.
|
||||
#
|
||||
|
||||
all: xall
|
||||
|
||||
include ../../Makefile.arch
|
||||
include ../../Makefile.master
|
||||
|
||||
|
||||
STDSRC = nice.c rand.c times.c
|
||||
# these should just be pitched, but in the interest of compatibility...
|
||||
TRASHSRC = getpw.c
|
||||
SRCS = $(STDSRC) $(TRASHSRC)
|
||||
OBJS = $(SRCS:%.c=$(VARIANT)/%.o)
|
||||
HDRS = epoch.h
|
||||
|
||||
.KEEP_STATE:
|
||||
|
||||
xall: $$(LIBS)
|
||||
$(LIBS) : symlink $(HDRS) $$(VARIANT) $$(OBJS)
|
||||
|
||||
clean: master.clean
|
||||
rm -f mkepoch epoch.h a.out
|
||||
|
||||
epoch.h: mkepoch
|
||||
./mkepoch >epoch.h
|
||||
|
||||
mkepoch: mkepoch.c
|
||||
$(CC) -USUNPRO_DEPENDENCIES -O -o mkepoch mkepoch.c
|
||||
|
||||
symlink:
|
||||
rm -rf strings;\
|
||||
ln -s ../../strings strings
|
||||
43
lib/libc/compat/sys5/getpw.c
Normal file
43
lib/libc/compat/sys5/getpw.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)getpw.c 1.1 94/10/31 Copyr 1984 Sun Micro";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1984 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
struct passwd *getpwuid();
|
||||
|
||||
getpw(uid, buf)
|
||||
int uid;
|
||||
char buf[];
|
||||
{
|
||||
struct passwd *pw;
|
||||
char numbuf[20];
|
||||
|
||||
pw = getpwuid(uid);
|
||||
if(pw == 0)
|
||||
return 1;
|
||||
strcpy(buf, pw->pw_name);
|
||||
strcat(buf, ":");
|
||||
strcat(buf, pw->pw_passwd);
|
||||
if (*pw->pw_age != '\0') {
|
||||
strcat(buf, ",");
|
||||
strcat(buf, pw->pw_age);
|
||||
}
|
||||
strcat(buf, ":");
|
||||
sprintf(numbuf, "%d", pw->pw_uid);
|
||||
strcat(buf, numbuf);
|
||||
strcat(buf, ":");
|
||||
sprintf(numbuf, "%d", pw->pw_gid);
|
||||
strcat(buf, numbuf);
|
||||
strcat(buf, ":");
|
||||
strcat(buf, pw->pw_gecos);
|
||||
strcat(buf, ":");
|
||||
strcat(buf, pw->pw_dir);
|
||||
strcat(buf, ":");
|
||||
strcat(buf, pw->pw_shell);
|
||||
return 0;
|
||||
}
|
||||
40
lib/libc/compat/sys5/mkepoch.c
Normal file
40
lib/libc/compat/sys5/mkepoch.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)mkepoch.c 1.1 94/10/31 SMI";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986 Sun Microsystems Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Put out a C declaration which initializes "epoch" to the time ("tv_sec"
|
||||
* portion) when this program was run.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int gettimeofday();
|
||||
void perror();
|
||||
void exit();
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
if (gettimeofday(&now, (struct timezone *)NULL) < 0) {
|
||||
perror("mkepoch: gettimeofday failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (printf("static long epoch = %ld;\n", now.tv_sec) == EOF) {
|
||||
perror("mkepoch: can't write output");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
47
lib/libc/compat/sys5/nice.c
Normal file
47
lib/libc/compat/sys5/nice.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)nice.c 1.1 94/10/31 SMI"; /* from UCB 4.1 83/05/30 */
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
* Backwards compatible nice.
|
||||
*/
|
||||
int
|
||||
nice(incr)
|
||||
int incr;
|
||||
{
|
||||
register int prio;
|
||||
int serrno;
|
||||
|
||||
/* put in brain-damaged upper range checking */
|
||||
if ((incr > 40) && (geteuid() != 0)) {
|
||||
errno = EPERM;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
serrno = errno;
|
||||
errno = 0;
|
||||
prio = getpriority(PRIO_PROCESS, 0);
|
||||
if (prio == -1 && errno)
|
||||
return (-1);
|
||||
prio += incr;
|
||||
if (prio < -20)
|
||||
prio = -20;
|
||||
else if (prio > 19)
|
||||
prio = 19;
|
||||
if (setpriority(PRIO_PROCESS, 0, prio) == -1) {
|
||||
/*
|
||||
* 4.3BSD stupidly returns EACCES on an attempt by a
|
||||
* non-super-user process to lower a priority; map
|
||||
* it to EPERM.
|
||||
*/
|
||||
if (errno == EACCES)
|
||||
errno = EPERM;
|
||||
return (-1);
|
||||
}
|
||||
errno = serrno;
|
||||
return (prio);
|
||||
}
|
||||
20
lib/libc/compat/sys5/rand.c
Normal file
20
lib/libc/compat/sys5/rand.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)rand.c 1.1 94/10/31 SMI"; /* from S5R2 1.2 */
|
||||
#endif
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
static long randx=1;
|
||||
|
||||
void
|
||||
srand(x)
|
||||
unsigned x;
|
||||
{
|
||||
randx = x;
|
||||
}
|
||||
|
||||
int
|
||||
rand()
|
||||
{
|
||||
return(((randx = randx * 1103515245L + 12345)>>16) & 0x7fff);
|
||||
}
|
||||
36
lib/libc/compat/sys5/times.c
Normal file
36
lib/libc/compat/sys5/times.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)times.c 1.1 94/10/31 SMI"; /* from UCB 4.2 83/06/02 */
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/resource.h>
|
||||
#include "epoch.h"
|
||||
|
||||
static clock_t
|
||||
scale60(tvp)
|
||||
register struct timeval *tvp;
|
||||
{
|
||||
return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
|
||||
}
|
||||
|
||||
clock_t
|
||||
times(tmsp)
|
||||
register struct tms *tmsp;
|
||||
{
|
||||
struct rusage ru;
|
||||
struct timeval now;
|
||||
|
||||
if (getrusage(RUSAGE_SELF, &ru) < 0)
|
||||
return (clock_t)(-1);
|
||||
tmsp->tms_utime = scale60(&ru.ru_utime);
|
||||
tmsp->tms_stime = scale60(&ru.ru_stime);
|
||||
if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
|
||||
return (clock_t)(-1);
|
||||
tmsp->tms_cutime = scale60(&ru.ru_utime);
|
||||
tmsp->tms_cstime = scale60(&ru.ru_stime);
|
||||
if (gettimeofday(&now, (struct timezone *)0) < 0)
|
||||
return (clock_t)(-1);
|
||||
now.tv_sec -= epoch;
|
||||
return (scale60(&now));
|
||||
}
|
||||
Reference in New Issue
Block a user