Merge the nathanw_sa branch.

This commit is contained in:
thorpej 2003-01-18 10:52:16 +00:00
parent c62a74e6d5
commit 3fdac2b8c5
411 changed files with 5888 additions and 1687 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.21 2002/06/19 08:11:55 jdolecek Exp $ */
/* $NetBSD: extern.h,v 1.22 2003/01/18 10:52:16 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -43,49 +43,47 @@ struct varent;
extern double ccpu;
extern int eval, fscale, mempages, nlistread, rawcpu, maxslp, uspace;
extern int sumrusage, termwidth, totwidth;
extern int needenv, needcomm, commandonly, dontuseprocfs;
extern int needenv, needcomm, commandonly;
extern uid_t myuid;
extern kvm_t *kd;
extern VAR var[];
extern VARENT *vhead;
__BEGIN_DECLS
void command __P((struct kinfo_proc2 *, VARENT *, int));
void cputime __P((struct kinfo_proc2 *, VARENT *, int));
void command __P((void *, VARENT *, int));
void cputime __P((void *, VARENT *, int));
int donlist __P((void));
int donlist_sysctl __P((void));
void fmt_puts __P((char *, int *));
void fmt_putc __P((int, int *));
double getpcpu __P((struct kinfo_proc2 *));
double getpmem __P((struct kinfo_proc2 *));
void logname __P((struct kinfo_proc2 *, VARENT *, int));
void longtname __P((struct kinfo_proc2 *, VARENT *, int));
void lstarted __P((struct kinfo_proc2 *, VARENT *, int));
void maxrss __P((struct kinfo_proc2 *, VARENT *, int));
void logname __P((void *, VARENT *, int));
void longtname __P((void *, VARENT *, int));
void lstarted __P((void *, VARENT *, int));
void lstate __P((void *, VARENT *, int));
void maxrss __P((void *, VARENT *, int));
void nlisterr __P((struct nlist *));
void p_rssize __P((struct kinfo_proc2 *, VARENT *, int));
void pagein __P((struct kinfo_proc2 *, VARENT *, int));
void p_rssize __P((void *, VARENT *, int));
void pagein __P((void *, VARENT *, int));
void parsefmt __P((char *));
void pcpu __P((struct kinfo_proc2 *, VARENT *, int));
void pmem __P((struct kinfo_proc2 *, VARENT *, int));
void pnice __P((struct kinfo_proc2 *, VARENT *, int));
void pri __P((struct kinfo_proc2 *, VARENT *, int));
void pcpu __P((void *, VARENT *, int));
void pmem __P((void *, VARENT *, int));
void pnice __P((void *, VARENT *, int));
void pri __P((void *, VARENT *, int));
void printheader __P((void));
struct kinfo_proc2
*getkinfo_procfs __P((int, int, int *));
char **procfs_getargv __P((const struct kinfo_proc2 *, int));
void pvar __P((struct kinfo_proc2 *, VARENT *, int));
void rssize __P((struct kinfo_proc2 *, VARENT *, int));
void runame __P((struct kinfo_proc2 *, VARENT *, int));
void pvar __P((void *, VARENT *, int));
void rssize __P((void *, VARENT *, int));
void runame __P((void *, VARENT *, int));
void showkey __P((void));
void started __P((struct kinfo_proc2 *, VARENT *, int));
void state __P((struct kinfo_proc2 *, VARENT *, int));
void tdev __P((struct kinfo_proc2 *, VARENT *, int));
void tname __P((struct kinfo_proc2 *, VARENT *, int));
void tsize __P((struct kinfo_proc2 *, VARENT *, int));
void ucomm __P((struct kinfo_proc2 *, VARENT *, int));
void uname __P((struct kinfo_proc2 *, VARENT *, int));
void uvar __P((struct kinfo_proc2 *, VARENT *, int));
void vsize __P((struct kinfo_proc2 *, VARENT *, int));
void wchan __P((struct kinfo_proc2 *, VARENT *, int));
void started __P((void *, VARENT *, int));
void state __P((void *, VARENT *, int));
void tdev __P((void *, VARENT *, int));
void tname __P((void *, VARENT *, int));
void tsize __P((void *, VARENT *, int));
void ucomm __P((void *, VARENT *, int));
void uname __P((void *, VARENT *, int));
void uvar __P((void *, VARENT *, int));
void vsize __P((void *, VARENT *, int));
void wchan __P((void *, VARENT *, int));
__END_DECLS

View File

@ -1,4 +1,4 @@
/* $NetBSD: keyword.c,v 1.28 2002/10/17 23:50:17 itojun Exp $ */
/* $NetBSD: keyword.c,v 1.29 2003/01/18 10:52:16 thorpej Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -38,12 +38,13 @@
#if 0
static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: keyword.c,v 1.28 2002/10/17 23:50:17 itojun Exp $");
__RCSID("$NetBSD: keyword.c,v 1.29 2003/01/18 10:52:16 thorpej Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/lwp.h>
#include <sys/proc.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
@ -73,6 +74,7 @@ static int vcmp __P((const void *, const void *));
/* Compute offset in common structures. */
#define POFF(x) offsetof(struct kinfo_proc2, x)
#define LOFF(x) offsetof(struct kinfo_lwp, x)
#define UIDFMT "u"
#define UID(n1, n2, fn, off) \
@ -95,7 +97,7 @@ VAR var[] = {
{"cputime", "", "time"},
{"f", "F", NULL, 0, pvar, 0, POFF(p_flag), INT, "x"},
{"flags", "", "f"},
{"holdcnt", "HOLDCNT", NULL, 0, pvar, 0, POFF(p_holdcnt), INT, "d"},
{"holdcnt", "HOLDCNT", NULL, LWP, pvar, 0, LOFF(l_holdcnt), INT, "d"},
{"ignored", "", "sigignore"},
{"inblk", "INBLK", NULL, 0, pvar, 0, POFF(p_uru_inblock), UINT64, "llu"},
{"inblock", "", "inblk"},
@ -103,10 +105,12 @@ VAR var[] = {
{"ktrace", "KTRACE", NULL, 0, pvar, 0, POFF(p_traceflag), INT, "x"},
/* XXX */
{"ktracep", "KTRACEP", NULL, 0, pvar, 0, POFF(p_tracep), KPTR, "llx"},
{"lid", "LID", NULL, LWP, pvar, 0, LOFF(l_lid), ULONG, "d"},
{"lim", "LIM", NULL, 0, maxrss},
{"login", "LOGIN", NULL, LJUST, logname},
{"logname", "", "login"},
{"lstart", "STARTED", NULL, LJUST, lstarted},
{"lstate", "STAT", NULL, LJUST|LWP, lstate},
{"majflt", "MAJFLT", NULL, 0, pvar, 0, POFF(p_uru_majflt), UINT64, "llu"},
{"minflt", "MINFLT", NULL, 0, pvar, 0, POFF(p_uru_minflt), UINT64, "llu"},
{"msgrcv", "MSGRCV", NULL, 0, pvar, 0, POFF(p_uru_msgrcv), UINT64, "llu"},
@ -114,12 +118,13 @@ VAR var[] = {
{"ni", "", "nice"},
{"nice", "NI", NULL, 0, pnice},
{"nivcsw", "NIVCSW", NULL, 0, pvar, 0, POFF(p_uru_nivcsw), UINT64, "llu"},
{"nlwp", "NLWP", NULL, 0, pvar, 0, POFF(p_nlwps), UINT64, "lld"},
{"nsignals", "", "nsigs"},
{"nsigs", "NSIGS", NULL, 0, pvar, 0, POFF(p_uru_nsignals), UINT64, "llu"},
{"nswap", "NSWAP", NULL, 0, pvar, 0, POFF(p_uru_nswap), UINT64, "llu"},
{"nvcsw", "NVCSW", NULL, 0, pvar, 0, POFF(p_uru_nvcsw), UINT64, "llu"},
/* XXX */
{"nwchan", "WCHAN", NULL, 0, pvar, 0, POFF(p_wchan), KPTR, "llx"},
{"nwchan", "WCHAN", NULL, LWP, pvar, 0, LOFF(l_wchan), KPTR, "llx"},
{"oublk", "OUBLK", NULL, 0, pvar, 0, POFF(p_uru_oublock), UINT64, "llu"},
{"oublock", "", "oublk"},
/* XXX */
@ -133,11 +138,12 @@ VAR var[] = {
PID("pid", "PID", pvar, POFF(p_pid)),
{"pmem", "", "%mem"},
PID("ppid", "PPID", pvar, POFF(p_ppid)),
{"pri", "PRI", NULL, 0, pri},
{"re", "RE", NULL, INF127, pvar, 0, POFF(p_swtime), UINT, "u"},
{"pri", "PRI", NULL, LWP, pri},
{"re", "RE", NULL, INF127|LWP, pvar, 0, LOFF(l_swtime), UINT, "u"},
GID("rgid", "RGID", pvar, POFF(p_rgid)),
/* XXX */
{"rlink", "RLINK", NULL, 0, pvar, 0, POFF(p_back), KPTR, "llx"},
{"rlink", "RLINK", NULL, LWP, pvar, 0, LOFF(l_back), KPTR, "llx"},
{"rlwp", "RLWP", NULL, 0, pvar, 0, POFF(p_nrlwps), UINT64, "lld"},
{"rss", "RSS", NULL, 0, p_rssize},
{"rssize", "", "rsz"},
{"rsz", "RSZ", NULL, 0, rssize},
@ -153,7 +159,7 @@ VAR var[] = {
NULL, 0, pvar, 0, POFF(p_sigignore), SIGLIST, "s"},
{"sigmask", "BLOCKED",
NULL, 0, pvar, 0, POFF(p_sigmask), SIGLIST, "s"},
{"sl", "SL", NULL, INF127, pvar, 0, POFF(p_slptime), UINT, "u"},
{"sl", "SL", NULL, INF127|LWP, pvar, 0, LOFF(l_slptime), UINT, "u"},
{"start", "STARTED", NULL, 0, started},
{"stat", "", "state"},
{"state", "STAT", NULL, LJUST, state},
@ -168,12 +174,12 @@ VAR var[] = {
{"tty", "TTY", NULL, LJUST, longtname},
{"ucomm", "UCOMM", NULL, LJUST, ucomm},
UID("uid", "UID", pvar, POFF(p_uid)),
{"upr", "UPR", NULL, 0, pvar, 0, POFF(p_usrpri), UCHAR, "u"},
{"upr", "UPR", NULL, LWP, pvar, 0, LOFF(l_usrpri), UCHAR, "u"},
{"user", "USER", NULL, LJUST, uname},
{"usrpri", "", "upr"},
{"vsize", "", "vsz"},
{"vsz", "VSZ", NULL, 0, vsize},
{"wchan", "WCHAN", NULL, LJUST, wchan},
{"wchan", "WCHAN", NULL, LJUST|LWP, wchan},
{"xstat", "XSTAT", NULL, 0, pvar, 0, POFF(p_xstat), USHORT, "x"},
{""},
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: nlist.c,v 1.18 2001/07/14 06:53:44 matt Exp $ */
/* $NetBSD: nlist.c,v 1.19 2003/01/18 10:52:17 thorpej Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -74,12 +74,13 @@
#if 0
static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: nlist.c,v 1.18 2001/07/14 06:53:44 matt Exp $");
__RCSID("$NetBSD: nlist.c,v 1.19 2003/01/18 10:52:17 thorpej Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/lwp.h>
#include <sys/proc.h>
#include <sys/resource.h>
#include <sys/sysctl.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.75 2003/01/06 13:04:54 wiz Exp $ */
/* $NetBSD: print.c,v 1.76 2003/01/18 10:52:17 thorpej Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -74,13 +74,14 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
__RCSID("$NetBSD: print.c,v 1.75 2003/01/06 13:04:54 wiz Exp $");
__RCSID("$NetBSD: print.c,v 1.76 2003/01/18 10:52:17 thorpej Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/lwp.h>
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/ucred.h>
@ -264,11 +265,12 @@ strprintorsetwidth(v, str, mode)
}
void
command(ki, ve, mode)
struct kinfo_proc2 *ki;
command(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *ki;
VAR *v;
int left;
char **argv, **p, *name;
@ -276,6 +278,7 @@ command(ki, ve, mode)
if (mode == WIDTHMODE)
return;
ki = arg;
v = ve->var;
if (ve->next != NULL || termwidth != UNLIMITED) {
if (ve->next == NULL) {
@ -343,40 +346,46 @@ command(ki, ve, mode)
}
void
ucomm(k, ve, mode)
struct kinfo_proc2 *k;
ucomm(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
strprintorsetwidth(v, k->p_comm, mode);
}
void
logname(k, ve, mode)
struct kinfo_proc2 *k;
logname(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
strprintorsetwidth(v, k->p_login, mode);
}
void
state(k, ve, mode)
struct kinfo_proc2 *k;
state(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
int flag, is_zombie;
char *cp;
VAR *v;
char buf[16];
k = arg;
is_zombie = 0;
v = ve->var;
flag = k->p_flag;
@ -384,34 +393,38 @@ state(k, ve, mode)
switch (k->p_stat) {
case SSTOP:
case LSSTOP:
*cp = 'T';
break;
case SSLEEP:
if (flag & P_SINTR) /* interruptable (long) */
case LSSLEEP:
if (flag & L_SINTR) /* interruptable (long) */
*cp = k->p_slptime >= maxslp ? 'I' : 'S';
else
*cp = 'D';
break;
case SRUN:
case SIDL:
case SONPROC:
case LSRUN:
case LSIDL:
case LSONPROC:
*cp = 'R';
break;
case SZOMB:
case SDEAD:
case LSZOMB:
case LSDEAD:
*cp = 'Z';
is_zombie = 1;
break;
case LSSUSPENDED:
*cp = 'U';
break;
default:
*cp = '?';
}
cp++;
if (flag & P_INMEM) {
if (flag & L_INMEM) {
} else
*cp++ = 'W';
if (k->p_nice < NZERO)
@ -433,6 +446,10 @@ state(k, ve, mode)
*cp++ = 'L';
if (k->p_eflag & EPROC_SLEADER)
*cp++ = 's';
if (flag & P_SA)
*cp++ = 'a';
else if (k->p_nlwps > 1)
*cp++ = 'l';
if ((flag & P_CONTROLT) && k->p__pgid == k->p_tpgid)
*cp++ = '+';
*cp = '\0';
@ -440,63 +457,135 @@ state(k, ve, mode)
}
void
pnice(k, ve, mode)
struct kinfo_proc2 *k;
lstate(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_lwp *k;
int flag, is_zombie;
char *cp;
VAR *v;
char buf[16];
k = arg;
is_zombie = 0;
v = ve->var;
flag = k->l_flag;
cp = buf;
switch (k->l_stat) {
case LSSTOP:
*cp = 'T';
break;
case LSSLEEP:
if (flag & L_SINTR) /* interuptable (long) */
*cp = k->l_slptime >= maxslp ? 'I' : 'S';
else
*cp = 'D';
break;
case LSRUN:
case LSIDL:
case LSONPROC:
*cp = 'R';
break;
case LSZOMB:
case LSDEAD:
*cp = 'Z';
is_zombie = 1;
break;
case LSSUSPENDED:
*cp = 'U';
break;
default:
*cp = '?';
}
cp++;
if (flag & L_INMEM) {
} else
*cp++ = 'W';
if (k->l_holdcnt)
*cp++ = 'L';
if (flag & L_DETACHED)
*cp++ = '-';
*cp = '\0';
strprintorsetwidth(v, buf, mode);
}
void
pnice(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
intprintorsetwidth(v, k->p_nice - NZERO, mode);
}
void
pri(k, ve, mode)
struct kinfo_proc2 *k;
pri(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_lwp *l;
VAR *v;
l = arg;
v = ve->var;
intprintorsetwidth(v, k->p_priority - PZERO, mode);
intprintorsetwidth(v, l->l_priority - PZERO, mode);
}
void
uname(k, ve, mode)
struct kinfo_proc2 *k;
uname(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
strprintorsetwidth(v, user_from_uid(k->p_uid, 0), mode);
}
void
runame(k, ve, mode)
struct kinfo_proc2 *k;
runame(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
strprintorsetwidth(v, user_from_uid(k->p_ruid, 0), mode);
}
void
tdev(k, ve, mode)
struct kinfo_proc2 *k;
tdev(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
dev_t dev;
char buff[16];
k = arg;
v = ve->var;
dev = k->p_tdev;
if (dev == NODEV) {
@ -514,16 +603,18 @@ tdev(k, ve, mode)
}
void
tname(k, ve, mode)
struct kinfo_proc2 *k;
tname(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
dev_t dev;
const char *ttname;
int noctty;
k = arg;
v = ve->var;
dev = k->p_tdev;
if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL) {
@ -554,15 +645,17 @@ tname(k, ve, mode)
}
void
longtname(k, ve, mode)
struct kinfo_proc2 *k;
longtname(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
dev_t dev;
const char *ttname;
k = arg;
v = ve->var;
dev = k->p_tdev;
if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL) {
@ -579,17 +672,19 @@ longtname(k, ve, mode)
}
void
started(k, ve, mode)
struct kinfo_proc2 *k;
started(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
static time_t now;
time_t startt;
struct tm *tp;
char buf[100], *cp;
k = arg;
v = ve->var;
if (!k->p_uvalid) {
if (mode == PRINTMODE)
@ -617,15 +712,17 @@ started(k, ve, mode)
}
void
lstarted(k, ve, mode)
struct kinfo_proc2 *k;
lstarted(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
time_t startt;
char buf[100];
k = arg;
v = ve->var;
if (!k->p_uvalid) {
/*
@ -647,22 +744,24 @@ lstarted(k, ve, mode)
}
void
wchan(k, ve, mode)
struct kinfo_proc2 *k;
wchan(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_lwp *l;
VAR *v;
char *buf;
l = arg;
v = ve->var;
if (k->p_wchan) {
if (k->p_wmesg) {
strprintorsetwidth(v, k->p_wmesg, mode);
if (l->l_wchan) {
if (l->l_wmesg) {
strprintorsetwidth(v, l->l_wmesg, mode);
v->width = min(v->width, WMESGLEN);
} else {
(void)asprintf(&buf, "%-*llx", v->width,
(long long)k->p_wchan);
(long long)l->l_wchan);
if (buf == NULL)
err(1, "%s", "");
strprintorsetwidth(v, buf, mode);
@ -678,54 +777,62 @@ wchan(k, ve, mode)
#define pgtok(a) (((a)*getpagesize())/1024)
void
vsize(k, ve, mode)
struct kinfo_proc2 *k;
vsize(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
intprintorsetwidth(v,
pgtok(k->p_vm_dsize + k->p_vm_ssize + k->p_vm_tsize), mode);
}
void
rssize(k, ve, mode)
struct kinfo_proc2 *k;
rssize(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
/* XXX don't have info about shared */
intprintorsetwidth(v, pgtok(k->p_vm_rssize), mode);
}
void
p_rssize(k, ve, mode) /* doesn't account for text */
struct kinfo_proc2 *k;
p_rssize(arg, ve, mode) /* doesn't account for text */
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
intprintorsetwidth(v, pgtok(k->p_vm_rssize), mode);
}
void
cputime(k, ve, mode)
struct kinfo_proc2 *k;
cputime(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
int32_t secs;
int32_t psecs; /* "parts" of a second. first micro, then centi */
int fmtlen;
k = arg;
v = ve->var;
if (P_ZOMBIE(k) || k->p_uvalid == 0) {
secs = 0;
@ -785,7 +892,7 @@ getpcpu(k)
#define fxtofl(fixpt) ((double)(fixpt) / fscale)
/* XXX - I don't like this */
if (k->p_swtime == 0 || (k->p_flag & P_INMEM) == 0 ||
if (k->p_swtime == 0 || (k->p_flag & L_INMEM) == 0 ||
k->p_stat == SZOMB || k->p_stat == SDEAD)
return (0.0);
if (rawcpu)
@ -795,13 +902,15 @@ getpcpu(k)
}
void
pcpu(k, ve, mode)
struct kinfo_proc2 *k;
pcpu(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
doubleprintorsetwidth(v, getpcpu(k), 1, mode);
}
@ -819,7 +928,7 @@ getpmem(k)
if (failure)
return (0.0);
if ((k->p_flag & P_INMEM) == 0)
if ((k->p_flag & L_INMEM) == 0)
return (0.0);
/* XXX want pmap ptpages, segtab, etc. (per architecture) */
szptudot = uspace/getpagesize();
@ -829,32 +938,36 @@ getpmem(k)
}
void
pmem(k, ve, mode)
struct kinfo_proc2 *k;
pmem(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
doubleprintorsetwidth(v, getpmem(k), 1, mode);
}
void
pagein(k, ve, mode)
struct kinfo_proc2 *k;
pagein(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
intprintorsetwidth(v, k->p_uvalid ? k->p_uru_majflt : 0, mode);
}
void
maxrss(k, ve, mode)
struct kinfo_proc2 *k;
maxrss(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
@ -867,13 +980,15 @@ maxrss(k, ve, mode)
}
void
tsize(k, ve, mode)
struct kinfo_proc2 *k;
tsize(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
struct kinfo_proc2 *k;
VAR *v;
k = arg;
v = ve->var;
intprintorsetwidth(v, pgtok(k->p_vm_tsize), mode);
}
@ -1112,13 +1227,13 @@ printval(bp, v, mode)
}
void
pvar(k, ve, mode)
struct kinfo_proc2 *k;
pvar(arg, ve, mode)
void *arg;
VARENT *ve;
int mode;
{
VAR *v;
v = ve->var;
printval((char *)k + v->off, v, mode);
printval((char *)arg + v->off, v, mode);
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ps.1,v 1.56 2002/10/01 15:11:08 wiz Exp $
.\" $NetBSD: ps.1,v 1.57 2003/01/18 10:52:17 thorpej Exp $
.\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@ -41,7 +41,7 @@
.Nd process status
.Sh SYNOPSIS
.Nm ""
.Op Fl acCehjlmrSTuvwx
.Op Fl acCehjlmrsSTuvwx
.Bk -words
.Op Fl M Ar core
.Ek
@ -163,6 +163,11 @@ Sort by current cpu usage, instead of by process
.It Fl S
Change the way the process time is calculated by summing all exited
children to their parent process.
.It Fl s
Display one line for each LWP, rather than one line for each process,
and display information associated with the following keywords:
uid, pid, ppid, cpu, lid, nlwp, pri, nice, vsz, rss, wchan, lstate, tt, time
and command.
.It Fl T
Display information about processes attached to the device associated
with the standard input.
@ -312,6 +317,8 @@ information:
.Bl -tag -width indent -compact
.It +
The process is in the foreground process group of its control terminal.
.It -
The LWP is detached (can't be waited for).
.It \*[Lt]
The process has raised
.Tn CPU
@ -326,6 +333,8 @@ the process has asked for random page replacement
from
.Xr madvise 2 ,
for example, a LISP interpreter in a garbage collect).
.It a
The process is using scheduler activations.
.It E
The process is trying to exit.
.It K
@ -333,6 +342,8 @@ The process is a kernel thread or system process.
.It L
The process has pages locked in core (for example, for raw
.Tn I/O ) .
.It l
The process has multiple LWPs.
.It N
The process has reduced
.Tn CPU
@ -453,12 +464,16 @@ number of holds on the process (if non-zero, process can't be swapped)
tracing flags
.It ktracep
tracing vnode
.It lid
ID of the LWP
.It lim
memoryuse limit
.It logname
login name of user who started the process
.It lstart
time started
.It lstate
symbolic LWP state
.It majflt
total page faults
.It minflt
@ -471,6 +486,8 @@ total messages sent (writes on pipes/sockets)
nice value (alias ni)
.It nivcsw
total involuntary context switches
.It nlwp
Number of LWPs in the process
.It nsigs
total signals taken (alias nsignals)
.It nswap
@ -506,6 +523,8 @@ real group
.Tn ID
.It rlink
reverse link on run queue, or 0
.It rlwp
Number of LWPs on a processor or run queue
.It rss
resident set size
.It rsz

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.c,v 1.47 2002/06/19 08:11:56 jdolecek Exp $ */
/* $NetBSD: ps.c,v 1.48 2003/01/18 10:52:17 thorpej Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -79,7 +79,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: ps.c,v 1.47 2002/06/19 08:11:56 jdolecek Exp $");
__RCSID("$NetBSD: ps.c,v 1.48 2003/01/18 10:52:17 thorpej Exp $");
#endif
#endif /* not lint */
@ -87,6 +87,7 @@ __RCSID("$NetBSD: ps.c,v 1.47 2002/06/19 08:11:56 jdolecek Exp $");
#include <sys/user.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/lwp.h>
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@ -112,7 +113,7 @@ __RCSID("$NetBSD: ps.c,v 1.47 2002/06/19 08:11:56 jdolecek Exp $");
* ARGOPTS must contain all option characters that take arguments
* (except for 't'!) - it is used in kludge_oldps_options()
*/
#define GETOPTSTR "acCeghjKLlM:mN:O:o:p:rSTt:U:uvW:wx"
#define GETOPTSTR "acCeghjLlM:mN:O:o:p:rSsTt:U:uvW:wx"
#define ARGOPTS "MNOopUW"
struct kinfo_proc2 *kinfo;
@ -124,11 +125,14 @@ int sumrusage; /* -S */
int termwidth; /* width of screen (0 == infinity) */
int totwidth; /* calculated width of requested variables */
int needcomm, needenv, commandonly, use_procfs;
int needcomm, needenv, commandonly;
uid_t myuid;
enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
static struct kinfo_lwp
*pick_representative_lwp __P((struct kinfo_proc2 *,
struct kinfo_lwp *, int));
static struct kinfo_proc2
*getkinfo_kvm __P((kvm_t *, int, int, int *));
static char *kludge_oldps_options __P((char *));
@ -142,6 +146,7 @@ char jfmt[] = "user pid ppid pgid sess jobc state tt time command";
char lfmt[] = "uid pid ppid cpu pri nice vsz rss wchan state tt time command";
char o1[] = "pid";
char o2[] = "tt state time command";
char sfmt[] = "uid pid ppid cpu lid nlwp pri nice vsz rss wchan lstate tt time command";
char ufmt[] = "user pid %cpu %mem vsz rss tt state start time command";
char vfmt[] = "pid state time sl re pagein vsz rss lim tsiz %cpu %mem command";
@ -154,8 +159,9 @@ main(argc, argv)
{
struct varent *vent;
struct winsize ws;
int ch, flag, i, fmt, lineno, nentries;
int prtheader, wflag, what, xflg, mode;
struct kinfo_lwp *kl, *l;
int ch, flag, i, j, fmt, lineno, nentries, nlwps;
int prtheader, wflag, what, xflg, mode, showlwps;
char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX];
char *ttname;
@ -170,7 +176,7 @@ main(argc, argv)
if (argc > 1)
argv[1] = kludge_oldps_options(argv[1]);
fmt = prtheader = wflag = xflg = 0;
fmt = prtheader = wflag = xflg = showlwps = 0;
what = KERN_PROC_UID;
flag = myuid = getuid();
memf = nlistf = swapf = NULL;
@ -242,6 +248,13 @@ main(argc, argv)
case 'S':
sumrusage = 1;
break;
case 's':
/* -L was already taken... */
showlwps = 1;
parsefmt(sfmt);
fmt = 1;
sfmt[0] = '\0';
break;
case 'T':
if ((ttname = ttyname(STDIN_FILENO)) == NULL)
errx(1, "stdin: not a terminal");
@ -357,12 +370,8 @@ main(argc, argv)
/*
* select procs
*/
if (!kd || !(kinfo = getkinfo_kvm(kd, what, flag, &nentries)))
{
if (kd)
warnx("%s.", kvm_geterr(kd));
exit(1);
}
if (!(kinfo = getkinfo_kvm(kd, what, flag, &nentries)))
err(1, "%s", kvm_geterr(kd));
if (nentries == 0) {
printheader();
exit(1);
@ -383,8 +392,25 @@ main(argc, argv)
if (xflg == 0 && (ki->p_tdev == NODEV ||
(ki->p_flag & P_CONTROLT) == 0))
continue;
for (vent = vhead; vent; vent = vent->next)
(vent->var->oproc)(ki, vent, WIDTHMODE);
kl = kvm_getlwps(kd, ki->p_pid, ki->p_paddr,
sizeof(struct kinfo_lwp), &nlwps);
if (kl == 0)
nlwps = 0;
if (showlwps == 0) {
l = pick_representative_lwp(ki, kl, nlwps);
for (vent = vhead; vent; vent = vent->next)
OUTPUT(vent, ki, l, WIDTHMODE);
} else {
/* The printing is done with the loops
* reversed, but here we don't need that,
* and this improves the code locality a bit.
*/
for (vent = vhead; vent; vent = vent->next)
for (j = 0; j < nlwps; j++)
OUTPUT(vent, ki, &kl[j],
WIDTHMODE);
}
}
/*
* Print header - AFTER determining process field widths.
@ -402,22 +428,106 @@ main(argc, argv)
if (xflg == 0 && (ki->p_tdev == NODEV ||
(ki->p_flag & P_CONTROLT ) == 0))
continue;
for (vent = vhead; vent; vent = vent->next) {
(vent->var->oproc)(ki, vent, mode);
if (vent->next != NULL)
(void)putchar(' ');
}
(void)putchar('\n');
if (prtheader && lineno++ == prtheader - 4) {
kl = kvm_getlwps(kd, ki->p_pid, (u_long)ki->p_paddr,
sizeof(struct kinfo_lwp), &nlwps);
if (kl == 0)
nlwps = 0;
if (showlwps == 0) {
l = pick_representative_lwp(ki, kl, nlwps);
for (vent = vhead; vent; vent = vent->next) {
OUTPUT(vent, ki, l, mode);
if (vent->next != NULL)
(void)putchar(' ');
}
(void)putchar('\n');
printheader();
lineno = 0;
if (prtheader && lineno++ == prtheader - 4) {
(void)putchar('\n');
printheader();
lineno = 0;
}
} else {
for (j = 0; j < nlwps; j++) {
for (vent = vhead; vent; vent = vent->next) {
OUTPUT(vent, ki, &kl[j], mode);
if (vent->next != NULL)
(void)putchar(' ');
}
(void)putchar('\n');
if (prtheader && lineno++ == prtheader - 4) {
(void)putchar('\n');
printheader();
lineno = 0;
}
}
}
}
exit(eval);
/* NOTREACHED */
}
static struct kinfo_lwp *
pick_representative_lwp(ki, kl, nlwps)
struct kinfo_proc2 *ki;
struct kinfo_lwp *kl;
int nlwps;
{
int i, onproc, running, sleeping, stopped, suspended;
static struct kinfo_lwp zero_lwp;
if (kl == 0)
return &zero_lwp;
/* Trivial case: only one LWP */
if (nlwps == 1)
return kl;
switch (ki->p_realstat) {
case SSTOP:
case SACTIVE:
/* Pick the most live LWP */
onproc = running = sleeping = stopped = suspended = -1;
for (i = 0; i < nlwps; i++) {
switch (kl[i].l_stat) {
case LSONPROC:
onproc = i;
break;
case LSRUN:
running = i;
break;
case LSSLEEP:
sleeping = i;
break;
case LSSTOP:
stopped = i;
break;
case LSSUSPENDED:
suspended = i;
break;
}
}
if (onproc != -1)
return &kl[onproc];
if (running != -1)
return &kl[running];
if (sleeping != -1)
return &kl[sleeping];
if (stopped != -1)
return &kl[stopped];
if (suspended != -1)
return &kl[suspended];
break;
case SDEAD:
case SZOMB:
/* First will do */
return kl;
break;
}
/* Error condition! */
warnx("Inconsistent LWP state for process %d\n", ki->p_pid);
return kl;
}
static struct kinfo_proc2 *
getkinfo_kvm(kdp, what, flag, nentriesp)
kvm_t *kdp;
@ -532,7 +642,7 @@ usage()
(void)fprintf(stderr,
"usage:\t%s\n\t %s\n\t%s\n",
"ps [-acCehjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty]",
"ps [-acCehjlmrsSTuvwx] [-O|o fmt] [-p pid] [-t tty]",
"[-M core] [-N system] [-W swap] [-U username]",
"ps [-L]");
exit(1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.h,v 1.18 2002/04/24 21:41:22 nathanw Exp $ */
/* $NetBSD: ps.h,v 1.19 2003/01/18 10:52:18 thorpej Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -58,9 +58,10 @@ typedef struct var {
#define COMM 0x01 /* needs exec arguments and environment (XXX) */
#define LJUST 0x02 /* left adjust on output (trailing blanks) */
#define INF127 0x04 /* 127 = infinity: if > 127, print 127. */
#define LWP 0x08 /* dispatch to kinfo_lwp routine */
u_int flag;
/* output routine */
void (*oproc) __P((struct kinfo_proc2 *, struct varent *, int));
void (*oproc) __P((void *, struct varent *, int));
short width; /* printing width */
/*
* The following (optional) elements are hooks for passing information
@ -78,4 +79,11 @@ typedef struct var {
double longestnd; /* longest negative double */
} VAR;
#define OUTPUT(vent, ki, kl, mode) do { \
if ((vent)->var->flag & LWP) \
((vent)->var->oproc)((void *)(kl), (vent), (mode)); \
else \
((vent)->var->oproc)((void *)(ki), (vent), (mode)); \
} while (/*CONSTCOND*/ 0)
#include "extern.h"

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.107 2002/08/19 14:55:14 lukem Exp $
# $NetBSD: Makefile,v 1.108 2003/01/18 11:04:39 thorpej Exp $
# @(#)Makefile 8.2 (Berkeley) 2/3/94
#
# All library objects contain sccsid strings by default; they may be
@ -90,6 +90,7 @@ INCSDIR= /usr/include
.include "${.CURDIR}/stdlib/Makefile.inc"
.include "${.CURDIR}/string/Makefile.inc"
.include "${.CURDIR}/termios/Makefile.inc"
.include "${.CURDIR}/thread-stub/Makefile.inc"
.include "${.CURDIR}/time/Makefile.inc"
.include "${.CURDIR}/sys/Makefile.inc"
.if (${MKYP} != "no")

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.8 2002/02/19 13:08:16 simonb Exp $
# $NetBSD: Makefile.inc,v 1.9 2003/01/18 11:04:39 thorpej Exp $
SRCS+= fabs.S
@ -14,5 +14,7 @@ SRCS+= setjmp.S __setjmp14.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
SRCS+= byte_swap_2.S byte_swap_4.S bswap64.c
SRCS+= makecontext.c resumecontext.c swapcontext.S _lwp.c
LSRCS+= Lint_bswap16.c Lint_bswap32.c
DPSRCS+= Lint_bswap16.c Lint_bswap32.c

View File

@ -0,0 +1,64 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:04:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nathan J. Williams.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
__greg_t *gr;
getcontext(u);
gr = u->uc_mcontext.__gregs;
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
gr[_REG_PC] = (unsigned long)start;
gr[_REG_T12] = (unsigned long) start;
gr[_REG_RA] = (unsigned long) _lwp_exit;
gr[_REG_A0] = (unsigned long) arg;
gr[_REG_SP] = ((unsigned long) (stack_base + stack_size)) & ~0x7;
gr[_REG_S6] = 0;
}

View File

@ -0,0 +1,79 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:04:39 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:04:39 thorpej Exp $");
#endif
#include <stddef.h>
#include <inttypes.h>
#include <ucontext.h>
#include "extern.h"
#include <stdarg.h>
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
int i;
unsigned long *sp;
va_list ap;
/* Compute and align stack pointer. */
sp = (unsigned long *)
(((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~0x7);
/* Allocate necessary stack space for arguments exceeding a0-5. */
if (argc > 6)
sp -= (argc - 6);
gr[_REG_SP] = (__greg_t)sp;
/* Arrange for return via the trampoline code. */
gr[_REG_RA] = (__greg_t)_resumecontext;
gr[_REG_PC] = (__greg_t)func;
gr[_REG_PV] = (__greg_t)func;
va_start(ap, argc);
/* Pass up to six arguments in a0-5. */
for (i = 0; i < argc && i < 6; i++)
gr[_REG_A0 + i] = va_arg(ap, unsigned long);
/* Pass any additional arguments on the stack. */
for (argc -= i; argc > 0; argc--)
*sp++ = va_arg(ap, unsigned long);
va_end(ap);
}

View File

@ -0,0 +1,56 @@
/* $NetBSD: resumecontext.c,v 1.2 2003/01/18 11:04:39 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.2 2003/01/18 11:04:39 thorpej Exp $");
#endif
#include "namespace.h"
#include <ucontext.h>
#include "extern.h"
void
_resumecontext()
{
ucontext_t uct;
(void)getcontext(&uct);
(void)setcontext(uct.uc_link);
/* NOTREACHED */
}

View File

@ -0,0 +1,62 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:04:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
NESTED(swapcontext, 2, 24, ra, IM_RA|IM_A0|IM_A1, 0)
LDGP(pv)
lda sp, -24(sp)
stq ra, (24- 8)(sp) /* must save ra, oucp, ucp */
stq a0, (24-16)(sp)
stq a1, (24-24)(sp)
CALL(_getcontext) /* getcontext(oucp) */
ldq t0, (24-16)(sp)
bne v0, Lerr
ldq t1, (24- 8)(sp)
stq t1, (56 + 26 * 8)(t0) /* Adjust saved RA */
stq t1, (56 + 32 * 8)(t0) /* Adjust saved PC */
lda t1, 24(sp)
stq t1, (56 + 30 * 8)(t0) /* Adjust saved SP */
ldq a0, (24-24)(sp)
CALL(setcontext) /* setcontext(ucp) */
Lerr:
ldq ra, (24- 8)(sp)
lda sp, 24(sp)
RET
END(swapcontext)

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:35 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:04:40 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -0,0 +1,50 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:04:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
LEAF(_getcontext, 1)
CALLSYS_ERROR(getcontext)
stq ra, (56 + 32 * 8)(a0) /* Adjust saved PC */
stq zero, (56 + 0 * 8)(a0) /* Arrange for a return value of 0 */
RET
END(_getcontext)

View File

@ -1,37 +0,0 @@
/* $NetBSD: setlogin.S,v 1.2 2000/06/14 06:49:03 cgd Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include "SYS.h"
IMPORT(__logname_valid, 4) /* in getlogin() */
SYSCALL(setlogin)
stl zero, __logname_valid /* clear it */
RET
END(setlogin)

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.2 2002/02/19 13:08:17 simonb Exp $
# $NetBSD: Makefile.inc,v 1.3 2003/01/18 11:06:24 thorpej Exp $
SRCS+= alloca.S byte_swap_2.S byte_swap_4.S bswap64.c divsi3.S \
fabs.c flt_rounds.c \
@ -13,5 +13,12 @@ SRCS+= setjmp.S __setjmp14.S
SRCS+= _setjmp.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
SRCS+= makecontext.c resumecontext.c swapcontext.S
SRCS+= _lwp.c
LSRCS+= Lint_bswap16.c Lint_bswap32.c
DPSRCS+= Lint_bswap16.c Lint_bswap32.c
LSRCS+= Lint_swapcontext.c
DPSRCS+= Lint_swapcontext.c

View File

@ -0,0 +1,65 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:06:25 thorpej Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
void **sp;
getcontext(u);
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
sp = (void **) (stack_base + stack_size);
/*
* Note: We make sure the stack is 8-byte aligned, here.
*/
u->uc_mcontext.__gregs[_REG_R0] = (__greg_t) arg;
u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t) sp) & ~7;
u->uc_mcontext.__gregs[_REG_LR] = (__greg_t) _lwp_exit;
u->uc_mcontext.__gregs[_REG_PC] = (__greg_t) start;
}

View File

@ -0,0 +1,80 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:06:24 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:06:24 thorpej Exp $");
#endif
#include <stddef.h>
#include <inttypes.h>
#include <ucontext.h>
#include "extern.h"
#include <stdarg.h>
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
int i;
unsigned int *sp;
va_list ap;
/* Compute and align stack pointer. */
sp = (unsigned int *)
(((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~7);
/* Allocate necessary stack space for arguments exceeding r0-3. */
if (argc > 4)
sp -= argc - 4;
gr[_REG_SP] = (__greg_t)sp;
/* Wipe out frame pointer. */
gr[_REG_FP] = 0;
/* Arrange for return via the trampoline code. */
gr[_REG_LR] = (__greg_t)_resumecontext;
gr[_REG_PC] = (__greg_t)func;
va_start(ap, argc);
/* Pass up to four arguments in r0-3. */
for (i = 0; i < argc && i < 4; i++)
gr[_REG_R0 + i] = va_arg(ap, int);
/* Pass any additional arguments on the stack. */
for (argc -= i; argc > 0; argc--)
*sp++ = va_arg(ap, int);
va_end(ap);
}

View File

@ -0,0 +1,56 @@
/* $NetBSD: resumecontext.c,v 1.2 2003/01/18 11:06:25 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.2 2003/01/18 11:06:25 thorpej Exp $");
#endif
#include "namespace.h"
#include <ucontext.h>
#include "extern.h"
void
_resumecontext()
{
ucontext_t uct;
(void)getcontext(&uct);
(void)setcontext(uct.uc_link);
/* NOTREACHED */
}

View File

@ -0,0 +1,65 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:06:25 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: swapcontext.S,v 1.2 2003/01/18 11:06:25 thorpej Exp $")
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
stmfd sp!, {r0-r1, lr} /* Must save oucp, ucp, lr. */
bl PIC_SYM(_C_LABEL(_getcontext), PLT) /* getcontext(oucp) */
cmp r0, #0
ldmfd sp!, {r0-r1, lr}
#ifdef __APCS_26__
movnes pc, lr
#else
movne pc, lr
#endif
str lr, [r0, #(36 + 15*4)] /* Adjust saved PC. */
#ifdef SOFTFLOAT
/* Ahem. */
#endif
mov r0, r1
bl PIC_SYM(_C_LABEL(setcontext), PLT)
#ifdef __APCS_26__
movs pc, lr
#else
mov pc, lr
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:36 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:06:25 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -0,0 +1,65 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:06:25 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: getcontext.S,v 1.2 2003/01/18 11:06:25 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
ENTRY(_getcontext)
mov r2, r0 /* Must save argument pointer. */
swi SYS_getcontext
bcs PIC_SYM(CERROR, PLT)
str lr, [r2, #(36 + 15*4)] /* Adjust PC. */
#ifdef SOFTFLOAT
/* Ahem. */
/* Judging from the softfloat code we should at least save
the exception codes and rounding mode here. */
#endif
mov r0, #0
str r0, [r2, #(36 + 0*4)] /* Return 0. */
#ifdef __APCS_26__
movs pc, lr
#else
mov pc, lr
#endif

View File

@ -1,69 +0,0 @@
/* $NetBSD: setlogin.S,v 1.3 2002/08/17 19:54:32 thorpej Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)setlogin.s 5.2 (Berkeley) 4/12/91
*/
#include <machine/asm.h>
#include "SYS.h"
.globl _C_LABEL(__logname_valid) /* in getlogin() */
SYSCALL(setlogin)
#ifdef PIC
/* Setup the GOT */
ldr r0, .Lgot
add r0, pc, r0
.L1:
ldr r1, .Llogname
ldr r1, [r0, r1]
#else
ldr r1, .Llogname
#endif
mov r0, #0x00000000
str r0, [r1]
#ifdef __APCS_26__
movs r15, r14
#else
mov r15, r14
#endif
#ifdef PIC
.align 0
.Lgot:
.word _C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (.L1+4))
#endif
.Llogname:
.word PIC_SYM(_C_LABEL(__logname_valid), GOT)

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.12 2002/02/19 13:08:19 simonb Exp $
# $NetBSD: Makefile.inc,v 1.13 2003/01/18 11:08:11 thorpej Exp $
# objects built from assembler sources (need lint stubs)
SRCS+= alloca.S byte_swap_2.S byte_swap_4.S fabs.S modf.S \
@ -9,8 +9,10 @@ SRCS+= setjmp.S __setjmp14.S
SRCS+= _setjmp.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
SRCS+= resumecontext.S swapcontext.S
# objects built from C sources
SRCS+= bswap64.c ldexp.c
SRCS+= bswap64.c ldexp.c _lwp.c makecontext.c
# Common ieee754 constants and functions
SRCS+= ieee754_infinity.c ieee754_nanf.c
@ -24,9 +26,11 @@ LSRCS+= Lint__setjmp.c Lint_alloca.c Lint_bswap16.c Lint_bswap32.c \
Lint_fabs.c Lint_modf.c \
Lint___setjmp14.c Lint___sigsetjmp14.c Lint_flt_rounds.c \
Lint_fpgetmask.c Lint_fpgetround.c Lint_fpgetsticky.c \
Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c
Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c \
Lint_resumecontext.c Lint_swapcontext.c
DPSRCS+= Lint__setjmp.c Lint_alloca.c Lint_bswap16.c Lint_bswap32.c \
Lint_fabs.c Lint_modf.c \
Lint___setjmp14.c Lint___sigsetjmp14.c Lint_flt_rounds.c \
Lint_fpgetmask.c Lint_fpgetround.c Lint_fpgetsticky.c \
Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c
Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c \
Lint_resumecontext.c Lint_swapcontext.c

View File

@ -0,0 +1,70 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:08:12 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nathan J. Williams.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <inttypes.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
void **sp;
getcontext(u);
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
/* LINTED uintptr_t is safe */
u->uc_mcontext.__gregs[_REG_EIP] = (uintptr_t)start;
/* Align to a word */
sp = (void **) ((uintptr_t)(stack_base + stack_size) & ~0x3);
*--sp = arg;
*--sp = (void *) _lwp_exit;
/* LINTED uintptr_t is safe */
u->uc_mcontext.__gregs[_REG_UESP] = (uintptr_t) sp;
/* LINTED private is currently unused */
}

View File

@ -0,0 +1,98 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:08:11 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:08:11 thorpej Exp $");
#endif
#include <inttypes.h>
#include <stddef.h>
#include <ucontext.h>
#include "extern.h"
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
#else
makecontext(ucp, func, argc, va_alist)
ucontext_t *ucp;
void (*func)();
int argc;
va_dcl
#endif
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
unsigned int *sp;
va_list ap;
/* LINTED __greg_t is safe */
gr[_REG_EIP] = (__greg_t)func;
/* LINTED uintptr_t is safe */
sp = (int *)((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
/* LINTED uintptr_t is safe */
sp = (int *)((uintptr_t)sp & ~0x3); /* Align on word boundary. */
sp -= argc + 1; /* Make room for ret and args. */
/* LINTED __greg_t is safe */
gr[_REG_UESP] = (__greg_t)sp;
gr[_REG_EBP] = (__greg_t)0; /* Wipe out frame pointer. */
/* Put return address on top of stack. */
/* LINTED uintptr_t is safe */
*sp++ = (uintptr_t)_resumecontext;
/* Construct argument list. */
#if __STDC__
va_start(ap, argc);
#else
va_start(ap);
#endif
while (argc-- > 0) {
/* LINTED uintptr_t is safe */
*sp++ = va_arg(ap, uintptr_t);
}
va_end(ap);
}

View File

@ -0,0 +1,71 @@
/* $NetBSD: resumecontext.S,v 1.2 2003/01/18 11:08:12 thorpej Exp $ &/
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: resumecontext.S,v 1.2 2003/01/18 11:08:12 thorpej Exp $")
#endif /* LIBC_SCCS && !lint */
/*
* This assembly-language implementation differs from the (obvious)
* C-language implementation only in not clobbering the previous
* function's return address (us), which is the point of the exercise.
*/
NENTRY(_resumecontext) /* profiling prologue would clobber TOS */
subl $(4 + 512),%esp
movl %esp,%ecx
PIC_PROLOGUE
pushl %ecx
#ifdef PIC
call PIC_PLT(_C_LABEL(_getcontext))
#else
call _C_LABEL(_getcontext)
#endif
addl $4,%esp
PIC_EPILOGUE
movl 4(%esp),%ecx
PIC_PROLOGUE
pushl %ecx
#ifdef PIC
call PIC_PLT(_C_LABEL(setcontext))
#else
call _C_LABEL(setcontext)
#endif
/* NOTREACHED */

View File

@ -0,0 +1,79 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:08:12 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: swapcontext.S,v 1.2 2003/01/18 11:08:12 thorpej Exp $")
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
movl 4(%esp),%ecx
PIC_PROLOGUE
pushl %ecx /* push oucp */
#ifdef PIC
call PIC_PLT(_C_LABEL(getcontext))
#else
call _C_LABEL(getcontext)
#endif
addl $4,%esp /* pop oucp */
PIC_EPILOGUE
testl %eax,%eax
jnz 2f
movl 4(%esp),%ecx
movl 0(%esp),%edx
movl %edx,(36 + 14 * 4)(%ecx) /* Adjust saved %eip ... */
#ifdef PIC
movl %ebx,(36 + 8 * 4)(%ecx) /* ... clobbered PIC reg ... */
leal 12(%esp),%edx
#else
leal 8(%esp),%edx
#endif
movl %edx,(36 + 17 * 36)(%ecx) /* ... and %esp. */
/* Note: oucp->%eax has been cleared by getcontext(). */
movl 8(%esp),%ecx
PIC_PROLOGUE
pushl %ecx /* push ucp */
#ifdef PIC
call PIC_PLT(_C_LABEL(setcontext))
#else
call _C_LABEL(setcontext)
#endif
addl $4,%esp /* pop ucp */
PIC_EPILOGUE
/* No need to error-check: setcontext() must have failed. */
2: ret

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:36 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:08:12 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -0,0 +1,57 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:08:12 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: getcontext.S,v 1.2 2003/01/18 11:08:12 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
_SYSCALL(_getcontext,getcontext)
movl 4(%esp),%ecx
movl 0(%esp),%edx
movl %edx,(36 + 14 * 4)(%ecx) /* Adjust saved %eip ... */
leal 4(%esp),%edx
movl %edx,(36 + 17 * 4)(%ecx) /* ... and %esp. */
movl $0,(36 + 11 * 4)(%ecx) /* Arrange for return of 0. */
xorl %eax,%eax
ret

View File

@ -1,59 +0,0 @@
/* $NetBSD: setlogin.S,v 1.7 1998/07/01 06:24:25 thorpej Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)setlogin.s 5.2 (Berkeley) 4/12/91
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: setlogin.S,v 1.7 1998/07/01 06:24:25 thorpej Exp $")
#endif
#include "SYS.h"
.globl _C_LABEL(__logname_valid) /* in getlogin() */
SYSCALL(setlogin)
xorl %eax,%eax
#ifdef PIC
PIC_PROLOGUE
movl PIC_GOT(_C_LABEL(__logname_valid)),%edx
PIC_EPILOGUE
movl %eax,(%edx)
#else
movl %eax,_C_LABEL(__logname_valid)
#endif
ret /* setlogin(name) */

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.14 2002/02/19 13:08:20 simonb Exp $
# $NetBSD: Makefile.inc,v 1.15 2003/01/18 11:09:36 thorpej Exp $
SRCS+= alloca.S fabs.S
@ -10,6 +10,7 @@ SRCS+= ashlsi3.S ashrsi3.S \
lshlsi3.S lshrsi3.S \
negdf2.S negsf2.S
SRCS+= bswap16.S bswap32.S bswap64.S
SRCS+= _lwp.c
# 68000-based machines build with a libgcc that includes
# much of the (soft)float and integer support that would
@ -32,6 +33,8 @@ SRCS+= setjmp.S __setjmp14.S
SRCS+= _setjmp.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
SRCS+= makecontext.c resumecontext.S swapcontext.S
.ifdef M68040
SRCS+= ieee754_ldexp.c # generic ieee754 version
.elifdef M68060
@ -43,3 +46,6 @@ SRCS+= ldexp_881.c
.endif
LSRCS+= Lint_bswap16.c Lint_bswap32.c Lint_bswap64.c
DPSRCS+= Lint_bswap16.c Lint_bswap32.c Lint_bswap64.c
LSRCS+= Lint_resumecontext.c Lint_swapcontext.c
DPSRCS+= Lint_resumecontext.c Lint_swapcontext.c

View File

@ -0,0 +1,64 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:09:36 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nathan J. Williams and Steve C. Woodford.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
void **sp;
getcontext(u);
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
u->uc_mcontext.__gregs[_REG_PC] = (int)start;
sp = (void **) (stack_base + stack_size);
*--sp = arg;
*--sp = (void *) _lwp_exit;
u->uc_mcontext.__gregs[_REG_A7] = (int) sp;
}

View File

@ -0,0 +1,72 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:09:36 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:09:36 thorpej Exp $");
#endif
#include <sys/types.h>
#include <inttypes.h>
#include <ucontext.h>
#include "extern.h"
#include <stdarg.h>
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
mcontext_t *mcp = &ucp->uc_mcontext;
int *sp;
va_list ap;
mcp->__gregs[_REG_PC] = (__greg_t)func;
sp = (int *)((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
sp = (int *)((uintptr_t)sp & ~0x3); /* Align on word boundary. */
sp -= (argc + 1); /* Make room for retaddr and args. */
mcp->__gregs[_REG_A7] = (__greg_t)sp;
mcp->__gregs[_REG_A6] = 0; /* Wipe out frame pointer. */
*sp++ = (int)_resumecontext;
va_start(ap, argc);
while (argc-- > 0)
*sp++ = va_arg(ap, int);
va_end(ap);
}

View File

@ -0,0 +1,58 @@
/* $NetBSD: resumecontext.S,v 1.2 2003/01/18 11:09:36 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: resumecontext.S,v 1.2 2003/01/18 11:09:36 thorpej Exp $")
#endif /* LIBC_SCCS && !lint */
/*
* This assembly-language implementation differs from the (obvious)
* C-language implementation only in not clobbering the previous
* function's return address (us), which is the point of the exercise.
*/
ENTRY(_resumecontext)
subl #(4 + 1024),%sp | retattr preservation + ucontext_t
lea %sp@,%a0
movl %a0,%sp@-
jbsr PIC_PLT(_C_LABEL(_getcontext))
movl %sp@(4 + 4),%sp@
jbsr PIC_PLT(_C_LABEL(setcontext))
/* NOTREACHED */

View File

@ -0,0 +1,56 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:09:36 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: swapcontext.S,v 1.2 2003/01/18 11:09:36 thorpej Exp $")
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
movl %sp@(4),%sp@- | push oucp on stack
jbsr PIC_PLT(_C_LABEL(_getcontext)) | getcontext(oucp)
tstl %d0 | OK?
jne L1
movl %sp@,%a0
addql #8,%a0@(96) | adjust saved stack pointer (again)
movl %sp@(4),%a0@(100) | adjust saved program counter (again)
movl %sp@(12),%sp@ | push ucp on stack
jbsr PIC_PLT(_C_LABEL(setcontext)) | setcontext(ucp)
L1: addql #4,%sp | pop ucp
rts

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:37 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:09:37 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -0,0 +1,54 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:09:37 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: getcontext.S,v 1.2 2003/01/18 11:09:37 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
_SYSCALL(_getcontext,getcontext)
movl %sp@(4),%a0
addql #4,%a0@(96) | adjust saved stack pointer
movl %sp@,%a0@(100) | adjust saved program counter
clrl %a0@(36) | arrange for return value of 0
rts

View File

@ -1,62 +0,0 @@
/* $NetBSD: setlogin.S,v 1.7 1999/10/25 23:48:17 thorpej Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)setlogin.s 5.1 (Berkeley) 5/6/91")
#else
RCSID("$NetBSD: setlogin.S,v 1.7 1999/10/25 23:48:17 thorpej Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
.globl _C_LABEL(__logname_valid) /* in getlogin() */
SYSCALL(setlogin)
#ifdef PIC
#ifdef __ELF__
lea %pc@(_GLOBAL_OFFSET_TABLE_@GOTPC),%a1
movl %a1@(_C_LABEL(__logname_valid)@GOT:w),%a1
#else
movl #_C_LABEL(_GLOBAL_OFFSET_TABLE_),%a1
lea %pc@(0,%a1:l),%a1
movl %a1@(_C_LABEL(__logname_valid):w),%a1
#endif
clrl %a1@
#else
clrl _C_LABEL(__logname_valid)
#endif
rts /* setlogin(name) */

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.13 2002/02/19 13:08:23 simonb Exp $
# $NetBSD: Makefile.inc,v 1.14 2003/01/18 11:10:43 thorpej Exp $
SRCS+= fabs.S ldexp.S modf.S
@ -14,8 +14,13 @@ SRCS+= _setjmp.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
SRCS+= byte_swap_2.S byte_swap_4.S bswap64.c
SRCS+= makecontext.c resumecontext.c _resumecontext.S swapcontext.S _lwp.c
# mips abi builtin extensions (used by GCC for lexical-closure trampoline)
SRCS+= cacheflush.c
LSRCS+= Lint_bswap16.c Lint_bswap32.c
DPSRCS+= Lint_bswap16.c Lint_bswap32.c
LSRCS+= Lint_swapcontext.c
DPSRCS+= Lint_swapcontext.c

View File

@ -0,0 +1,65 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:10:44 thorpej Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Wayne Knowles
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
#define CALLFRAME_SIZ 24
void _lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
caddr_t sp;
__greg_t *gr;
getcontext(u);
gr = u->uc_mcontext.__gregs;
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
sp = stack_base + stack_size - CALLFRAME_SIZ;
gr[_REG_EPC] = (unsigned long) start;
gr[_REG_T9] = (unsigned long) start; /* required for .abicalls */
gr[_REG_RA] = (unsigned long) _lwp_exit;
gr[_REG_A0] = (unsigned long) arg;
gr[_REG_SP] = (unsigned long) sp;
}

View File

@ -0,0 +1,55 @@
/* $NetBSD: _resumecontext.S,v 1.2 2003/01/18 11:38:51 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Wayne Knowles.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#include <machine/mcontext.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
ASMSTR("$NetBSD: _resumecontext.S,v 1.2 2003/01/18 11:38:51 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
.set reorder
LEAF_NOPROFILE(__resumecontext)
move t9, ra
PIC_PROLOGUE(_resumecontext, t9)
la t9, _C_LABEL(_resumecontext)
jr t9
nop
END(__resumecontext)

View File

@ -0,0 +1,85 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:10:44 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:10:44 thorpej Exp $");
#endif
#include <inttypes.h>
#include <stddef.h>
#include <ucontext.h>
#include "extern.h"
#include <stdarg.h>
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
uintptr_t *sp;
int i;
va_list ap;
void __resumecontext(void);
/* LINTED uintptr_t is safe */
sp = (uintptr_t *)
((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
/* LINTED uintptr_t is safe */
sp -= (argc >= 4 ? argc : 4); /* Make room for >=4 arguments. */
sp = (uintptr_t *)
((u_long)sp & ~0x7); /* Align on double-word boundary. */
gr[_REG_SP] = (__greg_t)sp;
gr[_REG_RA] = (__greg_t)__resumecontext;
gr[_REG_T9] = (__greg_t)func; /* required for .abicalls */
gr[_REG_EPC] = (__greg_t)func;
/* Construct argument list. */
va_start(ap, argc);
/* Up to the first four arguments are passed in $a0-3. */
for (i = 0; i < argc && i < 4; i++)
/* LINTED uintptr_t is safe */
gr[_REG_A0 + i] = va_arg(ap, uintptr_t);
/* Pass remaining arguments on the stack above the $a0-3 gap. */
for (sp += 4; i < argc; i++)
/* LINTED uintptr_t is safe */
*sp++ = va_arg(ap, uintptr_t);
va_end(ap);
}

View File

@ -0,0 +1,56 @@
/* $NetBSD: resumecontext.c,v 1.2 2003/01/18 11:10:44 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.2 2003/01/18 11:10:44 thorpej Exp $");
#endif
#include "namespace.h"
#include <ucontext.h>
#include "extern.h"
void
_resumecontext()
{
ucontext_t uct;
(void)getcontext(&uct);
(void)setcontext(uct.uc_link);
/* NOTREACHED */
}

View File

@ -0,0 +1,76 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:10:44 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#include <machine/mcontext.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
ASMSTR("$NetBSD: swapcontext.S,v 1.2 2003/01/18 11:10:44 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
#ifdef __ABICALLS__
.abicalls
#endif
.set reorder
NESTED(swapcontext, CALLFRAME_SIZ, ra)
.mask 0x80000030, (CALLFRAME_RA - CALLFRAME_SIZ)
subu sp, sp, CALLFRAME_SIZ
sw ra, CALLFRAME_RA(sp) # save ra
sw a0, 0(sp) # stash away oucp
sw a1, 4(sp) # stash away ucp
SYSTRAP(getcontext)
lw ra, CALLFRAME_RA(sp)
bne a3, zero, 1f
lw v1, 0(sp) # load oucp again for adjustment
lw a0, 4(sp) # load ucp
addiu v0, sp, CALLFRAME_SIZ
REG_PROLOGUE
REG_S zero, (_OFFSETOF_UC_GREGS + _REG_V0 * SZREG)(v1)
REG_S ra, (_OFFSETOF_UC_GREGS + _REG_EPC * SZREG)(v1)
REG_S v0, (_OFFSETOF_UC_GREGS + _REG_SP * SZREG)(v1)
REG_EPILOGUE
SYSTRAP(setcontext)
/* NOTREACHED */
1:
addiu sp, sp, CALLFRAME_SIZ
la t9, _C_LABEL(__cerror)
jr t9
END(swapcontext)

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:37 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:10:45 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -1,4 +1,4 @@
/* $NetBSD: cerror.S,v 1.10 2002/11/10 18:10:26 thorpej Exp $ */
/* $NetBSD: cerror.S,v 1.11 2003/01/18 11:11:36 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -40,9 +40,31 @@
#if defined(LIBC_SCCS) && !defined(lint)
ASMSTR("from: @(#)cerror.s 8.1 (Berkeley) 6/16/93")
ASMSTR("$NetBSD: cerror.S,v 1.10 2002/11/10 18:10:26 thorpej Exp $")
ASMSTR("$NetBSD: cerror.S,v 1.11 2003/01/18 11:11:36 thorpej Exp $")
#endif /* LIBC_SCCS and not lint */
#ifdef _REENTRANT
.globl _C_LABEL(__errno)
NESTED_NOPROFILE(__cerror, CALLFRAME_SIZ, ra)
PIC_PROLOGUE(__cerror, t9)
subu sp, sp, CALLFRAME_SIZ
.mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
sw ra, CALLFRAME_RA(sp)
sw v0, 12(sp) # save errno value
la t9, _C_LABEL(__errno) # locate address of errno
jalr t9
nop
lw t0, 12(sp)
lw ra, CALLFRAME_RA(sp)
sw t0, 0(v0) # update errno value
addiu sp, sp, CALLFRAME_SIZ
li v0, -1
j ra
move v1, v0 # -BDSlot
END(__cerror)
#else
.globl _C_LABEL(errno)
LEAF_NOPROFILE(__cerror)
.set noreorder
@ -52,5 +74,6 @@ LEAF_NOPROFILE(__cerror)
sw v0, _C_LABEL(errno)
li v0, -1
j ra
li v1, -1
move v1, v0
END(__cerror)
#endif /* _REENTRANT */

View File

@ -0,0 +1,61 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:10:45 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#include <machine/mcontext.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
ASMSTR("$NetBSD: getcontext.S,v 1.2 2003/01/18 11:10:45 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
.set reorder
LEAF(_getcontext)
SYSTRAP(getcontext)
bne a3, zero, 1f
REG_PROLOGUE
REG_S zero, (_OFFSETOF_UC_GREGS + _REG_V0 * SZREG)(a0)
REG_S ra, (_OFFSETOF_UC_GREGS + _REG_EPC * SZREG)(a0)
REG_EPILOGUE
j ra
1:
PIC_CALL(__cerror, t9)
END(_getcontext)

View File

@ -1,60 +0,0 @@
/* $NetBSD: setlogin.S,v 1.9 2002/11/10 18:10:26 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
ASMSTR("from: @(#)setlogin.s 8.1 (Berkeley) 6/4/93")
ASMSTR("$NetBSD: setlogin.S,v 1.9 2002/11/10 18:10:26 thorpej Exp $")
#endif /* LIBC_SCCS and not lint */
LEAF(setlogin)
#ifdef __ABICALLS__
.set noreorder
.cpload t9
.set reorder
#endif
li v0, SYS_setlogin # setlogin(name)
syscall
bne a3, zero, 1f
sw zero, _C_LABEL(__logname_valid) # in getlogin()
j ra
1:
la t9, _C_LABEL(__cerror)
jr t9
END(setlogin)

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.9 2002/02/19 13:08:26 simonb Exp $
# $NetBSD: Makefile.inc,v 1.10 2003/01/18 11:12:53 thorpej Exp $
SRCS+= _setjmp.S setjmp.S sigsetjmp.S __setjmp14.S __sigsetjmp14.S
SRCS+= bswap16.c bswap32.c bswap64.c
@ -6,10 +6,12 @@ SRCS+= fabs.c flt_rounds.c
SRCS+= fpgetround.c fpsetround.c fpgetmask.c fpsetmask.c
SRCS+= fpgetsticky.c fpsetsticky.c
SRCS+= syncicache.c
SRCS+= _lwp.c makecontext.c resumecontext.c swapcontext.S
# Common ieee754 constants and functions
SRCS+= ieee754_infinity.c ieee754_nanf.c
SRCS+= ieee754_frexp.c ieee754_isinf.c ieee754_isnan.c ieee754_ldexp.c
SRCS+= ieee754_modf.c
KMSRCS+=syncicache.c
LSRCS+= Lint_swapcontext.c
DPSRCS+=Lint_swapcontext.c

View File

@ -0,0 +1,61 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:12:53 thorpej Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Allen Briggs for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *), void *arg,
void *private, caddr_t stack_base, size_t stack_size)
{
void **sp;
getcontext(u);
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
sp = (void **) (stack_base + stack_size);
u->uc_mcontext.__gregs[3] = (int) arg; /* arg1 */
u->uc_mcontext.__gregs[1] = ((int) sp) - 12; /* stack */
u->uc_mcontext.__gregs[33] = (int) _lwp_exit; /* LR */
u->uc_mcontext.__gregs[34] = (int) start; /* PC */
}

View File

@ -0,0 +1,91 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:12:54 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:12:54 thorpej Exp $");
#endif
#include <inttypes.h>
#include <stddef.h>
#include <ucontext.h>
#include "extern.h"
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
int *sp;
int i;
va_list ap;
/* LINTED uintptr_t is safe */
sp = (int *)
((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
/* LINTED uintptr_t is safe */
sp -= 2 + (argc > 8 ? argc - 8: 0); /* Make room for call frame. */
sp = (int *)
((uintptr_t)sp & ~0xf); /* Align on quad-word boundary. */
/*
* Start executing at <func> -- when <func> completes, return to
* <_resumecontext>.
*/
gr[1] = (__greg_t)sp;
gr[33] = (__greg_t)_resumecontext;
gr[34] = (__greg_t)func;
/* Wipe out stack frame backchain pointer. */
*sp = 0;
/* Construct argument list. */
va_start(ap, argc);
/* Up to the first eight arguments are passed in r3-10. */
for (i = 0; i < argc && i < 8; i++)
gr[3 + i] = va_arg(ap, int);
/* Pass remaining arguments on the stack above the backchain/lr gap. */
for (sp += 2; i < argc; i++)
*sp++ = va_arg(ap, int);
va_end(ap);
}

View File

@ -0,0 +1,56 @@
/* $NetBSD: resumecontext.c,v 1.2 2003/01/18 11:12:54 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.2 2003/01/18 11:12:54 thorpej Exp $");
#endif
#include "namespace.h"
#include <ucontext.h>
#include "extern.h"
void
_resumecontext()
{
ucontext_t uct;
(void)getcontext(&uct);
(void)setcontext(uct.uc_link);
/* NOTREACHED */
}

View File

@ -0,0 +1,66 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:12:54 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
.text
.asciz "$NetBSD: swapcontext.S,v 1.2 2003/01/18 11:12:54 thorpej Exp $"
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
stwu 1, -16(1) # set up new stack frame
mflr 0
stw 0, 20(1) # save link register
stw 3, 8(1) # must save oucp
stw 4, 12(1) # must save ucp
bl PIC_PLT(_C_LABEL(_getcontext)) # getcontext(oucp)
cmpwi 3, 0
bne 1f
lwz 11, 8(1) # load oucp for adjustment
lwz 0, 20(1)
stw 0, (48 + 34 * 4)(11) # pc <- lr
la 0, 16(1)
stw 0, (48 + 1 * 4)(11) # adjust sp
lwz 3, 12(1) # load ucp
bl PIC_PLT(_C_LABEL(setcontext)) # setcontext(ucp)
1:
lwz 0, 20(1)
mtlr 0
la 1, 16(1)
blr

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:38 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:12:55 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -0,0 +1,60 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:12:55 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(SYSLIBC_SCCS) && !defined(lint)
.text
.asciz "$NetBSD: getcontext.S,v 1.2 2003/01/18 11:12:55 thorpej Exp $"
#endif /* SYSLIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
ENTRY(_getcontext)
mr 5, 3 # must save pointer
li 0, SYS_getcontext
sc
bso 1f
mflr 4
stw 4, (48 + 34 * 4)(5) # saved pc <- lr
stw 3, (48 + 3 * 4)(5) # arrange for return value 0
blr
1:
b PIC_PLT(_C_LABEL(__cerror))

View File

@ -1,21 +0,0 @@
/* $NetBSD: setlogin.S,v 1.4 2002/07/30 06:08:01 matt Exp $ */
#include "SYS.h"
.globl _C_LABEL(__logname_valid) /* in getlogin() */
SYSCALL(setlogin)
#ifdef PIC
mflr %r10
bl _GLOBAL_OFFSET_TABLE_@local-4
mflr %r4
lwz %r4,_C_LABEL(__logname_valid)@got(%r4)
li %r5,0
stw %r5,0(%r4)
mtlr %r10
#else
lis %r4,_C_LABEL(__logname_valid)@ha
li %r5,0
stw %r5,_C_LABEL(__logname_valid)@l(%r4)
#endif
blr

View File

@ -1,7 +1,11 @@
# $NetBSD: Makefile.inc,v 1.7 2002/09/05 08:35:15 msaitoh Exp $
# $NetBSD: Makefile.inc,v 1.8 2003/01/18 11:14:00 thorpej Exp $
SRCS+= _setjmp.S setjmp.S sigsetjmp.S __setjmp14.S __sigsetjmp14.S
SRCS+= makecontext.c resumecontext.c swapcontext.S
SRCS+= _lwp.c
SRCS+= fabs.c flt_rounds.c bswap16.c bswap32.c bswap64.c
# Common ieee754 constants and functions
@ -14,3 +18,6 @@ SRCS+= ashiftrt.S ashlsi3.S ashrsi3.S lshrsi3.S movstr.S movstr_i4.S \
KMSRCS+= ashiftrt.S ashlsi3.S ashrsi3.S lshrsi3.S movstr.S movstr_i4.S \
movstrSI.S mulsi3.S sdivsi3.S udivsi3.S
LSRCS+= Lint_swapcontext.c
DPSRCS+= Lint_swapcontext.c

View File

@ -0,0 +1,61 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:14:00 thorpej Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
void **sp;
getcontext(u);
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
sp = (void **) (stack_base + stack_size);
u->uc_mcontext.__gregs[_REG_R4] = (__greg_t) arg;
u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t) sp) & ~3;
u->uc_mcontext.__gregs[_REG_PR] = (__greg_t) _lwp_exit;
u->uc_mcontext.__gregs[_REG_PC] = (__greg_t) start;
}

