Skip to content

Commit b5d2929

Browse files
committed
Remove obsolete darwin dynloader code
not needed since macOS 10.3 (2003)
1 parent 3ebdd21 commit b5d2929

File tree

1 file changed

+0
-103
lines changed

1 file changed

+0
-103
lines changed

src/backend/port/dynloader/darwin.c

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
/*
22
* Dynamic loading support for macOS (Darwin)
33
*
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-
*
74
* src/backend/port/dynloader/darwin.c
85
*/
96
#include "postgres.h"
107

11-
#ifdef HAVE_DLOPEN
128
#include <dlfcn.h>
13-
#else
14-
#include <mach-o/dyld.h>
15-
#endif
169

1710
#include "dynloader.h"
1811

1912

20-
#ifdef HAVE_DLOPEN
21-
2213
void *
2314
pg_dlopen(const char *filename)
2415
{
@@ -34,7 +25,6 @@ pg_dlclose(void *handle)
3425
PGFunction
3526
pg_dlsym(void *handle, const char *funcname)
3627
{
37-
/* Do not prepend an underscore: see dlopen(3) */
3828
return dlsym(handle, funcname);
3929
}
4030

@@ -43,96 +33,3 @@ pg_dlerror(void)
4333
{
4434
return dlerror();
4535
}
46-
#else /* !HAVE_DLOPEN */
47-
48-
/*
49-
* These routines were taken from the Apache source, but were made
50-
* available with a PostgreSQL-compatible license. Kudos Wilfredo
51-
* Sánchez <wsanchez@apple.com>.
52-
*/
53-
54-
static NSObjectFileImageReturnCode cofiff_result = NSObjectFileImageFailure;
55-
56-
void *
57-
pg_dlopen(const char *filename)
58-
{
59-
NSObjectFileImage image;
60-
61-
cofiff_result = NSCreateObjectFileImageFromFile(filename, &image);
62-
if (cofiff_result != NSObjectFileImageSuccess)
63-
return NULL;
64-
return NSLinkModule(image, filename,
65-
NSLINKMODULE_OPTION_BINDNOW |
66-
NSLINKMODULE_OPTION_RETURN_ON_ERROR);
67-
}
68-
69-
void
70-
pg_dlclose(void *handle)
71-
{
72-
NSUnLinkModule(handle, NSUNLINKMODULE_OPTION_NONE);
73-
}
74-
75-
PGFunction
76-
pg_dlsym(void *handle, const char *funcname)
77-
{
78-
NSSymbol symbol;
79-
char *symname = (char *) malloc(strlen(funcname) + 2);
80-
81-
if (!symname)
82-
return NULL;
83-
84-
sprintf(symname, "_%s", funcname);
85-
if (NSIsSymbolNameDefined(symname))
86-
{
87-
symbol = NSLookupAndBindSymbol(symname);
88-
89-
free(symname);
90-
return (PGFunction) NSAddressOfSymbol(symbol);
91-
}
92-
else
93-
{
94-
free(symname);
95-
return NULL;
96-
}
97-
}
98-
99-
char *
100-
pg_dlerror(void)
101-
{
102-
NSLinkEditErrors c;
103-
int errorNumber;
104-
const char *fileName;
105-
const char *errorString = NULL;
106-
107-
switch (cofiff_result)
108-
{
109-
case NSObjectFileImageSuccess:
110-
/* must have failed in NSLinkModule */
111-
NSLinkEditError(&c, &errorNumber, &fileName, &errorString);
112-
if (errorString == NULL || *errorString == '\0')
113-
errorString = "unknown link-edit failure";
114-
break;
115-
case NSObjectFileImageFailure:
116-
errorString = "failed to open object file";
117-
break;
118-
case NSObjectFileImageInappropriateFile:
119-
errorString = "inappropriate object file";
120-
break;
121-
case NSObjectFileImageArch:
122-
errorString = "object file is for wrong architecture";
123-
break;
124-
case NSObjectFileImageFormat:
125-
errorString = "object file has wrong format";
126-
break;
127-
case NSObjectFileImageAccess:
128-
errorString = "insufficient permissions for object file";
129-
break;
130-
default:
131-
errorString = "unknown failure to open object file";
132-
break;
133-
}
134-
135-
return (char *) errorString;
136-
}
137-
138-
#endif /* HAVE_DLOPEN */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy