From d0347cff040746bea0a719e9a6d8b4a530c91036 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Fri, 21 Apr 2006 02:47:43 +0000 Subject: [PATCH] Add sem_init() return value check. Check that the endian macros work correctly. --- src/xpdev/wraptest.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/xpdev/wraptest.c b/src/xpdev/wraptest.c index 2e77761fe6..f7fd22d07a 100644 --- a/src/xpdev/wraptest.c +++ b/src/xpdev/wraptest.c @@ -13,6 +13,7 @@ #include "sockwrap.h" #include "threadwrap.h" #include "xpbeep.h" +#include "xpendian.h" #define LOCK_FNAME "test.fil" #define LOCK_OFFSET 0 @@ -229,14 +230,18 @@ int main() /* Thread (and inter-process communication) test */ printf("\nSemaphore test\n"); getkey(); - sem_init(&thread_data.parent_sem + if(sem_init(&thread_data.parent_sem ,0 /* shared between processes */ ,0 /* initial count */ - ); - sem_init(&thread_data.child_sem + )) { + printf("sem_init failed\n"); + } + if(sem_init(&thread_data.child_sem ,0 /* shared between processes */ ,0 /* initial count */ - ); + )) { + printf("sem_init failed\n"); + } if(_beginthread( sem_test_thread /* entry point */ ,0 /* stack size (0=auto) */ @@ -287,6 +292,14 @@ int main() printf("\ntimed-out after %ld seconds (should be 5 seconds)\n",time(NULL)-t); sem_destroy(&thread_data.parent_sem); sem_destroy(&thread_data.child_sem); + printf("\nendian check..."); + memcpy(&i,"\x01\x02\x03\x04",4); + if(LE_LONG(i)==67305985) { + printf("OK!\n"); + } + else { + printf("FAILED!\n"); + } return 0; } -- GitLab