Mailing List Archive

[PATCH 4/5] Deal with c99 inline semantics.
From: Thomas Klausner <wiz@NetBSD.org>

Needed for compilation with recent LLVM/Clang.
---
mpi/mpi-inline.h | 4 ----
mpi/mpi-internal.h | 20 ++++++++++++++------
2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/mpi/mpi-inline.h b/mpi/mpi-inline.h
index c32adae..31a6362 100644
--- a/mpi/mpi-inline.h
+++ b/mpi/mpi-inline.h
@@ -28,10 +28,6 @@
#ifndef G10_MPI_INLINE_H
#define G10_MPI_INLINE_H

-#ifndef G10_MPI_INLINE_DECL
-#define G10_MPI_INLINE_DECL extern __inline__
-#endif
-
G10_MPI_INLINE_DECL mpi_limb_t
mpihelp_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
mpi_size_t s1_size, mpi_limb_t s2_limb)
diff --git a/mpi/mpi-internal.h b/mpi/mpi-internal.h
index c1df30a..38a624e 100644
--- a/mpi/mpi-internal.h
+++ b/mpi/mpi-internal.h
@@ -29,6 +29,14 @@
#ifndef G10_MPI_INTERNAL_H
#define G10_MPI_INTERNAL_H

+#ifndef G10_MPI_INLINE_DECL
+#if defined(__GNUC_STDC_INLINE__) && __GNUC_STDC_INLINE__
+#define G10_MPI_INLINE_DECL __inline__
+#else
+#define G10_MPI_INLINE_DECL extern __inline__
+#endif
+#endif
+
#include "mpi.h"
#include "mpi-asm-defs.h"

@@ -198,19 +206,19 @@ void mpi_lshift_limbs( MPI a, unsigned int count );


/*-- mpihelp-add.c --*/
-mpi_limb_t mpihelp_add_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+G10_MPI_INLINE_DECL mpi_limb_t mpihelp_add_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
mpi_size_t s1_size, mpi_limb_t s2_limb );
-mpi_limb_t mpihelp_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+G10_MPI_INLINE_DECL mpi_limb_t mpihelp_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
mpi_ptr_t s2_ptr, mpi_size_t size);
-mpi_limb_t mpihelp_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+G10_MPI_INLINE_DECL mpi_limb_t mpihelp_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
mpi_ptr_t s2_ptr, mpi_size_t s2_size);

/*-- mpihelp-sub.c --*/
-mpi_limb_t mpihelp_sub_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+G10_MPI_INLINE_DECL mpi_limb_t mpihelp_sub_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
mpi_size_t s1_size, mpi_limb_t s2_limb );
-mpi_limb_t mpihelp_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
+G10_MPI_INLINE_DECL mpi_limb_t mpihelp_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
mpi_ptr_t s2_ptr, mpi_size_t size);
-mpi_limb_t mpihelp_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
+G10_MPI_INLINE_DECL mpi_limb_t mpihelp_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
mpi_ptr_t s2_ptr, mpi_size_t s2_size);

/*-- mpihelp-cmp.c --*/
--
1.7.12.2


_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH 4/5] Deal with c99 inline semantics. [ In reply to ]
On Sat, 27 Oct 2012 19:56, tk@giga.or.at said:

> Needed for compilation with recent LLVM/Clang.

That might be anotherr clang bug; see
http://rem.eifzilla.de/archives/2012/08/10/identify-theft-by-clang (IPv6
only) for more comments. If that is not the case, please explain why
code working for more than a decade on dozens of OSes and compilers
stops working with clang.


Shalom-Salam,

Werner

--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH 4/5] Deal with c99 inline semantics. [ In reply to ]
On Mon, Nov 05, 2012 at 08:30:18AM +0100, Werner Koch wrote:
> On Sat, 27 Oct 2012 19:56, tk@giga.or.at said:
>
> > Needed for compilation with recent LLVM/Clang.
>
> That might be anotherr clang bug; see
> http://rem.eifzilla.de/archives/2012/08/10/identify-theft-by-clang (IPv6
> only) for more comments. If that is not the case, please explain why
> code working for more than a decade on dozens of OSes and compilers
> stops working with clang.

The difference between gcc and clang here is that clang by default
defines -std=gnu99. You probably will see the same problem when
compiling the code with GCC and that setting (see also
__GNUC_STDC_INLINE__).
Thomas

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH 4/5] Deal with c99 inline semantics. [ In reply to ]
On Mon, 5 Nov 2012 17:29, tk@giga.or.at said:

