Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3a2ef59

Browse files
committed
Fix Linux dynloader code for pre-HAVE_DLOPEN systems, which evidently
are still in use out there. Per report from Brendan LeFebvre.
1 parent 951ec87 commit 3a2ef59

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

src/backend/port/dynloader/linux.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* dynloader.c
3+
* linux.c
44
* Dynamic Loader for Postgres for Linux, generated from those for
55
* Ultrix.
66
*
@@ -11,18 +11,22 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.22 2002/06/20 20:29:33 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/port/dynloader/linux.c,v 1.23 2002/10/15 16:04:17 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
1818

1919
#include "postgres.h"
20+
2021
#ifdef HAVE_DLD_H
21-
#include "dld.h"
22+
#include <dld.h>
2223
#endif
2324

24-
#ifdef NOT_USED
25-
extern char pg_pathname[];
25+
#include "dynloader.h"
26+
#include "miscadmin.h"
27+
28+
29+
#ifndef HAVE_DLOPEN
2630

2731
void *
2832
pg_dlopen(char *filename)
@@ -98,8 +102,28 @@ pg_dlopen(char *filename)
98102
#endif
99103
}
100104

105+
PGFunction
106+
pg_dlsym(void *handle, char *funcname)
107+
{
108+
#ifndef HAVE_DLD_H
109+
return NULL;
110+
#else
111+
return (PGFunction) dld_get_func((funcname));
112+
#endif
113+
}
114+
115+
void
116+
pg_dlclose(void *handle)
117+
{
118+
#ifndef HAVE_DLD_H
119+
#else
120+
dld_unlink_by_file(handle, 1);
121+
free(handle);
122+
#endif
123+
}
124+
101125
char *
102-
pg_dlerror()
126+
pg_dlerror(void)
103127
{
104128
#ifndef HAVE_DLD_H
105129
return "dynaloader unspported";
@@ -108,4 +132,4 @@ pg_dlerror()
108132
#endif
109133
}
110134

111-
#endif
135+
#endif /* !HAVE_DLOPEN */

src/backend/port/dynloader/linux.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: linux.h,v 1.18 2002/06/20 20:29:33 momjian Exp $
10+
* $Id: linux.h,v 1.19 2002/10/15 16:04:17 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -20,21 +20,7 @@
2020
#endif
2121

2222

23-
#ifndef HAVE_DLOPEN
24-
25-
#ifndef HAVE_DLD_H
26-
#define pg_dlsym(handle, funcname) (NULL)
27-
#define pg_dlclose(handle) {}
28-
#else
29-
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
30-
#define pg_dlclose(handle) \
31-
do { \
32-
dld_unlink_by_file(handle, 1); \
33-
free(handle); \
34-
} while (0)
35-
#endif
36-
37-
#else /* HAVE_DLOPEN */
23+
#ifdef HAVE_DLOPEN
3824

3925
/*
4026
* In some older systems, the RTLD_NOW flag isn't defined and the mode
@@ -53,6 +39,7 @@ do { \
5339
#define pg_dlsym dlsym
5440
#define pg_dlclose dlclose
5541
#define pg_dlerror dlerror
42+
5643
#endif /* HAVE_DLOPEN */
5744

5845
#endif /* PORT_PROTOS_H */

0 commit comments

Comments
 (0)