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