|
1 | 1 | /*
|
2 |
| - * This is a place holder until someone supplies a dynamic loader |
3 |
| - * interface for this platform. |
| 2 | + * These routines were taken from the Apache source, but were made |
| 3 | + * available with a PostgreSQL-compatible license. Kudos Wilfredo |
| 4 | + * Sánchez <wsanchez@apple.com>. |
4 | 5 | *
|
5 |
| - * $Header: /cvsroot/pgsql/src/backend/port/dynloader/darwin.c,v 1.1 2000/10/31 19:55:19 petere Exp $ |
| 6 | + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/darwin.c,v 1.2 2000/11/09 19:00:50 petere Exp $ |
6 | 7 | */
|
7 | 8 |
|
8 |
| -#include"postgres.h" |
9 |
| -#include"fmgr.h" |
10 |
| -#include"utils/dynamic_loader.h" |
| 9 | +#include<mach-o/dyld.h> |
11 | 10 | #include"dynloader.h"
|
12 | 11 |
|
13 |
| -void* |
14 |
| -pg_dlopen(char*filename) |
| 12 | +void*pg_dlopen(constchar*filename) |
15 | 13 | {
|
16 |
| -return (void*)NULL; |
| 14 | +NSObjectFileImageimage; |
| 15 | + |
| 16 | +if (NSCreateObjectFileImageFromFile(filename,&image)!= |
| 17 | +NSObjectFileImageSuccess) |
| 18 | +returnNULL; |
| 19 | +returnNSLinkModule(image,filename, TRUE); |
17 | 20 | }
|
18 | 21 |
|
19 |
| -PGFunction |
20 |
| -pg_dlsym(void*handle,char*funcname) |
| 22 | +voidpg_dlclose(void*handle) |
21 | 23 | {
|
22 |
| -returnNULL; |
| 24 | +NSUnLinkModule(handle,FALSE); |
| 25 | +return; |
23 | 26 | }
|
24 | 27 |
|
25 |
| -void |
26 |
| -pg_dlclose(void*handle) |
| 28 | +PGFunction*pg_dlsym(void*handle,constchar*funcname) |
27 | 29 | {
|
| 30 | +NSSymbolsymbol; |
| 31 | +char*symname= (char*)malloc(strlen(funcname)+2); |
| 32 | + |
| 33 | +sprintf(symname,"_%s",funcname); |
| 34 | +symbol=NSLookupAndBindSymbol(symname); |
| 35 | +free(symname); |
| 36 | +return (PGFunction*)NSAddressOfSymbol(symbol); |
28 | 37 | }
|
29 | 38 |
|
30 |
| -char* |
31 |
| -pg_dlerror() |
| 39 | +constchar*pg_dlerror(void) |
32 | 40 | {
|
33 |
| -staticcharerrmsg[]="the dynamic loader for darwin doesn't exist yet"; |
34 |
| - |
35 |
| -returnerrmsg; |
| 41 | +return"no error message available"; |
36 | 42 | }
|