seh_try_macros-04-NOOP.diff

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



LICENSE: X11/Bugroff
CHANGELOG:
* dlls/ntdll: exception.c
  dlls/ntdll/tests: seh_macros.c
  include/wine: exception.h
  Greg Turner <gmturner007@ameritch.net>
- fix indentation
- some comments

--
diff -ur -x CVS -x 'bigdif*' -x autom4te.cache ../wine.test/dlls/ntdll/exception.c ./dlls/ntdll/exception.c
--- ../wine.test/dlls/ntdll/exception.c	2003-01-13 20:48:06.000000000 -0600
+++ ./dlls/ntdll/exception.c	2003-01-13 20:11:01.000000000 -0600
@@ -72,24 +72,24 @@
     if (wine_seh_f_tls_index == -1)
         if ((wine_seh_f_tls_index = TlsAlloc()) == -1) assert(FALSE);
     if ((wine_SEH_FData = (wine_seh_f_data *) TlsGetValue(wine_seh_f_tls_index)) == 0)
-      if (GetLastError())
-        assert(FALSE);
+        if (GetLastError())
+            assert(FALSE);
     if (!wine_SEH_FData) {
-      wine_SEH_FData = (wine_seh_f_data *) LocalAlloc(LPTR, sizeof(wine_seh_f_data));
-      assert(wine_SEH_FData);
-      if (!(TlsSetValue(wine_seh_f_tls_index, (LPVOID) wine_SEH_FData))) assert (FALSE);
+        wine_SEH_FData = (wine_seh_f_data *) LocalAlloc(LPTR, sizeof(wine_seh_f_data));
+        assert(wine_SEH_FData);
+        if (!(TlsSetValue(wine_seh_f_tls_index, (LPVOID) wine_SEH_FData))) assert (FALSE);
     }
 }
 
 int __wine_get_seh_f_loop()
 { 
-  wine_init_thread_seh_f();
-  return wine_SEH_FData->loop;
+    wine_init_thread_seh_f();
+    return wine_SEH_FData->loop;
 }
 
 void __wine_set_seh_f_loop(int val) {
-  wine_init_thread_seh_f();
-  wine_SEH_FData->loop = val;
+    wine_init_thread_seh_f();
+    wine_SEH_FData->loop = val;
 }
 
 void __wine_push_seh_f_reraise(int val)
diff -ur -x CVS -x 'bigdif*' -x autom4te.cache ../wine.test/dlls/ntdll/tests/seh_macros.c ./dlls/ntdll/tests/seh_macros.c
--- ../wine.test/dlls/ntdll/tests/seh_macros.c	2003-01-13 20:48:06.000000000 -0600
+++ ./dlls/ntdll/tests/seh_macros.c	2003-01-13 20:32:28.000000000 -0600
@@ -34,32 +34,32 @@
      * generates asserts, ATM.  Once that is fixed the test should be silent.
      */
     #define CRASH_OUT \
-      \
-      if (x) /* I think this branch stops gcc from performing optimizations that break some tests */ \
-        x += (int)(*(int **)0); \
-      else \
-        x -= (int)(*(int **)0);
+        \
+        if (x) /* I think this branch stops gcc from performing optimizations that break some tests */ \
+            x += (int)(*(int **)0); \
+        else \
+            x -= (int)(*(int **)0);
 
     trace("beginning TryMacros:\n");
     trace("  basic no-exception-handling macro test\n");
 
     x = 0;
     __try {
-       x = 1; 
+         x = 1; 
     } __except( ok(FALSE, "Expression shouldn't run."), 1 ) {
-      ok(FALSE, "Except clause shouldn't run.");
+        ok(FALSE, "Except clause shouldn't run.");
     }
 
     trace("  handle exception:\n");
 
     x = 0;
     __try {
-      x++;
-      CRASH_OUT;
-      x++;
+        x++;
+        CRASH_OUT;
+        x++;
     } __except( ( (x!=1) ? ( ok(FALSE, "x should be 1 was %d",x) ) : (x=3) ), 1) {
-      ok((x==3), "x should be 3 was %d", x);
-      if (x==3) x = 4;
+        ok((x==3), "x should be 3 was %d", x);
+        if (x==3) x = 4;
     }
     ok((x==4), "x should be 4 was %d", x);
 
