summaryrefslogtreecommitdiff
path: root/test/testatomic.c
diff options
context:
space:
mode:
authorianh <ianh@13f79535-47bb-0310-9956-ffa450edef68>2002-02-18 06:23:40 +0000
committerianh <ianh@13f79535-47bb-0310-9956-ffa450edef68>2002-02-18 06:23:40 +0000
commit473c45a3949b933f536e19941e378d454ba77021 (patch)
tree171a4cae442e33f9c67c2d44862dc4f75a479df6 /test/testatomic.c
parent1fcbab19b669e75a2f406b74095f1f8ac998c544 (diff)
downloadlibapr-473c45a3949b933f536e19941e378d454ba77021.tar.gz
basic test for non-threaded machines
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63021 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testatomic.c')
-rw-r--r--test/testatomic.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/test/testatomic.c b/test/testatomic.c
index d10adabc8..4d4c98d42 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -68,12 +68,35 @@
#ifndef WIN32
#include <pthread.h>
#endif
-#if !APR_HAS_THREADS
+
+apr_pool_t *context;
+apr_atomic_t y; /* atomic locks */
+#if !APR_HAS_HREADS
int main(void)
{
+ apr_status_t rv;
fprintf(stderr,
"This program won't work on this platform because there is no "
"support for threads.\n");
+ if (apr_pool_create(&context, NULL) != APR_SUCCESS) {
+ fflush(stdout);
+ fprintf(stderr, "Failed.\nCould not initialize\n");
+ exit(-1);
+ }
+ rv = apr_atomic_init(context);
+ if (rv != APR_SUCCESS) {
+ fprintf(stderr, "Failed.\nCould not initialize atomics\n");
+ }
+ apr_atomic_set(&y,0);
+ apr_atomic_add(&y,20);
+ apr_atomic_inc(&y);
+ if (apr_atomic_read(&y) != 21) {
+ fprintf(stderr, "Failed.\natomics do not add up\n");
+ }
+ else {
+ fprintf(stdout, "no threads .. OK\n");
+ }
+
return 0;
}
#else /* !APR_HAS_THREADS */
@@ -83,10 +106,8 @@ void * APR_THREAD_FUNC thread_func_atomic(apr_thread_t *thd, void *data);
void * APR_THREAD_FUNC thread_func_none(apr_thread_t *thd, void *data);
apr_lock_t *thread_lock;
-apr_pool_t *context;
apr_thread_once_t *control = NULL;
volatile long x = 0; /* mutex locks */
-apr_atomic_t y; /* atomic locks */
volatile long z = 0; /* no locks */
int value = 0;
apr_status_t exit_ret_val = 123; /* just some made up number to check on later */