1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-05 02:22:28 +03:00

re-integrate nextstep dynloader functionality

From: Jacek Lasecki <jacek@sound.eti.pg.gda.pl>
This commit is contained in:
Marc G. Fournier
1998-08-25 14:07:13 +00:00
parent 875a3f6604
commit dd70e439df
2 changed files with 4 additions and 4 deletions

View File

@@ -1,81 +0,0 @@
#include <mach-o/rld.h>
#include <streams/streams.h>
#include <stdlib.h>
static char *lastError = NULL;
static NXStream *
OpenError()
{
return NXOpenMemory(NULL, 0, NX_WRITEONLY);
}
static void
CloseError(NXStream * s)
{
if (s)
NXCloseMemory(s, NX_FREEBUFFER);
}
static void
TransferError(NXStream * s)
{
char *buffer;
int len,
maxlen;
if (lastError)
free(lastError);
NXGetMemoryBuffer(s, &buffer, &len, &maxlen);
lastError = malloc(len + 1);
strcpy(lastError, buffer);
}
void *
next_dlopen(char *name)
{
int rld_success;
NXStream *errorStream;
char *result = NULL;
char **p;
errorStream = OpenError();
p = calloc(2, sizeof(void *));
p[0] = name;
rld_success = rld_load(errorStream, NULL, p, NULL);
free(p);
if (!rld_success)
{
TransferError(errorStream);
result = (char *) 1;
}
CloseError(errorStream);
return result;
}
int
next_dlclose(void *handle)
{
return 0;
}
void *
next_dlsym(void *handle, char *symbol)
{
NXStream *errorStream = OpenError();
char symbuf[1024];
unsigned long symref = 0;
sprintf(symbuf, "_%s", symbol);
if (!rld_lookup(errorStream, symbuf, &symref))
TransferError(errorStream);
CloseError(errorStream);
return (void *) symref;
}
char *
next_dlerror(void)
{
return lastError;
}

View File

@@ -1,27 +0,0 @@
/*-------------------------------------------------------------------------
*
* port-protos.h--
* port-specific prototypes for NeXT
*
-------------------------------------------------------------------------
*/
#ifndef PORT_PROTOS_H
#define PORT_PROTOS_H
#include "fmgr.h" /* for func_ptr */
#include "utils/dynamic_loader.h"
void *next_dlopen(char *name);
int next_dlclose(void *handle);
void *next_dlsym(void *handle, char *symbol);
char *next_dlerror(void);
#define pg_dlopen(f) next_dlopen
#define pg_dlsym next_dlsym
#define pg_dlclose next_dlclose
#define pg_dlerror next_dlerror
/* port.c */
#endif /* PORT_PROTOS_H */