|
1 | 1 | /*
|
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>. |
| 2 | + * Dynamic loading support for Darwin |
5 | 3 | *
|
6 |
| - * $PostgreSQL: pgsql/src/backend/port/dynloader/darwin.c,v 1.10 2004/01/07 18:56:27 neilc Exp $ |
| 4 | + * If dlopen() is available (Darwin 10.3 and later), we just use it. |
| 5 | + * Otherwise we emulate it with the older, now deprecated, NSLinkModule API. |
| 6 | + * |
| 7 | + * $PostgreSQL: pgsql/src/backend/port/dynloader/darwin.c,v 1.11 2006/10/08 19:31:03 tgl Exp $ |
7 | 8 | */
|
8 | 9 | #include"postgres.h"
|
9 | 10 |
|
| 11 | +#ifdefHAVE_DLOPEN |
| 12 | +#include<dlfcn.h> |
| 13 | +#else |
10 | 14 | #include<mach-o/dyld.h>
|
| 15 | +#endif |
11 | 16 |
|
12 | 17 | #include"dynloader.h"
|
13 | 18 |
|
14 | 19 |
|
15 |
| -staticNSObjectFileImageReturnCodecofiff_result=NSObjectFileImageFailure; |
| 20 | +#ifdefHAVE_DLOPEN |
| 21 | + |
| 22 | +void* |
| 23 | +pg_dlopen(char*filename) |
| 24 | +{ |
| 25 | +returndlopen(filename,RTLD_NOW |RTLD_GLOBAL); |
| 26 | +} |
| 27 | + |
| 28 | +void |
| 29 | +pg_dlclose(void*handle) |
| 30 | +{ |
| 31 | +dlclose(handle); |
| 32 | +} |
| 33 | + |
| 34 | +PGFunction |
| 35 | +pg_dlsym(void*handle,char*funcname) |
| 36 | +{ |
| 37 | +/* Do not prepend an underscore: see dlopen(3) */ |
| 38 | +returndlsym(handle,funcname); |
| 39 | +} |
16 | 40 |
|
| 41 | +char* |
| 42 | +pg_dlerror(void) |
| 43 | +{ |
| 44 | +returndlerror(); |
| 45 | +} |
| 46 | + |
| 47 | +#else/* !HAVE_DLOPEN */ |
| 48 | + |
| 49 | +/* |
| 50 | + * These routines were taken from the Apache source, but were made |
| 51 | + * available with a PostgreSQL-compatible license.Kudos Wilfredo |
| 52 | + * Sánchez <wsanchez@apple.com>. |
| 53 | + */ |
| 54 | + |
| 55 | +staticNSObjectFileImageReturnCodecofiff_result=NSObjectFileImageFailure; |
17 | 56 |
|
18 | 57 | void*
|
19 | 58 | pg_dlopen(char*filename)
|
@@ -92,3 +131,5 @@ pg_dlerror(void)
|
92 | 131 |
|
93 | 132 | return (char*)errorString;
|
94 | 133 | }
|
| 134 | + |
| 135 | +#endif/* HAVE_DLOPEN */ |