public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
To: libffi-discuss@sourceware.org
Subject: [RFC] Proposal for m*vc build issue (#138)
Date: Wed, 12 Nov 2014 13:08:00 -0000	[thread overview]
Message-ID: <20141112130755.GA24721@linux.vnet.ibm.com> (raw)

[-- 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


             reply	other threads:[~2014-11-12 13:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 13:08 Dominik Vogt [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141112130755.GA24721@linux.vnet.ibm.com \
    --to=vogt@linux.vnet.ibm.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).