public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: mpi: Use "static inline" instead of "extern inline" in header file for __GNUC__
@ 2014-11-09  8:58 Chen Gang
  2014-11-09  9:11 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Gang @ 2014-11-09  8:58 UTC (permalink / raw)
  To: dmitry.kasatkin; +Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org

In header file, "extern inline" may cause multiple definition, so need
change it to "static inline". And also need be quoted  by __GNUC__ for
they are as inline functions only for __GNUC__.

The related error (with allmodconfig under tile):

    LD      lib/mpi/mpi.o
  lib/mpi/generic_mpih-mul1.o: In function `mpihelp_add_1':
  generic_mpih-mul1.c:(.text+0x0): multiple definition of `mpihelp_add_1'
  lib/mpi/generic_mpih-lshift.o:generic_mpih-lshift.c:(.text+0x0): first defined here
  lib/mpi/generic_mpih-mul1.o: In function `mpihelp_add':
  generic_mpih-mul1.c:(.text+0xe8): multiple definition of `mpihelp_add'
  lib/mpi/generic_mpih-lshift.o:generic_mpih-lshift.c:(.text+0xe8): first defined here
  lib/mpi/generic_mpih-mul1.o: In function `mpihelp_sub_1':
  generic_mpih-mul1.c:(.text+0x278): multiple definition of `mpihelp_sub_1'
  lib/mpi/generic_mpih-lshift.o:generic_mpih-lshift.c:(.text+0x278): first defined here
  lib/mpi/generic_mpih-mul1.o: In function `mpihelp_sub':
  generic_mpih-mul1.c:(.text+0x368): multiple definition of `mpihelp_sub'
  lib/mpi/generic_mpih-lshift.o:generic_mpih-lshift.c:(.text+0x368): first defined here
  ...

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 lib/mpi/mpi-inline.h   |  2 +-
 lib/mpi/mpi-internal.h | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/mpi/mpi-inline.h b/lib/mpi/mpi-inline.h
index e2b3985..c245ea3 100644
--- a/lib/mpi/mpi-inline.h
+++ b/lib/mpi/mpi-inline.h
@@ -30,7 +30,7 @@
 #define G10_MPI_INLINE_H
 
 #ifndef G10_MPI_INLINE_DECL
-#define G10_MPI_INLINE_DECL  extern inline
+#define G10_MPI_INLINE_DECL  static inline
 #endif
 
 G10_MPI_INLINE_DECL mpi_limb_t
diff --git a/lib/mpi/mpi-internal.h b/lib/mpi/mpi-internal.h
index 60cf765..91ef8ac 100644
--- a/lib/mpi/mpi-internal.h
+++ b/lib/mpi/mpi-internal.h
@@ -168,20 +168,24 @@ void mpi_rshift_limbs(MPI a, unsigned int count);
 int mpi_lshift_limbs(MPI a, unsigned int count);
 
 /*-- mpihelp-add.c --*/
+#ifndef __GNUC__
 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,
-			 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,
 		       mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+#endif
+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);
 
 /*-- mpihelp-sub.c --*/
+#ifndef __GNUC__
 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,
-			 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,
 		       mpi_ptr_t s2_ptr, mpi_size_t s2_size);
+#endif
+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);
 
 /*-- mpihelp-cmp.c --*/
 int mpihelp_cmp(mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size);
-- 
1.9.3

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

* Re: [PATCH] lib: mpi: Use "static inline" instead of "extern inline" in header file for __GNUC__
  2014-11-09  8:58 [PATCH] lib: mpi: Use "static inline" instead of "extern inline" in header file for __GNUC__ Chen Gang
@ 2014-11-09  9:11 ` Joe Perches
  2014-11-09  9:25   ` Chen Gang
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2014-11-09  9:11 UTC (permalink / raw)
  To: Chen Gang
  Cc: dmitry.kasatkin, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org

On Sun, 2014-11-09 at 16:58 +0800, Chen Gang wrote:
> In header file, "extern inline" may cause multiple definition, so need
> change it to "static inline". And also need be quoted  by __GNUC__ for
> they are as inline functions only for __GNUC__.
[]
> diff --git a/lib/mpi/mpi-inline.h b/lib/mpi/mpi-inline.h
[]
> @@ -30,7 +30,7 @@
>  #define G10_MPI_INLINE_H
>  
>  #ifndef G10_MPI_INLINE_DECL
> -#define G10_MPI_INLINE_DECL  extern inline
> +#define G10_MPI_INLINE_DECL  static inline

Why not remove the #define and use static inline
in the 4 places the #define is currently used?



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

* Re: [PATCH] lib: mpi: Use "static inline" instead of "extern inline" in header file for __GNUC__
  2014-11-09  9:11 ` Joe Perches
@ 2014-11-09  9:25   ` Chen Gang
  0 siblings, 0 replies; 3+ messages in thread
From: Chen Gang @ 2014-11-09  9:25 UTC (permalink / raw)
  To: Joe Perches
  Cc: dmitry.kasatkin, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org

On 11/09/2014 05:11 PM, Joe Perches wrote:
> On Sun, 2014-11-09 at 16:58 +0800, Chen Gang wrote:
>> In header file, "extern inline" may cause multiple definition, so need
>> change it to "static inline". And also need be quoted  by __GNUC__ for
>> they are as inline functions only for __GNUC__.
> []
>> diff --git a/lib/mpi/mpi-inline.h b/lib/mpi/mpi-inline.h
> []
>> @@ -30,7 +30,7 @@
>>  #define G10_MPI_INLINE_H
>>  
>>  #ifndef G10_MPI_INLINE_DECL
>> -#define G10_MPI_INLINE_DECL  extern inline
>> +#define G10_MPI_INLINE_DECL  static inline
> 
> Why not remove the #define and use static inline
> in the 4 places the #define is currently used?
> 

I just follow the original author's ways, the original author may think
it is useful.

I guess, it may be used by other systems (neither Linux kernel nor gcc).
For another compiler, it may need another syntax for it (although I am
not quite sure about it).

So for safety reason, still keep it no touch, at present.

Thanks.
-- 
Chen Gang

Open share and attitude like air water and life which God blessed

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

end of thread, other threads:[~2014-11-09  9:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09  8:58 [PATCH] lib: mpi: Use "static inline" instead of "extern inline" in header file for __GNUC__ Chen Gang
2014-11-09  9:11 ` Joe Perches
2014-11-09  9:25   ` Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox