diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-07 17:11:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-07 17:11:53 -0300 |
commit | de57dc2653ff9efcdfd1ddc5f21aaaa159e5f79a (patch) | |
tree | 292ba203a083ee051d584cdf772beb29079a621a | |
parent | d1df829f8dc62966f46525aca24227a3e05db1df (diff) | |
download | lua-de57dc2653ff9efcdfd1ddc5f21aaaa159e5f79a.tar.gz lua-de57dc2653ff9efcdfd1ddc5f21aaaa159e5f79a.tar.bz2 lua-de57dc2653ff9efcdfd1ddc5f21aaaa159e5f79a.zip |
new scheme to control `loadlib' configuration (default for dlopen
implementation is not to include it)
-rw-r--r-- | loadlib.c | 76 | ||||
-rw-r--r-- | makefile | 4 |
2 files changed, 59 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.2 2003/03/18 12:25:01 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.3 2003/04/02 13:09:14 roberto Exp roberto $ |
3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | * | 5 | * |
@@ -30,17 +30,11 @@ | |||
30 | #include "lauxlib.h" | 30 | #include "lauxlib.h" |
31 | #include "lualib.h" | 31 | #include "lualib.h" |
32 | 32 | ||
33 | #ifndef USE_LOADLIB | ||
34 | #define USE_LOADLIB 1 | ||
35 | #endif | ||
36 | 33 | ||
37 | #ifndef USE_DLOPEN | 34 | #undef LOADLIB |
38 | #define USE_DLOPEN 0 | ||
39 | #endif | ||
40 | 35 | ||
41 | #if USE_LOADLIB | ||
42 | 36 | ||
43 | #if defined(linux) || defined(sun) || defined(sgi) || defined(BSD) || USE_DLOPEN | 37 | #ifdef USE_DLOPEN |
44 | #define LOADLIB | 38 | #define LOADLIB |
45 | /* | 39 | /* |
46 | * This is an implementation of loadlib based on the dlfcn interface. | 40 | * This is an implementation of loadlib based on the dlfcn interface. |
@@ -66,6 +60,7 @@ static int loadlib(lua_State *L) | |||
66 | return 1; | 60 | return 1; |
67 | } | 61 | } |
68 | } | 62 | } |
63 | /* else return appropriate error messages */ | ||
69 | lua_pushnil(L); | 64 | lua_pushnil(L); |
70 | lua_pushstring(L,dlerror()); | 65 | lua_pushstring(L,dlerror()); |
71 | lua_pushstring(L,(lib!=NULL) ? "init" : "open"); | 66 | lua_pushstring(L,(lib!=NULL) ? "init" : "open"); |
@@ -73,7 +68,23 @@ static int loadlib(lua_State *L) | |||
73 | return 3; | 68 | return 3; |
74 | } | 69 | } |
75 | 70 | ||
76 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) | 71 | #endif |
72 | |||
73 | |||
74 | |||
75 | /* | ||
76 | ** In Windows, default is to use dll; otherwise, default is not to use dll | ||
77 | */ | ||
78 | #ifndef USE_DLL | ||
79 | #ifdef _WIN32 | ||
80 | #define USE_DLL 1 | ||
81 | #else | ||
82 | #define USE_DLL 0 | ||
83 | #endif | ||
84 | #endif | ||
85 | |||
86 | |||
87 | #if USE_DLL | ||
77 | #define LOADLIB | 88 | #define LOADLIB |
78 | /* | 89 | /* |
79 | * This is an implementation of loadlib for Windows using native functions. | 90 | * This is an implementation of loadlib for Windows using native functions. |
@@ -114,21 +125,48 @@ static int loadlib(lua_State *L) | |||
114 | return 3; | 125 | return 3; |
115 | } | 126 | } |
116 | 127 | ||
117 | #else | 128 | #endif |
129 | |||
130 | |||
131 | |||
132 | #ifndef LOADLIB | ||
133 | /* Fallback for other systems */ | ||
134 | |||
118 | /* | 135 | /* |
119 | * write an implementation for your system here and send it to us, together | 136 | ** Those systems support dlopen, so they should have defined USE_DLOPEN. |
120 | * with preprocessing symbols that identify your system. | 137 | ** The default (no)implementation gives them a special error message. |
121 | */ | 138 | */ |
139 | #ifdef linux | ||
140 | #define LOADLIB | ||
122 | #endif | 141 | #endif |
142 | |||
143 | #ifdef sun | ||
144 | #define LOADLIB | ||
123 | #endif | 145 | #endif |
124 | 146 | ||
125 | #ifndef LOADLIB | 147 | #ifdef sgi |
126 | /* Fallback for other systems */ | 148 | #define LOADLIB |
149 | #endif | ||
150 | |||
151 | #ifdef BSD | ||
152 | #define LOADLIB | ||
153 | #endif | ||
154 | |||
155 | #ifdef _WIN32 | ||
156 | #define LOADLIB | ||
157 | #endif | ||
158 | |||
159 | #ifdef LOADLIB | ||
160 | #undef LOADLIB | ||
161 | #define LOADLIB "`loadlib' not installed (check your Lua configuration)" | ||
162 | #else | ||
163 | #define LOADLIB "`loadlib' not supported" | ||
164 | #endif | ||
127 | 165 | ||
128 | static int loadlib(lua_State *L) | 166 | static int loadlib(lua_State *L) |
129 | { | 167 | { |
130 | lua_pushnil(L); | 168 | lua_pushnil(L); |
131 | lua_pushliteral(L,"`loadlib' not supported"); | 169 | lua_pushliteral(L,LOADLIB); |
132 | lua_pushliteral(L,"absent"); | 170 | lua_pushliteral(L,"absent"); |
133 | return 3; | 171 | return 3; |
134 | } | 172 | } |
@@ -141,9 +179,9 @@ LUALIB_API int luaopen_loadlib (lua_State *L) | |||
141 | } | 179 | } |
142 | 180 | ||
143 | /* | 181 | /* |
144 | * Here are some links por to available implementations of dlfcn and | 182 | * Here are some links to available implementations of dlfcn and |
145 | * interfaces to other native dynamic loaders on top of which loadlib could | 183 | * interfaces to other native dynamic loaders on top of which loadlib |
146 | * be implemented. Please send contributions and corrections to us. | 184 | * could be implemented. Please send contributions and corrections to us. |
147 | * | 185 | * |
148 | * AIX | 186 | * AIX |
149 | * Starting with AIX 4.2, dlfcn is included in the base OS. | 187 | * Starting with AIX 4.2, dlfcn is included in the base OS. |
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | ## $Id: makefile,v 1.39 2002/12/06 17:20:45 roberto Exp roberto $ | 2 | ## $Id: makefile,v 1.40 2003/03/19 21:27:30 roberto Exp roberto $ |
3 | ## Makefile | 3 | ## Makefile |
4 | ## See Copyright Notice in lua.h | 4 | ## See Copyright Notice in lua.h |
5 | # | 5 | # |
@@ -14,7 +14,7 @@ OPTIMIZE = -O2 \ | |||
14 | # -fomit-frame-pointer | 14 | # -fomit-frame-pointer |
15 | 15 | ||
16 | 16 | ||
17 | CONFIG = $(DEBUG) $(OPTIMIZE) -DLUA_COMPATUPSYNTAX -DUSE_TMPNAME | 17 | CONFIG = $(DEBUG) $(OPTIMIZE) -DLUA_COMPATUPSYNTAX -DUSE_TMPNAME -DUSE_DLOPEN |
18 | 18 | ||
19 | 19 | ||
20 | # Compilation parameters | 20 | # Compilation parameters |