Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
errno concept implementation
authorcherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 19 Dec 2006 16:27:45 +0000 (16:27 +0000)
committercherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 19 Dec 2006 16:27:45 +0000 (16:27 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3011 48e7efb5-ca39-0410-a469-dd3cf9ba447f

win32_test_app/src/TErrno.c [new file with mode: 0644]

diff --git a/win32_test_app/src/TErrno.c b/win32_test_app/src/TErrno.c
new file mode 100644 (file)
index 0000000..6fc7c01
--- /dev/null
@@ -0,0 +1,49 @@
+#include <TErrno.h>
+
+/* Global variable */
+static errno_t __errno = E_SUCCESS;
+static CRITICAL_SECTION errno_cs;
+static bool errno_cs_initialized = false;
+static is_last_errno = false;
+
+void initializeErrno(void)
+{
+       if(!errno_cs_initialized)
+       {
+               memset(&errno_cs,0,sizeof(CRITICAL_SECTION)) ;
+               InitializeCriticalSection(&errno_cs);
+               errno_cs_initialized = true;
+       }
+}
+
+void terminateErrno(void)
+{
+       if(errno_cs_initialized)
+       {
+               DeleteCriticalSection(&errno_cs);
+       }
+}
+
+
+void setErrno(errno_t e)
+{
+       EnterCriticalSection(&errno_cs);
+
+    if((E_SUCCESS != e) && !is_last_errno)
+    {
+           __errno = e;
+        is_last_errno = true;
+    }
+        
+   LeaveCriticalSection(&errno_cs);
+}
+
+errno_t getErrno(void)
+{
+       errno_t e;
+       EnterCriticalSection(&errno_cs);
+       e = __errno;
+       LeaveCriticalSection(&errno_cs);
+       
+       return e;
+}
\ No newline at end of file