1 | /* |
---|
2 | * Developer's BB tests |
---|
3 | */ |
---|
4 | |
---|
5 | #include <Singular/mod2.h> |
---|
6 | |
---|
7 | #include <Singular/blackbox.h> |
---|
8 | |
---|
9 | #include <Singular/tok.h> |
---|
10 | #include <Singular/ipid.h> |
---|
11 | #include <Singular/lists.h> |
---|
12 | |
---|
13 | #include <dlfcn.h> |
---|
14 | |
---|
15 | #include "bigintm.h" |
---|
16 | |
---|
17 | |
---|
18 | static inline void NoReturn(leftv& res) |
---|
19 | { |
---|
20 | res->rtyp = NONE; |
---|
21 | res->data = NULL; |
---|
22 | } |
---|
23 | |
---|
24 | |
---|
25 | /// listing all blackbox types (debug stuff) |
---|
26 | BOOLEAN printBlackboxTypes0(leftv __res, leftv __v) |
---|
27 | { |
---|
28 | NoReturn(__res); |
---|
29 | printBlackboxTypes(); |
---|
30 | return FALSE; |
---|
31 | } |
---|
32 | |
---|
33 | /// init the bigintm (a sample blackbox) type |
---|
34 | BOOLEAN bigintm_setup0(leftv __res, leftv __v) |
---|
35 | { |
---|
36 | NoReturn(__res); |
---|
37 | return bigintm_setup(); |
---|
38 | } |
---|
39 | |
---|
40 | static long int load_counter = -1; |
---|
41 | |
---|
42 | /// init the bigintm (a sample blackbox) type |
---|
43 | BOOLEAN print_load_counter(leftv __res, leftv __v) |
---|
44 | { |
---|
45 | Print("print_load_counter: load counter: %ld", load_counter); |
---|
46 | Print(", printBlackboxTypes: %p", (void*)(printBlackboxTypes0)); |
---|
47 | Print(", bigintm_setup: %p", (void*)(bigintm_setup0)); |
---|
48 | PrintLn(); |
---|
49 | |
---|
50 | NoReturn(__res); |
---|
51 | return FALSE; |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | extern "C" |
---|
56 | { |
---|
57 | int mod_init(SModulFunctions* psModulFunctions) |
---|
58 | { |
---|
59 | load_counter++; |
---|
60 | |
---|
61 | if( !load_counter) |
---|
62 | { |
---|
63 | |
---|
64 | psModulFunctions->iiAddCproc(currPack->libname,(char*)"printBlackboxTypes",FALSE, printBlackboxTypes0); |
---|
65 | psModulFunctions->iiAddCproc(currPack->libname,(char*)"bigintm_setup",FALSE, bigintm_setup0); |
---|
66 | psModulFunctions->iiAddCproc(currPack->libname,(char*)"bigintm_print_load_counter",FALSE, print_load_counter); |
---|
67 | |
---|
68 | // Q: should we call 'bigintm_setup' here??!?!? |
---|
69 | return 0; |
---|
70 | } |
---|
71 | else |
---|
72 | { |
---|
73 | PrintS("ERROR: Sorry this dynamic module was already loaded...!!!"); |
---|
74 | PrintLn(); |
---|
75 | // Q: what about loading this module multipple times...? |
---|
76 | return 0; // -1? - No difference!!! |
---|
77 | |
---|
78 | } |
---|
79 | |
---|
80 | } |
---|
81 | } |
---|