/
dl_hpux.c
69 lines (49 loc) · 1.49 KB
/
dl_hpux.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*==============================================================================
$Id: dl_hpux.c,v 1.1.1.1 2004/06/01 12:16:17 raph Exp $
simple dlopen()-like implementation above HP-UX shl_xxx() API
Written by Miodrag Vallat <miod@mikmod.org>, released in the public domain
==============================================================================*/
/*
* This implementation currently only works on hppa systems.
* It could be made working on m68k (hp9000s300) series, but my HP-UX 5.5
* disk is dead and I don't have the system tapes...
*/
#ifdef HAVE_CONFIG_H
#include "config.h" /* const */
#endif
#ifdef MIKMOD_DLAPI_HP
#include <dl.h>
#include <malloc.h>
#include <string.h>
#include "dlfcn.h"
extern char *_mm_strdup (const char *__s);
void *dlopen(const char *name, int flags)
{
shl_t handle;
char *library;
if (name == NULL || *name == '\0')
return NULL;
/* By convention, libmikmod will look for "foo.so" while on HP-UX the
name would be "foo.sl". Change the last letter here. */
library = _mm_strdup(name);
library[strlen(library) - 1] = 'l';
handle = shl_load(library,
(flags & RTLD_LAZY ? BIND_DEFERRED : BIND_IMMEDIATE) | DYNAMIC_PATH,
0L);
free(library);
return (void *)handle;
}
int dlclose(void *handle)
{
return shl_unload((shl_t)handle);
}
void *dlsym(void *handle, const char *sym)
{
shl_t h = (shl_t)handle;
void *address;
if (shl_findsym(&h, sym, TYPE_UNDEFINED, &address) == 0)
return address;
return NULL;
}
#endif
/* ex:set ts=4: */