mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
Real dynamic loader code
This commit is contained in:
parent
6b70f3862c
commit
700032ad6f
@ -1,36 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
|
* Sánchez <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;
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
/* $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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user