Skip to content

Commit 152df97

Browse files
author
Davi Arnaut
committed
WL#5498: Remove dead and unused source code
Remove wrappers around inline -- static inline is used without wrappers throughout the source code. We rely on the compiler or linker to eliminate unused static functions.
1 parent e815069 commit 152df97

6 files changed

Lines changed: 14 additions & 76 deletions

File tree

configure.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ case $SYSTEM_TYPE in
12101210
# Fixes for HPUX 11.0 compiler
12111211
if test "$ac_cv_prog_gcc" = "no"
12121212
then
1213-
CFLAGS="$CFLAGS -DHAVE_BROKEN_INLINE"
12141213
# set working flags first in line, letting override it (i. e. for debug):
12151214
CXXFLAGS="+O2 $CXXFLAGS"
12161215
MAX_C_OPTIMIZE=""
@@ -1997,6 +1996,9 @@ fi
19971996
dnl Checks for typedefs, structures, and compiler characteristics.
19981997
AC_C_CONST
19991998
AC_C_INLINE
1999+
AS_IF([test "x$ac_cv_c_inline" = "xno"],
2000+
[AC_MSG_WARN([The C compiler does not support inline. Beware that unused
2001+
functions might not be eliminated the object files.])])
20002002
AC_TYPE_OFF_T
20012003
AC_STRUCT_ST_RDEV
20022004
AC_HEADER_TIME

include/my_atomic.h

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,8 @@ make_transparent_unions(ptr)
155155
#define U_set set
156156
#endif /* __GCC__ transparent_union magic */
157157

158-
#ifdef HAVE_INLINE
159-
160158
#define make_atomic_cas(S) \
161-
STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
159+
static inline int my_atomic_cas ## S(Uv_ ## S U_a, \
162160
Uv_ ## S U_cmp, U_ ## S U_set) \
163161
{ \
164162
int8 ret; \
@@ -167,55 +165,36 @@ STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
167165
}
168166

169167
#define make_atomic_add(S) \
170-
STATIC_INLINE int ## S my_atomic_add ## S( \
168+
static inline int ## S my_atomic_add ## S( \
171169
Uv_ ## S U_a, U_ ## S U_v) \
172170
{ \
173171
make_atomic_add_body(S); \
174172
return v; \
175173
}
176174

177175
#define make_atomic_fas(S) \
178-
STATIC_INLINE int ## S my_atomic_fas ## S( \
176+
static inline int ## S my_atomic_fas ## S( \
179177
Uv_ ## S U_a, U_ ## S U_v) \
180178
{ \
181179
make_atomic_fas_body(S); \
182180
return v; \
183181
}
184182

185183
#define make_atomic_load(S) \
186-
STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \
184+
static inline int ## S my_atomic_load ## S(Uv_ ## S U_a) \
187185
{ \
188186
int ## S ret; \
189187
make_atomic_load_body(S); \
190188
return ret; \
191189
}
192190

193191
#define make_atomic_store(S) \
194-
STATIC_INLINE void my_atomic_store ## S( \
192+
static inline void my_atomic_store ## S( \
195193
Uv_ ## S U_a, U_ ## S U_v) \
196194
{ \
197195
make_atomic_store_body(S); \
198196
}
199197

200-
#else /* no inline functions */
201-
202-
#define make_atomic_add(S) \
203-
extern int ## S my_atomic_add ## S(Uv_ ## S U_a, U_ ## S U_v);
204-
205-
#define make_atomic_fas(S) \
206-
extern int ## S my_atomic_fas ## S(Uv_ ## S U_a, U_ ## S U_v);
207-
208-
#define make_atomic_cas(S) \
209-
extern int my_atomic_cas ## S(Uv_ ## S U_a, Uv_ ## S U_cmp, U_ ## S U_set);
210-
211-
#define make_atomic_load(S) \
212-
extern int ## S my_atomic_load ## S(Uv_ ## S U_a);
213-
214-
#define make_atomic_store(S) \
215-
extern void my_atomic_store ## S(Uv_ ## S U_a, U_ ## S U_v);
216-
217-
#endif /* HAVE_INLINE */
218-
219198
#ifdef MY_ATOMIC_HAS_8_16
220199
make_atomic_cas(8)
221200
make_atomic_cas(16)

include/my_bit.h

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
C_MODE_START
9-
#ifdef HAVE_INLINE
109

1110
extern const char _my_bits_nbits[256];
1211
extern const uchar _my_bits_reverse_table[256];
@@ -16,14 +15,14 @@ extern const uchar _my_bits_reverse_table[256];
1615
This can be used to divide a number with value by doing a shift instead
1716
*/
1817

19-
STATIC_INLINE uint my_bit_log2(ulong value)
18+
static inline uint my_bit_log2(ulong value)
2019
{
2120
uint bit;
2221
for (bit=0 ; value > 1 ; value>>=1, bit++) ;
2322
return bit;
2423
}
2524