@@ -67,52 +67,52 @@
 
     x = 0;
     __try {
-      ok((x==0), "x should be 0 was %d", x);
-      if (x==0) x = 1;
-      __try {
-        ok((x==1), "x should be 1, was %d", x);
-	if (x==1) x = 2;
-      } __except(0) {
-        ok(FALSE, "exception handler code shouldn't run");
-	x = -99;
-	CRASH_OUT;
-      }
-      ok((x==2), "x should be 2 was %d", x);
-      if (x==2) x = 3;
-    } __except(1) {
-      ok(FALSE, " exception handler code shouldn't run");
-      x = -98;
-    }
+        ok((x==0), "x should be 0 was %d", x);
+        if (x==0) x = 1;
+        __try {
+            ok((x==1), "x should be 1, was %d", x);
+	    if (x==1) x = 2;
+        } __except(0) {
+            ok(FALSE, "exception handler code shouldn't run");
+	    x = -99;
+	    CRASH_OUT;
+        }
+        ok((x==2), "x should be 2 was %d", x);
+        if (x==2) x = 3;
+        } __except(1) {
+            ok(FALSE, " exception handler code shouldn't run");
+            x = -98;
+        }
 
-    ok((x==3), "x should be 3 was %d", x);
+        ok((x==3), "x should be 3 was %d", x);
 
-    trace("  twice nested exceptions test: all exceptions\n");
+        trace("  twice nested exceptions test: all exceptions\n");
 
     x = 0;
     __try {
-      __try {
-        ok((x==0), "x should be 0 was %d", x);
-	if (x==0) x = 1;
-	CRASH_OUT;
-      } __except(1) {
-        ok((x==1), "x should be 1 was %d", x);
-	if (x==1) x = 2;
-	CRASH_OUT;
-      }
-      ok(FALSE, "this code should be skipped");
+        __try {
+            ok((x==0), "x should be 0 was %d", x);
+	    if (x==0) x = 1;
+	    CRASH_OUT;
+        } __except(1) {
+            ok((x==1), "x should be 1 was %d", x);
+	    if (x==1) x = 2;
+	    CRASH_OUT;
+        }
+        ok(FALSE, "this code should be skipped");
     } __except(1) {
-      ok ((x==2), "x should be 2 was %d", x);
-      if (x==2) x = 3;
-      __try {
-        ok ((x==3), "x should be 3 was %d", x);
-	if (x==3) x = 4;
-	CRASH_OUT;
-      } __except(1) {
-        ok ((x==4), "x should be 4 was %d", x);
-	if (x==4) x = 5;
-      }
-      ok ((x==5), "x should be 5 was %d", x);
-      if (x==5) x = 6;
+        ok ((x==2), "x should be 2 was %d", x);
+        if (x==2) x = 3;
+        __try {
+            ok ((x==3), "x should be 3 was %d", x);
+	    if (x==3) x = 4;
+	    CRASH_OUT;
+        } __except(1) {
+            ok ((x==4), "x should be 4 was %d", x);
+	    if (x==4) x = 5;
+        }
+        ok ((x==5), "x should be 5 was %d", x);
+        if (x==5) x = 6;
     }
     ok ((x==6), "x should be 6 was %d", x);
 
@@ -147,7 +147,7 @@
     #define nesttry6(x) __try {x++; nesttry5(x) } __except(1) { x++; nesttry5(x); CRASH_OUT; }
     #define nesttry7(x) __try {x++; nesttry6(x); CRASH_OUT; } __except(1) { x++; nesttry6(x); CRASH_OUT; } 
     __try {
-      nesttry7(x)
+        nesttry7(x)
     } __except (1) {
     }
     #undef nesttry7
