Adding define-c-int-type to the FFI and using it for socklen_t.

This commit is contained in:
Alex Shinn 2011-11-04 22:17:26 +09:00
parent 6a6e5746c5
commit 163b21a815
2 changed files with 13 additions and 2 deletions

View file

@ -3,6 +3,8 @@
(c-system-include "sys/socket.h")
(c-system-include "netdb.h")
(define-c-int-type socklen_t)
(define-c-struct sockaddr
predicate: sockaddr?)
@ -33,7 +35,7 @@
;;> Accept a connection on a socket.
(define-c int accept (int sockaddr (pointer unsigned)))
(define-c int accept (int sockaddr (pointer socklen_t)))
;;> Create an endpoint for communication.

View file

@ -103,8 +103,17 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; type predicates
(define *c-int-types* '())
(define-syntax define-c-int-type
(syntax-rules ()
((define-c-int-type type)
(if (not (memq 'type *c-int-types*))
(set! *c-int-types* (cons 'type *c-int-types*))))))
(define (signed-int-type? type)
(memq type '(signed-char short int long boolean)))
(or (memq type '(signed-char short int long boolean))
(memq type *c-int-types*)))
(define (unsigned-int-type? type)
(memq type '(unsigned-char unsigned-short unsigned unsigned-int unsigned-long