mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-01 09:49:24 +03:00
dff0f1da43
The Network.Socket.Data code previously used hardcoded constants manually read from auto-generated C source code, however these constants are specific to Linux. The original code looked like this: export ToCode SocketFamily where -- Don't know how to read a constant value from C code in idris2... -- gotta to hardcode those for now toCode AF_UNSPEC = 0 -- unsafePerformIO (cMacro "#AF_UNSPEC" Int) toCode AF_UNIX = 1 toCode AF_INET = 2 toCode AF_INET6 = 10 The AF_INET6 constant is correct on my Debian 10 laptop: molly on flywheel ~> grep -rE '^#define AF_INET6' /usr/include /usr/include/x86_64-linux-gnu/bits/socket.h:#define AF_INET6 PF_INET6 molly on flywheel ~> grep -rE '^#define PF_INET6' /usr/include /usr/include/x86_64-linux-gnu/bits/socket.h:#define PF_INET6 10 /* IP version 6. */ However, this is not the case on an OpenBSD machine: spanner# grep -rE '^#define[[:space:]]+AF_INET6' /usr/include /usr/include/sys/socket.h:#define AF_INET6 24 /* IPv6 */ This commit adds accessor functions to the C runtime support library for retrieving the values of these macros as they appear in the system libc header files, which can then be invoked using the normal C FFI machinery. |
||
---|---|---|
.. | ||
Socket | ||
FFI.idr | ||
Socket.idr |