[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 98/324: utils: Define module for defining platform-speci
From: |
gnunet |
Subject: |
[gnunet-scheme] 98/324: utils: Define module for defining platform-specifing enumerations. |
Date: |
Tue, 21 Sep 2021 13:22:18 +0200 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
commit c39e0113d477935d3552aadd5b0ecf1bbdec32bc
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Mar 24 13:51:02 2021 +0100
utils: Define module for defining platform-specifing enumerations.
(gnu extractor enum) is not suitable as it assumes the enumeration
values are the same on all target platforms.
* gnu/gnunet/utils/platform-enum.scm
(that-platform?): Define syntax for writing platform-specific code.
(define-platform-enumeration): Define syntax for defining
platform-specific C-style enumerations compactly.
* Makefile.am (modules): Compile the new module.
* README.org (modules): Note this module exists.
---
Makefile.am | 1 +
README.org | 2 ++
gnu/gnunet/utils/platform-enum.scm | 48 ++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 1e20804..ea62015 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,6 +46,7 @@ modules = \
gnu/gnunet/utils/bv-slice.scm \
gnu/gnunet/utils/hat-let.scm \
gnu/gnunet/utils/netstruct.scm \
+ gnu/gnunet/utils/platform-enum.scm \
\
gnu/gnunet/util/cmsg.scm \
gnu/gnunet/icmp/struct.scm \
diff --git a/README.org b/README.org
index 0e54618..f67d273 100644
--- a/README.org
+++ b/README.org
@@ -50,6 +50,8 @@
+ gnu/gnunet/concurrency/update.scm: a box with a value,
that can be updated, resulting in a new box. Updates
can be waited upon.
+ + gnu/gnunet/utils/platform-enum.scm: Platform-specific
+ C-style enum values.
** Message queues
Message queues have three parts: the input queue, the output
diff --git a/gnu/gnunet/utils/platform-enum.scm
b/gnu/gnunet/utils/platform-enum.scm
new file mode 100644
index 0000000..f3207ca
--- /dev/null
+++ b/gnu/gnunet/utils/platform-enum.scm
@@ -0,0 +1,48 @@
+;; This file is part of scheme-GNUnet.
+;; Copyright (C) 2021 Maxime Devos
+;;
+;; scheme-GNUnet is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU Affero General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+;;
+;; scheme-GNUnet is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Affero General Public License for more details.
+;;
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;
+;; SPDX-License-Identifier: AGPL3.0-or-later
+
+;; Brief: C-style enumeration that are platform-specific.
+;; TODO: autoconfery
+
+(define-module (gnu gnunet utils platform-enum)
+ #:export (that-platform? define-platform-enumeration))
+
+;; Define an enumeration, with values depending
+;; on the platform. If the value is not supported
+;; on the target platform, set it to #f instead.
+
+(define-syntax that-platform?
+ (syntax-rules (or and not)
+ ((_ #:hurd) (string-prefix? "gnu" (target-os)))
+ ((_ #:linux) (string-prefix? "linux" (target-os)))
+ ((_ (or a ...)) ((@ (guile) or) (that-platform? a) ...))
+ ((_ (and a ...)) ((@ (guile) and) (that-platform? a) ...))
+ ((_ (not a)) ((@ (guile) not) (that-platform? a)))
+ ((_ #t) #t)
+ ((_ #f) #f)
+ ((_ #nil) #f)))
+
+(define-syntax define-platform-enumeration
+ (syntax-rules ()
+ ((_ (name (platform value) ...) ...)
+ (begin
+ (define name
+ (cond ((that-platform? platform) value)
+ ...
+ (#t #f)))
+ ...))))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 100/324: config: parser: Define return types for expansion parser., (continued)
- [gnunet-scheme] 100/324: config: parser: Define return types for expansion parser., gnunet, 2021/09/21
- [gnunet-scheme] 108/324: tets: message-handler: Correct imports., gnunet, 2021/09/21
- [gnunet-scheme] 110/324: config: Define a quaject for quering and modifying a configuration., gnunet, 2021/09/21
- [gnunet-scheme] 71/324: doc: Document maintainer quirk, gnunet, 2021/09/21
- [gnunet-scheme] 77/324: util: add missing import, gnunet, 2021/09/21
- [gnunet-scheme] 82/324: Implement self-documenting ‘network structures’, gnunet, 2021/09/21
- [gnunet-scheme] 88/324: mq: Move message queue modules to (gnu gnunet mq SOMETHING)., gnunet, 2021/09/21
- [gnunet-scheme] 101/324: utils: hat-let: Add <--, a variant on <-., gnunet, 2021/09/21
- [gnunet-scheme] 89/324: doc: Document current list of defined GNUnet network structures., gnunet, 2021/09/21
- [gnunet-scheme] 94/324: bv-slice: Correct offset calculation in slice-slice., gnunet, 2021/09/21
- [gnunet-scheme] 98/324: utils: Define module for defining platform-specifing enumerations.,
gnunet <=
- [gnunet-scheme] 95/324: util: Allow splitting and constructing ancillary messages., gnunet, 2021/09/21
- [gnunet-scheme] 103/324: config: parser: parse ${variable} expansions., gnunet, 2021/09/21
- [gnunet-scheme] 105/324: config: value-parser: Parse values in configuration files., gnunet, 2021/09/21
- [gnunet-scheme] 107/324: tests: message-io: Unbreak., gnunet, 2021/09/21
- [gnunet-scheme] 106/324: doc: Classify modules., gnunet, 2021/09/21
- [gnunet-scheme] 120/324: netstruct syntactic: Fix error when field is constant., gnunet, 2021/09/21
- [gnunet-scheme] 121/324: netstruct: Correct argument order to slice-uN-set!., gnunet, 2021/09/21
- [gnunet-scheme] 113/324: hat-let: Avoid having to import '_' from (rnrs base)., gnunet, 2021/09/21
- [gnunet-scheme] 112/324: config: parser: Fix typo in documentation., gnunet, 2021/09/21
- [gnunet-scheme] 93/324: doc: Some tips on testing., gnunet, 2021/09/21