[kaffe] CVS kaffe (guilhem): Cleaning up stack size computation.
Kaffe CVS
cvs-commits at kaffe.org
Sat Apr 24 10:07:02 PDT 2004
PatchSet 4690
Date: 2004/04/24 16:57:21
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Cleaning up stack size computation.
* config/i386/beos/md.h, config/i386/bsdi/md.h,
config/i386/dgux/md.h, config/i386/freebsd2/md.h,
config/i386/gnu/md.h, config/i386/linux/md.h,
config/i386/netbsd1/md.h, config/i386/nextstep3/md.h,
config/i386/openbsd2/md.h, config/i386/oskit/md.h,
config/i386/qnx/md.h, config/i386/sco3.2v5/md.h,
config/i386/solaris2/md.h, config/i386/univel_svr4/md.h,
config/sparc/bsdi3/md.h, config/sparc/linux/md.h,
config/sparc/openbsd2/md.h, config/sparc/solaris2/md.h,
config/sparc/sunos4/md.h, config/sparc/uxpds/md.h:
Defined macro KAFFEMD_STACKSIZE and implemented new
function mdGetStackSize.
* kaffe/kaffevm/thread.c
(initNativeThreads): If KAFFEMD_STACKSIZE is defined
use mdGetStackSize to retrieve the real stack size.
* kaffe/kaffevm/systems/unix-jthreads/signal.c
(detectStackBoundaries): Removed redundant code.
* test/internal/jit_stub.c:
(main) If KAFFEMD_STACKSIZE is defined use
mdGetStackSize to retrieve the real stack size.
* FAQ/FAQ.kaffemd: New file to describe the
different KAFFEMD_* defines.
Members:
ChangeLog:1.2266->1.2267
config/i386/beos/md.h:1.7->1.8
config/i386/bsdi/md.h:1.5->1.6
config/i386/dgux/md.h:1.4->1.5
config/i386/freebsd2/md.h:1.8->1.9
config/i386/gnu/md.h:1.5->1.6
config/i386/linux/md.h:1.8->1.9
config/i386/netbsd1/md.h:1.4->1.5
config/i386/nextstep3/md.h:1.5->1.6
config/i386/openbsd2/md.h:1.5->1.6
config/i386/oskit/md.h:1.6->1.7
config/i386/qnx/md.h:1.7->1.8
config/i386/sco3.2v5/md.h:1.5->1.6
config/i386/solaris2/md.h:1.5->1.6
config/i386/univel_svr4/md.h:1.7->1.8
config/sparc/bsdi3/md.h:1.3->1.4
config/sparc/linux/md.h:1.5->1.6
config/sparc/openbsd2/md.h:1.4->1.5
config/sparc/solaris2/md.h:1.3->1.4
config/sparc/sunos4/md.h:1.6->1.7
config/sparc/uxpds/md.h:1.3->1.4
kaffe/kaffevm/thread.c:1.63->1.64
kaffe/kaffevm/systems/unix-jthreads/signal.c:1.14->1.15
test/internal/jit_stub.c:1.5->1.6
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2266 kaffe/ChangeLog:1.2267
--- kaffe/ChangeLog:1.2266 Sat Apr 24 12:32:43 2004
+++ kaffe/ChangeLog Sat Apr 24 16:57:21 2004
@@ -1,5 +1,34 @@
2004-04-24 Guilhem Lavaux <guilhem at kaffe.org>
+ * config/i386/beos/md.h, config/i386/bsdi/md.h,
+ config/i386/dgux/md.h, config/i386/freebsd2/md.h,
+ config/i386/gnu/md.h, config/i386/linux/md.h,
+ config/i386/netbsd1/md.h, config/i386/nextstep3/md.h,
+ config/i386/openbsd2/md.h, config/i386/oskit/md.h,
+ config/i386/qnx/md.h, config/i386/sco3.2v5/md.h,
+ config/i386/solaris2/md.h, config/i386/univel_svr4/md.h,
+ config/sparc/bsdi3/md.h, config/sparc/linux/md.h,
+ config/sparc/openbsd2/md.h, config/sparc/solaris2/md.h,
+ config/sparc/sunos4/md.h, config/sparc/uxpds/md.h:
+ Defined macro KAFFEMD_STACKSIZE and implemented new
+ function mdGetStackSize.
+
+ * kaffe/kaffevm/thread.c
+ (initNativeThreads): If KAFFEMD_STACKSIZE is defined
+ use mdGetStackSize to retrieve the real stack size.
+
+ * kaffe/kaffevm/systems/unix-jthreads/signal.c
+ (detectStackBoundaries): Removed redundant code.
+
+ * test/internal/jit_stub.c:
+ (main) If KAFFEMD_STACKSIZE is defined use
+ mdGetStackSize to retrieve the real stack size.
+
+ * FAQ/FAQ.kaffemd: New file to describe the
+ different KAFFEMD_* defines.
+
+2004-04-24 Guilhem Lavaux <guilhem at kaffe.org>
+
* config/powerpc/darwin/md.h: Implemented SIGNAL_ARGS,
SIGNAL_CONTEXT_POINTER, GET_SIGNAL_CONTEXT_POINTER, STACK_POINTER.
Index: kaffe/config/i386/beos/md.h
diff -u kaffe/config/i386/beos/md.h:1.7 kaffe/config/i386/beos/md.h:1.8
--- kaffe/config/i386/beos/md.h:1.7 Thu Apr 22 16:28:09 2004
+++ kaffe/config/i386/beos/md.h Sat Apr 24 16:57:24 2004
@@ -18,6 +18,12 @@
#include "i386/common.h"
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/*
* Redefine stack pointer offset.
@@ -39,6 +45,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/i386/bsdi/md.h
diff -u kaffe/config/i386/bsdi/md.h:1.5 kaffe/config/i386/bsdi/md.h:1.6
--- kaffe/config/i386/bsdi/md.h:1.5 Thu Apr 22 16:28:09 2004
+++ kaffe/config/i386/bsdi/md.h Sat Apr 24 16:57:24 2004
@@ -19,6 +19,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
/*
* Redefine stack pointer offset.
*/
@@ -59,6 +66,20 @@
#undef JTHREAD_JMPBUF
#define JTHREAD_JMPBUF i386_jmp_buf
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
#endif
Index: kaffe/config/i386/dgux/md.h
diff -u kaffe/config/i386/dgux/md.h:1.4 kaffe/config/i386/dgux/md.h:1.5
--- kaffe/config/i386/dgux/md.h:1.4 Thu Apr 22 16:28:11 2004
+++ kaffe/config/i386/dgux/md.h Sat Apr 24 16:57:25 2004
@@ -19,6 +19,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
/**/
/* Extra exception handling information. */
/**/
@@ -34,6 +41,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/i386/freebsd2/md.h
diff -u kaffe/config/i386/freebsd2/md.h:1.8 kaffe/config/i386/freebsd2/md.h:1.9
--- kaffe/config/i386/freebsd2/md.h:1.8 Thu Apr 22 16:28:11 2004
+++ kaffe/config/i386/freebsd2/md.h Sat Apr 24 16:57:25 2004
@@ -19,6 +19,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
/*
* Redefine stack pointer offset.
*/
@@ -51,6 +58,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/i386/gnu/md.h
diff -u kaffe/config/i386/gnu/md.h:1.5 kaffe/config/i386/gnu/md.h:1.6
--- kaffe/config/i386/gnu/md.h:1.5 Fri Apr 23 13:37:18 2004
+++ kaffe/config/i386/gnu/md.h Sat Apr 24 16:57:27 2004
@@ -31,6 +31,12 @@
#if defined(HAVE_SIGCONTEXT_H)
#include <sigcontext.h>
#endif
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/* newer Linux kernel actually implement SA_SIGINFO.
* But we don't need it, so let's turn it off
@@ -61,5 +67,19 @@
/* Linux requires a little initialisation */
extern void init_md(void);
#define INIT_MD() init_md()
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
#endif
Index: kaffe/config/i386/linux/md.h
diff -u kaffe/config/i386/linux/md.h:1.8 kaffe/config/i386/linux/md.h:1.9
--- kaffe/config/i386/linux/md.h:1.8 Fri Apr 23 13:37:19 2004
+++ kaffe/config/i386/linux/md.h Sat Apr 24 16:57:27 2004
@@ -37,6 +37,12 @@
#if defined(HAVE_SIGCONTEXT_H)
#include <sigcontext.h>
#endif
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/*
* newer Linux kernel actually implement SA_SIGINFO.
@@ -69,6 +75,20 @@
#define GET_SIGNAL_CONTEXT_POINTER(sc) (&sc)
#define SIGNAL_PC(scp) (scp)->eip
#define STACK_POINTER(scp) (scp)->esp
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
#if defined(TRANSLATOR)
#include "jit-md.h"
Index: kaffe/config/i386/netbsd1/md.h
diff -u kaffe/config/i386/netbsd1/md.h:1.4 kaffe/config/i386/netbsd1/md.h:1.5
--- kaffe/config/i386/netbsd1/md.h:1.4 Thu Apr 22 16:28:12 2004
+++ kaffe/config/i386/netbsd1/md.h Sat Apr 24 16:57:28 2004
@@ -19,6 +19,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
/*
* Redefine stack pointer offset.
*/
@@ -35,4 +42,19 @@
#include "jit-md.h"
#endif
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
+
#endif
+
Index: kaffe/config/i386/nextstep3/md.h
diff -u kaffe/config/i386/nextstep3/md.h:1.5 kaffe/config/i386/nextstep3/md.h:1.6
--- kaffe/config/i386/nextstep3/md.h:1.5 Thu Apr 22 16:28:12 2004
+++ kaffe/config/i386/nextstep3/md.h Sat Apr 24 16:57:28 2004
@@ -19,6 +19,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
/*
* Redefine stack pointer offset.
*/
@@ -34,6 +41,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/i386/openbsd2/md.h
diff -u kaffe/config/i386/openbsd2/md.h:1.5 kaffe/config/i386/openbsd2/md.h:1.6
--- kaffe/config/i386/openbsd2/md.h:1.5 Thu Apr 22 16:28:12 2004
+++ kaffe/config/i386/openbsd2/md.h Sat Apr 24 16:57:29 2004
@@ -19,6 +19,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
/*
* Redefine stack pointer offset.
*/
@@ -34,6 +41,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/i386/oskit/md.h
diff -u kaffe/config/i386/oskit/md.h:1.6 kaffe/config/i386/oskit/md.h:1.7
--- kaffe/config/i386/oskit/md.h:1.6 Thu Apr 22 16:28:12 2004
+++ kaffe/config/i386/oskit/md.h Sat Apr 24 16:57:29 2004
@@ -18,6 +18,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
/*
* Undefine stack pointer offset, we don't need it
*/
@@ -45,6 +52,20 @@
*/
extern char *default_classpath;
#define DEFAULT_CLASSPATH default_classpath
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
/*
* Main thread uses default stacksize.
Index: kaffe/config/i386/qnx/md.h
diff -u kaffe/config/i386/qnx/md.h:1.7 kaffe/config/i386/qnx/md.h:1.8
--- kaffe/config/i386/qnx/md.h:1.7 Thu Apr 22 16:28:13 2004
+++ kaffe/config/i386/qnx/md.h Sat Apr 24 16:57:30 2004
@@ -24,8 +24,14 @@
#include "i386/common.h"
#include "i386/threads.h"
-
#include "support.h"
+
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/*
* Redefine stack pointer offset.
*/
@@ -121,5 +127,20 @@
" subl %0,%%esp \n"
" " : : "r" ((call)->argsize * sizeof(jint)) : "cc");
}
+
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
#endif
Index: kaffe/config/i386/sco3.2v5/md.h
diff -u kaffe/config/i386/sco3.2v5/md.h:1.5 kaffe/config/i386/sco3.2v5/md.h:1.6
--- kaffe/config/i386/sco3.2v5/md.h:1.5 Fri Apr 23 13:37:20 2004
+++ kaffe/config/i386/sco3.2v5/md.h Sat Apr 24 16:57:30 2004
@@ -19,6 +19,13 @@
#include "i386/sysdepCallMethod.h"
#include "i386/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
#define POSIX_SIGNALS
/**/
@@ -37,6 +44,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/i386/solaris2/md.h
diff -u kaffe/config/i386/solaris2/md.h:1.5 kaffe/config/i386/solaris2/md.h:1.6
--- kaffe/config/i386/solaris2/md.h:1.5 Fri Apr 23 13:37:20 2004
+++ kaffe/config/i386/solaris2/md.h Sat Apr 24 16:57:31 2004
@@ -24,6 +24,12 @@
/**/
#include <siginfo.h>
#include <ucontext.h>
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
#define SIGNAL_ARGS(sig, sc) int sig, siginfo_t* sip, ucontext_t* sc
#define SIGNAL_CONTEXT_POINTER(scp) struct ucontext_t * scp
@@ -35,4 +41,18 @@
#include "jit-md.h"
#endif
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_cur);
+}
#endif
Index: kaffe/config/i386/univel_svr4/md.h
diff -u kaffe/config/i386/univel_svr4/md.h:1.7 kaffe/config/i386/univel_svr4/md.h:1.8
--- kaffe/config/i386/univel_svr4/md.h:1.7 Fri Apr 23 13:37:21 2004
+++ kaffe/config/i386/univel_svr4/md.h Sat Apr 24 16:57:32 2004
@@ -24,6 +24,12 @@
/**/
#include <siginfo.h>
#include <ucontext.h>
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/* Function prototype for signal handlers */
#define SIGNAL_ARGS(sig, sc) int sig, siginfo_t* sip, ucontext_t* sc
@@ -39,5 +45,19 @@
/* NCR MP-RAS requires a little initialisation */
extern void init_md(void);
#define INIT_MD() init_md()
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
#endif
Index: kaffe/config/sparc/bsdi3/md.h
diff -u kaffe/config/sparc/bsdi3/md.h:1.3 kaffe/config/sparc/bsdi3/md.h:1.4
--- kaffe/config/sparc/bsdi3/md.h:1.3 Thu Apr 22 16:28:13 2004
+++ kaffe/config/sparc/bsdi3/md.h Sat Apr 24 16:57:32 2004
@@ -14,6 +14,12 @@
#include "sparc/common.h"
#include "sparc/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
#define SIGNAL_ARGS(sig, sc) int sig, int code, struct sigcontext* sc
#define SIGNAL_CONTEXT_POINTER(scp) struct sigcontext* scp
@@ -23,6 +29,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/sparc/linux/md.h
diff -u kaffe/config/sparc/linux/md.h:1.5 kaffe/config/sparc/linux/md.h:1.6
--- kaffe/config/sparc/linux/md.h:1.5 Thu Apr 22 16:28:14 2004
+++ kaffe/config/sparc/linux/md.h Sat Apr 24 16:57:33 2004
@@ -32,6 +32,12 @@
#include <sigcontext.h>
#endif
#include <asm/ptrace.h>
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/* Function prototype for signal handlers */
#define SIGNAL_ARGS(sig, sc) int sig, struct sigcontext* sc
@@ -47,5 +53,19 @@
/* Linux requires a little initialisation */
extern void init_md(void);
#define INIT_MD() init_md()
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
+#endif
#endif
Index: kaffe/config/sparc/openbsd2/md.h
diff -u kaffe/config/sparc/openbsd2/md.h:1.4 kaffe/config/sparc/openbsd2/md.h:1.5
--- kaffe/config/sparc/openbsd2/md.h:1.4 Thu Apr 22 16:28:15 2004
+++ kaffe/config/sparc/openbsd2/md.h Sat Apr 24 16:57:33 2004
@@ -14,6 +14,12 @@
#include "sparc/common.h"
#include "sparc/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
#undef SP_OFFSET
#define SP_OFFSET 2
@@ -27,6 +33,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/config/sparc/solaris2/md.h
diff -u kaffe/config/sparc/solaris2/md.h:1.3 kaffe/config/sparc/solaris2/md.h:1.4
--- kaffe/config/sparc/solaris2/md.h:1.3 Thu Apr 22 16:28:15 2004
+++ kaffe/config/sparc/solaris2/md.h Sat Apr 24 16:57:34 2004
@@ -20,6 +20,12 @@
/**/
#include <siginfo.h>
#include <ucontext.h>
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/* Function prototype for signal handlers */
#define SIGNAL_ARGS(sig, sc) int sig, siginfo_t* sip, ucontext_t* sc
@@ -27,6 +33,20 @@
#define GET_SIGNAL_CONTEXT_POINTER(scp) (scp)
#define SIGNAL_PC(scp) ((scp)->uc_mcontext.gregs[REG_PC])
#define STACK_POINTER(scp) ((scp)->uc_mcontext.gregs[REG_SP])
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return rl.rlim_cur;
+}
+#endif
#if defined(TRANSLATOR)
#include "jit-md.h"
Index: kaffe/config/sparc/sunos4/md.h
diff -u kaffe/config/sparc/sunos4/md.h:1.6 kaffe/config/sparc/sunos4/md.h:1.7
--- kaffe/config/sparc/sunos4/md.h:1.6 Thu Apr 22 16:28:15 2004
+++ kaffe/config/sparc/sunos4/md.h Sat Apr 24 16:57:34 2004
@@ -14,6 +14,12 @@
#include "sparc/common.h"
#include "sparc/threads.h"
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/*
* Redefine stack pointer offset.
@@ -42,5 +48,19 @@
extern int getpeername(int, struct sockaddr*, int*);
extern int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
extern int vfprintf(FILE *, char *, va_list);
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return rl.rlim_cur;
+}
+#endif
#endif
Index: kaffe/config/sparc/uxpds/md.h
diff -u kaffe/config/sparc/uxpds/md.h:1.3 kaffe/config/sparc/uxpds/md.h:1.4
--- kaffe/config/sparc/uxpds/md.h:1.3 Thu Apr 22 16:28:15 2004
+++ kaffe/config/sparc/uxpds/md.h Sat Apr 24 16:57:35 2004
@@ -20,6 +20,12 @@
/**/
#include <siginfo.h>
#include <ucontext.h>
+#if defined(HAVE_SYS_RESOURCE_H)
+#include <sys/resource.h>
+#endif
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
/* Function prototype for signal handlers */
#define SIGNAL_ARGS(sig, sc) int sig, siginfo_t* sip, ucontext_t* sc
@@ -30,6 +36,20 @@
#if defined(TRANSLATOR)
#include "jit-md.h"
+#endif
+
+#if defined(HAVE_GETRLIMIT)
+#define KAFFEMD_STACKSIZE
+
+static inline size_t mdGetStackSize()
+{
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_STACK, &rl) < 0)
+ return -1;
+ else
+ return (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
+}
#endif
#endif
Index: kaffe/kaffe/kaffevm/thread.c
diff -u kaffe/kaffe/kaffevm/thread.c:1.63 kaffe/kaffe/kaffevm/thread.c:1.64
--- kaffe/kaffe/kaffevm/thread.c:1.63 Thu Apr 22 16:28:16 2004
+++ kaffe/kaffe/kaffevm/thread.c Sat Apr 24 16:57:35 2004
@@ -714,15 +714,13 @@
* Since everything is stored in the threadData struct now, we can simply
* attach a faked java.lang.Thread instance later on.
*/
-#if defined(HAVE_GETRLIMIT)
- {
- struct rlimit rl;
-
- if (getrlimit(RLIMIT_STACK, &rl) < 0)
- stackSize = MAINSTACKSIZE;
- else
- stackSize = (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
- }
+#if defined(KAFFEMD_STACKSIZE)
+ stackSize = mdGetStackSize();
+ if (stackSize < 0)
+ {
+ dprintf("WARNING: Impossible to retrieve the real stack size\n");
+ dprintf("WARNING: You may experience deadlocks\n");
+ }
#else
stackSize = MAINSTACKSIZE;
#endif
Index: kaffe/kaffe/kaffevm/systems/unix-jthreads/signal.c
diff -u kaffe/kaffe/kaffevm/systems/unix-jthreads/signal.c:1.14 kaffe/kaffe/kaffevm/systems/unix-jthreads/signal.c:1.15
--- kaffe/kaffe/kaffevm/systems/unix-jthreads/signal.c:1.14 Fri Apr 23 12:32:05 2004
+++ kaffe/kaffe/kaffevm/systems/unix-jthreads/signal.c Sat Apr 24 16:57:36 2004
@@ -378,13 +378,6 @@
{
stack_t newstack;
-#if defined(HAVE_GETRLIMIT)
- struct rlimit rl;
-
- if (getrlimit(RLIMIT_STACK, &rl) >= 0)
- mainThreadStackSize = (rl.rlim_max >= RLIM_INFINITY) ? rl.rlim_cur : rl.rlim_max;
-#endif
-
#if defined(STACK_POINTER) && defined(SA_ONSTACK) && defined(HAVE_SIGALTSTACK)
/*
Index: kaffe/test/internal/jit_stub.c
diff -u kaffe/test/internal/jit_stub.c:1.5 kaffe/test/internal/jit_stub.c:1.6
--- kaffe/test/internal/jit_stub.c:1.5 Mon Mar 8 21:21:41 2004
+++ kaffe/test/internal/jit_stub.c Sat Apr 24 16:57:36 2004
@@ -29,6 +29,7 @@
#include "jthread.h"
#include "stringParsing.h"
#include "stringSupport.h"
+#include "md.h"
#include <xprof/debugFile.h>
@@ -147,6 +148,7 @@
Hjava_lang_Thread mainThread;
parsedString testName;
char *tests;
+ int stackSize;
initTypes();
loadStaticClass(&ObjectClass, "java/lang/Object");
@@ -155,7 +157,14 @@
loadStaticClass(&javaLangNullPointerException, "java/lang/NullPointerException");
loadStaticClass(&javaLangArrayIndexOutOfBoundsException, "java/lang/ArrayIndexOutOfBoundsException");
memset(&mainThread, 0, sizeof(mainThread));
- jthread_createfirst(MAINSTACKSIZE,
+#if defined(KAFFEMD_STACKSIZE)
+ stackSize = mdGetStackSize();
+ if (stackSize < 0)
+ stackSize = MAINSTACKSIZE;
+#else
+ stackSize = MAINSTACKSIZE;
+#endif
+ jthread_createfirst(stackSize,
java_lang_Thread_NORM_PRIORITY,
&mainThread);
More information about the kaffe
mailing list