Re: [PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations

From: hpa
Date: Wed Jun 06 2018 - 12:41:58 EST


On June 6, 2018 1:05:45 AM PDT, Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:
>Hi,
>
>when discovering 'gnu_inline', I found ...
>
>$ git grep -w __FORTIFY_INLINE
>include/linux/string.h:#define __FORTIFY_INLINE extern __always_inline
>__attribute__((gnu_inline))
>include/linux/string.h:__FORTIFY_INLINE char *strncpy(char *p, const
>char *q, __kernel_size_t size)
>include/linux/string.h:__FORTIFY_INLINE char *strcat(char *p, const
>char *q)
>include/linux/string.h:__FORTIFY_INLINE __kernel_size_t strlen(const
>char *p)
>include/linux/string.h:__FORTIFY_INLINE __kernel_size_t strnlen(const
>char *p, __kernel_size_t maxlen)
>include/linux/string.h:__FORTIFY_INLINE size_t strlcpy(char *p, const
>char *q, size_t size)
>include/linux/string.h:__FORTIFY_INLINE char *strncat(char *p, const
>char *q, __kernel_size_t count)
>include/linux/string.h:__FORTIFY_INLINE void *memset(void *p, int c,
>__kernel_size_t size)
>include/linux/string.h:__FORTIFY_INLINE void *memcpy(void *p, const
>void *q, __kernel_size_t size)
>include/linux/string.h:__FORTIFY_INLINE void *memmove(void *p, const
>void *q, __kernel_size_t size)
>include/linux/string.h:__FORTIFY_INLINE void *memscan(void *p, int c,
>__kernel_size_t size)
>include/linux/string.h:__FORTIFY_INLINE int memcmp(const void *p,
>const void *q, __kernel_size_t size)
>include/linux/string.h:__FORTIFY_INLINE void *memchr(const void *p,
>int c, __kernel_size_t size)
>include/linux/string.h:__FORTIFY_INLINE void *memchr_inv(const void
>*p, int c, size_t size)
>include/linux/string.h:__FORTIFY_INLINE void *kmemdup(const void *p,
>size_t size, gfp_t gfp)
>include/linux/string.h:__FORTIFY_INLINE char *strcpy(char *p, const
>char *q)
>
>After the inline changes suggested by Joe this can be adapted?
>
>Beyond this, a general question: Can someone explain why all these
>inline defines are in compiler-gcc.h (as there exists compiler.h and
>compiler-clang.h)?
>
>Thanks.
>
>Regards,
>- Sedat -

Because gcc itself also supports both GNU89-style and C99-style inlines, but the kernel was built with the former, and it is not necessarily a trivial modification, except for "static inline" which is the same for both.

The other option is to pass -fgnu89-inline on the command line, which is supported by both gcc and clang. The two methods are fully equivalent.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.