From: Jonathan Lennox Date: Thu, 27 Oct 2011 16:06:12 +0000 (+0000) Subject: Fix inline functions when compiling as C99. X-Git-Tag: v1.2.20~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50791508b18a5254bdff6013909b989cb2556a6d;p=thirdparty%2Ffreeswitch.git Fix inline functions when compiling as C99. Make private inlines in C files 'static inline', not just 'inline', or the compiler can discard the definition if it chooses not to inline it. Make functions declared in header files not be declared inline (if they're defined in a .c file). It looks like no functions in this category are used in LibSRTP's critical path, only for unit tests or generating AES tables. To see the problem prior to this commit, compile with "gcc -O0 -std=gnu99". Signed-off-by: Travis Cross This cherry-picks commit e2774dbd551ffe5f872eaec2b2d40b712a54e1ba from libsrtp upstream. FS-6196 --resolve --- diff --git a/libs/srtp/crypto/cipher/aes_icm.c b/libs/srtp/crypto/cipher/aes_icm.c index 152e4c93b7..354ad1656d 100644 --- a/libs/srtp/crypto/cipher/aes_icm.c +++ b/libs/srtp/crypto/cipher/aes_icm.c @@ -284,7 +284,7 @@ aes_icm_set_iv(aes_icm_ctx_t *c, void *iv) { * this is an internal, hopefully inlined function */ -inline void +static inline void aes_icm_advance_ismacryp(aes_icm_ctx_t *c, uint8_t forIsmacryp) { /* fill buffer with new keystream */ v128_copy(&c->keystream_buffer, &c->counter); @@ -309,7 +309,7 @@ aes_icm_advance_ismacryp(aes_icm_ctx_t *c, uint8_t forIsmacryp) { } } -inline void aes_icm_advance(aes_icm_ctx_t *c) { +static inline void aes_icm_advance(aes_icm_ctx_t *c) { aes_icm_advance_ismacryp(c, 0); } diff --git a/libs/srtp/crypto/math/datatypes.c b/libs/srtp/crypto/math/datatypes.c index 58c7502176..2bd8c3429f 100644 --- a/libs/srtp/crypto/math/datatypes.c +++ b/libs/srtp/crypto/math/datatypes.c @@ -124,7 +124,7 @@ octet_string_hex_string(const void *s, int length) { return bit_string; } -inline int +static inline int hex_char_to_nibble(uint8_t c) { switch(c) { case ('0'): return 0x0; diff --git a/libs/srtp/crypto/math/gf2_8.c b/libs/srtp/crypto/math/gf2_8.c index 7bd5a0dea2..fe6e4790fc 100644 --- a/libs/srtp/crypto/math/gf2_8.c +++ b/libs/srtp/crypto/math/gf2_8.c @@ -50,7 +50,7 @@ /* gf2_8_shift() moved to gf2_8.h as an inline function */ -inline gf2_8 +gf2_8 gf2_8_multiply(gf2_8 x, gf2_8 y) { gf2_8 z = 0; diff --git a/libs/srtp/crypto/math/math.c b/libs/srtp/crypto/math/math.c index 0d4757792d..c2f2d5b607 100644 --- a/libs/srtp/crypto/math/math.c +++ b/libs/srtp/crypto/math/math.c @@ -173,7 +173,7 @@ v32_weight(v32_t a) { return wt; } -inline unsigned char +unsigned char v32_distance(v32_t x, v32_t y) { x.value ^= y.value; return v32_weight(x); @@ -524,13 +524,13 @@ A_times_x_plus_b(uint8_t A[8], uint8_t x, uint8_t b) { return b; } -inline void +void v16_copy_octet_string(v16_t *x, const uint8_t s[2]) { x->v8[0] = s[0]; x->v8[1] = s[1]; } -inline void +void v32_copy_octet_string(v32_t *x, const uint8_t s[4]) { x->v8[0] = s[0]; x->v8[1] = s[1]; @@ -538,7 +538,7 @@ v32_copy_octet_string(v32_t *x, const uint8_t s[4]) { x->v8[3] = s[3]; } -inline void +void v64_copy_octet_string(v64_t *x, const uint8_t s[8]) { x->v8[0] = s[0]; x->v8[1] = s[1]; @@ -632,7 +632,7 @@ v128_set_bit_to(v128_t *x, int i, int y){ #endif /* DATATYPES_USE_MACROS */ -inline void +static inline void v128_left_shift2(v128_t *x, int num_bits) { int i; int word_shift = num_bits >> 5;