@@ -163,9 +163,9 @@
     
     x = 0;
     __try {
-      x++;
+        x++;
     } __finally {
-      x++;
+        x++;
     }
     ok((x==2), "x should be 2 was %d", x);
 
@@ -173,9 +173,9 @@
 
     x = 0;
     __try {
-      x++;
+        x++;
     } __finally {
-      x++;
+        x++;
     }
     ok((x==2), "x should be 2 was %d", x);
 
@@ -183,17 +183,17 @@
 
     x = 0;
     __try {
-      __try {
-        x++;
-	CRASH_OUT;
-        x++;
-      } __finally {
-        ok((x==1), "x should be 1 was %d", x);
-        if (x==1) x = 2;
-      }
+        __try {
+            x++;
+	    CRASH_OUT;
+            x++;
+        } __finally {
+            ok((x==1), "x should be 1 was %d", x);
+            if (x==1) x = 2;
+        }
     } __except (1) {
-      ok((x==2), "x should be 2 was %d", x);
-      if (x==2) x = 3;
+        ok((x==2), "x should be 2 was %d", x);
+        if (x==2) x = 3;
     }
     ok((x==3), "x should be 3 was %d", x);
 
@@ -201,15 +201,15 @@
 
     x = 0;
     __try {
-      x++;
-      __try {
         x++;
-      } __finally {
+        __try {
+            x++;
+        } __finally {
+            x++;
+        }
         x++;
-      }
-      x++;
     } __finally {
-      x++;
+        x++;
     }
     x++;
     ok((x==6), "x should be 6 was %d", x);
@@ -218,29 +218,29 @@
 
     x = 0;
     __try {
-      ok((x==0), "x should be 0 was %d", x);
-      if (x==0) x = 1;
-      __try {
-        ok((x==1), "x should be 1 was %d", x);
-	if (x==1) x = 2;
+        ok((x==0), "x should be 0 was %d", x);
+        if (x==0) x = 1;
         __try {
-	  ok((x==2), "x should be 2 was %d", x);
-	  if (x==2) x = 3;
-	  CRASH_OUT;
-	  ok(FALSE, "this code should not execute");
-	} __finally {
-	  ok((x==3), "x should be 3 was %d", x);
-	  if (x==3) x = 4;
-	}
-	ok(FALSE, "this code should not execute");
-      } __finally {
-        ok((x==4), "x should be 4 was %d", x);
-	if (x==4) x = 5;
-      }
-      ok(FALSE, "this code should not execute");
+            ok((x==1), "x should be 1 was %d", x);
+	    if (x==1) x = 2;
+            __try {
+	        ok((x==2), "x should be 2 was %d", x);
+	        if (x==2) x = 3;
+	        CRASH_OUT;
+	        ok(FALSE, "this code should not execute");
+	    } __finally {
+	        ok((x==3), "x should be 3 was %d", x);
+	        if (x==3) x = 4;
+	    }
+	    ok(FALSE, "this code should not execute");
+        } __finally {
+            ok((x==4), "x should be 4 was %d", x);
+	    if (x==4) x = 5;
+        }
+        ok(FALSE, "this code should not execute");
     } __except (1) {
-      ok((x==5), "x should be 5 was %d", x);
-      if (x==5) x = 6;
+        ok((x==5), "x should be 5 was %d", x);
+        if (x==5) x = 6;
     }
     ok((x==6), "x should be 6 was %d", x);
 
