aboutsummaryrefslogtreecommitdiff
path: root/guix/utils.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/utils.scm')
-rw-r--r--guix/utils.scm33
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 *))))