4 * Public interface declarations for (approximately) POSIX conforming
5 * dlopen(), dlsym(), dlclose(), and dlerror() API functions.
9 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
10 * Copyright (C) 2014, MinGW.org Project
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
20 * The above copyright notice, this permission notice, and the following
21 * disclaimer shall be included in all copies or substantial portions of
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
30 * DEALINGS IN THE SOFTWARE.
35 #pragma GCC system_header
39 /* POSIX requires the following four definitions. Our implementation
40 * (currently) does not support the behaviour associated with RTLD_LAZY;
41 * if specified, it is simply ignored; RTLD_NOW behaviour will prevail.
48 /* POSIX does not yet require the following pair, but reserves them for
49 * future capabilities; they will be used in contexts where a DLL module
50 * handle is expected, so we reserve values of suitable type, which are
51 * unlikely to ever occur as real module handles in practice.
53 #define RTLD_DEFAULT (void *)(-1)
54 #define RTLD_NEXT (void *)(-3)
56 /* The four dlfcn API functions, dlopen(), dlsym(), dlerror(), and dlclose(),
57 * are each defined privately, and made publicly accessible via corresponding
58 * function pointers, within the following publicly visible structure.
60 _EXTERN_C struct __dlfcn__
61 { void *(*dlopen)( const char *, int );
62 void *(*dlsym)( void *__restrict__, const char *__restrict__ );
63 char *(*dlerror)( void );
64 int (*dlclose)( void * );
67 /* Declare the public API for each of these functions...
71 /* In any event, we always declare prototypes for all four functions.
73 void * dlopen( const char *, int );
74 void * dlsym( void *__restrict__, const char *__restrict__ );
75 int dlclose( void * );
76 char * dlerror( void );
78 __CRT_ALIAS __LIBIMPL__(( FUNCTION = dlopen ))
79 void *dlopen( const char *__name, int __mode )
80 { return __mingw_dlfcn.dlopen( __name, __mode ); }
82 __CRT_ALIAS __LIBIMPL__(( FUNCTION = dlsym ))
83 void *dlsym( void *__restrict__ __module, const char *__restrict__ __name )
84 { return __mingw_dlfcn.dlsym( __module, __name ); }
86 __CRT_ALIAS __LIBIMPL__(( FUNCTION = dlclose ))
87 int dlclose( void *__module ){ return __mingw_dlfcn.dlclose( __module ); }
89 __CRT_ALIAS __LIBIMPL__(( FUNCTION = dlerror ))
90 char *dlerror( void ){ return __mingw_dlfcn.dlerror(); }
94 #endif /* _DLFCN_H: $RCSfile$: end of file */