|
|
@ -481,7 +481,7 @@ int ast_utils_init(void)
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __linux__
|
|
|
|
#ifndef __linux__
|
|
|
|
#undef pthread_create /* For ast_pthread_create function only */
|
|
|
|
#undef pthread_create /* For ast_pthread_create function only */
|
|
|
|
#endif /* ! LINUX */
|
|
|
|
#endif /* !__linux__ */
|
|
|
|
|
|
|
|
|
|
|
|
int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize)
|
|
|
|
int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -691,7 +691,7 @@ char *strcasestr(const char *haystack, const char *needle)
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !HAVE_STRCASESTR */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_STRNLEN
|
|
|
|
#ifndef HAVE_STRNLEN
|
|
|
|
size_t strnlen(const char *s, size_t n)
|
|
|
|
size_t strnlen(const char *s, size_t n)
|
|
|
@ -704,7 +704,7 @@ size_t strnlen(const char *s, size_t n)
|
|
|
|
|
|
|
|
|
|
|
|
return len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !HAVE_STRNLEN */
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
|
|
|
|
#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
|
|
|
|
char *strndup(const char *s, size_t n)
|
|
|
|
char *strndup(const char *s, size_t n)
|
|
|
@ -718,7 +718,7 @@ char *strndup(const char *s, size_t n)
|
|
|
|
new[len] = '\0';
|
|
|
|
new[len] = '\0';
|
|
|
|
return memcpy(new, s, len);
|
|
|
|
return memcpy(new, s, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) */
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
|
|
|
|
#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
|
|
|
|
int vasprintf(char **strp, const char *fmt, va_list ap)
|
|
|
|
int vasprintf(char **strp, const char *fmt, va_list ap)
|
|
|
@ -738,7 +738,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
|
|
|
|
|
|
|
|
|
|
|
|
return size;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_STRTOQ
|
|
|
|
#ifndef HAVE_STRTOQ
|
|
|
|
#define LONG_MIN (-9223372036854775807L-1L)
|
|
|
|
#define LONG_MIN (-9223372036854775807L-1L)
|
|
|
@ -835,7 +835,43 @@ uint64_t strtoq(const char *nptr, char **endptr, int base)
|
|
|
|
*((const char **)endptr) = any ? s - 1 : nptr;
|
|
|
|
*((const char **)endptr) = any ? s - 1 : nptr;
|
|
|
|
return acc;
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !HAVE_STRTOQ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if (!defined(getloadavg))
|
|
|
|
|
|
|
|
#ifdef linux
|
|
|
|
|
|
|
|
/* Alternative method of getting load avg on Linux only */
|
|
|
|
|
|
|
|
int getloadavg(double *list, int nelem)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *LOADAVG;
|
|
|
|
|
|
|
|
double avg[3] = { 0.0, 0.0, 0.0 };
|
|
|
|
|
|
|
|
int i, res = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((LOADAVG = fopen("/proc/loadavg", "r"))) {
|
|
|
|
|
|
|
|
fscanf(LOADAVG, "%lf %lf %lf", &avg[0], &avg[1], &avg[2]);
|
|
|
|
|
|
|
|
res = 0;
|
|
|
|
|
|
|
|
fclose(LOADAVG);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; (i < nelem) && (i < 3); i++) {
|
|
|
|
|
|
|
|
list[i] = avg[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !linux */
|
|
|
|
|
|
|
|
/* Return something that won't cancel the call, but still return -1, in case
|
|
|
|
|
|
|
|
* we correct the implementation to check return value */
|
|
|
|
|
|
|
|
int getloadavg(double *list, int nelem)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < nelem; i++) {
|
|
|
|
|
|
|
|
list[i] = 0.1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* linux */
|
|
|
|
|
|
|
|
#endif /* !defined(getloadavg) */
|
|
|
|
|
|
|
|
|
|
|
|
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
|
|
|
|
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
|
|
|
|
{
|
|
|
|
{
|
|
|
|