summaryrefslogtreecommitdiff
path: root/module/system
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2024-03-04 22:14:04 +0100
committerAndy Wingo <wingo@pobox.com>2024-03-17 21:40:58 +0100
commit2b58dea2d24068e2a9dbe002cdceb6fec5a13a82 (patch)
tree083367dcf8c8f1388f737d21f802c7ca16a3568b /module/system
parent137b0e85b956a7b7e7c9bc0029d09fe6868e5b17 (diff)
downloadguile-2b58dea2d24068e2a9dbe002cdceb6fec5a13a82.tar.gz
(scheme foreign): API is less configuration-dependent
* libguile/foreign.h: * libguile/foreign.c: Always define complex-float and complex-double. Fall back to alignof float / 2*sizeof float if no complex numbers. (But with C99 surely it exists everywhere.) * module/system/foreign.scm (*writers*, *readers*): Always include complex-float and complex-double readers and writers. * test-suite/tests/foreign.test: Always run the complex tests.
Diffstat (limited to 'module/system')
-rw-r--r--module/system/foreign.scm52
1 files changed, 23 insertions, 29 deletions
diff --git a/module/system/foreign.scm b/module/system/foreign.scm
index 7fdd6dd95..3ddfd204b 100644
--- a/module/system/foreign.scm
+++ b/module/system/foreign.scm
@@ -1,19 +1,18 @@
-;;;; Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc.
-;;;;
-;;;; This library is free software; you can redistribute it and/or
-;;;; modify it under the terms of the GNU Lesser General Public
-;;;; License as published by the Free Software Foundation; either
-;;;; version 2.1 of the License, or (at your option) any later version.
-;;;;
-;;;; This library 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
-;;;; Lesser General Public License for more details.
-;;;;
-;;;; You should have received a copy of the GNU Lesser General Public
-;;;; License along with this library; if not, write to the Free Software
-;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;;;;
+;;; Copyright (C) 2010-2011,2013-2014,2024 Free Software Foundation, Inc.
+;;;
+;;; This library is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU Lesser General Public License as
+;;; published by the Free Software Foundation, either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This library 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
+;;; Lesser General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
(define-module (system foreign)
@@ -108,12 +107,10 @@
(define *writers*
`((,float . ,bytevector-ieee-single-native-set!)
(,double . ,bytevector-ieee-double-native-set!)
- ,@(if (defined? 'complex-float)
- `((,complex-float
- . ,(writer-complex bytevector-ieee-single-native-set! (sizeof float)))
- (,complex-double
- . ,(writer-complex bytevector-ieee-double-native-set! (sizeof double))))
- '())
+ (,complex-float
+ . ,(writer-complex bytevector-ieee-single-native-set! (sizeof float)))
+ (,complex-double
+ . ,(writer-complex bytevector-ieee-double-native-set! (sizeof double)))
(,int8 . ,bytevector-s8-set!)
(,uint8 . ,bytevector-u8-set!)
(,int16 . ,bytevector-s16-native-set!)
@@ -127,12 +124,10 @@
(define *readers*
`((,float . ,bytevector-ieee-single-native-ref)
(,double . ,bytevector-ieee-double-native-ref)
- ,@(if (defined? 'complex-float)
- `((,complex-float
- . ,(reader-complex bytevector-ieee-single-native-ref (sizeof float)))
- (,complex-double
- . ,(reader-complex bytevector-ieee-double-native-ref (sizeof double))))
- '())
+ (,complex-float
+ . ,(reader-complex bytevector-ieee-single-native-ref (sizeof float)))
+ (,complex-double
+ . ,(reader-complex bytevector-ieee-double-native-ref (sizeof double)))
(,int8 . ,bytevector-s8-ref)
(,uint8 . ,bytevector-u8-ref)
(,int16 . ,bytevector-s16-native-ref)
@@ -143,7 +138,6 @@
(,uint64 . ,bytevector-u64-native-ref)
(* . ,bytevector-pointer-ref)))
-
(define (align off alignment)
(1+ (logior (1- off) (1- alignment))))