[69a954] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
[5ea75c] | 4 | /* $Id: mod_raw.cc,v 1.8 2000-05-23 13:10:10 Singular Exp $ */ |
---|
[69a954] | 5 | /* |
---|
| 6 | * ABSTRACT: machine depend code for dynamic modules |
---|
| 7 | * |
---|
| 8 | * Provides: dynl_open() |
---|
| 9 | * dynl_sym() |
---|
| 10 | * dynl_error() |
---|
| 11 | * dunl_close() |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | #include "mod2.h" |
---|
[5ea75c] | 15 | #include "static.h" |
---|
| 16 | #ifdef HAVE_STATIC |
---|
| 17 | #undef HAVE_DYNAMIC_LOADING |
---|
| 18 | #undef HAVE_DYN_RL |
---|
| 19 | #endif |
---|
| 20 | |
---|
[60ec78] | 21 | #if defined(HAVE_DYNAMIC_LOADING) || defined(HAVE_DYN_RL) |
---|
[69a954] | 22 | #include "mod_raw.h" |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | /***************************************************************************** |
---|
[9d38d4] | 26 | * SECTION ix86-linux / alpha-linux * |
---|
[69a954] | 27 | *****************************************************************************/ |
---|
[9c5d43] | 28 | #if defined(ix86_Linux) || defined(DecAlpha_Linux) || defined(ix86_Linux_libc5) |
---|
[60ec78] | 29 | #include <dlfcn.h> |
---|
[69a954] | 30 | |
---|
| 31 | void *dynl_open( |
---|
| 32 | char *filename /* I: filename to load */ |
---|
| 33 | ) |
---|
| 34 | { |
---|
[b60fb4] | 35 | return(dlopen(filename, RTLD_NOW|RTLD_GLOBAL)); |
---|
[69a954] | 36 | } |
---|
| 37 | |
---|
| 38 | void *dynl_sym(void *handle, char *symbol) |
---|
| 39 | { |
---|
| 40 | return(dlsym(handle, symbol)); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | int dynl_close (void *handle) |
---|
| 44 | { |
---|
| 45 | return(dlclose (handle)); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | const char *dynl_error() |
---|
| 49 | { |
---|
| 50 | return(dlerror()); |
---|
| 51 | } |
---|
[60ec78] | 52 | #endif /* ix86_Linux */ |
---|
[69a954] | 53 | |
---|
| 54 | /***************************************************************************** |
---|
| 55 | * SECTION HPUX-9/10 * |
---|
| 56 | *****************************************************************************/ |
---|
[60ec78] | 57 | #if defined(HPUX_9) || defined(HPUX_10) |
---|
| 58 | #include <dl.h> |
---|
| 59 | |
---|
[69a954] | 60 | typedef char *((*func_ptr) ()); |
---|
| 61 | |
---|
| 62 | void *dynl_open(char *filename) |
---|
| 63 | { |
---|
| 64 | shl_t handle = shl_load(filename, BIND_DEFERRED, 0); |
---|
| 65 | |
---|
| 66 | return ((void *) handle); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | void *dynl_sym(void *handle, char *symbol) |
---|
| 70 | { |
---|
| 71 | func_ptr f; |
---|
| 72 | |
---|
| 73 | if (shl_findsym((shl_t *) & handle, symbol, TYPE_PROCEDURE, &f) == -1) |
---|
| 74 | { |
---|
[200969] | 75 | if (shl_findsym((shl_t *) & handle, symbol, TYPE_UNDEFINED, &f) == -1) |
---|
| 76 | { |
---|
| 77 | f = (func_ptr) NULL; |
---|
| 78 | } |
---|
[69a954] | 79 | } |
---|
| 80 | return (f); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | int dynl_close (void *handle) |
---|
| 84 | { |
---|
| 85 | shl_unload((shl_t) handle); |
---|
| 86 | return(0); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | const char *dynl_error() |
---|
| 90 | { |
---|
| 91 | static char errmsg[] = "shl_load failed"; |
---|
[60ec78] | 92 | |
---|
[69a954] | 93 | return errmsg; |
---|
| 94 | } |
---|
| 95 | #endif /* HPUX_9 or HPUX_10 */ |
---|
| 96 | |
---|
| 97 | /***************************************************************************** |
---|
| 98 | * SECTION 68k-MPW * |
---|
| 99 | *****************************************************************************/ |
---|
[60ec78] | 100 | #ifdef 68k_MPW |
---|
[69a954] | 101 | /* # include <> */ |
---|
| 102 | |
---|
| 103 | void *dynl_open(char *filename) |
---|
| 104 | { |
---|
| 105 | return(NULL); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | void *dynl_sym(void *handle, char *symbol) |
---|
| 109 | { |
---|
| 110 | return(NULL); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | int dynl_close (void *handle) |
---|
| 114 | { |
---|
| 115 | return(0); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | const char *dynl_error() |
---|
| 119 | { |
---|
| 120 | static char errmsg[] = "support for dynamic loading not implemented"; |
---|
[60ec78] | 121 | |
---|
[69a954] | 122 | return errmsg; |
---|
| 123 | } |
---|
| 124 | # endif /* 68k_MPW */ |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | /***************************************************************************** |
---|
| 128 | * SECTION AIX-4 * |
---|
| 129 | *****************************************************************************/ |
---|
[60ec78] | 130 | #ifdef AIX_4 |
---|
[69a954] | 131 | /* # include <> */ |
---|
| 132 | |
---|
| 133 | void *dynl_open(char *filename) |
---|
| 134 | { |
---|
| 135 | return(NULL); |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | void *dynl_sym(void *handle, char *symbol) |
---|
| 139 | { |
---|
| 140 | return(NULL); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | int dynl_close (void *handle) |
---|
| 144 | { |
---|
| 145 | return(0); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | const char *dynl_error() |
---|
| 149 | { |
---|
| 150 | static char errmsg[] = "support for dynamic loading not implemented"; |
---|
[60ec78] | 151 | |
---|
[69a954] | 152 | return errmsg; |
---|
| 153 | } |
---|
| 154 | # endif /* AIX_4 */ |
---|
| 155 | |
---|
| 156 | /***************************************************************************** |
---|
| 157 | * SECTION IRIX-6 * |
---|
| 158 | *****************************************************************************/ |
---|
[60ec78] | 159 | #ifdef IRIX_6 |
---|
[69a954] | 160 | /* # include <> */ |
---|
| 161 | |
---|
| 162 | void *dynl_open(char *filename) |
---|
| 163 | { |
---|
| 164 | return(NULL); |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | void *dynl_sym(void *handle, char *symbol) |
---|
| 168 | { |
---|
| 169 | return(NULL); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | int dynl_close (void *handle) |
---|
| 173 | { |
---|
| 174 | return(0); |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | const char *dynl_error() |
---|
| 178 | { |
---|
| 179 | static char errmsg[] = "support for dynamic loading not implemented"; |
---|
[60ec78] | 180 | |
---|
[69a954] | 181 | return errmsg; |
---|
| 182 | } |
---|
| 183 | # endif /* IRIX_6 */ |
---|
| 184 | |
---|
| 185 | /***************************************************************************** |
---|
| 186 | * SECTION Sun3OS-4 * |
---|
| 187 | *****************************************************************************/ |
---|
[60ec78] | 188 | #ifdef Sun3OS_4 |
---|
[69a954] | 189 | /* # include <> */ |
---|
| 190 | |
---|
| 191 | void *dynl_open(char *filename) |
---|
| 192 | { |
---|
| 193 | return(NULL); |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | void *dynl_sym(void *handle, char *symbol) |
---|
| 197 | { |
---|
| 198 | return(NULL); |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | int dynl_close (void *handle) |
---|
| 202 | { |
---|
| 203 | return(0); |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | const char *dynl_error() |
---|
| 207 | { |
---|
| 208 | static char errmsg[] = "support for dynamic loading not implemented"; |
---|
[60ec78] | 209 | |
---|
[69a954] | 210 | return errmsg; |
---|
| 211 | } |
---|
[60ec78] | 212 | #endif /* Sun3OS_4 */ |
---|
[69a954] | 213 | |
---|
| 214 | /***************************************************************************** |
---|
| 215 | * SECTION SunOS-4/5 * |
---|
| 216 | *****************************************************************************/ |
---|
[60ec78] | 217 | #if defined(SunOS_4) || defined(SunOS_5) |
---|
[69a954] | 218 | /* # include <> */ |
---|
| 219 | |
---|
| 220 | void *dynl_open(char *filename) |
---|
| 221 | { |
---|
| 222 | return(NULL); |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | void *dynl_sym(void *handle, char *symbol) |
---|
| 226 | { |
---|
| 227 | return(NULL); |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | int dynl_close (void *handle) |
---|
| 231 | { |
---|
| 232 | return(0); |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | const char *dynl_error() |
---|
| 236 | { |
---|
| 237 | static char errmsg[] = "support for dynamic loading not implemented"; |
---|
[60ec78] | 238 | |
---|
[69a954] | 239 | return errmsg; |
---|
| 240 | } |
---|
[60ec78] | 241 | #endif /* SunOS_4 or SunOS_5 */ |
---|
[69a954] | 242 | |
---|
| 243 | /***************************************************************************** |
---|
| 244 | * SECTION ix86-win * |
---|
| 245 | *****************************************************************************/ |
---|
[60ec78] | 246 | #ifdef ix86_win |
---|
[69a954] | 247 | /* # include <> */ |
---|
| 248 | |
---|
| 249 | void *dynl_open(char *filename) |
---|
| 250 | { |
---|
| 251 | return(NULL); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | void *dynl_sym(void *handle, char *symbol) |
---|
| 255 | { |
---|
| 256 | return(NULL); |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | int dynl_close (void *handle) |
---|
| 260 | { |
---|
| 261 | return(0); |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | const char *dynl_error() |
---|
| 265 | { |
---|
| 266 | static char errmsg[] = "support for dynamic loading not implemented"; |
---|
[60ec78] | 267 | |
---|
[69a954] | 268 | return errmsg; |
---|
| 269 | } |
---|
[60ec78] | 270 | #endif /* ix86_win */ |
---|
[69a954] | 271 | |
---|
| 272 | /***************************************************************************** |
---|
| 273 | * SECTION ppc-MPW * |
---|
| 274 | *****************************************************************************/ |
---|
[60ec78] | 275 | #ifdef ppc_MPW |
---|
[69a954] | 276 | /* # include <> */ |
---|
| 277 | |
---|
| 278 | void *dynl_open(char *filename) |
---|
| 279 | { |
---|
| 280 | return(NULL); |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | void *dynl_sym(void *handle, char *symbol) |
---|
| 284 | { |
---|
| 285 | return(NULL); |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | int dynl_close (void *handle) |
---|
| 289 | { |
---|
| 290 | return(0); |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | const char *dynl_error() |
---|
| 294 | { |
---|
| 295 | static char errmsg[] = "support for dynamic loading not implemented"; |
---|
| 296 | return errmsg; |
---|
| 297 | } |
---|
| 298 | # endif /* ppc_MPW */ |
---|
| 299 | |
---|
| 300 | |
---|
| 301 | #endif /* HAVE_DYNAMIC_LOADING */ |
---|