This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.26-265-g50c66c7


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  50c66c7acd90f257b295e58bf938ed120cbc27c7 (commit)
      from  a617bd119f1b36a7ff2d2fdecf0d2f56970d0288 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=50c66c7acd90f257b295e58bf938ed120cbc27c7

commit 50c66c7acd90f257b295e58bf938ed120cbc27c7
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Fri Sep 1 09:31:13 2017 -0700

    2017-09-01  Paul Pluzhnikov  <ppluzhnikov@google.com>
    
    	* stdlib/tst-atexit-common.c (do_test): Test support for at least
    	32 atexit handlers.

diff --git a/ChangeLog b/ChangeLog
index 32b304b..0e566ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-01  Paul Pluzhnikov  <ppluzhnikov@google.com>
+
+	* stdlib/tst-atexit-common.c (do_test): Test support for at least
+	32 atexit handlers.
+
 2017-09-01  Zack Weinberg  <zackw@panix.com>
 
 	* math/math.h (HUGE_VAL): Improve commentary.
diff --git a/stdlib/tst-atexit-common.c b/stdlib/tst-atexit-common.c
index 99b00bf..d6dcf08 100644
--- a/stdlib/tst-atexit-common.c
+++ b/stdlib/tst-atexit-common.c
@@ -23,7 +23,13 @@
 #include <unistd.h>
 #include <sys/wait.h>
 
-#define MAX_ATEXIT 20  /* Large enough for current set of invocations.  */
+/* http://pubs.opengroup.org/onlinepubs/000095399/functions/atexit.html
+   requires that we support at least 32 atexit handlers.
+
+   The number we actually support is limited by memory. Here we simply
+   check that we support at least the minimum required.  */
+#define MAX_ATEXIT 32
+
 static char crumbs[MAX_ATEXIT];
 static int next_slot = 0;
 
@@ -66,7 +72,7 @@ static void
 fn_final (void)
 {
   /* Arbitrary sequence matching current registrations.  */
-  const char expected[] = "3021121130211";
+  const char expected[] = "00000000000000000000000003021121130211";
 
   if (strcmp (crumbs, expected) == 0)
     _exit_with_flush (0);
@@ -76,25 +82,26 @@ fn_final (void)
   _exit_with_flush (1);
 }
 
-/* This is currently just a basic test to verify that exit handlers execute
-   in LIFO order, even when the handlers register additional new handlers.
-
-   TODO: Additional tests that we should do:
-   1. POSIX says we need to support at least ATEXIT_MAX
-   2. ...  */
-
 static int
 do_test (void)
 {
+  int slots_remaining = MAX_ATEXIT;
+
   /* Register this first so it can verify expected order of the rest.  */
-  ATEXIT (fn_final);
+  ATEXIT (fn_final); --slots_remaining;
 
-  ATEXIT (fn1);
-  ATEXIT (fn3);
-  ATEXIT (fn1);
-  ATEXIT (fn2);
-  ATEXIT (fn1);
-  ATEXIT (fn3);
+  ATEXIT (fn1); --slots_remaining;
+  ATEXIT (fn3); --slots_remaining;
+  ATEXIT (fn1); --slots_remaining;
+  ATEXIT (fn2); --slots_remaining;
+  ATEXIT (fn1); --slots_remaining;
+  ATEXIT (fn3); --slots_remaining;
+
+  /* Fill the rest of available slots with fn0.  */
+  while (slots_remaining > 0)
+    {
+      ATEXIT (fn0); --slots_remaining;
+    }
 
   /* Verify that handlers registered above are inherited across fork.  */
   const pid_t child = fork ();

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                  |    5 +++++
 stdlib/tst-atexit-common.c |   39 +++++++++++++++++++++++----------------
 2 files changed, 28 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]