diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-05-10 21:49:11 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-05-10 22:55:34 +0200 |
commit | 29fa45f45d3192ad0f8d2c46523d7a7d6422c9e9 (patch) | |
tree | 6da920c74bc4ab967faad05d33b71d9c2d34d8c6 /guix/utils.scm | |
parent | 02139eb9b2bdbe1b342a0550dd8725a764716c28 (diff) | |
download | gnu-guix-29fa45f45d3192ad0f8d2c46523d7a7d6422c9e9.tar gnu-guix-29fa45f45d3192ad0f8d2c46523d7a7d6422c9e9.tar.gz |
Add (guix build syscalls).
* guix/build/syscalls.scm, tests/syscalls.scm: New files.
* Makefile.am (MODULES): Add guix/build/syscalls.scm.
(SCM_TESTS): Add tests/syscalls.scm.
* guix/utils.scm (%libc-errno-pointer, errno): Remove; take from (guix
build syscalls).
Diffstat (limited to 'guix/utils.scm')
-rw-r--r-- | guix/utils.scm | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/guix/utils.scm b/guix/utils.scm index 53fc68d27b..700a191d71 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -28,6 +28,7 @@ #:use-module (rnrs bytevectors) #:use-module ((rnrs io ports) #:select (put-bytevector)) #:use-module ((guix build utils) #:select (dump-port)) + #:use-module ((guix build syscalls) #:select (errno)) #:use-module (ice-9 vlist) #:use-module (ice-9 format) #:autoload (ice-9 popen) (open-pipe*) @@ -366,38 +367,6 @@ that goes to PORT according to COMPRESSION, a symbol such as 'xz." ((string-contains %host-type "linux") #(0 1 2)) ; *-linux-gnu (else #(1 2 3))))) ; *-gnu* -(define %libc-errno-pointer - ;; Glibc's 'errno' pointer. - (let ((errno-loc (dynamic-func "__errno_location" (dynamic-link)))) - (and errno-loc - (let ((proc (pointer->procedure '* errno-loc '()))) - (proc))))) - -(define errno - (if %libc-errno-pointer - (let ((bv (pointer->bytevector %libc-errno-pointer (sizeof int)))) - (lambda () - "Return the current errno." - ;; XXX: We assume that nothing changes 'errno' while we're doing all this. - ;; In particular, that means that no async must be running here. - - ;; Use one of the fixed-size native-ref procedures because they are - ;; optimized down to a single VM instruction, which reduces the risk - ;; that we fiddle with 'errno' (needed on Guile 2.0.5, libc 2.11.) - (let-syntax ((ref (lambda (s) - (syntax-case s () - ((_ bv) - (case (sizeof int) - ((4) - #'(bytevector-s32-native-ref bv 0)) - ((8) - #'(bytevector-s64-native-ref bv 0)) - (else - (error "unsupported 'int' size" - (sizeof int))))))))) - (ref bv)))) - (lambda () 0))) - (define fcntl-flock (let* ((ptr (dynamic-func "fcntl" (dynamic-link))) (proc (pointer->procedure int ptr `(,int ,int *)))) |