mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 13:37:35 +02:00
Adding define-c-int-type to the FFI and using it for socklen_t.
This commit is contained in:
parent
6a6e5746c5
commit
163b21a815
2 changed files with 13 additions and 2 deletions
|
@ -3,6 +3,8 @@
|
||||||
(c-system-include "sys/socket.h")
|
(c-system-include "sys/socket.h")
|
||||||
(c-system-include "netdb.h")
|
(c-system-include "netdb.h")
|
||||||
|
|
||||||
|
(define-c-int-type socklen_t)
|
||||||
|
|
||||||
(define-c-struct sockaddr
|
(define-c-struct sockaddr
|
||||||
predicate: sockaddr?)
|
predicate: sockaddr?)
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@
|
||||||
|
|
||||||
;;> Accept a connection on a socket.
|
;;> 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.
|
;;> Create an endpoint for communication.
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,17 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; type predicates
|
;; 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)
|
(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)
|
(define (unsigned-int-type? type)
|
||||||
(memq type '(unsigned-char unsigned-short unsigned unsigned-int unsigned-long
|
(memq type '(unsigned-char unsigned-short unsigned unsigned-int unsigned-long
|
||||||
|
|
Loading…
Add table
Reference in a new issue