Skip to content

Commit

Permalink
FFI/ARM64/OSX: Fix vararg call handling.
Browse files Browse the repository at this point in the history
Thanks to Igor Munkin.

(cherry picked from commit 521b367)

This patch fixes the issue introduced by commit
2e2fb8f ('OSX/iOS: Handle iOS simulator
and ARM64 Macs.'). Within the mentioned commit LJ_TARGET_IOS define is
set via Apple system header to enable several features (e.g. JIT and
external unwinder) on ARM64 Macs, but its usage was not adjusted
source-wide. This is done for FFI machinery within this commit.

All LJ_TARGET_IOS uses in FFI sources are done with LJ_TARGET_ARM64
define being set, so we can simply replace these occurrences with
LJ_TARGET_OSX.

Igor Munkin:
* added the description and the test for the problem

Resolves tarantool/tarantool#6066
Part of tarantool/tarantool#5629
Relates to tarantool/tarantool#5983

Reported-by: Nikita Pettik <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Reviewed-by: Sergey Ostanevich <[email protected]>
Signed-off-by: Igor Munkin <[email protected]>
  • Loading branch information
Mike Pall authored and igormunkin committed Jun 16, 2022
1 parent f10b933 commit 7854c67
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/tarantool-tests/lj-695-ffi-vararg-call.test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local tap = require('tap')

local test = tap.test('lj-695-ffi-vararg-call')
test:plan(2)

local ffi = require('ffi')
local str = ffi.new('char[256]')
ffi.cdef('int sprintf(char *str, const char *format, ...)')
local strlen = ffi.C.sprintf(str, 'try vararg function: %s:%.2f(%d) - %llu',
'imun', 9, 9LL, -1ULL)

local result = ffi.string(str)
test:is(#result, strlen)
test:is(result, 'try vararg function: imun:9.00(9) - 18446744073709551615')

os.exit(test:check() and 0 or 1)

0 comments on commit 7854c67

Please sign in to comment.