View File

@ -0,0 +1,78 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:14:00 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:14:00 thorpej Exp $");
#endif
#include <stddef.h>
#include <inttypes.h>
#include <ucontext.h>
#include "extern.h"
#include <stdarg.h>
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
int i;
unsigned int *sp;
va_list ap;
/* Compute and align stack pointer. */
sp = (unsigned int *)
(((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~3);
/* Allocate necessary stack space for arguments exceeding r4-7. */
if (argc > 4)
sp -= argc - 4;
gr[_REG_SP] = (__greg_t)sp;
/* Arrange for return via the trampoline code. */
gr[_REG_PR] = (__greg_t)_resumecontext;
gr[_REG_PC] = (__greg_t)func;
va_start(ap, argc);
/* Pass up to four arguments in r4-7. */
for (i = 0; i < argc && i < 4; i++)
gr[_REG_R4 + i] = va_arg(ap, int);
/* Pass any additional arguments on the stack. */
for (argc -= i; argc > 0; argc--)
*sp++ = va_arg(ap, int);
va_end(ap);
}

View File

@ -0,0 +1,56 @@
/* $NetBSD: resumecontext.c,v 1.2 2003/01/18 11:14:00 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.2 2003/01/18 11:14:00 thorpej Exp $");
#endif
#include "namespace.h"
#include <ucontext.h>
#include "extern.h"
void
_resumecontext()
{
ucontext_t uct;
(void)getcontext(&uct);
(void)setcontext(uct.uc_link);
/* NOTREACHED */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:38 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:14:02 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -0,0 +1,55 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:14:01 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: getcontext.S,v 1.2 2003/01/18 11:14:01 thorpej Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext,_getcontext)
#endif
_SYSCALL(_getcontext,getcontext)
sts pr, r2
mov.l r2, @(36 + 1 * 4, r4) /* saved pc <- pr */
add #36 + 20 * 4, r4
rts
mov.l r0, @r4 /* arrange for return value 0 */

