From de2c29656ab0c3196429935d6995e333d6775832 Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 12 May 2019 23:20:02 +0100 Subject: [PATCH] other platform testing --- cl-sipc.lisp | 29 ++++++++++++++++------------- libsipc/Makefile | 9 +++++---- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/cl-sipc.lisp b/cl-sipc.lisp index 525bcdd..e45b647 100644 --- a/cl-sipc.lisp +++ b/cl-sipc.lisp @@ -9,24 +9,26 @@ ;; wrappers (defun bind (file) - "bind to the AF_UNIX socket `file'" - "returns the sd on success, nil on failure" - "(remember it has to be deleted first!)" + "bind to the AF_UNIX socket `file' + returns the sd on success, nil on failure + (remember it has to be deleted first!) + " (let ((rc (si-bind file))) (if (< rc 0) ;error nil rc))) (defun hook (sd on-err on-msg) - "listen on socket `sd'" - "on error call the callback `on-err' with args (error)" - "on message call the callback `on-msg' with args (type message)" - "type can be: + "listen on socket `sd' + on error call the callback `on-err' with args (error) + on message call the callback `on-msg' with args (type message) + type can be: :string - a string :binary - (TODO) a foreign pointer - :close - a close request" - "returns rc on success (1), and nil on failure" - "(note: this function blocks until the connection closes)" + :close - a close request + returns rc on success (1), and nil on failure + (note: this function blocks until the connection closes) + " (let ((*on-message* on-msg) (*on-err* on-err)) (let ((rc (si-listen sd (callback si-error-callback) (callback si-callback)))) @@ -40,9 +42,10 @@ t) (defmacro with-bound-socket (desc &body body) - "bind socket, run `body', then close the socket" - "example: (with-bound-socket (socket \"file.socket\") (hook socket ...))" - "returns the last value from body on success, returns NIL without running body if the socket failed to bind" + "bind socket, run `body', then close the socket + example: (with-bound-socket (socket \"file.socket\") (hook socket ...)) + returns the last value from body on success, returns NIL without running body if the socket failed to bind + " `(let* ((,(first desc) (bind ,(second desc))) (return-value (if (null ,(first desc)) ;;bind failed diff --git a/libsipc/Makefile b/libsipc/Makefile index 5b55a41..190fe27 100644 --- a/libsipc/Makefile +++ b/libsipc/Makefile @@ -1,6 +1,7 @@ TRANS:=src/sipc.c INCLUDE:=include/ -CFLAGS:= -c -Wall -pedantic -fPIC -I$(INCLUDE) +CFLAGS:= -c -Wall -fPIC -I$(INCLUDE) +STD:=--std=gnu11 all: clean libsipc sipcli @@ -13,13 +14,13 @@ clean: rm -f *.socket libsipc: - gcc $(CFLAGS) $(TRANS) + gcc $(STD) $(CFLAGS) $(TRANS) gcc -shared -o $@.so *.o libsipc-ffi: - gcc $(CFLAGS) $(TRANS) src/ffi.c + gcc $(STD) $(CFLAGS) $(TRANS) src/ffi.c gcc -shared -o $@.so *.o sipcli: libsipc - gcc -Wall -pedantic -I$(INCLUDE) -Wl,-rpath=./ src/test.c -o $@ -L./ -lsipc + gcc $(STD) -Wall -pedantic -I$(INCLUDE) -Wl,-rpath=./ src/test.c -o $@ -L./ -lsipc ./$@