> The difference between gcc and clang here is that clang by default
> defines -std=gnu99. You probably will see the same problem when
> compiling the code with GCC and that setting (see also

But it seems not to behave exactly as defined for gnu99. If you can
show that there is a problem when using gcc -std=gnu99 I will look at it
again.


Shalom-Salam,

Werner

--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH 4/5] Deal with c99 inline semantics. [ In reply to ]
On Tue, Nov 06, 2012 at 08:37:46AM +0100, Werner Koch wrote:
> On Mon, 5 Nov 2012 17:29, tk@giga.or.at said:
>
> > The difference between gcc and clang here is that clang by default
> > defines -std=gnu99. You probably will see the same problem when
> > compiling the code with GCC and that setting (see also
>
> But it seems not to behave exactly as defined for gnu99. If you can
> show that there is a problem when using gcc -std=gnu99 I will look at it
> again.

That's easy, here goes:
# gcc --version
gcc (NetBSD nb1 20120916) 4.5.4
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# cd /tmp
# tar xzf /distfiles/gnupg-1.4.12.tar.bz2
# cd gnupg-1.4.12
# ./configure CPPFLAGS=-std=gnu99
...
# gmake CPPFLAGS=-std=gnu99
...
gcc -g -O2 -Wall -Wno-pointer-sign -o mpicalc mpicalc.o ../cipher/libcipher.a ../mpi/libmpi.a ../util/libutil.a ../intl/libintl.a
../mpi/libmpi.a(mpi-bit.o): In function `mpihelp_add_1':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:41: multiple definition of `mpihelp_add_1'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:41: first defined here
../mpi/libmpi.a(mpi-bit.o): In function `mpihelp_add':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:68: multiple definition of `mpihelp_add'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:68: first defined here
../mpi/libmpi.a(mpi-bit.o): In function `mpihelp_sub_1':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:87: multiple definition of `mpihelp_sub_1'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:87: first defined here
../mpi/libmpi.a(mpi-bit.o): In function `mpihelp_sub':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:114: multiple definition of `mpihelp_sub'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:114: first defined here
../mpi/libmpi.a(mpi-div.o): In function `mpihelp_add_1':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:41: multiple definition of `mpihelp_add_1'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:41: first defined here
../mpi/libmpi.a(mpi-div.o): In function `mpihelp_add':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:68: multiple definition of `mpihelp_add'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:68: first defined here
../mpi/libmpi.a(mpi-div.o): In function `mpihelp_sub_1':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:87: multiple definition of `mpihelp_sub_1'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:87: first defined here
../mpi/libmpi.a(mpi-div.o): In function `mpihelp_sub':
/tmp/gnupg-1.4.12/mpi/mpi-inline.h:114: multiple definition of `mpihelp_sub'
../mpi/libmpi.a(mpi-add.o):/tmp/gnupg-1.4.12/mpi/mpi-inline.h:114: first defined here
../mpi/libmpi.a(mpi-gcd.o): In function `mpihelp_add_1':
(and lots more of the same)

Thomas

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH 4/5] Deal with c99 inline semantics. [ In reply to ]
On Tue, 6 Nov 2012 08:52, tk@giga.or.at said:

>> But it seems not to behave exactly as defined for gnu99. If you can
>> show that there is a problem when using gcc -std=gnu99 I will look at it
>> again.
>
> That's easy, here goes:

You are right. I just pushed this:

>From 5093bed27580e608de073bcc5953bd76b6b8b2de Mon Sep 17 00:00:00 2001
From: Werner Koch <wk@gnupg.org>
Date: Tue, 6 Nov 2012 17:14:04 +0100
Subject: [PATCH] Fix extern inline use for gcc > 4.3 in c99 mode

* mpi/mpi-inline.h [!G10_MPI_INLINE_DECL]: Take care of changed extern
inline semantics in gcc.
--

I am not use how this will work out with non-gcc. However, we had no
problems in the past and thus this change is the least invasive for
non-gcc compilers.
---
mpi/mpi-inline.h | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/mpi/mpi-inline.h b/mpi/mpi-inline.h
index c32adae..6e44518 100644
--- a/mpi/mpi-inline.h
+++ b/mpi/mpi-inline.h
@@ -28,8 +28,15 @@
#ifndef G10_MPI_INLINE_H
#define G10_MPI_INLINE_H

+/* Starting with gcc 4.3 "extern inline" conforms in c99 mode to the
+ c99 semantics. To keep the useful old semantics we use an
+ attribute. */
#ifndef G10_MPI_INLINE_DECL
-#define G10_MPI_INLINE_DECL extern __inline__
+# ifdef __GNUC_STDC_INLINE__
+# define G10_MPI_INLINE_DECL extern inline __attribute__ ((__gnu_inline__))
+# else
+# define G10_MPI_INLINE_DECL extern __inline__
+# endif
#endif

G10_MPI_INLINE_DECL mpi_limb_t
--
1.7.7.1


Thanks,

Werner


--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.


_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Re: [PATCH 4/5] Deal with c99 inline semantics. [ In reply to ]
On Tue, Nov 06, 2012 at 05:19:12PM +0100, Werner Koch wrote:
> You are right. I just pushed this:
>
> >From 5093bed27580e608de073bcc5953bd76b6b8b2de Mon Sep 17 00:00:00 2001
> From: Werner Koch <wk@gnupg.org>
> Date: Tue, 6 Nov 2012 17:14:04 +0100
> Subject: [PATCH] Fix extern inline use for gcc > 4.3 in c99 mode
>
> * mpi/mpi-inline.h [!G10_MPI_INLINE_DECL]: Take care of changed extern
> inline semantics in gcc.

That works as well, thanks. I've switched pkgsrc to use this.
Thomas

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel