Skip to content

Commit 73d9a90

Browse files
committed
Modernize dlopen interface code for FreeBSD and OpenBSD.
Remove the hard-wired assumption that __mips__ (and only __mips__) lacks dlopen in FreeBSD and OpenBSD. This assumption is outdated at least for OpenBSD, as per report from an anonymous 9.1 tester. We can perfectly well use HAVE_DLOPEN instead to decide which code to use. Some other cosmetic adjustments to make freebsd.c, netbsd.c, and openbsd.c exactly alike.
1 parent 1eb2231 commit 73d9a90

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/backend/port/dynloader/freebsd.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/* src/backend/port/dynloader/freebsd.c */
2-
31
/*
42
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
53
* Portions Copyright (c) 1990 The Regents of the University of California.
64
* All rights reserved.
75
*
6+
* src/backend/port/dynloader/freebsd.c
7+
*
88
* Redistribution and use in source and binary forms, with or without
99
* modification, are permitted provided that the following conditions
1010
* are met:
@@ -57,7 +57,7 @@ BSD44_derived_dlerror(void)
5757
void *
5858
BSD44_derived_dlopen(const char *file, int num)
5959
{
60-
#if defined(__mips__)
60+
#if !defined(HAVE_DLOPEN)
6161
snprintf(error_message, sizeof(error_message),
6262
"dlopen (%s) not supported", file);
6363
return NULL;
@@ -74,7 +74,7 @@ BSD44_derived_dlopen(const char *file, int num)
7474
void *
7575
BSD44_derived_dlsym(void *handle, const char *name)
7676
{
77-
#if defined(__mips__)
77+
#if !defined(HAVE_DLOPEN)
7878
snprintf(error_message, sizeof(error_message),
7979
"dlsym (%s) failed", name);
8080
return NULL;
@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
8989
snprintf(buf, sizeof(buf), "_%s", name);
9090
name = buf;
9191
}
92-
#endif
92+
#endif /* !__ELF__ */
9393
if ((vp = dlsym(handle, (char *) name)) == NULL)
9494
snprintf(error_message, sizeof(error_message),
9595
"dlsym (%s) failed", name);
@@ -100,8 +100,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
100100
void
101101
BSD44_derived_dlclose(void *handle)
102102
{
103-
#if defined(__mips__)
104-
#else
103+
#if defined(HAVE_DLOPEN)
105104
dlclose(handle);
106105
#endif
107106
}

src/backend/port/dynloader/netbsd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,18 @@ BSD44_derived_dlsym(void *handle, const char *name)
7878
snprintf(error_message, sizeof(error_message),
7979
"dlsym (%s) failed", name);
8080
return NULL;
81-
#elif defined(__ELF__)
82-
return dlsym(handle, name);
8381
#else
8482
void *vp;
83+
84+
#ifndef __ELF__
8585
char buf[BUFSIZ];
8686

8787
if (*name != '_')
8888
{
8989
snprintf(buf, sizeof(buf), "_%s", name);
9090
name = buf;
9191
}
92+
#endif /* !__ELF__ */
9293
if ((vp = dlsym(handle, (char *) name)) == NULL)
9394
snprintf(error_message, sizeof(error_message),
9495
"dlsym (%s) failed", name);

src/backend/port/dynloader/openbsd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ BSD44_derived_dlerror(void)
5757
void *
5858
BSD44_derived_dlopen(const char *file, int num)
5959
{
60-
#if defined(__mips__)
60+
#if !defined(HAVE_DLOPEN)
6161
snprintf(error_message, sizeof(error_message),
6262
"dlopen (%s) not supported", file);
6363
return NULL;
@@ -74,21 +74,22 @@ BSD44_derived_dlopen(const char *file, int num)
7474
void *
7575
BSD44_derived_dlsym(void *handle, const char *name)
7676
{
77-
#if defined(__mips__)
77+
#if !defined(HAVE_DLOPEN)
7878
snprintf(error_message, sizeof(error_message),
7979
"dlsym (%s) failed", name);
8080
return NULL;
81-
#elif defined(__ELF__)
82-
return dlsym(handle, name);
8381
#else
8482
void *vp;
83+
84+
#ifndef __ELF__
8585
char buf[BUFSIZ];
8686

8787
if (*name != '_')
8888
{
8989
snprintf(buf, sizeof(buf), "_%s", name);
9090
name = buf;
9191
}
92+
#endif /* !__ELF__ */
9293
if ((vp = dlsym(handle, (char *) name)) == NULL)
9394
snprintf(error_message, sizeof(error_message),
9495
"dlsym (%s) failed", name);
@@ -99,8 +100,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
99100
void
100101
BSD44_derived_dlclose(void *handle)
101102
{
102-
#if defined(__mips__)
103-
#else
103+
#if defined(HAVE_DLOPEN)
104104
dlclose(handle);
105105
#endif
106106
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy