all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] syscalls: Turn syscalls wrappers into procedures.
@ 2015-08-22 13:27 Manolis Ragkousis
  2015-08-22 13:30 ` Manolis Ragkousis
  2015-08-26 11:29 ` Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: Manolis Ragkousis @ 2015-08-22 13:27 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

In hurd there are some syscalls that are not available. By turning
those scheme wrappers in procedures we can just delegate their
evaluation till they are actually needed, thus bypassing the need for
them to actually exist for now and enable guix to build on Hurd.

[-- Attachment #2: 0001-syscalls-Turn-syscalls-wrappers-into-procedures.patch --]
[-- Type: text/x-patch, Size: 3262 bytes --]

From 1dbdd1f9908799ebc32854e91619cfaae96b4dc4 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Fri, 21 Aug 2015 22:00:16 +0300
Subject: [PATCH] syscalls: Turn syscalls wrappers into procedures.

* guix/build/syscalls.scm (mount, umount, swapon, swapoff,
  setns, pivot-root, clone): Turn into procedures.
---
 guix/build/syscalls.scm | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index fc801a5..44f9f4e 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -182,7 +182,7 @@
 (define MNT_EXPIRE      4)
 (define UMOUNT_NOFOLLOW 8)
 
-(define mount
+(define (mount)
   (let* ((ptr  (dynamic-func "mount" (dynamic-link)))
          (proc (pointer->procedure int ptr `(* * * ,unsigned-long *))))
     (lambda* (source target type #:optional (flags 0) options
@@ -211,7 +211,7 @@ error."
         (when update-mtab?
           (augment-mtab source target type options))))))
 
-(define umount
+(define (umount)
   (let* ((ptr  (dynamic-func "umount2" (dynamic-link)))
          (proc (pointer->procedure int ptr `(* ,int))))
     (lambda* (target #:optional (flags 0)
@@ -239,7 +239,7 @@ constants from <sys/mount.h>."
                 ((source mount-point _ ...)
                  (loop (cons mount-point result))))))))))
 
-(define swapon
+(define (swapon)
   (let* ((ptr  (dynamic-func "swapon" (dynamic-link)))
          (proc (pointer->procedure int ptr (list '* int))))
     (lambda* (device #:optional (flags 0))
@@ -251,7 +251,7 @@ constants from <sys/mount.h>."
                  (list device (strerror err))
                  (list err)))))))
 
-(define swapoff
+(define (swapoff)
   (let* ((ptr  (dynamic-func "swapoff" (dynamic-link)))
          (proc (pointer->procedure int ptr '(*))))
     (lambda (device)
@@ -310,9 +310,12 @@ string TMPL and return its file name.  TMPL must end with 'XXXXXX'."
 (define CLONE_NEWPID  #x20000000)
 (define CLONE_NEWNET  #x40000000)
 
+;; By turning the syscalls wrappers into procedures we can delegate their evaluation
+;; till they are actually needed, thus enabling Guix to build on systems which the
+;; syscalls are not available. 
 ;; The libc interface to sys_clone is not useful for Scheme programs, so the
 ;; low-level system call is wrapped instead.
-(define clone
+(define (clone)
   (let* ((ptr        (dynamic-func "syscall" (dynamic-link)))
          (proc       (pointer->procedure int ptr (list int int '*)))
          ;; TODO: Don't do this.
@@ -327,7 +330,7 @@ Unlike the fork system call, clone accepts FLAGS that specify which resources
 are shared between the parent and child processes."
       (proc syscall-id flags %null-pointer))))
 
-(define setns
+(define (setns)
   ;; Some systems may be using an old (pre-2.14) version of glibc where there
   ;; is no 'setns' function available.
   (false-if-exception
@@ -345,7 +348,7 @@ there is no such limitation."
                   (list fdes nstype (strerror err))
                   (list err))))))))
 
-(define pivot-root
+(define (pivot-root)
   (let* ((ptr  (dynamic-func "pivot_root" (dynamic-link)))
          (proc (pointer->procedure int ptr (list '* '*))))
     (lambda (new-root put-old)
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-27  9:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-22 13:27 [PATCH] syscalls: Turn syscalls wrappers into procedures Manolis Ragkousis
2015-08-22 13:30 ` Manolis Ragkousis
2015-08-22 17:19   ` Mark H Weaver
2015-08-26 11:29 ` Ludovic Courtès
2015-08-26 22:50   ` Ludovic Courtès
2015-08-27  9:07     ` Manolis Ragkousis

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.