1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /*************************************************************** |
---|
5 | * File: slInit_Dynamic.cc |
---|
6 | * Purpose: link initialization for dynamic linking |
---|
7 | * Author: obachman (Olaf Bachmann) |
---|
8 | * Created: 12/00 |
---|
9 | *******************************************************************/ |
---|
10 | |
---|
11 | /*************************************************************** |
---|
12 | * |
---|
13 | * MP link Extension inits |
---|
14 | * |
---|
15 | ***************************************************************/ |
---|
16 | #include "config.h" |
---|
17 | #include <kernel/mod2.h> |
---|
18 | #include <Singular/silink.h> |
---|
19 | #include <Singular/slInit.h> |
---|
20 | #include <polys/mod_raw.h> |
---|
21 | |
---|
22 | #ifdef HAVE_DL |
---|
23 | #ifdef HAVE_MPSR |
---|
24 | #include <MP.h> |
---|
25 | #include "mpsr_sl.h" |
---|
26 | |
---|
27 | static void* mpsr_so_handle = NULL; |
---|
28 | typedef void (*voidProc)(); |
---|
29 | |
---|
30 | static void* slInitMPSRHandle() |
---|
31 | { |
---|
32 | if (mpsr_so_handle == NULL) |
---|
33 | { |
---|
34 | mpsr_so_handle = dynl_open_binary_warn("mpsr"); |
---|
35 | if (mpsr_so_handle != NULL) |
---|
36 | { |
---|
37 | voidProc init_proc = (voidProc) |
---|
38 | dynl_sym_warn(mpsr_so_handle, "mpsr_Init"); |
---|
39 | if (init_proc != NULL) |
---|
40 | (*init_proc)(); |
---|
41 | else |
---|
42 | mpsr_so_handle = NULL; |
---|
43 | } |
---|
44 | } |
---|
45 | return mpsr_so_handle; |
---|
46 | } |
---|
47 | |
---|
48 | si_link_extension slInitMPFileExtension(si_link_extension s) |
---|
49 | { |
---|
50 | void* handle = slInitMPSRHandle(); |
---|
51 | |
---|
52 | if (handle == NULL) return NULL; |
---|
53 | |
---|
54 | s->Open = (slOpenProc) dynl_sym_warn(handle, "slOpenMPFile"); |
---|
55 | s->Close = (slCloseProc) dynl_sym_warn(handle, "slCloseMP"); |
---|
56 | s->Kill = (slKillProc) s->Close; |
---|
57 | s->Read = (slReadProc) dynl_sym_warn(handle, "slReadMP"); |
---|
58 | s->Dump = (slDumpProc) dynl_sym_warn(handle, "slDumpMP"); |
---|
59 | s->GetDump = (slGetDumpProc) dynl_sym_warn(handle, "slGetDumpMP"); |
---|
60 | s->Write = (slWriteProc) dynl_sym_warn(handle, "slWriteMP"); |
---|
61 | s->Status = (slStatusProc) dynl_sym_warn(handle, "slStatusMP"); |
---|
62 | if (s->Open == NULL || s->Close == NULL || s->Kill == NULL || |
---|
63 | s->Read == NULL || s->Dump == NULL || s->GetDump == NULL || |
---|
64 | s->Write == NULL || s->Status == NULL) |
---|
65 | return NULL; |
---|
66 | |
---|
67 | s->type="MPfile"; |
---|
68 | return s; |
---|
69 | } |
---|
70 | |
---|
71 | si_link_extension slInitMPTcpExtension(si_link_extension s) |
---|
72 | { |
---|
73 | void* handle = slInitMPSRHandle(); |
---|
74 | |
---|
75 | if (handle == NULL) return NULL; |
---|
76 | |
---|
77 | s->Open = (slOpenProc) dynl_sym_warn(handle, "slOpenMPTcp"); |
---|
78 | s->Close = (slCloseProc) dynl_sym_warn(handle, "slCloseMP"); |
---|
79 | s->Kill = (slKillProc) dynl_sym_warn(handle, "slKillMP"); |
---|
80 | s->Read = (slReadProc) dynl_sym_warn(handle, "slReadMP"); |
---|
81 | s->Dump = (slDumpProc) dynl_sym_warn(handle, "slDumpMP"); |
---|
82 | s->GetDump = (slGetDumpProc) dynl_sym_warn(handle, "slGetDumpMP"); |
---|
83 | s->Write = (slWriteProc) dynl_sym_warn(handle, "slWriteMP"); |
---|
84 | s->Status = (slStatusProc) dynl_sym_warn(handle, "slStatusMP"); |
---|
85 | |
---|
86 | if (s->Open == NULL || s->Close == NULL || s->Kill == NULL || |
---|
87 | s->Read == NULL || s->Dump == NULL || s->GetDump == NULL || |
---|
88 | s->Write == NULL || s->Status == NULL) |
---|
89 | return NULL; |
---|
90 | |
---|
91 | s->type="MPtcp"; |
---|
92 | return s; |
---|
93 | } |
---|
94 | |
---|
95 | BatchDoProc slInitMPBatchDo() |
---|
96 | { |
---|
97 | void* handle = slInitMPSRHandle(); |
---|
98 | |
---|
99 | if (handle == NULL) return NULL; |
---|
100 | return (BatchDoProc) dynl_sym_warn(handle, "Batch_do"); |
---|
101 | } |
---|
102 | #endif |
---|
103 | |
---|
104 | #ifdef HAVE_DBM |
---|
105 | #include "dbm_sl.h" |
---|
106 | |
---|
107 | static void* dbm_so_handle = NULL; |
---|
108 | static void* slInitDBMHandle() |
---|
109 | { |
---|
110 | if (dbm_so_handle == NULL) |
---|
111 | dbm_so_handle = dynl_open_binary_warn("dbmsr"); |
---|
112 | |
---|
113 | return dbm_so_handle; |
---|
114 | } |
---|
115 | |
---|
116 | si_link_extension slInitDBMExtension(si_link_extension s) |
---|
117 | { |
---|
118 | void* handle = slInitDBMHandle(); |
---|
119 | |
---|
120 | if (handle == NULL) return NULL; |
---|
121 | |
---|
122 | s->Open=(slOpenProc)dynl_sym_warn(handle, "dbOpen"); |
---|
123 | s->Close=(slCloseProc)dynl_sym_warn(handle, "dbClose"); |
---|
124 | s->Kill=(slKillProc)dynl_sym_warn(handle, "dbClose"); |
---|
125 | s->Read=(slReadProc)dynl_sym_warn(handle, "dbRead1"); |
---|
126 | s->Read2=(slRead2Proc)dynl_sym_warn(handle, "dbRead2"); |
---|
127 | s->Write=(slWriteProc)dynl_sym_warn(handle, "dbWrite"); |
---|
128 | |
---|
129 | if (s->Open == NULL || s->Close == NULL || s->Kill == NULL || |
---|
130 | s->Read == NULL || s->Read2 == NULL) |
---|
131 | return NULL; |
---|
132 | |
---|
133 | s->Status=slStatusAscii; |
---|
134 | s->type="DBM"; |
---|
135 | return s; |
---|
136 | } |
---|
137 | |
---|
138 | #endif |
---|
139 | #endif |
---|
140 | |
---|