From 3a2ef591168395149df9f2ad160d242ffe825e41 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 15 Oct 2002 16:04:17 +0000 Subject: [PATCH] Fix Linux dynloader code for pre-HAVE_DLOPEN systems, which evidently are still in use out there. Per report from Brendan LeFebvre. --- src/backend/port/dynloader/linux.c | 38 ++++++++++++++++++++++++------ src/backend/port/dynloader/linux.h | 19 +++------------ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/backend/port/dynloader/linux.c b/src/backend/port/dynloader/linux.c index 874de90d3a..2ee15661cd 100644 --- a/src/backend/port/dynloader/linux.c +++ b/src/backend/port/dynloader/linux.c @@ -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 #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 */ diff --git a/src/backend/port/dynloader/linux.h b/src/backend/port/dynloader/linux.h index 79cc068201..0adbdf8edf 100644 --- a/src/backend/port/dynloader/linux.h +++ b/src/backend/port/dynloader/linux.h @@ -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 */