View File

@ -1,56 +0,0 @@
/* $NetBSD: setlogin.S,v 1.4 2001/05/11 19:58:08 msaitoh Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)setlogin.s 5.2 (Berkeley) 4/12/91
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: setlogin.S,v 1.4 2001/05/11 19:58:08 msaitoh Exp $")
#endif
#include "SYS.h"
.globl _C_LABEL(__logname_valid) /* in getlogin() */
SYSCALL(setlogin)
xor r0, r0
mov.l L___logname_valid, r1
rts /* setlogin(name) */
mov.l r0, @r1
.align 2
L___logname_valid: .long _C_LABEL(__logname_valid)

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.7 2002/02/19 13:08:31 simonb Exp $
# $NetBSD: Makefile.inc,v 1.8 2003/01/18 11:15:08 thorpej Exp $
SRCS+= fabs.S modf.S
SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
@ -12,5 +12,7 @@ SRCS+= setjmp.S __setjmp14.S
SRCS+= _setjmp.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
SRCS+= makecontext.c resumecontext.c _lwp.c swapcontext.S
SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S
SRCS+= bswap16.c bswap32.c bswap64.c

View File

@ -0,0 +1,74 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:15:08 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *), void *arg,
void *private, caddr_t stack_base, size_t stack_size)
{
__greg_t *gr;
unsigned long *sp;
getcontext(u);
gr = u->uc_mcontext.__gregs;
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
sp = (ulong *)(stack_base + stack_size);
sp = (ulong *)((ulong)sp & ~0x07);
/* Make room for the fake caller stack frame (CCFSZ, only in words) */
sp -= 8 + 8 + 1 + 6 + 1;
/* Entering (*start)(arg), return is to _lwp_exit */
gr[_REG_PC] = (ulong) start;
gr[_REG_nPC] = (ulong) start + 4;
gr[_REG_O0] = (ulong)arg;
gr[_REG_O6] = (ulong)sp;
gr[_REG_O7] = (ulong)_lwp_exit - 8;
/* XXX: uwe: why do we need this? */
/* create loopback in the window save area on the stack? */
sp[8+6] = (ulong)sp; /* %i6 */
sp[8+7] = (ulong)_lwp_exit - 8; /* %i7 */
}

