diff options
| author | Lua Team <team@lua.org> | 2015-01-12 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 2015-01-12 12:00:00 +0000 |
| commit | 34c362812ab38172d3da36404ec9a85f929579c5 (patch) | |
| tree | a54637781398b630824152ae05672536c0fa8341 /src/loadlib.c | |
| parent | 6b0dd2d3885d020d3154e0da84de92e9ee8b2c82 (diff) | |
| download | lua-github-5.3.0.tar.gz | |
Diffstat (limited to 'src/loadlib.c')
| -rw-r--r-- | src/loadlib.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/loadlib.c b/src/loadlib.c index 1dab9bd0..7f8d9902 100644 --- a/src/loadlib.c +++ b/src/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.123 2014/11/12 13:31:51 roberto Exp $ +** $Id: loadlib.c,v 1.124 2015/01/05 13:51:39 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -135,6 +135,18 @@ static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym); #include <dlfcn.h> +/* +** Macro to covert pointer to void* to pointer to function. This cast +** is undefined according to ISO C, but POSIX assumes that it must work. +** (The '__extension__' in gnu compilers is only to avoid warnings.) +*/ +#if defined(__GNUC__) +#define cast_func(p) (__extension__ (lua_CFunction)(p)) +#else +#define cast_func(p) ((lua_CFunction)(p)) +#endif + + static void lsys_unloadlib (void *lib) { dlclose(lib); } @@ -148,7 +160,7 @@ static void *lsys_load (lua_State *L, const char *path, int seeglb) { static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + lua_CFunction f = cast_func(dlsym(lib, sym)); if (f == NULL) lua_pushstring(L, dlerror()); return f; } |
