<p>Chris Savinovich has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10933">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">force_inline: remove force_inline type from Asterisk.<br><br>A bug in GCC causes arithmetic calculations to fail if the<br>following conditions are met:<br>1. TEST_FRAMEWORK on<br>2. DONT_OPTIMIZE off<br>3. Fedora and Ubuntu<br>4. GCC 8.2.1<br>5. There must exist a certain combination of multithreading.<br>6. Optimization level -O2 and -O3<br>7. Flag -fpartial-inline activated (happens automatically when -O2)<br>Forcing inlining in our code is the actual error trigger, since it is<br>best to leave it to the compiler to determine what to inline (or so is<br>the new consensus). Therefore this fix removes all instances of<br>type force_inline wherever possible throughout the Asterisk code.<br><br>Change-Id: Iad74c085d98eb61132f39d39c977ceb170d21fc9<br>---<br>M include/asterisk/sem.h<br>M include/asterisk/strings.h<br>M include/asterisk/utils.h<br>M main/audiohook.c<br>M main/sem.c<br>M main/strings.c<br>M utils/extconf.c<br>7 files changed, 167 insertions(+), 184 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/10933/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/sem.h b/include/asterisk/sem.h</span><br><span>index fcab82a..306353f 100644</span><br><span>--- a/include/asterisk/sem.h</span><br><span>+++ b/include/asterisk/sem.h</span><br><span>@@ -28,50 +28,10 @@</span><br><span> * so see the POSIX documentation for further details.</span><br><span> */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifdef HAS_WORKING_SEMAPHORE</span><br><span> /* Working semaphore implementation detected */</span><br><span> </span><br><span> #include <semaphore.h></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-struct ast_sem {</span><br><span style="color: hsl(0, 100%, 40%);">- sem_t real_sem;</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-#define AST_SEM_VALUE_MAX SEM_VALUE_MAX</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/* These are thin wrappers; might as well inline them */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_sem_init(struct ast_sem *sem, int pshared, unsigned int value)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return sem_init(&sem->real_sem, pshared, value);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_sem_destroy(struct ast_sem *sem)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return sem_destroy(&sem->real_sem);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_sem_post(struct ast_sem *sem)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return sem_post(&sem->real_sem);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_sem_wait(struct ast_sem *sem)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return sem_wait(&sem->real_sem);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_sem_timedwait(struct ast_sem *sem, const struct timespec *abs_timeout)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return sem_timedwait(&sem->real_sem, abs_timeout);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_sem_getvalue(struct ast_sem *sem, int *sval)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return sem_getvalue(&sem->real_sem, sval);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-#else</span><br><span> /* Unnamed semaphores don't work. Rolling our own, I guess... */</span><br><span> </span><br><span> #include "asterisk/lock.h"</span><br><span>@@ -173,6 +133,4 @@</span><br><span> */</span><br><span> int ast_sem_getvalue(struct ast_sem *sem, int *sval);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> #endif /* ASTERISK_SEMAPHORE_H */</span><br><span>diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h</span><br><span>index aaf2737..c4ee51c 100644</span><br><span>--- a/include/asterisk/strings.h</span><br><span>+++ b/include/asterisk/strings.h</span><br><span>@@ -50,22 +50,10 @@</span><br><span> </span><br><span> #ifdef AST_DEVMODE</span><br><span> #define ast_strlen_zero(foo) _ast_strlen_zero(foo, __FILE__, __PRETTY_FUNCTION__, __LINE__)</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int _ast_strlen_zero(const char *s, const char *file, const char *function, int line)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- if (!s || (*s == '\0')) {</span><br><span style="color: hsl(0, 100%, 40%);">- return 1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- if (!strcmp(s, "(null)")) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(__LOG_WARNING, file, line, function, "Possible programming error: \"(null)\" is not NULL!\n");</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- return 0;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int _ast_strlen_zero(const char *s, const char *file, const char *function, int line);</span><br><span> </span><br><span> #else</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int attribute_pure ast_strlen_zero(const char *s)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return (!s || (*s == '\0'));</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_strlen_zero(const char *s);</span><br><span> #endif</span><br><span> </span><br><span> #ifdef SENSE_OF_HUMOR</span><br><span>@@ -91,16 +79,7 @@</span><br><span> \param prefix Prefix to look for.</span><br><span> \param 1 if \a str begins with \a prefix, 0 otherwise.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- ast_assert(str != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_assert(prefix != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- while (*str == *prefix && *prefix != '\0') {</span><br><span style="color: hsl(0, 100%, 40%);">- ++str;</span><br><span style="color: hsl(0, 100%, 40%);">- ++prefix;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- return *prefix == '\0';</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_begins_with(const char *str, const char *prefix);</span><br><span> </span><br><span> /*</span><br><span> \brief Checks whether a string ends with another.</span><br><span>@@ -109,22 +88,7 @@</span><br><span> \param suffix Suffix to look for.</span><br><span> \param 1 if \a str ends with \a suffix, 0 otherwise.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- size_t str_len;</span><br><span style="color: hsl(0, 100%, 40%);">- size_t suffix_len;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_assert(str != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_assert(suffix != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- str_len = strlen(str);</span><br><span style="color: hsl(0, 100%, 40%);">- suffix_len = strlen(suffix);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (suffix_len > str_len) {</span><br><span style="color: hsl(0, 100%, 40%);">- return 0;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return strcmp(str + str_len - suffix_len, suffix) == 0;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_ends_with(const char *str, const char *suffix);</span><br><span> </span><br><span> /*!</span><br><span> * \brief return Yes or No depending on the argument.</span><br><span>@@ -1137,10 +1101,7 @@</span><br><span> * (signed) int values. This function restricts an unsigned int hash</span><br><span> * value to the positive half of the (signed) int values.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int attribute_pure ast_str_hash_restrict(unsigned int hash)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return (int) (hash & (unsigned int) INT_MAX);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_str_hash_restrict(unsigned int hash);</span><br><span> </span><br><span> /*!</span><br><span> * \brief Compute a hash value on a string</span><br><span>@@ -1150,16 +1111,7 @@</span><br><span> *</span><br><span> * http://www.cse.yorku.ca/~oz/hash.html</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int attribute_pure ast_str_hash(const char *str)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int hash = 5381;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- while (*str) {</span><br><span style="color: hsl(0, 100%, 40%);">- hash = hash * 33 ^ (unsigned char) *str++;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_str_hash_restrict(hash);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_str_hash(const char *str);</span><br><span> </span><br><span> /*!</span><br><span> * \brief Compute a hash value on a string</span><br><span>@@ -1176,16 +1128,7 @@</span><br><span> *</span><br><span> * \sa http://www.cse.yorku.ca/~oz/hash.html</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_str_hash_add(const char *str, int seed)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int hash = (unsigned int) seed;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- while (*str) {</span><br><span style="color: hsl(0, 100%, 40%);">- hash = hash * 33 ^ (unsigned char) *str++;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_str_hash_restrict(hash);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_str_hash_add(const char *str, int seed);</span><br><span> </span><br><span> /*!</span><br><span> * \brief Compute a hash value on a case-insensitive string</span><br><span>@@ -1194,16 +1137,7 @@</span><br><span> * all characters to lowercase prior to computing a hash. This</span><br><span> * allows for easy case-insensitive lookups in a hash table.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int attribute_pure ast_str_case_hash(const char *str)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int hash = 5381;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- while (*str) {</span><br><span style="color: hsl(0, 100%, 40%);">- hash = hash * 33 ^ (unsigned char) tolower(*str++);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_str_hash_restrict(hash);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_str_case_hash(const char *str);</span><br><span> </span><br><span> /*!</span><br><span> * \brief Convert a string to all lower-case</span><br><span>@@ -1221,19 +1155,7 @@</span><br><span> *</span><br><span> * \retval str for convenience</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline char *attribute_pure ast_str_to_upper(char *str)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- char *str_orig = str;</span><br><span style="color: hsl(0, 100%, 40%);">- if (!str) {</span><br><span style="color: hsl(0, 100%, 40%);">- return str;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- for (; *str; ++str) {</span><br><span style="color: hsl(0, 100%, 40%);">- *str = toupper(*str);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return str_orig;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+char *attribute_pure ast_str_to_upper(char *str);</span><br><span> </span><br><span> /*!</span><br><span> * \since 12</span><br><span>diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h</span><br><span>index 4dc406d..ccedcfa 100644</span><br><span>--- a/include/asterisk/utils.h</span><br><span>+++ b/include/asterisk/utils.h</span><br><span>@@ -336,49 +336,10 @@</span><br><span> */</span><br><span> void ast_unescape_quoted(char *quote_str);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline void ast_slinear_saturated_add(short *input, short *value)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- int res;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- res = (int) *input + *value;</span><br><span style="color: hsl(0, 100%, 40%);">- if (res > 32767)</span><br><span style="color: hsl(0, 100%, 40%);">- *input = 32767;</span><br><span style="color: hsl(0, 100%, 40%);">- else if (res < -32768)</span><br><span style="color: hsl(0, 100%, 40%);">- *input = -32768;</span><br><span style="color: hsl(0, 100%, 40%);">- else</span><br><span style="color: hsl(0, 100%, 40%);">- *input = (short) res;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline void ast_slinear_saturated_subtract(short *input, short *value)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- int res;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- res = (int) *input - *value;</span><br><span style="color: hsl(0, 100%, 40%);">- if (res > 32767)</span><br><span style="color: hsl(0, 100%, 40%);">- *input = 32767;</span><br><span style="color: hsl(0, 100%, 40%);">- else if (res < -32768)</span><br><span style="color: hsl(0, 100%, 40%);">- *input = -32768;</span><br><span style="color: hsl(0, 100%, 40%);">- else</span><br><span style="color: hsl(0, 100%, 40%);">- *input = (short) res;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline void ast_slinear_saturated_multiply(short *input, short *value)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- int res;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- res = (int) *input * *value;</span><br><span style="color: hsl(0, 100%, 40%);">- if (res > 32767)</span><br><span style="color: hsl(0, 100%, 40%);">- *input = 32767;</span><br><span style="color: hsl(0, 100%, 40%);">- else if (res < -32768)</span><br><span style="color: hsl(0, 100%, 40%);">- *input = -32768;</span><br><span style="color: hsl(0, 100%, 40%);">- else</span><br><span style="color: hsl(0, 100%, 40%);">- *input = (short) res;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline void ast_slinear_saturated_divide(short *input, short *value)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- *input /= *value;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_add(short *input, short *value);</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_subtract(short *input, short *value);</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_multiply(short *input, short *value);</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_divide(short *input, short *value);</span><br><span> </span><br><span> #ifdef localtime_r</span><br><span> #undef localtime_r</span><br><span>@@ -585,12 +546,7 @@</span><br><span> return __VA_ARGS__; \</span><br><span> }\</span><br><span> })</span><br><span style="color: hsl(0, 100%, 40%);">-static void force_inline _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- if (__builtin_expect(!condition, 1)) {</span><br><span style="color: hsl(0, 100%, 40%);">- __ast_assert_failed(condition, condition_str, file, line, function);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+void _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function);</span><br><span> #else</span><br><span> #define ast_assert(a)</span><br><span> #define ast_assert_return(a, ...) \</span><br><span>diff --git a/main/audiohook.c b/main/audiohook.c</span><br><span>index 04a379f..c8d292c 100644</span><br><span>--- a/main/audiohook.c</span><br><span>+++ b/main/audiohook.c</span><br><span>@@ -1427,3 +1427,56 @@</span><br><span> </span><br><span> return (audiohook ? 0 : -1);</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_add(short *input, short *value)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ res = (int) *input + *value;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res > 32767)</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = 32767;</span><br><span style="color: hsl(120, 100%, 40%);">+ else if (res < -32768)</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = -32768;</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = (short) res;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_subtract(short *input, short *value)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ res = (int) *input - *value;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res > 32767)</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = 32767;</span><br><span style="color: hsl(120, 100%, 40%);">+ else if (res < -32768)</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = -32768;</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = (short) res;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_multiply(short *input, short *value)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ res = (int) *input * *value;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res > 32767)</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = 32767;</span><br><span style="color: hsl(120, 100%, 40%);">+ else if (res < -32768)</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = -32768;</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ *input = (short) res;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_slinear_saturated_divide(short *input, short *value)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ *input /= *value;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_DEVMODE</span><br><span style="color: hsl(120, 100%, 40%);">+void _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ if (__builtin_expect(!condition, 1)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ __ast_assert_failed(condition, condition_str, file, line, function);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>diff --git a/main/sem.c b/main/sem.c</span><br><span>index cb7b531..b7794f4 100644</span><br><span>--- a/main/sem.c</span><br><span>+++ b/main/sem.c</span><br><span>@@ -26,8 +26,6 @@</span><br><span> #include "asterisk/sem.h"</span><br><span> #include "asterisk/utils.h"</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef HAS_WORKING_SEMAPHORE</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /* DIY semaphores! */</span><br><span> </span><br><span> int ast_sem_init(struct ast_sem *sem, int pshared, unsigned int value)</span><br><span>@@ -141,5 +139,3 @@</span><br><span> </span><br><span> return 0;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span>diff --git a/main/strings.c b/main/strings.c</span><br><span>index a18bb48..d0124ee 100644</span><br><span>--- a/main/strings.c</span><br><span>+++ b/main/strings.c</span><br><span>@@ -436,3 +436,101 @@</span><br><span> return str_orig;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_DEVMODE</span><br><span style="color: hsl(120, 100%, 40%);">+int _ast_strlen_zero(const char *s, const char *file, const char *function, int line)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!s || (*s == '\0')) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strcmp(s, "(null)")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(__LOG_WARNING, file, line, function, "Possible programming error: \"(null)\" is not NULL!\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_strlen_zero(const char *s)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ return (!s || (*s == '\0'));</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_begins_with(const char *str, const char *prefix)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_assert(str != NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_assert(prefix != NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ while (*str == *prefix && *prefix != '\0') {</span><br><span style="color: hsl(120, 100%, 40%);">+ ++str;</span><br><span style="color: hsl(120, 100%, 40%);">+ ++prefix;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return *prefix == '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_ends_with(const char *str, const char *suffix)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t str_len;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t suffix_len;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_assert(str != NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_assert(suffix != NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ str_len = strlen(str);</span><br><span style="color: hsl(120, 100%, 40%);">+ suffix_len = strlen(suffix);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (suffix_len > str_len) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return strcmp(str + str_len - suffix_len, suffix) == 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_str_hash_restrict(unsigned int hash)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ return (int) (hash & (unsigned int) INT_MAX);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_str_hash(const char *str)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int hash = 5381;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ while (*str) {</span><br><span style="color: hsl(120, 100%, 40%);">+ hash = hash * 33 ^ (unsigned char) *str++;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_hash_restrict(hash);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int ast_str_hash_add(const char *str, int seed)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int hash = (unsigned int) seed;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ while (*str) {</span><br><span style="color: hsl(120, 100%, 40%);">+ hash = hash * 33 ^ (unsigned char) *str++;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_hash_restrict(hash);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int attribute_pure ast_str_case_hash(const char *str)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int hash = 5381;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ while (*str) {</span><br><span style="color: hsl(120, 100%, 40%);">+ hash = hash * 33 ^ (unsigned char) tolower(*str++);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_hash_restrict(hash);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+char *attribute_pure ast_str_to_upper(char *str)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ char *str_orig = str;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!str) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return str;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ for (; *str; ++str) {</span><br><span style="color: hsl(120, 100%, 40%);">+ *str = toupper(*str);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return str_orig;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/utils/extconf.c b/utils/extconf.c</span><br><span>index 129dcc8..4e0e1ad 100644</span><br><span>--- a/utils/extconf.c</span><br><span>+++ b/utils/extconf.c</span><br><span>@@ -90,7 +90,7 @@</span><br><span> </span><br><span> /* logger.h */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#define EVENTLOG "event_log"</span><br><span style="color: hsl(120, 100%, 40%);">+#define EVENTLOG "event_log"</span><br><span> #define QUEUELOG "queue_log"</span><br><span> </span><br><span> #define DEBUG_M(a) { \</span><br><span>@@ -949,7 +949,7 @@</span><br><span> </span><br><span> /* taken from strings.h */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static force_inline int ast_strlen_zero(const char *s)</span><br><span style="color: hsl(120, 100%, 40%);">+static int ast_strlen_zero(const char *s)</span><br><span> {</span><br><span> return (!s || (*s == '\0'));</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10933">change 10933</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10933"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iad74c085d98eb61132f39d39c977ceb170d21fc9 </div>
<div style="display:none"> Gerrit-Change-Number: 10933 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Chris Savinovich <csavinovich@digium.com> </div>