aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--llimits.h21
-rw-r--r--loslib.c11
-rw-r--r--luaconf.h6
3 files changed, 33 insertions, 5 deletions
diff --git a/llimits.h b/llimits.h
index 246dca8b..03cc51cb 100644
--- a/llimits.h
+++ b/llimits.h
@@ -70,11 +70,24 @@ typedef signed char ls_byte;
70 70
71 71
72/* 72/*
73** conversion of pointer to unsigned integer: 73** conversion of pointer to unsigned integer: this is for hashing only;
74** this is for hashing only; there is no problem if the integer 74** there is no problem if the integer cannot hold the whole pointer
75** cannot hold the whole pointer value 75** value. (In strict ISO C this may cause undefined behavior, but no
76** actual machine seems to bother.)
76*/ 77*/
77#define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX)) 78#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
79 __STDC_VERSION__ >= 199901L
80#include <stdint.h>
81#if defined(UINTPTR_MAX) /* even in C99 this type is optional */
82#define L_P2I uintptr_t
83#else /* no 'intptr'? */
84#define L_P2I uintmax_t /* use the largerst available integer */
85#endif
86#else /* C89 option */
87#define L_P2I size_t
88#endif
89
90#define point2uint(p) ((unsigned int)((L_P2I)(p) & UINT_MAX))
78 91
79 92
80 93
diff --git a/loslib.c b/loslib.c
index 854dcf69..89ac06bc 100644
--- a/loslib.c
+++ b/loslib.c
@@ -138,12 +138,21 @@
138/* }================================================================== */ 138/* }================================================================== */
139 139
140 140
141#if !defined(l_system)
142#if defined(LUA_USE_IOS)
143/* Despite claiming to be ISO C, iOS does not implement 'system'. */
144#define l_system(cmd) ((cmd) == NULL ? 0 : -1)
145#else
146#define l_system(cmd) system(cmd) /* default definition */
147#endif
148#endif
149
141 150
142static int os_execute (lua_State *L) { 151static int os_execute (lua_State *L) {
143 const char *cmd = luaL_optstring(L, 1, NULL); 152 const char *cmd = luaL_optstring(L, 1, NULL);
144 int stat; 153 int stat;
145 errno = 0; 154 errno = 0;
146 stat = system(cmd); 155 stat = l_system(cmd);
147 if (cmd != NULL) 156 if (cmd != NULL)
148 return luaL_execresult(L, stat); 157 return luaL_execresult(L, stat);
149 else { 158 else {
diff --git a/luaconf.h b/luaconf.h
index e4650fbc..137103ed 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -70,6 +70,12 @@
70#endif 70#endif
71 71
72 72
73#if defined(LUA_USE_IOS)
74#define LUA_USE_POSIX
75#define LUA_USE_DLOPEN
76#endif
77
78
73/* 79/*
74@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. 80@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
75*/ 81*/