Index: branches/libc-0.6/src/emx/include/os2emx.h
===================================================================
--- branches/libc-0.6/src/emx/include/os2emx.h	(revision 3905)
+++ branches/libc-0.6/src/emx/include/os2emx.h	(revision 3906)
@@ -13347,7 +13347,7 @@
 
 
-/* --------------------- FS Save/Load/Restore macros ---------------------- */
-
-#if defined(INCL_FSMACROS)
+/* --------------------- Register preservation macros ---------------------- */
+
+#if defined(INCL_FSMACROS) || defined(INCL_PRESERVE_REGISTER_MACROS)
 
 #ifndef FS_DISABLED
@@ -13364,9 +13364,9 @@
 #endif
 
-#endif /* INCL_FSMACROS */
-
-#if defined(INCL_FPCWMACROS)
-
-#ifndef FSCW_DISABLED
+#endif /* INCL_FSMACROS || INCL_PRESERVE_REGISTER_MACROS */
+
+#if defined(INCL_FPCWMACROS) || defined(INCL_PRESERVE_REGISTER_MACROS)
+
+#ifndef FPCW_DISABLED
 #define FSCW_VAR()        volatile unsigned __fpcw__;
 #define FSCW_SAVE()       __asm__ __volatile__ ("fnstcw %0;" : : "m" (__fpcw__) )
@@ -13378,5 +13378,12 @@
 #endif
 
-#endif /* INCL_FPCWMACROS */
+#endif /* INCL_FPCWMACROS || INCL_PRESERVE_REGISTER_MACROS */
+
+#if defined(INCL_PRESERVE_REGISTER_MACROS) || (defined(INCL_FSMACROS) && defined(INCL_FPCWMACROS))
+# define PRESERVE_REGS_SAVE_LOAD_SAFE()       FS_VAR(); FSCW_VAR(); PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN()
+# define PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN() do { FS_SAVE_LOAD(); FSCW_SAVE(); } while (0)
+# define PRESERVE_REGS_RESTORE()              do { FSCW_RESTORE(); FS_RESTORE(); } while (0)
+#endif
+
 
 
Index: branches/libc-0.6/src/emx/src/lib/sys/DosFreeModuleEx.c
===================================================================
--- branches/libc-0.6/src/emx/src/lib/sys/DosFreeModuleEx.c	(revision 3905)
+++ branches/libc-0.6/src/emx/src/lib/sys/DosFreeModuleEx.c	(revision 3906)
@@ -4,5 +4,5 @@
  * DosFreeModuleEx.
  *
- * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ * Copyright (c) 2004-2014 knut st. osmundsen <bird-srcspam@anduin.net>
  *
  *
@@ -31,5 +31,5 @@
 #define INCL_ERRORS
 #define INCL_DOSMODULEMGR
-#define INCL_FSMACROS
+#define INCL_PRESERVE_REGISTER_MACROS
 #define INCL_EXAPIS
 #include <os2emx.h>