26-
STATIC_INLINE uint my_count_bits(ulonglong v)
25+
static inline uint my_count_bits(ulonglong v)
2726
{
2827
#if SIZEOF_LONG_LONG > 4
2928
/* The following code is a bit faster on 16 bit machines than if we would
@@ -45,7 +44,7 @@ STATIC_INLINE uint my_count_bits(ulonglong v)
4544
#endif
4645
}
4746

48-
STATIC_INLINE uint my_count_bits_ushort(ushort v)
47+
static inline uint my_count_bits_ushort(ushort v)
4948
{
5049
return _my_bits_nbits[v];
5150
}
@@ -70,7 +69,7 @@ STATIC_INLINE uint my_count_bits_ushort(ushort v)
7069
Comments shows how this works with 01100000000000000000000000001011
7170
*/
7271

73-
STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v)
72+
static inline uint32 my_round_up_to_next_power(uint32 v)
7473
{
7574
v--; /* 01100000000000000000000000001010 */
7675
v|= v >> 1; /* 01110000000000000000000000001111 */
@@ -81,7 +80,7 @@ STATIC_INLINE uint32 my_round_up_to_next_power(uint32 v)
8180
return v+1; /* 10000000000000000000000000000000 */
8281
}
8382

84-
STATIC_INLINE uint32 my_clear_highest_bit(uint32 v)
83+
static inline uint32 my_clear_highest_bit(uint32 v)
8584
{
8685
uint32 w=v >> 1;
8786
w|= w >> 1;
@@ -92,7 +91,7 @@ STATIC_INLINE uint32 my_clear_highest_bit(uint32 v)
9291
return v & w;
9392
}
9493

95-
STATIC_INLINE uint32 my_reverse_bits(uint32 key)
94+
static inline uint32 my_reverse_bits(uint32 key)
9695
{
9796
return
9897
(_my_bits_reverse_table[ key & 255] << 24) |
@@ -101,14 +100,6 @@ STATIC_INLINE uint32 my_reverse_bits(uint32 key)
101100
_my_bits_reverse_table[(key>>24) ];
102101
}
103102

104-
#else /* HAVE_INLINE */
105-
extern uint my_bit_log2(ulong value);
106-
extern uint32 my_round_up_to_next_power(uint32 v);
107-
uint32 my_clear_highest_bit(uint32 v);
108-
uint32 my_reverse_bits(uint32 key);
109-
extern uint my_count_bits(ulonglong v);
110-
extern uint my_count_bits_ushort(ushort v);
111-
#endif /* HAVE_INLINE */
112103
C_MODE_END
113104

114105
#endif /* MY_BIT_INCLUDED */

include/my_global.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,6 @@
198198
#define likely(x) __builtin_expect((x),1)
199199
#define unlikely(x) __builtin_expect((x),0)
200200

201-
/*
202-
now let's figure out if inline functions are supported
203-
autoconf defines 'inline' to be empty, if not
204-
*/
205-
#define inline_test_1(X) X ## 1
206-
#define inline_test_2(X) inline_test_1(X)
207-
#if inline_test_2(inline) != 1
208-
#define HAVE_INLINE
209-
#else
210-
#warning No "inline" support in C, all "static inline" functions will be instantiated in every .o file!!!
211-
#endif
212-
#undef inline_test_2
213-
#undef inline_test_1
214-
/* helper macro for "instantiating" inline functions */
215-
#define STATIC_INLINE static inline
216-
217201
/* Fix problem with S_ISLNK() on Linux */
218202
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
219203
#undef _GNU_SOURCE
@@ -323,10 +307,6 @@ C_MODE_END
323307
#undef HAVE_PREAD
324308
#undef HAVE_PWRITE
325309
#endif
326-
#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
327-
#undef inline
328-
#define inline
329-
#endif
330310

331311
#ifdef UNDEF_HAVE_GETHOSTBYNAME_R /* For OSF4.x */
332312
#undef HAVE_GETHOSTBYNAME_R

mysys/my_atomic.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
#include <my_global.h>
1717
#include <my_sys.h>
1818

19-
#ifndef HAVE_INLINE
20-
/* the following will cause all inline functions to be instantiated */
21-
#define HAVE_INLINE
22-
#undef STATIC_INLINE
23-
#define STATIC_INLINE extern
24-
#endif
25-
2619
#include <my_atomic.h>
2720

2821
/*

mysys/my_bit.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515

1616
#include <my_global.h>
1717

18-
#ifndef HAVE_INLINE
19-
/* the following will cause all inline functions to be instantiated */
20-
#define HAVE_INLINE
21-
#undef STATIC_INLINE
22-
#define STATIC_INLINE extern
23-
#endif
24-
2518
#include <my_bit.h>
2619

2720
const char _my_bits_nbits[256] = {

0 commit comments

Comments
 (0)