PostgreSQL Source Code  git master
openbsd.h File Reference
#include <nlist.h>
#include <link.h>
#include <dlfcn.h>
#include "utils/dynamic_loader.h"
Include dependency graph for openbsd.h:

Go to the source code of this file.

Macros

#define RTLD_NOW   1
 
#define RTLD_GLOBAL   0
 
#define pg_dlopen(f)   BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)
 
#define pg_dlsym   BSD44_derived_dlsym
 
#define pg_dlclose   BSD44_derived_dlclose
 
#define pg_dlerror   BSD44_derived_dlerror
 

Functions

char * BSD44_derived_dlerror (void)
 
void * BSD44_derived_dlopen (const char *filename, int num)
 
void * BSD44_derived_dlsym (void *handle, const char *name)
 
void BSD44_derived_dlclose (void *handle)
 

Macro Definition Documentation

◆ pg_dlclose

#define pg_dlclose   BSD44_derived_dlclose

Definition at line 50 of file openbsd.h.

◆ pg_dlerror

#define pg_dlerror   BSD44_derived_dlerror

Definition at line 51 of file openbsd.h.

◆ pg_dlopen

#define pg_dlopen (   f)    BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL)

Definition at line 48 of file openbsd.h.

◆ pg_dlsym

#define pg_dlsym   BSD44_derived_dlsym

Definition at line 49 of file openbsd.h.

◆ RTLD_GLOBAL

#define RTLD_GLOBAL   0

Definition at line 45 of file openbsd.h.

◆ RTLD_NOW

#define RTLD_NOW   1

Definition at line 42 of file openbsd.h.

Function Documentation

◆ BSD44_derived_dlclose()

void BSD44_derived_dlclose ( void *  handle)

Definition at line 101 of file freebsd.c.

References dlclose().

102 {
103 #if defined(HAVE_DLOPEN)
104  dlclose(handle);
105 #endif
106 }
int dlclose(void *handle)
Definition: win32.c:41

◆ BSD44_derived_dlerror()

char* BSD44_derived_dlerror ( void  )

Definition at line 48 of file freebsd.c.

References error_message.

49 {
50  static char ret[BUFSIZ];
51 
52  strcpy(ret, error_message);
53  error_message[0] = 0;
54  return (ret[0] == 0) ? NULL : ret;
55 }
static char error_message[BUFSIZ]
Definition: freebsd.c:45

◆ BSD44_derived_dlopen()

void* BSD44_derived_dlopen ( const char *  filename,
int  num 
)

Definition at line 58 of file freebsd.c.

References dlerror(), dlopen(), error_message, and snprintf().

59 {
60 #if !defined(HAVE_DLOPEN)
62  "dlopen (%s) not supported", file);
63  return NULL;
64 #else
65  void *vp;
66 
67  if ((vp = dlopen((char *) file, num)) == NULL)
69  "dlopen (%s) failed: %s", file, dlerror());
70  return vp;
71 #endif
72 }
char * dlerror(void)
Definition: win32.c:32
static char error_message[BUFSIZ]
Definition: freebsd.c:45
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
void * dlopen(const char *path, int mode)
Definition: win32.c:68

◆ BSD44_derived_dlsym()

void* BSD44_derived_dlsym ( void *  handle,
const char *  name 
)

Definition at line 75 of file freebsd.c.

References buf, dlsym(), error_message, and snprintf().

76 {
77 #if !defined(HAVE_DLOPEN)
79  "dlsym (%s) failed", name);
80  return NULL;
81 #else
82  void *vp;
83 
84 #ifndef __ELF__
85  char buf[BUFSIZ];
86 
87  if (*name != '_')
88  {
89  snprintf(buf, sizeof(buf), "_%s", name);
90  name = buf;
91  }
92 #endif /* !__ELF__ */
93  if ((vp = dlsym(handle, (char *) name)) == NULL)
95  "dlsym (%s) failed", name);
96  return vp;
97 #endif
98 }
static char error_message[BUFSIZ]
Definition: freebsd.c:45
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
void * dlsym(void *handle, const char *symbol)
Definition: win32.c:53
static char * buf
Definition: pg_test_fsync.c:67
const char * name
Definition: encode.c:521