2001-08-23 Roland McGrath <roland@frob.com>
authorroland <roland>
Fri, 24 Aug 2001 03:24:30 +0000 (03:24 +0000)
committerroland <roland>
Fri, 24 Aug 2001 03:24:30 +0000 (03:24 +0000)
* sysdeps/mach/bits/libc-lock.h (__libc_cleanup_region_start):
Take new first arg DOIT, a boolean saying whether to really install
any cleanup handler.
(__libc_cleanup_region_end): Do nothing if start's DOIT arg was zero.
(__libc_cleanup_end): Likewise.
* sysdeps/generic/bits/libc-lock.h: Same changes.
* stdio-common/vfscanf.c (LOCK_STREAM): Pass new arg.
* stdio-common/vfprintf.c (buffered_vfprintf, vfprintf): Likewise.
* sysdeps/mach/hurd/bits/stdio-lock.h (_IO_cleanup_region_start):
Likewise.
* misc/syslog.c (vsyslog, openlog, closelog): Likewise.
* sysdeps/generic/bits/stdio-lock.h
(_IO_cleanup_region_start, _IO_cleanup_region_start_noarg): Likewise.

bits/libc-lock.h
sysdeps/generic/bits/libc-lock.h

index ca90d35..700ebd6 100644 (file)
   } while (0)
 
 
-/* Start critical region with cleanup.  */
-#define __libc_cleanup_region_start(FCT, ARG)
-
-/* End critical region with cleanup.  */
-#define __libc_cleanup_region_end(DOIT)
+/* Start a critical region with a cleanup function */
+#define __libc_cleanup_region_start(DOIT, FCT, ARG)                        \
+{                                                                          \
+  typeof (***(FCT)) *__save_FCT = (DOIT) ? (FCT) : 0;                      \
+  typeof (ARG) __save_ARG = ARG;                                           \
+  /* close brace is in __libc_cleanup_region_end below. */
+
+/* End a critical region started with __libc_cleanup_region_start. */
+#define __libc_cleanup_region_end(DOIT)                                            \
+  if ((DOIT) && __save_FCT != 0)                                           \
+    (*__save_FCT)(__save_ARG);                                             \
+}
 
 /* Sometimes we have to exit the block in the middle.  */
-#define __libc_cleanup_end(DOIT)
+#define __libc_cleanup_end(DOIT)                                           \
+  if ((DOIT) && __save_FCT != 0)                                           \
+    (*__save_FCT)(__save_ARG);                                             \
 
 
 /* We need portable names for some of the functions.  */
index ca90d35..700ebd6 100644 (file)
   } while (0)
 
 
-/* Start critical region with cleanup.  */
-#define __libc_cleanup_region_start(FCT, ARG)
-
-/* End critical region with cleanup.  */
-#define __libc_cleanup_region_end(DOIT)
+/* Start a critical region with a cleanup function */
+#define __libc_cleanup_region_start(DOIT, FCT, ARG)                        \
+{                                                                          \
+  typeof (***(FCT)) *__save_FCT = (DOIT) ? (FCT) : 0;                      \
+  typeof (ARG) __save_ARG = ARG;                                           \
+  /* close brace is in __libc_cleanup_region_end below. */
+
+/* End a critical region started with __libc_cleanup_region_start. */
+#define __libc_cleanup_region_end(DOIT)                                            \
+  if ((DOIT) && __save_FCT != 0)                                           \
+    (*__save_FCT)(__save_ARG);                                             \
+}
 
 /* Sometimes we have to exit the block in the middle.  */
-#define __libc_cleanup_end(DOIT)
+#define __libc_cleanup_end(DOIT)                                           \
+  if ((DOIT) && __save_FCT != 0)                                           \
+    (*__save_FCT)(__save_ARG);                                             \
 
 
 /* We need portable names for some of the functions.  */