Commit 700032ad authored by Peter Eisentraut's avatar Peter Eisentraut

Real dynamic loader code

parent 6b70f386
/* /*
* This is a place holder until someone supplies a dynamic loader * These routines were taken from the Apache source, but were made
* interface for this platform. * available with a PostgreSQL-compatible license. Kudos Wilfredo
* Snchez <wsanchez@apple.com>.
* *
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/darwin.c,v 1.1 2000/10/31 19:55:19 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/darwin.c,v 1.2 2000/11/09 19:00:50 petere Exp $
*/ */
#include "postgres.h" #include <mach-o/dyld.h>
#include "fmgr.h"
#include "utils/dynamic_loader.h"
#include "dynloader.h" #include "dynloader.h"
void * void *pg_dlopen(const char *filename)
pg_dlopen(char *filename)
{ {
return (void *) NULL; NSObjectFileImage image;
if (NSCreateObjectFileImageFromFile(filename, &image) !=
NSObjectFileImageSuccess)
return NULL;
return NSLinkModule(image, filename, TRUE);
} }
PGFunction void pg_dlclose(void *handle)
pg_dlsym(void *handle, char *funcname)
{ {
return NULL; NSUnLinkModule(handle,FALSE);
return;
} }
void PGFunction *pg_dlsym(void *handle, const char *funcname)
pg_dlclose(void *handle)
{ {
NSSymbol symbol;
char *symname = (char*)malloc(strlen(funcname)+2);
sprintf(symname, "_%s", funcname);
symbol = NSLookupAndBindSymbol(symname);
free(symname);
return (PGFunction *) NSAddressOfSymbol(symbol);
} }
char * const char *pg_dlerror(void)
pg_dlerror()
{ {
static char errmsg[] = "the dynamic loader for darwin doesn't exist yet"; return "no error message available";
return errmsg;
} }
/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/darwin.h,v 1.1 2000/10/31 19:55:19 petere Exp $ */ /* $Header: /cvsroot/pgsql/src/backend/port/dynloader/darwin.h,v 1.2 2000/11/09 19:00:50 petere Exp $ */
void *pg_dlopen(char *filename);
PGFunction pg_dlsym(void *handle, char *funcname); #include "fmgr.h"
void *pg_dlopen(const char *filename);
PGFunction pg_dlsym(void *handle, const char *funcname);
void pg_dlclose(void *handle); void pg_dlclose(void *handle);
char *pg_dlerror(); const char *pg_dlerror(void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment