1 /* @(#)dlfcn.h	1.5 18/03/21 Copyright 2015-2018 J. Schilling */
2 /*
3  *	Abstraction from dlfcn.h
4  *
5  *	Copyright (c) 2015-2018 J. Schilling
6  */
7 /*
8  * The contents of this file are subject to the terms of the
9  * Common Development and Distribution License, Version 1.0 only
10  * (the "License").  You may not use this file except in compliance
11  * with the License.
12  *
13  * See the file CDDL.Schily.txt in this distribution for details.
14  * A copy of the CDDL is also available via the Internet at
15  * http://www.opensource.org/licenses/cddl1.txt
16  *
17  * When distributing Covered Code, include this CDDL HEADER in each
18  * file and include the License file CDDL.Schily.txt from this distribution.
19  */
20 
21 #ifndef _SCHILY_DLFCN_H
22 #define	_SCHILY_DLFCN_H
23 
24 #ifndef	_SCHILY_MCONFIG_H
25 #include <schily/mconfig.h>
26 #endif
27 
28 #ifdef	HAVE_DLFCN_H
29 #ifndef _INCL_DLFCN_H
30 #include <dlfcn.h>			/* POSIX */
31 #define	_INCL_DLFCN_H
32 #define	FOUND_DLFCN_H
33 #endif
34 #endif
35 
36 #ifdef	HAVE_DL_H
37 #ifndef	FOUND_DLFCN_H
38 #ifndef _INCL_DL_H
39 #include <dl.h>				/* HP-UX */
40 #define	_INCL_DL_H
41 #define	FOUND_DLFCN_H
42 #endif
43 #endif
44 #endif
45 
46 #if defined(HAVE_DLOPEN) && defined(HAVE_DLCLOSE)		/* POSIX */
47 #define	HAVE_LOADABLE_LIBS
48 #endif
49 
50 #if !defined(HAVE_LOADABLE_LIBS) && defined(HAVE_SHL_LOAD)	/* HP-UX */
51 #define	HAVE_LOADABLE_LIBS
52 #endif
53 
54 #if !defined(HAVE_LOADABLE_LIBS) && defined(HAVE_LOADLIBRARY)	/* Win-DOS */
55 #define	HAVE_LOADABLE_LIBS
56 #endif
57 
58 /*
59  * dlopen() modes
60  */
61 #ifndef	RTLD_LAZY			/* The only mode in SunOS-4.0 */
62 #define	RTLD_LAZY	0x00001
63 #define	RTLD_NOW	0x00002
64 #define	RTLD_GLOBAL	0x00100
65 #define	RTLD_LOCAL	0x00000
66 #endif
67 
68 #ifdef	__never_
69 /*
70  * dlsym() speudo handles
71  * These handles are not valid on SunOS-4.0
72  */
73 #ifndef	RTLD_NEXT
74 #define	RTLD_NEXT		(void *)-1
75 #define	RTLD_DEFAULT		(void *)-2
76 #define	RTLD_SELF		(void *)-3
77 #endif
78 #endif
79 
80 /*
81  * dlsym() speudo handle for SunOS-4.0
82  */
83 #if	defined(HAVE_DLSYM) && !defined(RTLD_SELF)
84 #define	RTLD_SELF		(void *)0
85 #endif
86 
87 #ifdef	__cplusplus
88 extern "C" {
89 #endif
90 
91 #ifndef	HAVE_DLOPEN
92 extern	void	*dlopen	__PR((const char *__pathname, int mode));
93 #endif
94 #ifndef	HAVE_DLCLOSE
95 extern	int	dlclose	__PR((void *__handle));
96 #endif
97 #ifndef	HAVE_DLSYM
98 extern	void	*dlsym	__PR((void  *__handle, const char *name));
99 #endif
100 #ifndef	HAVE_DLERROR
101 extern	char	*dlerror __PR((void));
102 #endif
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 
109 
110 #endif	/* _SCHILY_DLFCN_H */
111