00001 /*------------------------------------------------------------------------- 00002 * 00003 * freebsd.h 00004 * port-specific prototypes for FreeBSD 00005 * 00006 * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group 00007 * Portions Copyright (c) 1994, Regents of the University of California 00008 * 00009 * src/backend/port/dynloader/freebsd.h 00010 * 00011 *------------------------------------------------------------------------- 00012 */ 00013 #ifndef PORT_PROTOS_H 00014 #define PORT_PROTOS_H 00015 00016 #include <sys/types.h> 00017 #include <nlist.h> 00018 #include <link.h> 00019 #include <dlfcn.h> 00020 00021 #include "utils/dynamic_loader.h" /* pgrminclude ignore */ 00022 00023 /* 00024 * Dynamic Loader on NetBSD 1.0. 00025 * 00026 * this dynamic loader uses the system dynamic loading interface for shared 00027 * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared 00028 * library as the file to be dynamically loaded. 00029 * 00030 * agc - I know this is all a bit crufty, but it does work, is fairly 00031 * portable, and works (the stipulation that the d.l. function must 00032 * begin with an underscore is fairly tricky, and some versions of 00033 * NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.) 00034 */ 00035 00036 /* 00037 * In some older systems, the RTLD_NOW flag isn't defined and the mode 00038 * argument to dlopen must always be 1. The RTLD_GLOBAL flag is wanted 00039 * if available, but it doesn't exist everywhere. 00040 * If it doesn't exist, set it to 0 so it has no effect. 00041 */ 00042 #ifndef RTLD_NOW 00043 #define RTLD_NOW 1 00044 #endif 00045 #ifndef RTLD_GLOBAL 00046 #define RTLD_GLOBAL 0 00047 #endif 00048 00049 #define pg_dlopen(f) BSD44_derived_dlopen((f), RTLD_NOW | RTLD_GLOBAL) 00050 #define pg_dlsym BSD44_derived_dlsym 00051 #define pg_dlclose BSD44_derived_dlclose 00052 #define pg_dlerror BSD44_derived_dlerror 00053 00054 char *BSD44_derived_dlerror(void); 00055 void *BSD44_derived_dlopen(const char *filename, int num); 00056 void *BSD44_derived_dlsym(void *handle, const char *name); 00057 void BSD44_derived_dlclose(void *handle); 00058 00059 #endif /* PORT_PROTOS_H */