summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgallatin <gallatin@FreeBSD.org>2000-10-13 01:57:43 +0000
committergallatin <gallatin@FreeBSD.org>2000-10-13 01:57:43 +0000
commit103553a73496b20227a8b3c8568208aa52890169 (patch)
tree20b3751aa66fad9470b8f229b4fa56fe6c5e60cd
parentd1724c542c30df5f9f2a7626abe7a3685b27f8cb (diff)
downloadFreeBSD-src-103553a73496b20227a8b3c8568208aa52890169.zip
FreeBSD-src-103553a73496b20227a8b3c8568208aa52890169.tar.gz
This is the first of 3 commits that will get IBM's JDK 1.3 working
with FreeBSD (not including the MINSIGSTKSZ issue, which belongs to Marcel). Due to time constraints, I'm going to space them out over a few days. This fixes two problems with linux_sigaltstack() o ss == 0 is perfectly valid use, so do not fail in this case. o Fix flag handling: - Our SS_DISABLE is 4, linux's is 2, so we need conversion routines. These conversion routines will be needed by linux_rt_sendsig() and linux_rt_sigreturn (forthcoming), so they are not static. - Linux's flag 0 historically meant SS_ONSTACK according to a comment in their linux/kernel/signal.c file. Among other things, this fixes a warning from Sun's JDK 1.3: "Java HotSpot(TM) Client VM warning: cannot uninstall alt signal stack" Reviewed by: marcel Tested by: sto@stat.duke.edu, many others on freebsd-java@
-rw-r--r--sys/i386/linux/linux.h8
-rw-r--r--sys/i386/linux/linux_machdep.c49
2 files changed, 47 insertions, 10 deletions
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index 8887ec3..f399f05 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -159,6 +159,14 @@ struct linux_new_utsname {
/* sigaltstack */
#define LINUX_MINSIGSTKSZ 2048
+#define LINUX_SS_ONSTACK_BC 0 /* backwards compat SS_ONSTACK */
+#define LINUX_SS_ONSTACK 1
+#define LINUX_SS_DISABLE 2
+
+
+int linux_to_bsd_sigaltstack(int lsa);
+int bsd_to_linux_sigaltstack(int bsa);
+
typedef void (*linux_handler_t)(int);
typedef u_long linux_osigset_t;
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index afcfd4c..d5ea70f 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -67,6 +67,32 @@ struct linux_select_argv {
};
int
+linux_to_bsd_sigaltstack(int lsa)
+{
+ int bsa = 0;
+
+ if (lsa & LINUX_SS_DISABLE)
+ bsa |= SS_DISABLE;
+ if (lsa & LINUX_SS_ONSTACK)
+ bsa |= SS_ONSTACK;
+ if (lsa == LINUX_SS_ONSTACK_BC)
+ bsa = SS_ONSTACK;
+ return (bsa);
+}
+
+int
+bsd_to_linux_sigaltstack(int bsa)
+{
+ int lsa = 0;
+
+ if (bsa & SS_DISABLE)
+ lsa |= LINUX_SS_DISABLE;
+ if (bsa & SS_ONSTACK)
+ lsa |= LINUX_SS_ONSTACK;
+ return (lsa);
+}
+
+int
linux_execve(struct proc *p, struct linux_execve_args *args)
{
struct execve_args bsd;
@@ -606,16 +632,19 @@ linux_sigaltstack(p, uap)
(long)p->p_pid, uap->uss, uap->uoss);
#endif
- error = copyin(uap->uss, &lss, sizeof(linux_stack_t));
- if (error)
- return (error);
-
- ss = stackgap_alloc(&sg, sizeof(stack_t));
- ss->ss_sp = lss.ss_sp;
- ss->ss_size = (lss.ss_size >= LINUX_MINSIGSTKSZ &&
- lss.ss_size < MINSIGSTKSZ) ? MINSIGSTKSZ : lss.ss_size;
- ss->ss_flags = lss.ss_flags;
+ if (uap->uss == NULL) {
+ ss = NULL;
+ } else {
+ error = copyin(uap->uss, &lss, sizeof(linux_stack_t));
+ if (error)
+ return (error);
+ ss = stackgap_alloc(&sg, sizeof(stack_t));
+ ss->ss_sp = lss.ss_sp;
+ ss->ss_size = (lss.ss_size >= LINUX_MINSIGSTKSZ &&
+ lss.ss_size < MINSIGSTKSZ) ? MINSIGSTKSZ : lss.ss_size;
+ ss->ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags);
+ }
oss = (uap->uoss != NULL)
? stackgap_alloc(&sg, sizeof(stack_t))
: NULL;
@@ -627,7 +656,7 @@ linux_sigaltstack(p, uap)
if (!error && oss != NULL) {
lss.ss_sp = oss->ss_sp;
lss.ss_size = oss->ss_size;
- lss.ss_flags = oss->ss_flags;
+ lss.ss_flags = bsd_to_linux_sigaltstack(oss->ss_flags);
error = copyout(&lss, uap->uoss, sizeof(linux_stack_t));
}
OpenPOWER on IntegriCloud