mirror of https://github.com/postgres/postgres
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.7 KiB
76 lines
1.7 KiB
|
30 years ago
|
/*-------------------------------------------------------------------------
|
||
|
|
*
|
||
|
|
* dynloader.c--
|
||
|
29 years ago
|
* This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x.
|
||
|
|
* (Note that pg_dlsym and pg_dlclose are actually macros defined in
|
||
|
|
* "port-protos.h".)
|
||
|
|
*
|
||
|
30 years ago
|
* Copyright (c) 1994, Regents of the University of California
|
||
|
|
*
|
||
|
|
*
|
||
|
|
* IDENTIFICATION
|
||
|
28 years ago
|
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/ultrix4.c,v 1.1 1998/03/10 05:23:40 scrappy Exp $
|
||
|
30 years ago
|
*
|
||
|
|
*-------------------------------------------------------------------------
|
||
|
|
*/
|
||
|
|
#include <stdio.h>
|
||
|
30 years ago
|
#include <postgres.h>
|
||
|
30 years ago
|
#include "dl.h"
|
||
|
29 years ago
|
#include <utils/dynamic_loader.h>
|
||
|
30 years ago
|
#include "c.h"
|
||
|
|
#include "fmgr.h"
|
||
|
|
#include "port-protos.h"
|
||
|
|
#include "utils/elog.h"
|
||
|
|
|
||
|
29 years ago
|
extern char pg_pathname[];
|
||
|
30 years ago
|
|
||
|
28 years ago
|
void *
|
||
|
30 years ago
|
pg_dlopen(char *filename)
|
||
|
|
{
|
||
|
29 years ago
|
static int dl_initialized = 0;
|
||
|
|
void *handle;
|
||
|
30 years ago
|
|
||
|
|
/*
|
||
|
29 years ago
|
* initializes the dynamic loader with the executable's pathname.
|
||
|
|
* (only needs to do this the first time pg_dlopen is called.)
|
||
|
30 years ago
|
*/
|
||
|
29 years ago
|
if (!dl_initialized)
|
||
|
|
{
|
||
|
|
if (!dl_init(pg_pathname))
|
||
|
|
{
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
30 years ago
|
|
||
|
29 years ago
|
/*
|
||
|
|
* if there are undefined symbols, we want dl to search from the
|
||
|
|
* following libraries also.
|
||
|
|
*/
|
||
|
|
dl_setLibraries("/usr/lib/libm_G0.a:/usr/lib/libc_G0.a");
|
||
|
|
dl_initialized = 1;
|
||
|
|
}
|
||
|
30 years ago
|
|
||
|
29 years ago
|
/*
|
||
|
|
* open the file. We do the symbol resolution right away so that we
|
||
|
|
* will know if there are undefined symbols. (This is in fact the same
|
||
|
|
* semantics as "ld -A". ie. you cannot have undefined symbols.
|
||
|
|
*/
|
||
|
|
if ((handle = dl_open(filename, DL_NOW)) == NULL)
|
||
|
|
{
|
||
|
29 years ago
|
int count;
|
||
|
|
char **list = dl_undefinedSymbols(&count);
|
||
|
29 years ago
|
|
||
|
|
/* list the undefined symbols, if any */
|
||
|
|
if (count)
|
||
|
|
{
|
||
|
|
elog(NOTICE, "dl: Undefined:");
|
||
|
|
while (*list)
|
||
|
|
{
|
||
|
|
elog(NOTICE, " %s", *list);
|
||
|
|
list++;
|
||
|
|
}
|
||
|
|
}
|
||
|
30 years ago
|
}
|
||
|
|
|
||
|
29 years ago
|
return (void *) handle;
|
||
|
30 years ago
|
}
|