From acec4327e19328703693cffb0b8cb6fbdedcdac1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 6 Apr 2009 23:17:49 +0200 Subject: [PATCH] Expose endianness objects to C. * src/bytevector.c (scm_r6rs_endianness_big, scm_r6rs_endianness_little): New. * src/bytevector.h (scm_r6rs_endianness_big, scm_r6rs_endianness_little): New declarations. --- NEWS | 1 + src/bytevector.c | 10 ++++++---- src/bytevector.h | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 5610ebe..124bda7 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Applications should now use module names like `(rnrs bytevector)' instead of `(r6rs bytevector)'; the latter is still supported for backward compatibility, though. +*** New C variables `scm_r6rs_endianness_{big,little}' ** Bug fixes *** Fix custom binary input ports for Guile >= 1.8.6 diff --git a/src/bytevector.c b/src/bytevector.c index 930ce16..d5f3f87 100644 --- a/src/bytevector.c +++ b/src/bytevector.c @@ -1,5 +1,5 @@ /* Guile-R6RS-Libs --- Implementation of R6RS standard libraries. - Copyright (C) 2007, 2008 Ludovic Courtès + Copyright (C) 2007, 2008, 2009 Ludovic Courtès Guile-R6RS-Libs is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -309,6 +309,8 @@ SCM_SMOB_FREE (scm_tc16_r6rs_bytevector, free_bytevector, bv) SCM_SYMBOL (scm_sym_big, "big"); SCM_SYMBOL (scm_sym_little, "little"); +SCM scm_r6rs_endianness_big, scm_r6rs_endianness_little; + /* Host endianness (a symbol). */ static SCM native_endianness = SCM_UNSPECIFIED; @@ -1950,9 +1952,9 @@ scm_init_r6rs_bytevector (void) native_endianness = scm_sym_little; #endif + scm_r6rs_endianness_big = scm_sym_big; + scm_r6rs_endianness_little = scm_sym_little; + scm_r6rs_null_bytevector = scm_gc_protect_object (make_bytevector_from_buffer (0, NULL)); } - -/* arch-tag: e5a30664-90fc-40d7-8036-ee767aea5fb6 - */ diff --git a/src/bytevector.h b/src/bytevector.h index 84718e0..aff6a6e 100644 --- a/src/bytevector.h +++ b/src/bytevector.h @@ -1,5 +1,5 @@ /* Guile-R6RS-Libs --- Implementation of R6RS standard libraries. - Copyright (C) 2007 Ludovic Courtès + Copyright (C) 2007, 2009 Ludovic Courtès Guile-R6RS-Libs is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -34,6 +34,10 @@ SCM_API void scm_init_r6rs_bytevector (void); ? (signed char *) SCM_SMOB_OBJECT_2_LOC (_bv) \ : (signed char *) SCM_SMOB_DATA_2 (_bv)) + +SCM_API SCM scm_r6rs_endianness_big; +SCM_API SCM scm_r6rs_endianness_little; + SCM_API SCM scm_r6rs_make_bytevector (SCM, SCM); SCM_API SCM scm_r6rs_c_make_bytevector (unsigned); SCM_API SCM scm_r6rs_native_endianness (void); -- 2.11.4.GIT