@@ -248,28 +248,28 @@
 
     x = 0;
     __try {
-      ok((x==0), "x should be 0 was %d", x);
-      if (x==0) x = 1;
-      __try {
-        ok((x==1), "x should be 1 was %d", x);
-	if (x==1) x = 2;
+        ok((x==0), "x should be 0 was %d", x);
+        if (x==0) x = 1;
         __try {
-	  ok((x==2), "x should be 2 was %d", x);
-	  if (x==2) x = 3;
-	} __finally {
-	  ok((x==3), "x should be 3 was %d", x);
-	  if (x==3) x = 4;
-	}
-	CRASH_OUT;
-	ok(FALSE, "this code should not execute");
-      } __finally {
-        ok((x==4), "x should be 4 was %d", x);
-	if (x==4) x = 5;
-      }
-      ok(FALSE, "this code should not execute");
+            ok((x==1), "x should be 1 was %d", x);
+	    if (x==1) x = 2;
+            __try {
+	        ok((x==2), "x should be 2 was %d", x);
+	        if (x==2) x = 3;
+	    } __finally {
+	        ok((x==3), "x should be 3 was %d", x);
+	        if (x==3) x = 4;
+	    }
+	    CRASH_OUT;
+	    ok(FALSE, "this code should not execute");
+        } __finally {
+            ok((x==4), "x should be 4 was %d", x);
+	    if (x==4) x = 5;
+        }
+        ok(FALSE, "this code should not execute");
     } __except (1) {
-      ok((x==5), "x should be 5 was %d", x);
-      if (x==5) x = 6;
+        ok((x==5), "x should be 5 was %d", x);
+        if (x==5) x = 6;
     }
     ok((x==6), "x should be 6 was %d", x);
 
@@ -303,11 +303,11 @@
 
     x = 0;
     __try {
-      x = 1;
-      __leave;
-      x = 2;
+        x = 1;
+        __leave;
+        x = 2;
     } __except(1) {
-      x = 3;
+        x = 3;
     }
     ok((x==1), "x should be 1 was %d",x);
 
@@ -315,12 +315,12 @@
     
     x = 0;
     __try {
-      x = 1;
-      __leave;
-      x = 2;
+        x = 1;
+        __leave;
+        x = 2;
     } __finally {
-      ok((x==1), "x should be 1 was %d",x);
-      if (x==1) x = 3;
+        ok((x==1), "x should be 1 was %d",x);
+        if (x==1) x = 3;
     }
     ok((x==3), "x should be 3 was %d", x);
 
diff -ur -x CVS -x 'bigdif*' -x autom4te.cache ../wine.test/include/wine/exception.h ./include/wine/exception.h
--- ../wine.test/include/wine/exception.h	2003-01-13 20:48:06.000000000 -0600
+++ ./include/wine/exception.h	2003-01-13 20:24:04.000000000 -0600
@@ -59,6 +59,21 @@
  *          You can use them to leave a __EXCEPT block though.
  *
  * -- AJ
+ *
+ * Now we can implement the __try/__except/__finally magic of VC++ as standard (?) macros.
+ * this is a "good enough" implementation, it's incomplete (i.e.: no __leave yet, no :break in
+ * __try clauses, and who knows what else...), but should suffice for most uses.
+ * 
+ * The macros require some symbols to be found in ntdll.dll.so, so link with that DLL if you
+ * use them.
+ *
+ * If you are using VC++ and this header, #define USE_COMPILER_EXCEPTIONS before you include it.
+ *
+ * If you are using wrc, and having problems with this header, you can #define __NO_VC_SEH_MACROS__
+ * This will also work if you have some other reason to want __TRY and friends, but not the
+ * lower case versions.
+ *
+ * -gmt
  */
 
 /* Define this if you want to use your compiler built-in __try/__except support.
@@ -151,11 +166,6 @@
 extern DWORD __wine_finally_handler( PEXCEPTION_RECORD record, EXCEPTION_FRAME *frame,
                                      CONTEXT *context, LPVOID pdispatcher );
 
-/*
- * now we can implement the __try/__except/__finally magic of VC++ as standard (?) macros.
- * this is a "good enough" implementation, it's incomplete (i.e.: no __leave yet, no :break in
- * __try clauses, and who knows what else...); but should suffice for most uses.
- */
 
 /* these functions simultate a global thread-local variable */
 extern int __wine_get_seh_f_loop(); 