View File

@ -0,0 +1,61 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:15:08 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: getcontext.S,v 1.2 2003/01/18 11:15:08 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
ENTRY(_getcontext)
mov %o0, %o2 ! must save pointer
mov SYS_getcontext, %g1
t ST_SYSCALL
bcc,a 1f
clr [%o2 + 40 + 11 * 4] ! gr[_REG_O0] = 0
ERROR()
1:
add %o7, 8, %o1
st %o1, [%o2 + 40 + 1 * 4] ! gr[_REG_PC] = retaddr
add %o7, 12, %o1
retl
st %o1, [%o2 + 40 + 2 * 4] ! gr[_REG_nPC] = retaddr + 4

View File

@ -0,0 +1,82 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:15:08 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:15:08 thorpej Exp $");
#endif
#include <inttypes.h>
#include <stddef.h>
#include <ucontext.h>
#include "extern.h"
#include <stdarg.h>
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
int i;
unsigned long *sp;
va_list ap;
sp = (unsigned long *)
((unsigned long)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
/* Make room for: rwindow, struct return pointer, argd, argx */
sp -= 8 + 8 + 1 + 6 + 1; /* CCFSZ, only in words */
/* CCFSZ provides space for up to 7 arguments, add more if necessary */
if (argc > 7)
sp -= argc - 7;
/* Align on double-word boundary. */
sp = (unsigned long *)((unsigned long)sp & ~0x7);
gr[_REG_O6] = (__greg_t)sp;
gr[_REG_PC] = (__greg_t)func;
gr[_REG_nPC] = (__greg_t)func + 4;
gr[_REG_O7] = (__greg_t)_resumecontext - 8;
va_start(ap, argc);
/* Pass up to 6 arguments in %o0..%o5. */
for (i = 0; i < argc && i < 6; i++)
gr[_REG_O0 + i] = va_arg(ap, unsigned long);
/* Pass any additional arguments on the stack. */
for (/* i = 6 */; i < argc; i++)
sp[8 + 8 + 1 + 6 + (i - 6)] = va_arg(ap, unsigned long);
va_end(ap);
}

