summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/modules/bytes/test.lua4
-rw-r--r--xmake/core/base/bytes.lua12
2 files changed, 11 insertions, 5 deletions
diff --git a/tests/modules/bytes/test.lua b/tests/modules/bytes/test.lua
index 4cb272c94..aa29e3493 100644
--- a/tests/modules/bytes/test.lua
+++ b/tests/modules/bytes/test.lua
@@ -1,5 +1,9 @@
import("core.base.bytes")
+if not xmake.luajit() then
+ return
+end
+
function test_ctor(t)
t:are_equal(bytes("123456789"):str(), "123456789")
t:are_equal(bytes(bytes("123456789")):str(), "123456789")
diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua
index 6cebbdf2b..359a67f36 100644
--- a/xmake/core/base/bytes.lua
+++ b/xmake/core/base/bytes.lua
@@ -24,16 +24,18 @@ local _instance = _instance or {}
-- load modules
local bit = require("base/bit")
-local ffi = require("ffi")
+local ffi = xmake._LUAJIT and require("ffi") or nil
local os = require("base/os")
local utils = require("base/utils")
local todisplay = require("base/todisplay")
-- define ffi interfaces
-ffi.cdef[[
- void* malloc(size_t size);
- void free(void* data);
-]]
+if ffi then
+ ffi.cdef[[
+ void* malloc(size_t size);
+ void free(void* data);
+ ]]
+end
-- new a bytes instance
--