guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#26341: [PATCH 1/5] build: syscalls: Add reboot.


From: Ludovic Courtès
Subject: bug#26341: [PATCH 1/5] build: syscalls: Add reboot.
Date: Mon, 10 Apr 2017 11:42:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hi Mathieu,

Mathieu Othacehe <address@hidden> skribis:

> * guix/build/syscalls.scm (static-or-ffi): New macro. Used to dispatch between
>   static Guile core implementation and FFI version.
> (reboot): New export procedure. Reimplemented from guile-linux-syscalls.patch.
> (RB_AUTOBOOT, ..., RB_KEXEC): New exported flags replacing static Guile flags.

[...]

> +  #:replace (RB_AUTOBOOT
> +             RB_HALT_SYSTEM
> +             RB_ENABLED_CAD
> +             RB_DISABLE_CAD
> +             RB_POWER_OFF
> +             RB_SW_SUSPEND
> +             RB_KEXEC
> +             reboot))

The problem is that we cannot #:replace unconditionally (when not using
the patched Guile, there’s nothing to replace¹).

So perhaps we should remove #:export, #:replace, and #:re-export for
‘mount’ & co, and instead have a macro like this:

  (define-syntax define-as-needed
    (syntax-rules ()
      "Define VARIABLE.  If VARIABLE already exists in (guile) then re-export 
it,
  otherwise export the newly-defined VARIABLE."
      ((_ (proc args ...) body ...)
       (define-as-needed proc (lambda (args ...) body ...)))
      ((_ variable value)
       (begin
         (when (module-defined? the-scm-module 'variable)
           (re-export variable))

         (define variable
           (if (module-defined? the-scm-module 'variable)
               (module-ref the-scm-module 'variable)
               value))

         (unless (module-defined? the-scm-module 'variable)
           (export variable))))))

  (define-as-needed RB_AUTOBOOT #x123)
  (define-as-needed (mount foo bar)
    'baz)

WDYT?

Sorry that this simple thing ends up being complicated!  ;-)

Thank you,
Ludo’.

¹ In practice #:replace works even when there’s nothing to replace, but
  I’d rather not rely on it.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]