View File

@ -0,0 +1,56 @@
/* $NetBSD: resumecontext.c,v 1.2 2003/01/18 11:15:08 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.2 2003/01/18 11:15:08 thorpej Exp $");
#endif
#include "namespace.h"
#include <ucontext.h>
#include "extern.h"
void
_resumecontext()
{
ucontext_t uct;
(void)getcontext(&uct);
(void)setcontext(uct.uc_link);
/* NOTREACHED */
}

View File

@ -0,0 +1,63 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:15:08 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: swapcontext.S,v 1.2 2003/01/18 11:15:08 thorpej Exp $")
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
mov %o0, %o2 ! must save pointer
mov %o1, %o3 ! must save pointer
mov SYS_getcontext, %g1
t ST_SYSCALL
bcc,a 1f
st %g0, [%o2 + 40 + 11 * 4] ! gr[_REG_O0] = 0
ERROR()
1:
add %o7, 12, %o1
st %o1, [%o2 + 40 + 2 * 4] ! gr[_REG_nPC] = retaddr + 4
add %o7, 8, %o1
st %o1, [%o2 + 40 + 1 * 4] ! gr[_REG_PC] = retaddr
mov %o3, %o0
mov %o1, %g2 ! optimize `return'
mov SYS_setcontext|SYSCALL_G2RFLAG, %g1
t ST_SYSCALL
ERROR()

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:38 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:15:08 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -1,65 +0,0 @@
/* $NetBSD: setlogin.S,v 1.5 1998/07/01 02:16:28 tv Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: setlogin.s,v 1.1 91/07/06 13:06:00 torek Exp
*/
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: setlogin.S,v 1.5 1998/07/01 02:16:28 tv Exp $")
#endif
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
.globl _C_LABEL(__logname_valid) /* in getlogin() */
SYSCALL(setlogin)
#ifdef PIC
PIC_PROLOGUE(%g1,%g2)
ld [%g1 + _C_LABEL(__logname_valid)], %g1
retl
st %g0, [%g1]
#else
sethi %hi(_C_LABEL(__logname_valid)), %g1
retl
st %g0, [%g1 + %lo(_C_LABEL(__logname_valid))]
#endif

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.5 2002/02/19 13:08:33 simonb Exp $
# $NetBSD: Makefile.inc,v 1.6 2003/01/18 11:17:45 thorpej Exp $
SRCS+= fabs.S modf.S
SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
@ -13,5 +13,9 @@ SRCS+= setjmp.S __setjmp14.S
SRCS+= _setjmp.S
SRCS+= sigsetjmp.S __sigsetjmp14.S
SRCS+= makecontext.c resumecontext.c _lwp.c swapcontext.S
SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S
LSRCS+= Lint_swapcontext.c
DPSRCS+=Lint_swapcontext.c

View File

@ -0,0 +1,74 @@
/* $NetBSD: _lwp.c,v 1.2 2003/01/18 11:17:45 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ucontext.h>
#include <lwp.h>
#include <stdlib.h>
void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private,
caddr_t stack_base, size_t stack_size)
{
__greg_t *gr;
unsigned long *sp;
getcontext(u);
gr = u->uc_mcontext.__gregs;
u->uc_link = NULL;
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
sp = (ulong *)(stack_base + stack_size);
sp = (ulong *)((ulong)sp & ~0x0f);
sp -= 8 + 8 + 6;
sp[8] = (ulong)arg;
sp[14] = (ulong)sp - 2047;
sp[15] = (ulong)_lwp_exit - 8;
sp = (ulong *)((caddr_t)sp - 2047);
gr[_REG_PC] = (ulong) start;
gr[_REG_nPC] = (ulong) start + 4;
gr[_REG_O0] = (ulong) arg;
gr[_REG_O6] = (ulong) sp;
gr[_REG_O7] = (ulong)_lwp_exit - 8;
}

View File

@ -0,0 +1,88 @@
/* $NetBSD: makecontext.c,v 1.2 2003/01/18 11:17:45 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.2 2003/01/18 11:17:45 thorpej Exp $");
#endif
#include <inttypes.h>
#include <stddef.h>
#include <sys/types.h>
#include <ucontext.h>
#include "extern.h"
#include <stdarg.h>
void
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
__greg_t *gr = ucp->uc_mcontext.__gregs;
int i;
ulong *sp;
va_list ap;
sp = (ulong *)((caddr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
/* Align on quad-word boundary. */
sp = (long *)((ulong)sp & ~0xf);
/* Make room for: argx, argd, struct return pointer(?), rwindow. */
sp -= (argc > 6 ? argc - 6 : 0) + 6 + 8 + 8;
va_start(ap, argc);
/* Pass up to 6 arguments in %o0-5. */
for (i = 0; i < argc && i < 6; i++)
gr[_REG_O0 + i] = sp[i + 16] = va_arg(ap, unsigned long);
/* Pass any additional arguments on the stack. */
for (; i < argc; i++)
sp[i + 16] = va_arg(ap, unsigned long);
va_end(ap);
sp[14] = (ulong)sp - 2047;
sp[15] = (ulong)_resumecontext - 8;
sp = (ulong *)((caddr_t)sp - 2047);
gr[_REG_O6] = (__greg_t)sp;
gr[_REG_PC] = (__greg_t)func;
gr[_REG_nPC] = (__greg_t)func + 4;
gr[_REG_O7] = (__greg_t)_resumecontext - 8;
}

View File

@ -0,0 +1,56 @@
/* $NetBSD: resumecontext.c,v 1.2 2003/01/18 11:17:45 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.2 2003/01/18 11:17:45 thorpej Exp $");
#endif
#include "namespace.h"
#include <ucontext.h>
#include "extern.h"
void
_resumecontext()
{
ucontext_t uct;
(void)getcontext(&uct);
(void)setcontext(uct.uc_link);
/* NOTREACHED */
}

View File

@ -0,0 +1,63 @@
/* $NetBSD: swapcontext.S,v 1.2 2003/01/18 11:17:45 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: swapcontext.S,v 1.2 2003/01/18 11:17:45 thorpej Exp $")
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
mov %o0, %o2 /* must save pointer */
mov %o1, %o3 /* must save pointer */
mov SYS_getcontext, %g1
t ST_SYSCALL
bcc,a 1f
stx %g0, [%o2 + 64 + 11 * 8] /* gr[_REG_O0] = 0 */
ERROR()
1:
add %o7, 12, %o1
stx %o1, [%o2 + 64 + 2 * 8] /* gr[_REG_nPC] = retaddr + 4 */
add %o7, 8, %o1
stx %o1, [%o2 + 64 + 1 * 8] /* gr[_REG_PC] = retaddr */
mov %o3, %o0
mov %o1, %g2 /* optimize `return' */
mov SYS_setcontext|SYSCALL_G2RFLAG, %g1
t ST_SYSCALL
ERROR()

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2002/07/09 23:32:39 thorpej Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2003/01/18 11:17:46 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_1[];

