Implement errno for WinCE using NSPR's per-thread OSError value. WINCE_NSPRPUB_RELEASE_4_2_BETA1
authornelsonb%netscape.com
Sun, 24 Feb 2002 00:01:30 +0000
branchWINCE_NSPRPUB_RELEASE_4_2_BETA1
changeset 2274 80cea48c45dafd8afc02cc7831523e73edb0e857
parent 2273 4e2fc9e445326e9834e5b53ac7209e2d1e08db6a
child 2280 52dda25e27d19f0fa333d084e8009e38e29e4ca8
push idunknown
push userunknown
push dateunknown
Implement errno for WinCE using NSPR's per-thread OSError value. Modified Files: pr/include/md/_wince.cfg pr/include/private/pprthred.h pr/src/misc/prerror.c
pr/include/md/_wince.cfg
pr/include/private/pprthred.h
pr/src/misc/prerror.c
--- a/pr/include/md/_wince.cfg
+++ b/pr/include/md/_wince.cfg
@@ -51,16 +51,17 @@
 /*
  * Some needed types herein.
  */
 #include <windows.h>
 #include <winnt.h>
 #include <stdlib.h>
 typedef int ptrdiff_t; /* pointer difference */
 
+#define errno (*PR_GetOSErrorAddress())
 
 #define PR_AF_INET6 (-1) /* IPv6 not supported yet. */
 
 #if defined(_M_IX86) || defined(_X86_)
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 
--- a/pr/include/private/pprthred.h
+++ b/pr/include/private/pprthred.h
@@ -121,16 +121,22 @@ NSPR_API(PRInt32) PR_SetCPUAffinityMask(
 */
 NSPR_API(void) PR_ShowStatus(void);
 
 /*
 ** Set thread recycle mode to on (1) or off (0)
 */
 NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag);
 
+/*
+** Return the address of thread's last os error variable.
+** Used to implement errno on platforms that lack it.
+*/
+NSPR_API(PRInt32 *) PR_GetOSErrorAddress(void);
+
 
 /*---------------------------------------------------------------------------
 ** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS           
 ---------------------------------------------------------------------------*/
 
 /* 
 ** Only Garbage collectible threads participate in resume all, suspend all and 
 ** enumeration operations.  They are also different during creation when
--- a/pr/src/misc/prerror.c
+++ b/pr/src/misc/prerror.c
@@ -44,16 +44,22 @@ PR_IMPLEMENT(PRErrorCode) PR_GetError(vo
 }
 
 PR_IMPLEMENT(PRInt32) PR_GetOSError(void)
 {
     PRThread *thread = PR_GetCurrentThread();
     return thread->osErrorCode;
 }
 
+PR_IMPLEMENT(PRInt32 *) PR_GetOSErrorAddress(void)
+{
+    PRThread *thread = PR_GetCurrentThread();
+    return &thread->osErrorCode;
+}
+
 PR_IMPLEMENT(void) PR_SetError(PRErrorCode code, PRInt32 osErr)
 {
     PRThread *thread = PR_GetCurrentThread();
     thread->errorCode = code;
     thread->osErrorCode = osErr;
     thread->errorStringLength = 0;
 }