aboutsummaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-10 00:55:45 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-10 00:55:45 +0000
commit603f6f0ce31e225ff27afacb277afcc793211200 (patch)
tree66412a83f4893cdd194b97b489f2673d39cb9ef0 /utils.c
parent44b25415b67046f5c3803e8e08e272d0f6233c70 (diff)
Bug 5961 - new RAND() function
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7920 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index cc3510541..cf3bd09ee 100644
--- a/utils.c
+++ b/utils.c
@@ -881,6 +881,19 @@ int getloadavg(double *list, int nelem)
#endif /* linux */
#endif /* !defined(_BSD_SOURCE) */
+/* glibc puts a lock inside random(3), so that the results are thread-safe.
+ * BSD libc (and others) do not. */
+#ifndef linux
+long int ast_random(void)
+{
+ long int res;
+ ast_mutex_lock(&randomlock);
+ res = random();
+ ast_mutex_unlock(&randomlock);
+ return res;
+}
+#endif
+
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
{
char *dataPut = start;