aboutsummaryrefslogtreecommitdiff
path: root/nptl/tst-cancel24.cc
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /nptl/tst-cancel24.cc
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-zack/build-layout-experiment.tar
glibc-zack/build-layout-experiment.tar.gz
glibc-zack/build-layout-experiment.tar.bz2
glibc-zack/build-layout-experiment.zip
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'nptl/tst-cancel24.cc')
-rw-r--r--nptl/tst-cancel24.cc113
1 files changed, 0 insertions, 113 deletions
diff --git a/nptl/tst-cancel24.cc b/nptl/tst-cancel24.cc
deleted file mode 100644
index 1af709a8ca..0000000000
--- a/nptl/tst-cancel24.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <pthread.h>
-#include <semaphore.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-
-static volatile bool destr_called;
-static volatile bool except_caught;
-
-static pthread_barrier_t b;
-
-
-struct monitor
-{
- // gcc is broken and would generate a warning without this dummy
- // constructor.
- monitor () { }
- ~monitor() { destr_called = true; }
-};
-
-
-static void *
-tf (void *arg)
-{
- sem_t *s = static_cast<sem_t *> (arg);
-
- try
- {
- monitor m;
-
- pthread_barrier_wait (&b);
-
- while (1)
- sem_wait (s);
- }
- catch (...)
- {
- except_caught = true;
- throw;
- }
-
- return NULL;
-}
-
-
-static int
-do_test ()
-{
- if (pthread_barrier_init (&b, NULL, 2) != 0)
- {
- puts ("barrier_init failed");
- return 1;
- }
-
- sem_t s;
- if (sem_init (&s, 0, 0) != 0)
- {
- puts ("sem_init failed");
- return 1;
- }
-
- pthread_t th;
- if (pthread_create (&th, NULL, tf, &s) != 0)
- {
- puts ("pthread_create failed");
- return 1;
- }
-
- pthread_barrier_wait (&b);
-
- /* There is unfortunately no better method to try to assure the
- child thread reached the sem_wait call and is actually waiting
- than to sleep here. */
- sleep (1);
-
- if (pthread_cancel (th) != 0)
- {
- puts ("cancel failed");
- return 1;
- }
-
- void *res;
- if (pthread_join (th, &res) != 0)
- {
- puts ("join failed");
- return 1;
- }
-
- if (res != PTHREAD_CANCELED)
- {
- puts ("thread was not canceled");
- return 1;
- }
-
- if (! except_caught)
- {
- puts ("exception not caught");
- return 1;
- }
-
- if (! destr_called)
- {
- puts ("destructor not called");
- return 1;
- }
-
- return 0;
-}
-
-#define TEST_FUNCTION do_test ()
-#define TIMEOUT 3
-#include "../test-skeleton.c"