View File

@ -0,0 +1,61 @@
/* $NetBSD: getcontext.S,v 1.2 2003/01/18 11:17:46 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "SYS.h"
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: getcontext.S,v 1.2 2003/01/18 11:17:46 thorpej Exp $")
#endif /* SYSLIBC_SCCS && !lint */
#ifdef WEAK_ALIAS
WEAK_ALIAS(getcontext, _getcontext)
#endif
ENTRY(_getcontext)
mov %o0, %o2 /* must save pointer */
mov SYS_getcontext, %g1
t ST_SYSCALL
bcc,a 1f
stx %g0, [%o2 + 64 + 11 * 8] /* gr[_REG_O0] = 0 */
ERROR()
1:
add %o7, 8, %o1
stx %o1, [%o2 + 64 + 1 * 8] /* gr[_REG_PC] = retaddr */
add %o7, 12, %o1
retl
stx %o1, [%o2 + 64 + 2 * 8] /* gr[_REG_nPC] = retaddr + 4 */

View File

@ -1,78 +0,0 @@
/* $NetBSD: setlogin.S,v 1.4 2002/05/07 01:34:22 eeh Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: setlogin.s,v 1.1 91/07/06 13:06:00 torek Exp
*/
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: setlogin.S,v 1.4 2002/05/07 01:34:22 eeh Exp $")
#endif
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
.globl _C_LABEL(__logname_valid) /* in getlogin() */
SYSCALL(setlogin)
#ifdef PIC
#ifdef BIGPIC
PIC_PROLOGUE(%o1,%o2)
set _C_LABEL(__logname_valid), %o2
ldx [%o1 + %o2], %o1
retl
st %g0, [%o1]
#else
PIC_PROLOGUE(%o1,%o2)
ldx [%o1 + _C_LABEL(__logname_valid)], %o1
retl
st %g0, [%o1]
#endif
#else
/* Dunno what model we're using so we need to use full addresses */
sethi %hh(_C_LABEL(__logname_valid)), %o1
sethi %lm(_C_LABEL(__logname_valid)), %o2
or %o1, %hm(_C_LABEL(__logname_valid)), %o1
or %o2, %lo(_C_LABEL(__logname_valid)), %o2
sllx %o1, 32, %o1
retl
st %g0, [%o1 + %o2]
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2002/09/12 18:28:22 ragge Exp $ */
/* $NetBSD: __sigaction14_sigtramp.c,v 1.3 2003/01/18 11:18:02 thorpej Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -43,8 +43,10 @@
#include "extern.h"
__weak_alias(__sigaction14, __libc_sigaction14)
int
__sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
{
extern int __sigtramp_sigcontext_2[];

View File

@ -0,0 +1,14 @@
/* $NetBSD: Lint_resumecontext.c,v 1.2 2003/01/18 11:38:46 thorpej Exp $ */
/*
* This file placed in the public domain.
* Klaus Klein, January 26, 1999.
*/
#include <ucontext.h>
/*ARGSUSED*/
void
_resumecontext()
{
}

