Joe Perches
2018-Jun-05 17:23 UTC
[PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
On Tue, 2018-06-05 at 10:05 -0700, Nick Desaulniers wrote:> Functions marked extern inline do not emit an externally visible > function when the gnu89 C standard is used. Some KBUILD Makefiles > overwrite KBUILD_CFLAGS. This is an issue for GCC 5.1+ users as without > an explicit C standard specified, the default is gnu11. Since c99, the > semantics of extern inline have changed such that an externally visible > function is always emitted. This can lead to multiple definition errors > of extern inline functions at link time of compilation units whose build > files have removed an explicit C standard compiler flag for users of GCC > 5.1+ or Clang.[]> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h[]> @@ -72,17 +72,24 @@ > * -Wunused-function. This turns out to avoid the need for complex #ifdef > * directives. Suppress the warning in clang as well by using "unused" > * function attribute, which is redundant but not harmful for gcc. > + * Prefer gnu_inline, so that extern inline functions do not emit an > + * externally visible function. This makes extern inline behave as per gnu89 > + * semantics rather than c99. This prevents multiple symbol definition errors > + * of extern inline functions at link time. > */ > #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ > !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) > -#define inline inline __attribute__((always_inline,unused)) notrace > -#define __inline__ __inline__ __attribute__((always_inline,unused)) notrace > -#define __inline __inline __attribute__((always_inline,unused)) notrace > +#define inline \ > + inline __attribute__((always_inline, unused, gnu_inline)) notrace > +#define __inline__ \ > + __inline__ __attribute__((always_inline, unused, gnu_inline)) notrace > +#define __inline \ > + __inline __attribute__((always_inline, unused, gnu_inline)) notracePerhaps these are simpler as #define __inline__ inline #define __inline inline> #else > /* A lot of inline functions can cause havoc with function tracing */ > -#define inline inline __attribute__((unused)) notrace > -#define __inline__ __inline__ __attribute__((unused)) notrace > -#define __inline __inline __attribute__((unused)) notrace > +#define inline inline __attribute__((unused, gnu_inline)) notrace > +#define __inline__ __inline__ __attribute__((unused, gnu_inline)) notrace > +#define __inline __inline __attribute__((unused, gnu_inline)) notrace > #endifAnd only set once along with:> #define __always_inline inline __attribute__((always_inline))And perhaps this __always_inline should be updated with gnu_inline as well
Joe Perches
2018-Jun-05 19:13 UTC
[PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
On Tue, 2018-06-05 at 10:23 -0700, Joe Perches wrote:> Perhaps these are simpler as > > #define __inline__ inline > #define __inline inlineCurrently, there are these uses of inline variants in the kernel $ git grep -w inline | wc -l 68410 $ git grep -w __inline__ | wc -l 503 $ git grep -w __inline | wc -l 57 So it seems it's also reasonable to sed all uses of __inline to inline and perhaps remove __inline eventually altogether. (perhaps there are still too many __inline__ uses) Excluding scripts and a few other files, here's a possible patch done with: $ git grep -w --name-only __inline | \ grep -vP '^(?:arch/alpha/|include/|scripts/)' | \ xargs sed -r -i -e 's/\b__inline\b/inline/g' \ -e 's/\binline\s+static\b/static inline/g' --- Documentation/trace/tracepoint-analysis.rst | 2 +- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/include/drv_types.h | 6 +++--- drivers/staging/rtl8723bs/include/ieee80211.h | 6 +++--- drivers/staging/rtl8723bs/include/osdep_service.h | 10 +++++----- drivers/staging/rtl8723bs/include/osdep_service_linux.h | 14 +++++++------- drivers/staging/rtl8723bs/include/rtw_mlme.h | 14 +++++++------- drivers/staging/rtl8723bs/include/rtw_recv.h | 16 ++++++++-------- drivers/staging/rtl8723bs/include/sta_info.h | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 14 +++++++------- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 2 +- lib/zstd/mem.h | 2 +- 13 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Documentation/trace/tracepoint-analysis.rst b/Documentation/trace/tracepoint-analysis.rst index a4d3ff2e5efb..310f4c579cff 100644 --- a/Documentation/trace/tracepoint-analysis.rst +++ b/Documentation/trace/tracepoint-analysis.rst @@ -315,7 +315,7 @@ To see where within the function pixmanFillsse2 things are going wrong: 0.00 : 34eeb: 0f 18 08 prefetcht0 (%eax) : } : - : extern __inline void __attribute__((__gnu_inline__, __always_inline__, _ + : extern inline void __attribute__((__gnu_inline__, __always_inline__, _ : _mm_store_si128 (__m128i *__P, __m128i __B) : { : *__P = __B; 12.40 : 34eee: 66 0f 7f 80 40 ff ff movdqa %xmm0,-0xc0(%eax) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 85f7769ecc2d..811492e64350 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -839,12 +839,12 @@ static void pwr_rpwm_timeout_handler(struct timer_list *t) _set_workitem(&pwrpriv->rpwmtimeoutwi); } -static __inline void register_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) +static inline void register_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) { pwrctrl->alives |= tag; } -static __inline void unregister_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) +static inline void unregister_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) { pwrctrl->alives &= ~tag; } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index f6dc26c8bd3d..4e16087ef815 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -493,7 +493,7 @@ void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigne mutex_unlock(&(adapter_to_dvobj(padapter)->setch_mutex)); } -__inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) +inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) { return pnetwork->MacAddress; } diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index 16b81b1a3f33..5d487243a822 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -493,7 +493,7 @@ struct dvobj_priv #define dvobj_to_pwrctl(dvobj) (&(dvobj->pwrctl_priv)) #define pwrctl_to_dvobj(pwrctl) container_of(pwrctl, struct dvobj_priv, pwrctl_priv) -__inline static struct device *dvobj_to_dev(struct dvobj_priv *dvobj) +static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) { /* todo: get interface type from dvobj and the return the dev accordingly */ #ifdef RTW_DVOBJ_CHIP_HW_TYPE @@ -651,14 +651,14 @@ struct adapter { /* define RTW_DISABLE_FUNC(padapter, func) (atomic_add(&adapter_to_dvobj(padapter)->disable_func, (func))) */ /* define RTW_ENABLE_FUNC(padapter, func) (atomic_sub(&adapter_to_dvobj(padapter)->disable_func, (func))) */ -__inline static void RTW_DISABLE_FUNC(struct adapter *padapter, int func_bit) +static inline void RTW_DISABLE_FUNC(struct adapter *padapter, int func_bit) { int df = atomic_read(&adapter_to_dvobj(padapter)->disable_func); df |= func_bit; atomic_set(&adapter_to_dvobj(padapter)->disable_func, df); } -__inline static void RTW_ENABLE_FUNC(struct adapter *padapter, int func_bit) +static inline void RTW_ENABLE_FUNC(struct adapter *padapter, int func_bit) { int df = atomic_read(&adapter_to_dvobj(padapter)->disable_func); df &= ~(func_bit); diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index c8e5251c2760..78a4f2d836ce 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -858,18 +858,18 @@ enum ieee80211_state { #define IP_FMT "%pI4" #define IP_ARG(x) (x) -extern __inline int is_multicast_mac_addr(const u8 *addr) +extern inline int is_multicast_mac_addr(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } -extern __inline int is_broadcast_mac_addr(const u8 *addr) +extern inline int is_broadcast_mac_addr(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); } -extern __inline int is_zero_mac_addr(const u8 *addr) +extern inline int is_zero_mac_addr(const u8 *addr) { return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index e62ed71e1d80..ffaf9e366364 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -118,12 +118,12 @@ int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb); extern void _rtw_init_queue(struct __queue *pqueue); -static __inline void thread_enter(char *name) +static inline void thread_enter(char *name) { allow_signal(SIGTERM); } -__inline static void flush_signals_thread(void) +static inline void flush_signals_thread(void) { if (signal_pending (current)) { @@ -133,7 +133,7 @@ __inline static void flush_signals_thread(void) #define rtw_warn_on(condition) WARN_ON(condition) -__inline static int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *parg4) +static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *parg4) { int ret = true; @@ -144,7 +144,7 @@ __inline static int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *p #define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r)) #define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0: 1)) << 2) -__inline static u32 _RND4(u32 sz) +static inline u32 _RND4(u32 sz) { u32 val; @@ -155,7 +155,7 @@ __inline static u32 _RND4(u32 sz) } -__inline static u32 _RND8(u32 sz) +static inline u32 _RND8(u32 sz) { u32 val; diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index 711863d74a01..a8d5456d7f85 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -74,12 +74,12 @@ typedef struct work_struct _workitem; -__inline static struct list_head *get_next(struct list_head *list) +static inline struct list_head *get_next(struct list_head *list) { return list->next; } -__inline static struct list_head *get_list_head(struct __queue *queue) +static inline struct list_head *get_list_head(struct __queue *queue) { return (&(queue->queue)); } @@ -88,28 +88,28 @@ __inline static struct list_head *get_list_head(struct __queue *queue) #define LIST_CONTAINOR(ptr, type, member) \ container_of(ptr, type, member) -__inline static void _set_timer(_timer *ptimer, u32 delay_time) +static inline void _set_timer(_timer *ptimer, u32 delay_time) { mod_timer(ptimer , (jiffies+(delay_time*HZ/1000))); } -__inline static void _cancel_timer(_timer *ptimer, u8 *bcancelled) +static inline void _cancel_timer(_timer *ptimer, u8 *bcancelled) { del_timer_sync(ptimer); *bcancelled = true;/* true == 1; false == 0 */ } -__inline static void _init_workitem(_workitem *pwork, void *pfunc, void *cntx) +static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx) { INIT_WORK(pwork, pfunc); } -__inline static void _set_workitem(_workitem *pwork) +static inline void _set_workitem(_workitem *pwork) { schedule_work(pwork); } -__inline static void _cancel_workitem_sync(_workitem *pwork) +static inline void _cancel_workitem_sync(_workitem *pwork) { cancel_work_sync(pwork); } diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index 2e4f12b54929..40af3a34ed05 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -533,13 +533,13 @@ extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv); extern sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue); extern sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv); -__inline static u8 *get_bssid(struct mlme_priv *pmlmepriv) +static inline u8 *get_bssid(struct mlme_priv *pmlmepriv) { /* if sta_mode:pmlmepriv->cur_network.network.MacAddress => bssid */ /* if adhoc_mode:pmlmepriv->cur_network.network.MacAddress => ibss mac address */ return pmlmepriv->cur_network.network.MacAddress; } -__inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state) +static inline sint check_fwstate(struct mlme_priv *pmlmepriv, sint state) { if (pmlmepriv->fw_state & state) return true; @@ -547,7 +547,7 @@ __inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state) return false; } -__inline static sint get_fwstate(struct mlme_priv *pmlmepriv) +static inline sint get_fwstate(struct mlme_priv *pmlmepriv) { return pmlmepriv->fw_state; } @@ -559,7 +559,7 @@ __inline static sint get_fwstate(struct mlme_priv *pmlmepriv) * ### NOTE:#### (!!!!) * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock */ -__inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state) +static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state) { pmlmepriv->fw_state |= state; /* FOR HW integration */ @@ -568,7 +568,7 @@ __inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state) } } -__inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state) +static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state) { pmlmepriv->fw_state &= ~state; /* FOR HW integration */ @@ -581,7 +581,7 @@ __inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state) * No Limit on the calling context, * therefore set it to be the critical section... */ -__inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state) +static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state) { spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, state) == true) @@ -589,7 +589,7 @@ __inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state) spin_unlock_bh(&pmlmepriv->lock); } -__inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val) +static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val) { spin_lock_bh(&pmlmepriv->lock); pmlmepriv->num_of_scanned = val; diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h index d4986f5685c5..eac0c4870dd4 100644 --- a/drivers/staging/rtl8723bs/include/rtw_recv.h +++ b/drivers/staging/rtl8723bs/include/rtw_recv.h @@ -413,7 +413,7 @@ struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue); void rtw_reordering_ctrl_timeout_handler(struct timer_list *t); -__inline static u8 *get_rxmem(union recv_frame *precvframe) +static inline u8 *get_rxmem(union recv_frame *precvframe) { /* always return rx_head... */ if (precvframe == NULL) @@ -422,7 +422,7 @@ __inline static u8 *get_rxmem(union recv_frame *precvframe) return precvframe->u.hdr.rx_head; } -__inline static u8 *get_recvframe_data(union recv_frame *precvframe) +static inline u8 *get_recvframe_data(union recv_frame *precvframe) { /* alwasy return rx_data */ @@ -433,7 +433,7 @@ __inline static u8 *get_recvframe_data(union recv_frame *precvframe) } -__inline static u8 *recvframe_pull(union recv_frame *precvframe, sint sz) +static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz) { /* rx_data += sz; move rx_data sz bytes hereafter */ @@ -458,7 +458,7 @@ __inline static u8 *recvframe_pull(union recv_frame *precvframe, sint sz) } -__inline static u8 *recvframe_put(union recv_frame *precvframe, sint sz) +static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz) { /* rx_tai += sz; move rx_tail sz bytes hereafter */ @@ -487,7 +487,7 @@ __inline static u8 *recvframe_put(union recv_frame *precvframe, sint sz) -__inline static u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz) +static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz) { /* rmv data from rx_tail (by yitsen) */ @@ -511,7 +511,7 @@ __inline static u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz) } -__inline static union recv_frame *rxmem_to_recvframe(u8 *rxmem) +static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem) { /* due to the design of 2048 bytes alignment of recv_frame, we can reference the union recv_frame */ /* from any given member of recv_frame. */ @@ -521,13 +521,13 @@ __inline static union recv_frame *rxmem_to_recvframe(u8 *rxmem) } -__inline static sint get_recvframe_len(union recv_frame *precvframe) +static inline sint get_recvframe_len(union recv_frame *precvframe) { return precvframe->u.hdr.len; } -__inline static s32 translate_percentage_to_dbm(u32 SignalStrengthIndex) +static inline s32 translate_percentage_to_dbm(u32 SignalStrengthIndex) { s32 SignalPower; /* in dBm. */ diff --git a/drivers/staging/rtl8723bs/include/sta_info.h b/drivers/staging/rtl8723bs/include/sta_info.h index 84fa116fc5da..c1f7b9eed611 100644 --- a/drivers/staging/rtl8723bs/include/sta_info.h +++ b/drivers/staging/rtl8723bs/include/sta_info.h @@ -356,7 +356,7 @@ struct sta_priv { }; -__inline static u32 wifi_mac_hash(u8 *mac) +static inline u32 wifi_mac_hash(u8 *mac) { u32 x; diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 530d698f50d9..475f2e07ad02 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -355,7 +355,7 @@ enum WIFI_REG_DOMAIN { (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ ) -__inline static int IS_MCAST(unsigned char *da) +static inline int IS_MCAST(unsigned char *da) { if ((*da) & 0x01) return true; @@ -363,20 +363,20 @@ __inline static int IS_MCAST(unsigned char *da) return false; } -__inline static unsigned char * get_ra(unsigned char *pframe) +static inline unsigned char * get_ra(unsigned char *pframe) { unsigned char *ra; ra = GetAddr1Ptr(pframe); return ra; } -__inline static unsigned char * get_ta(unsigned char *pframe) +static inline unsigned char * get_ta(unsigned char *pframe) { unsigned char *ta; ta = GetAddr2Ptr(pframe); return ta; } -__inline static unsigned char * get_da(unsigned char *pframe) +static inline unsigned char * get_da(unsigned char *pframe) { unsigned char *da; unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); @@ -400,7 +400,7 @@ __inline static unsigned char * get_da(unsigned char *pframe) } -__inline static unsigned char * get_sa(unsigned char *pframe) +static inline unsigned char * get_sa(unsigned char *pframe) { unsigned char *sa; unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); @@ -423,7 +423,7 @@ __inline static unsigned char * get_sa(unsigned char *pframe) return sa; } -__inline static unsigned char * get_hdr_bssid(unsigned char *pframe) +static inline unsigned char * get_hdr_bssid(unsigned char *pframe) { unsigned char *sa = NULL; unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); @@ -447,7 +447,7 @@ __inline static unsigned char * get_hdr_bssid(unsigned char *pframe) } -__inline static int IsFrameTypeCtrl(unsigned char *pframe) +static inline int IsFrameTypeCtrl(unsigned char *pframe) { if (WIFI_CTRL_TYPE == GetFrameType(pframe)) return true; diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index af78d97980fa..767c444acc54 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -231,7 +231,7 @@ struct wlan_bssid_ex { u8 IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and capability information) */ } __packed; -__inline static uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) +static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) { return (sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->IELength); } diff --git a/lib/zstd/mem.h b/lib/zstd/mem.h index 3a0f34c8706c..739837a59ad6 100644 --- a/lib/zstd/mem.h +++ b/lib/zstd/mem.h @@ -27,7 +27,7 @@ /*-**************************************** * Compiler specifics ******************************************/ -#define ZSTD_STATIC static __inline __attribute__((unused)) +#define ZSTD_STATIC static inline __attribute__((unused)) /*-************************************************************** * Basic Types
Joe Perches
2018-Jun-05 21:59 UTC
[PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
On Tue, 2018-06-05 at 12:50 -0700, Nick Desaulniers wrote:> On Tue, Jun 5, 2018 at 12:14 PM Joe Perches <joe at perches.com> wrote: > > > > On Tue, 2018-06-05 at 10:23 -0700, Joe Perches wrote: > > > Perhaps these are simpler as > > > > > > #define __inline__ inline > > > #define __inline inline > > > > Currently, there are these uses of inline variants in the kernel > > > > $ git grep -w inline | wc -l > > 68410 > > $ git grep -w __inline__ | wc -l > > 503 > > $ git grep -w __inline | wc -l > > 57 > > > > So it seems it's also reasonable to sed all uses of __inline to inline > > and perhaps remove __inline eventually altogether. > > (perhaps there are still too many __inline__ uses) > > Yeah, that sounds good. Should I split that into 3 patches: > > > Excluding scripts and a few other files, > > here's a possible patch done with: > > > > $ git grep -w --name-only __inline | \ > > grep -vP '^(?:arch/alpha/|include/|scripts/)' | \ > > xargs sed -r -i -e 's/\b__inline\b/inline/g' \ > > -e 's/\binline\s+static\b/static inline/g' > > --- > > Documentation/trace/tracepoint-analysis.rst | 2 +- > > drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- > > drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- > > drivers/staging/rtl8723bs/include/drv_types.h | 6 +++--- > > drivers/staging/rtl8723bs/include/ieee80211.h | 6 +++--- > > drivers/staging/rtl8723bs/include/osdep_service.h | 10 +++++----- > > drivers/staging/rtl8723bs/include/osdep_service_linux.h | 14 +++++++------- > > drivers/staging/rtl8723bs/include/rtw_mlme.h | 14 +++++++------- > > drivers/staging/rtl8723bs/include/rtw_recv.h | 16 ++++++++-------- > > drivers/staging/rtl8723bs/include/sta_info.h | 2 +- > > drivers/staging/rtl8723bs/include/wifi.h | 14 +++++++------- > > drivers/staging/rtl8723bs/include/wlan_bssdef.h | 2 +- > > lib/zstd/mem.h | 2 +- > > 13 files changed, 47 insertions(+), 47 deletions(-) > > > 1 for documentation, 1 for rtl8723bs, 1 for zstd?Seems sensible to me.> Follow up set or include in v3?Your choice. Probably a follow up would work best. Also, the remaining __inline uses would be: arch/alpha/include/asm/compiler.h:#undef __inline include/linux/compiler-gcc.h:#define __inline __inline __attribute__((always_inline,unused)) notrace include/linux/compiler-gcc.h:#define __inline __inline __attribute__((unused)) notrace scripts/checkpatch.pl:our $Inline = qr{inline|__always_inline|noinline|__inline|__inline__}; scripts/checkpatch.pl:# Check for __inline__ and __inline, prefer inline scripts/checkpatch.pl: $line =~ /\b(__inline__|__inline)\b/) { scripts/checkpatch.pl: $fixed[$fixlinenr] =~ s/\b(__inline__|__inline)\b/inline/; scripts/genksyms/keywords.c: { "__inline", INLINE_KEYW }, scripts/kernel-doc: $prototype =~ s/^__inline +//; So all of these could be removed/updated appropriately too
hpa at zytor.com
2018-Jun-06 16:39 UTC
[PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
On June 6, 2018 1:05:45 AM PDT, Sedat Dilek <sedat.dilek at gmail.com> 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.
Apparently Analagous Threads
- [PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
- PROPOSAL: Extend inline asm syntax with size spec
- [PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
- [PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
- [PATCH v3 1/3] compiler-gcc.h: add gnu_inline to all inline declarations