summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-02-17 20:08:16 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-02-17 20:08:16 -0800
commitc27e986b91fe7db72ae87f731be84fec0e9fab53 (patch)
tree9f500b44c2641c997526b1fd659473f3d9951b85 /lib.c
parent42e6aaefb83fafc5338c892006f8189937b0667e (diff)
downloadtxr-c27e986b91fe7db72ae87f731be84fec0e9fab53.tar.gz
txr-c27e986b91fe7db72ae87f731be84fec0e9fab53.tar.bz2
txr-c27e986b91fe7db72ae87f731be84fec0e9fab53.zip
ffi: move socket stuff to socket module.
* alloca.h (zalloca): Macro moved here from ffi.c; it's useful to any code that wants to do a zero-filled alloca, and socket.c needs it now. * ffi.c (HAVE_SOCKETS): All includes conditional on HAVE_SOCKETS removed. (zalloca): Macro removed; moved to alloca.h. (ffi_type_struct_checked, ffi_type_lookup): Static functions changed to external linkage. (ffi_type_size, ffi_type_put, ffi_type_get): New functions, used by external module that has incomplete definition of struct txr_ffi_type. (type_by_size): New static array, moved out of ffi_init_extra_types function. (ffi_type_by_size): New function. (ffi_init_extra_types): type_by_size array relocated to file scope. (sock_opt, sock_set_opt): Moved to socket.c, and adjusted to use newly developed external access to needed ffi mechanisms. (ffi_init): Numerous definitions related to sockets removed; these go to socket.c. * ffi.h (struct txr_ffi_type): Declared here now as incomplete type. (ffi_type_struct_checked, ffi_type_size, ffi_type_put, ffi_type_get, ffi_type_lookup, ffi_type_by_size): Declared. * lib.c (init): Call new function sock_init. * socket.c (sock_opt, sock_set_opt): New functions, moved from ffi.c, and slightly adapted to work with external interfaces exposed by ffi.c. (sock_init): New function. This performs unconditional initializations not keyed to the lazy loading lisplib.c mechanism. Here we create the socklen-t FFI type. FFI types lookup doesn't trigger lazy loading, so we do it this way; the alternative would be to introduce lazy load triggering to FFI type lookup, just for this one type. (sock_load_init): All the socket function and variable registrations move here from ffi_init.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 39faca3e..2a3b7680 100644
--- a/lib.c
+++ b/lib.c
@@ -77,6 +77,7 @@
#include "buf.h"
#include "ffi.h"
#include "chksum.h"
+#include "socket.h"
#include "txr.h"
#include "debug.h"
@@ -14434,6 +14435,9 @@ void init(val *stack_bottom)
cadr_init();
time_init();
chksum_init();
+#if HAVE_SOCKETS
+ sock_init();
+#endif
cobj_populate_hash();