source: git/dyn_modules/bigintm/mod_main.cc @ e5a4ba

spielwiese
Last change on this file since e5a4ba was f24733, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
MV: moved WrongOP to blackbox FIX: dynamic modules must ONLY export 'mod_init'! From: Oleksandr Motsak <motsak@mathematik.uni-kl.de> git-svn-id: file:///usr/local/Singular/svn/trunk@13981 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
Line 
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
17namespace
18{
19
20static inline void NoReturn(leftv& res)
21{
22  res->rtyp = NONE;
23  res->data = NULL;
24}
25
26
27/// listing all blackbox types (debug stuff)
28static 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
36static BOOLEAN bigintm_setup0(leftv __res, leftv __v)
37{
38  NoReturn(__res);
39  return bigintm_setup();
40}
41
42static long int load_counter = -1;
43
44/// init the bigintm (a sample blackbox) type
45static 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
59extern "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}
Note: See TracBrowser for help on using the repository browser.