@@ -45,6 +45,5 @@
 {
     LIBCLOG_ENTER("hmod=%lx\n", hmod);
-    int         rc;
-    FS_VAR();
+    int rc;
 
     /*
@@ -57,9 +56,11 @@
      * Free module.
      */
-    FS_SAVE_LOAD();
     rc = __libc_dosexFree(DOSEX_TYPE_LOAD_MODULE, (unsigned)hmod);
     if (rc == -1)
+    {
+        PRESERVE_REGS_SAVE_LOAD_SAFE();
         rc = DosFreeModule(hmod);
-    FS_RESTORE();
+        PRESERVE_REGS_RESTORE();
+    }
     if (!rc)
         LIBCLOG_RETURN_INT(rc);
Index: branches/libc-0.6/src/emx/src/lib/sys/DosLoadModuleEx.c
===================================================================
--- branches/libc-0.6/src/emx/src/lib/sys/DosLoadModuleEx.c	(revision 3905)
+++ branches/libc-0.6/src/emx/src/lib/sys/DosLoadModuleEx.c	(revision 3906)
@@ -4,5 +4,5 @@
  * DosCreateEventSemEx.
  *
- * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
+ * Copyright (c) 2004-2014 knut st. osmundsen <bird-srcspam@anduin.net>
  *
  *
@@ -31,5 +31,5 @@
 #define INCL_ERRORS
 #define INCL_DOSMODULEMGR
-#define INCL_FSMACROS
+#define INCL_PRESERVE_REGISTER_MACROS
 #define INCL_EXAPIS
 #include <os2emx.h>
@@ -50,16 +50,13 @@
     HMODULE     hmte;
     int         rc;
-    FS_VAR();
 
     /*
      * Create the semaphore.
      */
-    FS_SAVE_LOAD();
+    PRESERVE_REGS_SAVE_LOAD_SAFE();
     rc = DosLoadModule(pszObject, cbObject, pszModule, phmod);
+    PRESERVE_REGS_RESTORE();
     if (rc)
-    {
-        FS_RESTORE();
         LIBCLOG_ERROR_RETURN_INT(rc);
-    }
 
     /*
@@ -82,6 +79,7 @@
         if (!pDosEx)
         {
+            PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN();
             DosFreeModule(hmte);
-            FS_RESTORE();
+            PRESERVE_REGS_RESTORE();
             LIBCLOG_ERROR_RETURN_INT(ERROR_NOT_ENOUGH_MEMORY);
         }
@@ -94,5 +92,4 @@
     }
 
-    FS_RESTORE();
     LIBCLOG_RETURN_MSG(0, "ret 0 *phmod=%#lx\n", hmte);
 }
Index: branches/libc-0.6/src/emx/src/lib/sys/__read.c
===================================================================
--- branches/libc-0.6/src/emx/src/lib/sys/__read.c	(revision 3905)
+++ branches/libc-0.6/src/emx/src/lib/sys/__read.c	(revision 3906)
@@ -3,6 +3,5 @@
 
 #include "libc-alias.h"
-#define INCL_FSMACROS
-#define INCL_FPCWMACROS
+#define INCL_PRESERVE_REGISTER_MACROS
 #define INCL_ERRORS
 #include <os2emx.h>
@@ -41,6 +40,4 @@
          */
         void   *pvBuf_safe = NULL;
-        FS_VAR();
-        FSCW_VAR();
 
         /*
@@ -60,9 +57,7 @@
         }
 
-        FS_SAVE_LOAD();
-        FSCW_SAVE();
+        PRESERVE_REGS_SAVE_LOAD_SAFE();
         rc = DosRead(handle, pvBuf_safe ? pvBuf_safe : buf, cbToRead, &cbRead);
-        FSCW_RESTORE();
-        FS_RESTORE();
+        PRESERVE_REGS_RESTORE();
         if (pvBuf_safe)
         {
Index: branches/libc-0.6/src/emx/src/lib/sys/__write.c
===================================================================
--- branches/libc-0.6/src/emx/src/lib/sys/__write.c	(revision 3905)
+++ branches/libc-0.6/src/emx/src/lib/sys/__write.c	(revision 3906)
@@ -3,6 +3,5 @@
 
 #include "libc-alias.h"
-#define INCL_FSMACROS
-#define INCL_FPCWMACROS
+#define INCL_PRESERVE_REGISTER_MACROS
 #define INCL_ERRORS
 #include <os2emx.h>
@@ -24,7 +23,4 @@
     int     rc;
     ULONG   cbWritten;
-    FS_VAR();
-    FSCW_VAR();
-
 
     /*
@@ -71,9 +67,7 @@
         }
 
-        FS_SAVE_LOAD();
-        FSCW_SAVE();
+        PRESERVE_REGS_SAVE_LOAD_SAFE();
         rc = DosWrite(handle, buf, cbToWrite, &cbWritten);
-        FSCW_RESTORE();
-        FS_RESTORE();
+        PRESERVE_REGS_RESTORE();
 
         if (pvBuf_safe)
