Changes:
- $Id: gennativetable.c 1371 2004-08-01 21:55:39Z stefan $
+ $Id: gennativetable.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#include "loader.h"
#include "tables.h"
#include "mm/boehm.h"
+#include "threads/locks.h"
#include "threads/thread.h"
#include "toolbox/chain.h"
#include "toolbox/memory.h"
suck_init(classpath);
-
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(USE_THREADS)
+#if defined(NATIVE_THREADS)
initThreadsEarly();
#endif
initLocks();
+#endif
+
loader_init((u1 *) &dummy);
if (!file)
panic("Can not open file 'nativetable' to store native-link-table");
- fprintf(file, "/* Table of native methods: nativetables.hh */\n");
+ fprintf(file, "/* Table of native methods: nativetables.inc */\n");
fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n");
+ fprintf(file, "#include \"config.h\"\n");
+
c = chain_first(nativeclass_chain);
while (c) {
gen_header_filename(classname, c->name);
chain_free(nativeclass_chain);
fprintf(file, "\n\n#include \"native.h\"\n\n");
+ fprintf(file, "#ifdef STATIC_CLASSPATH\n\n");
fprintf(file, "static nativeref nativetable[] = {\n");
m = chain_first(nativemethod_chain);
chain_free(nativemethod_chain);
fprintf(file, "};\n");
-
+ fprintf(file,"\n#else\n");
+ fprintf(file, "/*ensure that symbols for functions implemented within cacao are used and exported to dlopen*/\n");
+ fprintf(file, "static functionptr dummynativetable[]={\n");
+ {
+ FILE *implData=fopen("nat/implementednatives.data","r");
+ if (!implData) {fclose(file); exit(3);}
+ while (!feof(implData)) {
+ char functionLine[1024];
+ functionLine[0]='\0';
+ fgets(functionLine,1024,implData);
+ if (strlen(functionLine)<2) continue;
+ if (functionLine[strlen(functionLine)-1]!='\n') { fclose(implData); fclose(file); exit(4);}
+ functionLine[strlen(functionLine)-1]=',';
+ fprintf(file,"\t(functionptr) %s\n",functionLine);
+ }
+ fprintf(file,"\t(functionptr)0");
+ fclose(implData);
+ }
+ fprintf(file, "};\n");
+ fprintf(file,"\n#endif\n");
fclose(file);
-
+
/* release all resources */
loader_close();