Code formatting cleanups in utils.c and include/asterisk/lock.h

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3278 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
James Golovich
2004-06-22 19:53:36 +00:00
parent f5c18f62a1
commit 024f486810
2 changed files with 102 additions and 95 deletions

View File

@@ -354,7 +354,6 @@ static inline int ast_mutex_trylock(ast_mutex_t *pmutex)
#define AST_MUTEX_DEFINE_STATIC(mutex) __AST_MUTEX_DEFINE(static,mutex)
#define AST_MUTEX_DEFINE_EXPORTED(mutex) __AST_MUTEX_DEFINE(/**/,mutex)
#define AST_MUTEX_INITIALIZER __use_AST_MUTEX_DEFINE_STATIC_rather_than_AST_MUTEX_INITIALIZER__
#define gethostbyname __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__

24
utils.c
View File

@@ -160,18 +160,22 @@ static void *test_thread_body(void *data)
{
ast_mutex_lock(&test_lock);
lock_count += 10;
if(lock_count != 10) test_errors++;
if (lock_count != 10)
test_errors++;
ast_mutex_lock(&test_lock);
lock_count += 10;
if(lock_count != 20) test_errors++;
if (lock_count != 20)
test_errors++;
ast_mutex_lock(&test_lock2);
ast_mutex_unlock(&test_lock);
lock_count -= 10;
if(lock_count != 10) test_errors++;
if (lock_count != 10)
test_errors++;
ast_mutex_unlock(&test_lock);
lock_count -= 10;
ast_mutex_unlock(&test_lock2);
if(lock_count != 0) test_errors++;
if (lock_count != 0)
test_errors++;
return NULL;
}
@@ -185,19 +189,23 @@ int test_for_thread_safety(void)
pthread_create(&test_thread, NULL, test_thread_body, NULL);
pthread_yield();
usleep(100);
if(lock_count != 2) test_errors++;
if (lock_count != 2)
test_errors++;
ast_mutex_unlock(&test_lock);
lock_count -= 1;
pthread_yield();
usleep(100);
if(lock_count != 1) test_errors++;
if (lock_count != 1)
test_errors++;
ast_mutex_unlock(&test_lock);
lock_count -= 1;
if(lock_count != 0) test_errors++;
if (lock_count != 0)
test_errors++;
ast_mutex_unlock(&test_lock2);
pthread_yield();
usleep(100);
if(lock_count != 0) test_errors++;
if (lock_count != 0)
test_errors++;
pthread_join(test_thread, NULL);
return(test_errors); /* return 0 on success. */
}