View File

@ -0,0 +1,18 @@
/* $NetBSD: Lint_swapcontext.c,v 1.2 2003/01/18 11:38:47 thorpej Exp $ */
/*
* This file placed in the public domain.
* Klaus Klein, November 29, 1998.
*/
#include <ucontext.h>
/*ARGSUSED*/
int
swapcontext(oucp, ucp)
ucontext_t *oucp;
const ucontext_t *ucp;
{
return (0);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.116 2003/01/15 23:55:42 kleink Exp $
# $NetBSD: Makefile.inc,v 1.117 2003/01/18 11:23:53 thorpej Exp $
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
# gen sources
@ -49,6 +49,7 @@ MAN+= alarm.3 arc4random.3 basename.3 bswap.3 clock.3 confstr.3 \
humanize_number.3 initgroups.3 isalnum.3 isalpha.3 isascii.3 \
isblank.3 iscntrl.3 isdigit.3 isgraph.3 isinf.3 islower.3 isprint.3 \
ispunct.3 isspace.3 isupper.3 isxdigit.3 ldexp.3 lockf.3 \
_lwp_makecontext.3 \
modf.3 nice.3 nlist.3 pause.3 popen.3 psignal.3 pwcache.3 \
raise.3 realpath.3 scandir.3 setjmp.3 setmode.3 \
setproctitle.3 shquote.3 sighold.3 sigignore.3 siginterrupt.3 \

View File

@ -1,4 +1,4 @@
/* $NetBSD: _errno.c,v 1.9 2000/12/10 03:52:16 christos Exp $ */
/* $NetBSD: _errno.c,v 1.10 2003/01/18 11:23:53 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -36,7 +36,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "reentrant.h"
#include <errno.h>
#include <stdlib.h>
#undef errno
extern int errno;
@ -44,5 +46,14 @@ extern int errno;
int *
__errno(void)
{
#ifdef _REENTRANT
extern int __isthreaded;
if (__isthreaded == 0)
return &errno;
return thr_errno();
#else
return &errno;
#endif
}

View File

@ -0,0 +1,81 @@
.\" $NetBSD: _lwp_makecontext.3,v 1.2 2003/01/18 11:38:48 thorpej Exp $
.\"
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Jason R. Thorpe of Wasabi Systems, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd January 16, 2003
.Dt _LWP_MAKECONTEXT 3
.Os
.Sh NAME
.Nm _lwp_makecontext
.Nd create a new initial light-weight process execution context
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.Fd #include \*[Lt]lwp.h\*[Gt]
.Ft void
.Fn _lwp_makecontext "ucontext_t *context" "void (*start_routine)(void *)" \
"void *arg" "void *private" "caddr_t stack_base" "size_t stack_size"
.Sh DESCRIPTION
.Fn _lwp_makecontext
initializes the context structure pointed to by
.Fa context
in a manner suitable for using with
.Xr _lwp_create 2 .
The LWP will begin execution at the function specified by
.Fa start_routine
which will be passed a single argument
.Fa arg .
The LWP private data pointer will be set to
.Fa private .
The stack region for the new LWP is specified by the
.Fa stack_base
and
.Fa stack_size
arguments.
.Pp
The signal mask in the context structure is not initialized by
.Fn _lwp_makecontext .
.Sh SEE ALSO
.Xr _lwp_create 2 ,
.Xr _lwp_getprivate 2
.Sh HISTORY
The
.Fn _lwp_create
system call first appeared in
.Nx 2.0 .
.Sh BUGS
The LWP private data pointer is not initialized by the current
implementation of
.Fn _lwp_makecontext .

View File

@ -1,4 +1,4 @@
/* $NetBSD: execl.c,v 1.8 2002/05/26 14:03:19 wiz Exp $ */
/* $NetBSD: execl.c,v 1.9 2003/01/18 11:23:53 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: execl.c,v 1.8 2002/05/26 14:03:19 wiz Exp $");
__RCSID("$NetBSD: execl.c,v 1.9 2003/01/18 11:23:53 thorpej Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -54,7 +54,7 @@ __weak_alias(execl,_execl)
extern char **environ;
#ifdef _REENT
#ifdef _REENTRANT
extern rwlock_t __environ_lock;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: execv.c,v 1.5 2000/01/22 22:19:09 mycroft Exp $ */
/* $NetBSD: execv.c,v 1.6 2003/01/18 11:23:53 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: execv.c,v 1.5 2000/01/22 22:19:09 mycroft Exp $");
__RCSID("$NetBSD: execv.c,v 1.6 2003/01/18 11:23:53 thorpej Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -51,7 +51,7 @@ __weak_alias(execv,_execv)
#endif
extern char **environ;
#ifdef _REENT
#ifdef _REENTRANT
extern rwlock_t __environ_lock;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: execvp.c,v 1.20 2001/12/08 00:30:59 enami Exp $ */
/* $NetBSD: execvp.c,v 1.21 2003/01/18 11:23:53 thorpej Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: execvp.c,v 1.20 2001/12/08 00:30:59 enami Exp $");
__RCSID("$NetBSD: execvp.c,v 1.21 2003/01/18 11:23:53 thorpej Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -58,7 +58,7 @@ __weak_alias(execvp,_execvp)
#endif
extern char **environ;
#ifdef _REENT
#ifdef _REENTRANT
extern rwlock_t __environ_lock;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: getlogin.c,v 1.10 2000/01/22 22:19:10 mycroft Exp $ */
/* $NetBSD: getlogin.c,v 1.11 2003/01/18 11:23:53 thorpej Exp $ */
/*
* Copyright (c) 1988, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getlogin.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: getlogin.c,v 1.10 2000/01/22 22:19:10 mycroft Exp $");
__RCSID("$NetBSD: getlogin.c,v 1.11 2003/01/18 11:23:53 thorpej Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -53,6 +53,7 @@ __RCSID("$NetBSD: getlogin.c,v 1.10 2000/01/22 22:19:10 mycroft Exp $");
#ifdef __weak_alias
__weak_alias(getlogin,_getlogin)
__weak_alias(setlogin,_setlogin)
#endif
int __logname_valid; /* known to setlogin() */
@ -69,3 +70,14 @@ getlogin()
}
return (*logname ? logname : (char *)NULL);
}
int
setlogin(const char *name)
{
int retval;
retval = __setlogin(name);
__logname_valid = 0;
return (retval);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syslog.c,v 1.28 2002/05/26 14:03:20 wiz Exp $ */
/* $NetBSD: syslog.c,v 1.29 2003/01/18 11:23:53 thorpej Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
#else
__RCSID("$NetBSD: syslog.c,v 1.28 2002/05/26 14:03:20 wiz Exp $");
__RCSID("$NetBSD: syslog.c,v 1.29 2003/01/18 11:23:53 thorpej Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -79,7 +79,7 @@ static int LogMask = 0xff; /* mask of priorities to be logged */
static void openlog_unlocked __P((const char *, int, int));
static void closelog_unlocked __P((void));
#ifdef _REENT
#ifdef _REENTRANT
static mutex_t syslog_mutex = MUTEX_INITIALIZER;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.7 2002/07/09 23:35:49 thorpej Exp $ */
/* $NetBSD: extern.h,v 1.8 2003/01/18 11:23:53 thorpej Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@ -33,6 +33,8 @@ __BEGIN_DECLS
extern char *__minbrk;
int __getcwd __P((char *, size_t));
int __getlogin __P((char *, size_t));
int __setlogin __P((const char *));
void _resumecontext __P((void));
const char *__strerror __P((int , char *, size_t));
const char *__strsignal __P((int , char *, size_t));
char *__dtoa __P((double, int, int, int *, int *, char **));

View File

@ -1,4 +1,4 @@
/* $NetBSD: namespace.h,v 1.74 2002/11/30 03:04:45 lukem Exp $ */
/* $NetBSD: namespace.h,v 1.75 2003/01/18 11:23:54 thorpej Exp $ */
/*-
* Copyright (c) 1997-2002 The NetBSD Foundation, Inc.
@ -48,6 +48,7 @@
#define fork _fork
#define fseeko _fseeko
#define ftello _ftello
#define getcontext _getcontext
#define inet_aton _inet_aton
#define inet_pton _inet_pton
#define pipe _pipe
@ -192,6 +193,9 @@
#define execvp _execvp
#define fdopen _fdopen
#define fgetln _fgetln
#define flockfile _flockfile
#define ftrylockfile _ftrylockfile
#define funlockfile _funlockfile
#define fnmatch _fnmatch
#define fparseln _fparseln
#define fpgetmask _fpgetmask
@ -317,6 +321,7 @@
#define isinf _isinf
#define isnan _isnan
#define jrand48 _jrand48
#define kill _kill
#define l64a _l64a
#define l64a_r _l64a_r
#define lcong48 _lcong48
@ -402,6 +407,7 @@
#define setgroupent _setgroupent
#define sethostent _sethostent
#define sethostname _sethostname
#define setlogin _setlogin
#define setlogmask _setlogmask
#define setmode _setmode
#define setnetconfig _setnetconfig
@ -477,7 +483,7 @@
#define svcudp_create _svcudp_create
#define svcudp_enablecache _svcudp_enablecache
#define svis _svis
#define sysarch _sysarch
#define sysarch _sys_sysarch
#define sysctl _sysctl
#define syslog _syslog
#define tcdrain _tcdrain

View File

@ -1,11 +1,11 @@
/* $NetBSD: reentrant.h,v 1.6 2000/06/02 23:11:06 fvdl Exp $ */
/* $NetBSD: reentrant.h,v 1.7 2003/01/18 11:23:54 thorpej Exp $ */
/*-
* Copyright (c) 1997,98 The NetBSD Foundation, Inc.
* Copyright (c) 1997, 1998, 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by J.T. Conklin.
* by J.T. Conklin, by Nathan J. Williams, and by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -71,87 +71,155 @@
*
* Implementation Details:
*
* The mutex primitives used by the library (mutex_t, mutex_lock, etc.)
* The thread primitives used by the library (mutex_t, mutex_lock, etc.)
* are macros which expand to the cooresponding primitives provided by
* the thread engine or to nothing. The latter is used so that code is
* not unreasonably cluttered with #ifdefs when all thread safe support
* is removed.
*
* The mutex macros can be directly mapped to the mutex primitives from
* The thread macros can be directly mapped to the mutex primitives from
* pthreads, however it should be reasonably easy to wrap another mutex
* implementation so it presents a similar interface.
*
* Stub implementations of the mutex functions are provided with *weak*
* linkage. These functions simply return success. When linked with a
* thread library (i.e. -lpthread), the functions will override the
* stubs.
* The thread functions operate by dispatching to symbols which are, by
* default, weak-aliased to no-op functions in thread-stub/thread-stub.c
* (some uses of thread operations are conditional on __isthreaded, but
* not all of them are).
*
* When the thread library is linked in, it provides strong-alias versions
* of those symbols which dispatch to its own real thread operations.
*/
/* FIXME: Using _REENT during integration testing. It should be changed
to _REENTRANT once pthread engine is available */
#ifdef _REENT
#ifdef _REENTRANT
#include <pthread.h>
#include <signal.h>
#define mutex_t pthread_mutex_t
#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define mutex_t pthread_mutex_t
#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define mutex_init(m, a) pthread_mutex_init(m, a)
#define mutex_lock(m) pthread_mutex_lock(m)
#define mutex_trylock(m) pthread_mutex_trylock(m)
#define mutex_unlock(m) pthread_mutex_unlock(m)
#define mutexattr_t pthread_mutexattr_t
#define cond_t pthread_cond_t
#define cond_signal(m) pthread_cond_signal(m)
#define cond_wait(c, m) pthread_cond_wait(c, m)
#define cond_init(c, a, p) pthread_cond_init(c, a)
#define cond_t pthread_cond_t
#define COND_INITIALIZER PTHREAD_COND_INITIALIZER
#define rwlock_t pthread_rwlock_t
#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
#define condattr_t pthread_condattr_t
#define rwlock_init(l, a) pthread_rwlock_init(l, a)
#define rwlock_rdlock(l) pthread_rwlock_rdlock(l)
#define rwlock_wrlock(l) pthread_rwlock_wrlock(l)
#define rwlock_unlock(l) pthread_rwlock_unlock(l)
#define rwlock_t pthread_rwlock_t
#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
#define thread_key_t pthread_key_t
#define thr_keycreate(k, d) pthread_key_create(k, d)
#define thr_setspecific(k, p) pthread_setspecific(k, p)
#define thr_getspecific(k) pthread_getspecific(k)
#define thr_sigsetmask(f, n, o) pthread_sigmask(f, n, o)
#define rwlockattr_t pthread_rwlockattr_t
#define thr_self() pthread_self()
#define thr_exit(x) pthread_exit(x)
#define thread_key_t pthread_key_t
#define FLOCKFILE(fp) flockfile(fp)
#define FUNLOCKFILE(fp) funlockfile(fp)
#define thr_t pthread_t
#else
#define once_t pthread_once_t
#define ONCE_INITIALIZER PTHREAD_ONCE_INIT
#define mutex_init(m, a)
#define mutex_lock(m)
#define mutex_trylock(m)
#define mutex_unlock(m)
#ifndef __LIBC_THREAD_STUBS
#define cond_signal(m)
#define cond_wait(c, m)
#define cond_init(c, a, p)
int __libc_mutex_init(mutex_t *, const mutexattr_t *);
int __libc_mutex_lock(mutex_t *);
int __libc_mutex_trylock(mutex_t *);
int __libc_mutex_unlock(mutex_t *);
int __libc_mutex_destroy(mutex_t *);
#define rwlock_init(l, a)
#define rwlock_rdlock(l)
#define rwlock_wrlock(l)
#define rwlock_unlock(l)
#define mutex_init(m, a) __libc_mutex_init((m), (a))
#define mutex_lock(m) __libc_mutex_lock((m))
#define mutex_trylock(m) __libc_mutex_trylock((m))
#define mutex_unlock(m) __libc_mutex_unlock((m))
#define mutex_destroy(m) __libc_mutex_destroy((m))
#define thr_keycreate(k, d)
#define thr_setspecific(k, p)
#define thr_getspecific(k)
#define thr_sigsetmask(f, n, o)
int __libc_cond_init(cond_t *, const condattr_t *);
int __libc_cond_signal(cond_t *);
int __libc_cond_broadcast(cond_t *);
int __libc_cond_wait(cond_t *, mutex_t *);
int __libc_cond_timedwait(cond_t *, mutex_t *, const struct timespec *);
int __libc_cond_destroy(cond_t *);
#define thr_self()
#define thr_exit()
#define cond_init(c, t, a) __libc_cond_init((c), (a))
#define cond_signal(c) __libc_cond_signal((c))
#define cond_broadcast(c) __libc_cond_broadcast((c))
#define cond_wait(c, m) __libc_cond_wait((c), (m))
#define cond_timedwait(c, m, t) __libc_cond_timedwait((c), (m), (t))
#define cond_destroy(c) __libc_cond_destroy((c))
#define FLOCKFILE(fp)
#define FUNLOCKFILE(fp)
int __libc_rwlock_init(rwlock_t *, const rwlockattr_t *);
int __libc_rwlock_rdlock(rwlock_t *);
int __libc_rwlock_wrlock(rwlock_t *);
int __libc_rwlock_tryrdlock(rwlock_t *);
int __libc_rwlock_trywrlock(rwlock_t *);
int __libc_rwlock_unlock(rwlock_t *);
int __libc_rwlock_destroy(rwlock_t *);
#endif
#define rwlock_init(l, a) __libc_rwlock_init((l), (a))
#define rwlock_rdlock(l) __libc_rwlock_rdlock((l))
#define rwlock_wrlock(l) __libc_rwlock_wrlock((l))
#define rwlock_tryrdlock(l) __libc_rwlock_tryrdlock((l))
#define rwlock_trywrlock(l) __libc_rwlock_trywrlock((l))
#define rwlock_unlock(l) __libc_rwlock_unlock((l))
#define rwlock_destroy(l) __libc_rwlock_destroy((l))
int __libc_thr_keycreate(thread_key_t *, void (*)(void *));
int __libc_thr_setspecific(thread_key_t, const void *);
void *__libc_thr_getspecific(thread_key_t);
int __libc_thr_keydelete(thread_key_t);
#define thr_keycreate(k, d) __libc_thr_keycreate((k), (d))
#define thr_setspecific(k, p) __libc_thr_setspecific((k), (p))
#define thr_getspecific(k) __libc_thr_getspecific((k))
#define thr_keydelete(k) __libc_thr_keydelete((k))
int __libc_thr_once(once_t *, void (*)(void));
int __libc_thr_sigsetmask(int, const sigset_t *, sigset_t *);
thr_t __libc_thr_self(void);
int *__libc_thr_errno(void);
#define thr_once(o, f) __libc_thr_once((o), (f))
#define thr_sigsetmask(f, n, o) __libc_thr_sigsetmask((f), (n), (o))
#define thr_self() __libc_thr_self()
#define thr_errno() __libc_thr_errno()
#define FLOCKFILE(fp) flockfile(fp)
#define FUNLOCKFILE(fp) funlockfile(fp)
#endif /* __LIBC_THREAD_STUBS */
#else /* _REENTRANT */
#define mutex_init(m, a)
#define mutex_lock(m)
#define mutex_trylock(m)
#define mutex_unlock(m)
#define mutex_destroy(m)
#define cond_init(c, t, a)
#define cond_signal(c)
#define cond_broadcast(c)
#define cond_wait(c, m)
#define cond_timedwait(c, m, t)
#define cond_destroy(c)
#define rwlock_init(l, a)
#define rwlock_rdlock(l)
#define rwlock_wrlock(l)
#define rwlock_tryrdlock(l)
#define rwlock_trywrlock(l)
#define rwlock_unlock(l)
#define rwlock_destroy(l)
#define thr_keycreate(k, d)
#define thr_setspecific(k, p)
#define thr_getspecific(k)
#define thr_keydelete(k)
#define thr_once(o, f)
#define thr_sigsetmask(f, n, o)
#define thr_self()
#define thr_errno()
#define FLOCKFILE(fp)
#define FUNLOCKFILE(fp)
#endif /* _REENTRANT */

View File

@ -1,4 +1,4 @@
/* $NetBSD: auth_unix.c,v 1.18 2000/07/06 03:03:30 christos Exp $ */
/* $NetBSD: auth_unix.c,v 1.19 2003/01/18 11:29:03 thorpej Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
#else
__RCSID("$NetBSD: auth_unix.c,v 1.18 2000/07/06 03:03:30 christos Exp $");
__RCSID("$NetBSD: auth_unix.c,v 1.19 2003/01/18 11:29:03 thorpej Exp $");
#endif
#endif
@ -365,7 +365,7 @@ static const struct auth_ops *
authunix_ops()
{
static struct auth_ops ops;
#ifdef __REENT
#ifdef _REENTRANT
extern mutex_t ops_lock;
#endif

View File

@ -1,5 +1,5 @@
.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
.\" $NetBSD: bindresvport.3,v 1.10 2002/02/07 07:00:23 ross Exp $
.\" $NetBSD: bindresvport.3,v 1.11 2003/01/18 11:29:03 thorpej Exp $
.\"
.Dd November 22, 1987
.Dt BINDRESVPORT 3

View File

@ -1,4 +1,4 @@
/* $NetBSD: bindresvport.c,v 1.20 2001/11/04 13:57:30 lukem Exp $ */
/* $NetBSD: bindresvport.c,v 1.21 2003/01/18 11:29:03 thorpej Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)bindresvport.c 1.8 88/02/08 SMI";
static char *sccsid = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";
#else
__RCSID("$NetBSD: bindresvport.c,v 1.20 2001/11/04 13:57:30 lukem Exp $");
__RCSID("$NetBSD: bindresvport.c,v 1.21 2003/01/18 11:29:03 thorpej Exp $");
#endif
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_bcast.c,v 1.9 2002/11/08 00:13:07 fvdl Exp $ */
/* $NetBSD: clnt_bcast.c,v 1.10 2003/01/18 11:29:04 thorpej Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_dg.c,v 1.8 2002/11/08 00:13:07 fvdl Exp $ */
/* $NetBSD: clnt_dg.c,v 1.9 2003/01/18 11:29:04 thorpej Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -96,8 +96,9 @@ static int __rpc_timeval_to_msec __P((struct timeval *));
* at a time.
*/
static int *dg_fd_locks;
#ifdef __REENT
extern int __rpc_lock_value;
#ifdef _REENTRANT
extern int __isthreaded;
#define __rpc_lock_value __isthreaded;
extern mutex_t clnt_fd_lock;
static cond_t *dg_cv;
#define release_fd_lock(fd, mask) { \
@ -163,7 +164,7 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
struct cu_data *cu = NULL; /* private data */
struct timeval now;
struct rpc_msg call_msg;
#ifdef __REENT
#ifdef _REENTRANT
sigset_t mask;
#endif
sigset_t newmask;
@ -174,8 +175,8 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
if (dg_fd_locks == (int *) NULL) {
#ifdef __REENT
int cv_allocsz;
#ifdef _REENTRANT
size_t cv_allocsz;
#endif
size_t fd_allocsz;
int dtbsize = __rpc_dtbsize();
@ -189,7 +190,7 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
} else
memset(dg_fd_locks, '\0', fd_allocsz);
#ifdef __REENT
#ifdef _REENTRANT
cv_allocsz = dtbsize * sizeof (cond_t);
dg_cv = (cond_t *) mem_alloc(cv_allocsz);
if (dg_cv == (cond_t *) NULL) {
@ -319,8 +320,7 @@ clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
struct timeval retransmit_time;
struct timeval startime, curtime;
int firsttimeout = 1;
#ifdef __REENT
int dtbsize = __rpc_dtbsize();
#ifdef _REENTRANT
sigset_t mask;
#endif
sigset_t newmask;
@ -586,7 +586,7 @@ clnt_dg_freeres(cl, xdr_res, res_ptr)
struct cu_data *cu;
XDR *xdrs;
bool_t dummy;
#ifdef __REENT
#ifdef _REENTRANT
sigset_t mask;
#endif
sigset_t newmask;
@ -623,7 +623,7 @@ clnt_dg_control(cl, request, info)
{
struct cu_data *cu;
struct netbuf *addr;
#ifdef __REENT
#ifdef _REENTRANT
sigset_t mask;
#endif
sigset_t newmask;
@ -762,7 +762,7 @@ clnt_dg_destroy(cl)
{
struct cu_data *cu;
int cu_fd;
#ifdef __REENT
#ifdef _REENTRANT
sigset_t mask;
#endif
sigset_t newmask;
@ -795,7 +795,7 @@ static struct clnt_ops *
clnt_dg_ops()
{
static struct clnt_ops ops;
#ifdef __REENT
#ifdef _REENTRANT
extern mutex_t ops_lock;
sigset_t mask;
#endif

Some files were not shown because too many files have changed in this diff Show More