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

* Re: [RFC] Proposal for m*vc build issue (#138)
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2014-11-12 13:16 UTC (permalink / raw)
  To: libffi-discuss

On 11/12/2014 02:07 PM, Dominik Vogt wrote:
> 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.

Looks good to me.


r~

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

* Re: [RFC] Proposal for m*vc build issue (#138)
  2014-11-12 13:16 ` Richard Henderson
@ 2014-11-12 13:26   ` Dominik Vogt
  2014-11-12 13:36     ` Dominik Vogt
  0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2014-11-12 13:26 UTC (permalink / raw)
  To: libffi-discuss

On Wed, Nov 12, 2014 at 02:16:27PM +0100, Richard Henderson wrote:
> > It might be good to
> > specifically double check the detection of a compiler with complex
> > support using macros.
> 
> Looks good to me.

... but doesn't work with the gcc I use.  I'll check what's going
on.  Maybe the no-complex case should generate a warning.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

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

* Re: [RFC] Proposal for m*vc build issue (#138)
  2014-11-12 13:26   ` Dominik Vogt
@ 2014-11-12 13:36     ` Dominik Vogt
  2014-11-12 13:46       ` Grégory Pakosz
  0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2014-11-12 13:36 UTC (permalink / raw)
  To: libffi-discuss

On Wed, Nov 12, 2014 at 02:26:24PM +0100, Dominik Vogt wrote:
> On Wed, Nov 12, 2014 at 02:16:27PM +0100, Richard Henderson wrote:
> > > It might be good to
> > > specifically double check the detection of a compiler with complex
> > > support using macros.
> > 
> > Looks good to me.
> 
> ... but doesn't work with the gcc I use.  I'll check what's going
> on.  Maybe the no-complex case should generate a warning.

Hm, my gcc does not define __STDC_VERSION__ unless called
specifically with --std=c99 (or maybe other settings too that I did
not check).  So the test always thinks that complex types are not
available.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

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

* Re: [RFC] Proposal for m*vc build issue (#138)
  2014-11-12 13:36     ` Dominik Vogt
@ 2014-11-12 13:46       ` Grégory Pakosz
  0 siblings, 0 replies; 5+ messages in thread
From: Grégory Pakosz @ 2014-11-12 13:46 UTC (permalink / raw)
  To: libffi-discuss

About GCC and --std==c99

I noticed dlmalloc.c that ships with libffi contains #if defined (__GNUC__) && defined(i386)

This really should be #if defined (__GNUC__) && defined(__i386__) because when compiling with -std=c99, i386 is not defined whereas __i386__ is.

Gregory
________________________________________
From: libffi-discuss-owner@sourceware.org <libffi-discuss-owner@sourceware.org> on behalf of Dominik Vogt <vogt@linux.vnet.ibm.com>
Sent: Wednesday, November 12, 2014 2:35 PM
To: libffi-discuss@sourceware.org
Subject: Re: [RFC] Proposal for m*vc build issue (#138)

On Wed, Nov 12, 2014 at 02:26:24PM +0100, Dominik Vogt wrote:
> On Wed, Nov 12, 2014 at 02:16:27PM +0100, Richard Henderson wrote:
> > > It might be good to
> > > specifically double check the detection of a compiler with complex
> > > support using macros.
> >
> > Looks good to me.
>
> ... but doesn't work with the gcc I use.  I'll check what's going
> on.  Maybe the no-complex case should generate a warning.

Hm, my gcc does not define __STDC_VERSION__ unless called
specifically with --std=c99 (or maybe other settings too that I did
not check).  So the test always thinks that complex types are not
available.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt
IBM Germany

^ 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).