Welcome to the CHICKEN Scheme pasting service
gettimeofday example added by wasamasa on Mon Apr 27 15:02:11 2020
(import scheme) (import (chicken base)) (import (chicken foreign)) #> #include <stddef.h> #include <sys/time.h> <# (define (current-timestamp) (let-location ((sec long 0) (usec long 0)) ((foreign-lambda* void (((c-pointer long) sec) ((c-pointer long) usec)) "struct timeval tp; gettimeofday(&tp, NULL);" "*sec = tp.tv_sec; *usec = tp.tv_usec;") (location sec) (location usec)) (cons sec usec))) (let* ((timestamp (current-timestamp)) (sec (car timestamp)) (usec (cdr timestamp))) (print (exact->inexact (+ sec (/ usec 1000000)))))