Skip to content

Commit e30319c

Browse files
committed
ffi/posix_h: updated and corrected version
Use the new 2.0.0 version of ffi-cdecl to generate POSIX cdecls for each platform variant, and our updated helper to merge those individual files. This fix a number of issues, particularly with macOS (including a number of important constants: `EAGAIN`, `O_CLOEXEC`, `MAP_ANONYMOUS`, etc…). Some unused declarations have been removed, some new declarations have been added: - those used by the terminal plugin - those necessary for turbo, so its code can be patched to rely on `ffi/posix_h` NOTE: - `ffi/pthread_h` has been removed: pthread declarations are now included in `ffi/posix_h` - the frontend generic device code for retrieving network information will need updating: Linux only IOCTL values are not available to macOS anymore - Linux x86 support has been dropped (Android x86 support is still provided) - *BSD support has been dropped too
1 parent e266128 commit e30319c

21 files changed

Lines changed: 6202 additions & 1095 deletions

cmake/CMakeLists.txt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ ffi_target(linux einkfb_h.lua einkfb_decl.c ${EXCLUDE_FROM_ALL})
747747
ffi_target(linux inotify_h.lua inotify_decl.c ${EXCLUDE_FROM_ALL})
748748
ffi_target(linux linux_fb_h.lua linux_fb_decl.c ${EXCLUDE_FROM_ALL})
749749
ffi_target(linux linux_input_h.lua linux_input_decl.c ${EXCLUDE_FROM_ALL} ARGS -r ffi/posix_h)
750-
ffi_target(linux rtc_h.lua rtc_cdecl.c ${EXCLUDE_FROM_ALL})
750+
ffi_target(linux rtc_h.lua rtc_cdecl.c ${EXCLUDE_FROM_ALL} ARGS -r ffi/posix_h)
751751

752752
# lodepng
753753
ffi_target(lodepng lodepng_h.lua lodepng_decl.c)
@@ -763,6 +763,40 @@ else()
763763
endif()
764764
ffi_target(pocketbook mxcfb_pocketbook_h.lua mxcfb_pb_decl.c ${EXCLUDE_FROM_ALL})
765765

766+
# posix
767+
set(VERSIONS
768+
android_arm android_arm64 android_x86 android_x64
769+
linux_arm linux_arm64 linux_x64
770+
macos
771+
)
772+
add_custom_target(
773+
posix-ffi
774+
COMMAND ./utils/gen_merged_cdecl_h.py ffi/posix_h.lua ffi-cdecl/posix_h_.lua platform ffi-cdecl ${VERSIONS}
775+
COMMENT "Generating 'ffi/posix_h.lua'"
776+
VERBATIM
777+
WORKING_DIRECTORY ${BASE_DIR}
778+
)
779+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
780+
set(LUAJIT_ARCH "arm64")
781+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")
782+
set(LUAJIT_ARCH "arm")
783+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
784+
set(LUAJIT_ARCH "x86")
785+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
786+
set(LUAJIT_ARCH "x64")
787+
else()
788+
message(FATAL_ERROR "unsupported CMAKE_SYSTEM_PROCESSOR value: ${CMAKE_SYSTEM_PROCESSOR}")
789+
endif()
790+
if(ANDROID)
791+
set(POSIX_PLATFORM android_${LUAJIT_ARCH})
792+
elseif(APPLE)
793+
set(POSIX_PLATFORM macos)
794+
else()
795+
set(POSIX_PLATFORM linux_${LUAJIT_ARCH})
796+
endif()
797+
set(POSIX_PLATFORM ffi-cdecl/posix_h_${POSIX_PLATFORM}.lua)
798+
ffi_target(posix ${POSIX_PLATFORM} posix_cdecl.c ARGS -M -W EXCLUDE_FROM_ALL)
799+
766800
# remarkable
767801
if(REMARKABLE)
768802
set(EXCLUDE_FROM_ALL)

ffi-cdecl/appimage/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ libs/libtree-sitter.so.*[0-9]
2323
libs/libtree-sitter-c.so.*[0-9]
2424
ffi/loadlib.lua
2525
ffi/posix_h.lua
26-
ffi/posix_types_*_h.lua
2726
ffi/tree_sitter_h.lua
2827
endef
2928

0 commit comments

Comments
 (0)