Fix Linux dynloader code for pre-HAVE_DLOPEN systems, which evidently

are still in use out there.  Per report from Brendan LeFebvre.
This commit is contained in:
Tom Lane 2002-10-15 16:04:17 +00:00
parent 951ec872c7
commit 3a2ef59116
2 changed files with 34 additions and 23 deletions

View File

@ -1,6 +1,6 @@
/*-------------------------------------------------------------------------
*
* dynloader.c
* linux.c
* Dynamic Loader for Postgres for Linux, generated from those for
* Ultrix.
*
@ -11,18 +11,22 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.22 2002/06/20 20:29:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.23 2002/10/15 16:04:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#ifdef HAVE_DLD_H
#include "dld.h"
#include <dld.h>
#endif
#ifdef NOT_USED
extern char pg_pathname[];
#include "dynloader.h"
#include "miscadmin.h"
#ifndef HAVE_DLOPEN
void *
pg_dlopen(char *filename)
@ -98,8 +102,28 @@ pg_dlopen(char *filename)
#endif
}
PGFunction
pg_dlsym(void *handle, char *funcname)
{
#ifndef HAVE_DLD_H
return NULL;
#else
return (PGFunction) dld_get_func((funcname));
#endif
}
void
pg_dlclose(void *handle)
{
#ifndef HAVE_DLD_H
#else
dld_unlink_by_file(handle, 1);
free(handle);
#endif
}
char *
pg_dlerror()
pg_dlerror(void)
{
#ifndef HAVE_DLD_H
return "dynaloader unspported";
@ -108,4 +132,4 @@ pg_dlerror()
#endif
}
#endif
#endif /* !HAVE_DLOPEN */

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: linux.h,v 1.18 2002/06/20 20:29:33 momjian Exp $
* $Id: linux.h,v 1.19 2002/10/15 16:04:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -20,21 +20,7 @@
#endif
#ifndef HAVE_DLOPEN
#ifndef HAVE_DLD_H
#define pg_dlsym(handle, funcname) (NULL)
#define pg_dlclose(handle) {}
#else
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlclose(handle) \
do { \
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
#endif
#else /* HAVE_DLOPEN */
#ifdef HAVE_DLOPEN
/*
* In some older systems, the RTLD_NOW flag isn't defined and the mode
@ -53,6 +39,7 @@ do { \
#define pg_dlsym dlsym
#define pg_dlclose dlclose
#define pg_dlerror dlerror
#endif /* HAVE_DLOPEN */
#endif /* PORT_PROTOS_H */