@@ -169,52 +179,53 @@
 #ifndef __NO_VC_SEH_MACROS__
 
 #define __try \
-  \
-  if ( ({ \
-    __label__ __leavelabel; \
-    int seh_result = -2; \
-    static WINE_EXCEPTION_FILTER(seh_handler); \
-    __TRY {
+    \
+    if ( ({ \
+        __label__ __leavelabel; \
+        int seh_result = -2; \
+        static WINE_EXCEPTION_FILTER(seh_handler); \
+        __TRY { \
+	    \
 
 #define __finally \
-        \
-        __leavelabel: \
-	if (0) { goto __leavelabel; } /* appease compiler */ \
-    } __EXCEPT(seh_handler) { \
-    } __ENDTRY \
-    WINE_EXCEPTION_FILTER(seh_handler) { \
-      /* FIXME: remember exception info */ \
-      seh_result = -4; \
-      __wine_push_seh_f_reraise(1); \
-      return(1); \
-    } \
-    if (seh_result != -4) __wine_push_seh_f_reraise(0); \
-  0; }) ) { } else \
-    for (__wine_set_seh_f_loop(0); __wine_get_seh_f_loop() <= 1; __wine_inc_seh_f_loop() ) \
-      if (__wine_get_seh_f_loop() == 1) { \
-        if (__wine_pop_seh_f_reraise()) { \
-          /* FIXME: re-raise from stored exception info */ assert(FALSE); \
-	} else { \
-	  /* do nothing */ \
-	} \
-      } else
+            \
+            __leavelabel: \
+	    if (0) { goto __leavelabel; } /* appease compiler */ \
+        } __EXCEPT(seh_handler) { \
+        } __ENDTRY \
+        WINE_EXCEPTION_FILTER(seh_handler) { \
+            /* FIXME: remember exception info */ \
+            seh_result = -4; \
+            __wine_push_seh_f_reraise(1); \
+            return(1); \
+        } \
+        if (seh_result != -4) __wine_push_seh_f_reraise(0); \
+    0; }) ) { } else \
+        for (__wine_set_seh_f_loop(0); __wine_get_seh_f_loop() <= 1; __wine_inc_seh_f_loop() ) \
+            if (__wine_get_seh_f_loop() == 1) { \
+                if (__wine_pop_seh_f_reraise()) { \
+                    /* FIXME: re-raise from stored exception info */ assert(FALSE); \
+	        } else { \
+	            /* do nothing */ \
+	        } \
+            } else
 
 #define __except(...) \
-      \
-      __leavelabel: \
-      if (0) { goto __leavelabel; } /* appease compiler */ \
-    } __EXCEPT(seh_handler) { \
-      seh_result = -3; \
-    } __ENDTRY \
-    WINE_EXCEPTION_FILTER(seh_handler) { \
-      seh_result = (__VA_ARGS__); \
-      return(seh_result); \
-    } \
-  (seh_result != -3); }) ) { } else
+            \
+            __leavelabel: \
+            if (0) { goto __leavelabel; } /* appease compiler */ \
+        } __EXCEPT(seh_handler) { \
+            seh_result = -3; \
+        } __ENDTRY \
+        WINE_EXCEPTION_FILTER(seh_handler) { \
+            seh_result = (__VA_ARGS__); \
+            return(seh_result); \
+        } \
+    (seh_result != -3); }) ) { } else
 
 #define __leave \
-  \
-  goto __leavelabel
+    \
+    goto __leavelabel
 
 #endif /* NO_VC_SEH_MACROS */
 
-- 
gmt

note: again, the "\n" between "#endif /* NO_VC_SEH_MACROS */" and "--\ngmt"
      is part of the .diff.

"If everyone is thinking alike then somebody isn't
thinking." --George S. Patton



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux