37118c3a6e2b7db1e4b7140071788dc52da992ce
[org.ibex.core.git] / src / org / ibex / plat / Linux.cc
1 // IMPORTANT: inclusion order: always include gcjh'ed headers first, then superclass cc's, then system headers
2 #undef file
3 #include <stdint.h>
4 #include <java/lang/Class.h>
5 #include <org/ibex/js/JS.h>
6 #include <org/ibex/util/Log.h>
7 #include <org/ibex/plat/Linux.h>
8 #include "X11.cc"
9 #include <stdint.h>
10
11 // we love libgcj!
12 extern const char **_Jv_argv;
13 extern int _Jv_argc;
14
15 void org::ibex::plat::Linux::fixEnvironment() {
16   // this wreaks havoc on gdb
17   // see http://lists.debian.org/debian-glibc/2003/debian-glibc-200311/msg00647.html
18   const char* ld_assume_kernel = getenv("LD_ASSUME_KERNEL");
19   if (ld_assume_kernel == NULL || strcmp("2.4.1", ld_assume_kernel)) {
20     int result;
21     printf("respawning self (%s) with LD_ASSUME_KERNEL=2.4.1\n", _Jv_argv[0]);
22     setenv("LD_ASSUME_KERNEL", "2.4.1", 1);
23     result = execvp(_Jv_argv[0], (char* const*)((void*)_Jv_argv));
24     printf("execvp() failed with error code %d\n", result);
25     exit(-1);
26   }
27 }