public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* [RFC] Proposal for m*vc build issue (#138)
@ 2014-11-12 13:08 Dominik Vogt
  2014-11-12 13:16 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2014-11-12 13:08 UTC (permalink / raw)
  To: libffi-discuss

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

I've attached a patch implementing option 4 from here:
https://github.com/atgreen/libffi/issues/138 Please proof read the
patch and let me know what you think.  It might be good to
specifically double check the detection of a compiler with complex
support using macros.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-Detect-compiler-s-_Complex-support-by-checking-__STD.patch --]
[-- Type: text/x-diff, Size: 1580 bytes --]

From e854b00c2fb86a5f65e08d299bea64883cefb99c Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 11 Nov 2014 13:55:22 +0100
Subject: [PATCH] Detect compiler's _Complex support by checking
 __STDC_NO_COMPLEX__.

---
 src/types.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/types.c b/src/types.c
index ef4f151..5c7bd27 100644
--- a/src/types.c
+++ b/src/types.c
@@ -44,6 +44,7 @@ maybe_const ffi_type ffi_type_##name = {	\
   id, NULL					\
 }
 
+#if !defined __STDC_NO_COMPLEX__ && defined __STDC_VERSION__ && (__STDC_VERSION__ >= 199901L)
 #define FFI_COMPLEX_TYPEDEF(name, type, maybe_const)	\
 static ffi_type *ffi_elements_complex_##name [2] = {	\
 	(ffi_type *)(&ffi_type_##name), NULL		\
@@ -58,6 +59,24 @@ maybe_const ffi_type ffi_type_complex_##name = {	\
   FFI_TYPE_COMPLEX,					\
   (ffi_type **)ffi_elements_complex_##name		\
 }
+#else
+/* Bogus definition for compilers without C99 complex support.  */
+#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const)	\
+static ffi_type *ffi_elements_complex_##name [2] = {	\
+	(ffi_type *)(&ffi_type_##name), NULL		\
+};							\
+struct struct_align_complex_##name {			\
+  char c;						\
+  type x;						\
+  type y;						\
+};							\
+maybe_const ffi_type ffi_type_complex_##name = {	\
+  2 * sizeof(type),					\
+  offsetof(struct struct_align_complex_##name, x),	\
+  FFI_TYPE_COMPLEX,					\
+  (ffi_type **)ffi_elements_complex_##name		\
+}
+#endif
 
 /* Size and alignment are fake here. They must not be 0. */
 const ffi_type ffi_type_void = {
-- 
1.8.4.2


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

end of thread, other threads:[~2014-11-12 13:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-12 13:08 [RFC] Proposal for m*vc build issue (#138) Dominik Vogt
2014-11-12 13:16 ` Richard Henderson
2014-11-12 13:26   ` Dominik Vogt
2014-11-12 13:36     ` Dominik Vogt
2014-11-12 13:46       ` Grégory Pakosz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).