mirror of git://sourceware.org/git/glibc.git
* tst-join5.c (tf1, tf2): Add a cast.
* Makeconfig (includes): Append -I$(..)nptl to this variable. * tst-barrier2.c (do_test) [! _POSIX_THREAD_PROCESS_SHARED]: Don't test anything. * tst-cond4.c: Likewise. * tst-cond6.c: Likewise. * tst-flock2.c: Likewise. * tst-mutex4.c: Likewise. * tst-rwlock4.c: Likewise. * tst-signal1.c: Likewise. * tst-spin2.c: Likewise. * tst-cond11.c [! _POSIX_CLOCK_SELECTION]: Likewise. * tst-mutex4.c: Use test-skeleton.c. * tst-spin2.c: Likewise. * tst-sysconf.c: Likewise. * tst-barrier2.c: Likewise. * tst-cond4.c: Likewise. * tst-cond6.c: Likewise. * tst-rwlock4.c: Likewise. * tst-unload.c: Likewise. * tst-flock2.c (do_test): Use return instead of exit.
This commit is contained in:
parent
24eaaef61d
commit
b910f7887b
|
@ -1,3 +1,30 @@
|
||||||
|
2003-03-23 Roland McGrath <roland@redhat.com>
|
||||||
|
|
||||||
|
* tst-join5.c (tf1, tf2): Add a cast.
|
||||||
|
|
||||||
|
* Makeconfig (includes): Append -I$(..)nptl to this variable.
|
||||||
|
|
||||||
|
* tst-barrier2.c (do_test) [! _POSIX_THREAD_PROCESS_SHARED]:
|
||||||
|
Don't test anything.
|
||||||
|
* tst-cond4.c: Likewise.
|
||||||
|
* tst-cond6.c: Likewise.
|
||||||
|
* tst-flock2.c: Likewise.
|
||||||
|
* tst-mutex4.c: Likewise.
|
||||||
|
* tst-rwlock4.c: Likewise.
|
||||||
|
* tst-signal1.c: Likewise.
|
||||||
|
* tst-spin2.c: Likewise.
|
||||||
|
* tst-cond11.c [! _POSIX_CLOCK_SELECTION]: Likewise.
|
||||||
|
|
||||||
|
* tst-mutex4.c: Use test-skeleton.c.
|
||||||
|
* tst-spin2.c: Likewise.
|
||||||
|
* tst-sysconf.c: Likewise.
|
||||||
|
* tst-barrier2.c: Likewise.
|
||||||
|
* tst-cond4.c: Likewise.
|
||||||
|
* tst-cond6.c: Likewise.
|
||||||
|
* tst-rwlock4.c: Likewise.
|
||||||
|
* tst-unload.c: Likewise.
|
||||||
|
* tst-flock2.c (do_test): Use return instead of exit.
|
||||||
|
|
||||||
2003-03-22 Jakub Jelinek <jakub@redhat.com>
|
2003-03-22 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/fork.c (__fork): Add libc_hidden_def.
|
* sysdeps/unix/sysv/linux/fork.c (__fork): Add libc_hidden_def.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
# This file is part of the GNU C Library.
|
# This file is part of the GNU C Library.
|
||||||
# Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
# Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -28,3 +28,7 @@ static-thread-library = $(common-objpfx)nptl/libpthread.a
|
||||||
bounded-thread-library = $(common-objpfx)nptl/libpthread_b.a
|
bounded-thread-library = $(common-objpfx)nptl/libpthread_b.a
|
||||||
|
|
||||||
rpath-dirs += nptl
|
rpath-dirs += nptl
|
||||||
|
|
||||||
|
ifneq ($(subdir),nptl)
|
||||||
|
includes += -I$(..)nptl
|
||||||
|
endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -28,9 +28,15 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
main (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
size_t ps = sysconf (_SC_PAGESIZE);
|
size_t ps = sysconf (_SC_PAGESIZE);
|
||||||
char tmpfname[] = "/tmp/tst-barrier2.XXXXXX";
|
char tmpfname[] = "/tmp/tst-barrier2.XXXXXX";
|
||||||
char data[ps];
|
char data[ps];
|
||||||
|
@ -48,7 +54,7 @@ main (void)
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
printf ("cannot open temporary file: %m\n");
|
printf ("cannot open temporary file: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure it is always removed. */
|
/* Make sure it is always removed. */
|
||||||
|
@ -61,14 +67,14 @@ main (void)
|
||||||
if (write (fd, data, ps) != ps)
|
if (write (fd, data, ps) != ps)
|
||||||
{
|
{
|
||||||
puts ("short write");
|
puts ("short write");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (mem == MAP_FAILED)
|
if (mem == MAP_FAILED)
|
||||||
{
|
{
|
||||||
printf ("mmap failed: %m\n");
|
printf ("mmap failed: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
|
b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
|
||||||
|
@ -77,49 +83,49 @@ main (void)
|
||||||
if (pthread_barrierattr_init (&a) != 0)
|
if (pthread_barrierattr_init (&a) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrierattr_init failed");
|
puts ("barrierattr_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrierattr_getpshared (&a, &p) != 0)
|
if (pthread_barrierattr_getpshared (&a, &p) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st barrierattr_getpshared failed");
|
puts ("1st barrierattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != PTHREAD_PROCESS_PRIVATE)
|
if (p != PTHREAD_PROCESS_PRIVATE)
|
||||||
{
|
{
|
||||||
puts ("default pshared value wrong");
|
puts ("default pshared value wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrierattr_setpshared failed");
|
puts ("barrierattr_setpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrierattr_getpshared (&a, &p) != 0)
|
if (pthread_barrierattr_getpshared (&a, &p) != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd barrierattr_getpshared failed");
|
puts ("2nd barrierattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != PTHREAD_PROCESS_SHARED)
|
if (p != PTHREAD_PROCESS_SHARED)
|
||||||
{
|
{
|
||||||
puts ("pshared value after setpshared call wrong");
|
puts ("pshared value after setpshared call wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrier_init (b, &a, 2) != 0)
|
if (pthread_barrier_init (b, &a, 2) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrier_init failed");
|
puts ("barrier_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrierattr_destroy (&a) != 0)
|
if (pthread_barrierattr_destroy (&a) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrierattr_destroy failed");
|
puts ("barrierattr_destroy failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("going to fork now");
|
puts ("going to fork now");
|
||||||
|
@ -127,7 +133,7 @@ main (void)
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
puts ("fork failed");
|
puts ("fork failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just to be sure we don't hang forever. */
|
/* Just to be sure we don't hang forever. */
|
||||||
|
@ -145,7 +151,7 @@ main (void)
|
||||||
{
|
{
|
||||||
printf ("%s: barrier_wait returned value %d != 0 and PTHREAD_BARRIER_SERIAL_THREAD\n",
|
printf ("%s: barrier_wait returned value %d != 0 and PTHREAD_BARRIER_SERIAL_THREAD\n",
|
||||||
pid == 0 ? "child" : "parent", e);
|
pid == 0 ? "child" : "parent", e);
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +183,10 @@ main (void)
|
||||||
WEXITSTATUS (status) + serials, N);
|
WEXITSTATUS (status) + serials, N);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
exit (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if _POSIX_CLOCK_SELECTION
|
||||||
static int
|
static int
|
||||||
run_test (clockid_t cl)
|
run_test (clockid_t cl)
|
||||||
{
|
{
|
||||||
|
@ -149,15 +150,23 @@ run_test (clockid_t cl)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_CLOCK_SELECTION
|
||||||
|
|
||||||
|
puts ("_POSIX_CLOCK_SELECTION not supported, test skipped");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
int res = run_test (CLOCK_REALTIME);
|
int res = run_test (CLOCK_REALTIME);
|
||||||
|
|
||||||
#if defined _POSIX_MONOTONIC_CLOCK
|
# if defined _POSIX_MONOTONIC_CLOCK
|
||||||
# if _POSIX_MONOTONIC_CLOCK == 0
|
# if _POSIX_MONOTONIC_CLOCK == 0
|
||||||
int e = sysconf (_SC_MONOTONIC_CLOCK);
|
int e = sysconf (_SC_MONOTONIC_CLOCK);
|
||||||
if (e < 0)
|
if (e < 0)
|
||||||
puts ("CLOCK_MONOTONIC not supported");
|
puts ("CLOCK_MONOTONIC not supported");
|
||||||
|
@ -167,13 +176,14 @@ do_test (void)
|
||||||
res = 1;
|
res = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# endif
|
# endif
|
||||||
res |= run_test (CLOCK_MONOTONIC);
|
res |= run_test (CLOCK_MONOTONIC);
|
||||||
#else
|
# else
|
||||||
puts ("_POSIX_MONOTONIC_CLOCK not defined");
|
puts ("_POSIX_MONOTONIC_CLOCK not defined");
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TIMEOUT 3
|
#define TIMEOUT 3
|
||||||
|
|
|
@ -29,10 +29,16 @@
|
||||||
|
|
||||||
int *condition;
|
int *condition;
|
||||||
|
|
||||||
|
static int
|
||||||
int
|
do_test (void)
|
||||||
main (void)
|
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
size_t ps = sysconf (_SC_PAGESIZE);
|
size_t ps = sysconf (_SC_PAGESIZE);
|
||||||
char tmpfname[] = "/tmp/tst-cond4.XXXXXX";
|
char tmpfname[] = "/tmp/tst-cond4.XXXXXX";
|
||||||
char data[ps];
|
char data[ps];
|
||||||
|
@ -51,7 +57,7 @@ main (void)
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
printf ("cannot open temporary file: %m\n");
|
printf ("cannot open temporary file: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure it is always removed. */
|
/* Make sure it is always removed. */
|
||||||
|
@ -64,14 +70,14 @@ main (void)
|
||||||
if (write (fd, data, ps) != ps)
|
if (write (fd, data, ps) != ps)
|
||||||
{
|
{
|
||||||
puts ("short write");
|
puts ("short write");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (mem == MAP_FAILED)
|
if (mem == MAP_FAILED)
|
||||||
{
|
{
|
||||||
printf ("mmap failed: %m\n");
|
printf ("mmap failed: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mut1 = (pthread_mutex_t *) (((uintptr_t) mem
|
mut1 = (pthread_mutex_t *) (((uintptr_t) mem
|
||||||
|
@ -89,97 +95,97 @@ main (void)
|
||||||
if (pthread_mutexattr_init (&ma) != 0)
|
if (pthread_mutexattr_init (&ma) != 0)
|
||||||
{
|
{
|
||||||
puts ("mutexattr_init failed");
|
puts ("mutexattr_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutexattr_getpshared (&ma, &p) != 0)
|
if (pthread_mutexattr_getpshared (&ma, &p) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st mutexattr_getpshared failed");
|
puts ("1st mutexattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != PTHREAD_PROCESS_PRIVATE)
|
if (p != PTHREAD_PROCESS_PRIVATE)
|
||||||
{
|
{
|
||||||
puts ("default pshared value wrong");
|
puts ("default pshared value wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
{
|
{
|
||||||
puts ("mutexattr_setpshared failed");
|
puts ("mutexattr_setpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutexattr_getpshared (&ma, &p) != 0)
|
if (pthread_mutexattr_getpshared (&ma, &p) != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd mutexattr_getpshared failed");
|
puts ("2nd mutexattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != PTHREAD_PROCESS_SHARED)
|
if (p != PTHREAD_PROCESS_SHARED)
|
||||||
{
|
{
|
||||||
puts ("pshared value after setpshared call wrong");
|
puts ("pshared value after setpshared call wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_init (mut1, &ma) != 0)
|
if (pthread_mutex_init (mut1, &ma) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st mutex_init failed");
|
puts ("1st mutex_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_init (mut2, &ma) != 0)
|
if (pthread_mutex_init (mut2, &ma) != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd mutex_init failed");
|
puts ("2nd mutex_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_condattr_init (&ca) != 0)
|
if (pthread_condattr_init (&ca) != 0)
|
||||||
{
|
{
|
||||||
puts ("condattr_init failed");
|
puts ("condattr_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_condattr_getpshared (&ca, &p) != 0)
|
if (pthread_condattr_getpshared (&ca, &p) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st condattr_getpshared failed");
|
puts ("1st condattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != PTHREAD_PROCESS_PRIVATE)
|
if (p != PTHREAD_PROCESS_PRIVATE)
|
||||||
{
|
{
|
||||||
puts ("default value for pshared in condattr wrong");
|
puts ("default value for pshared in condattr wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_condattr_setpshared (&ca, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_condattr_setpshared (&ca, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
{
|
{
|
||||||
puts ("condattr_setpshared failed");
|
puts ("condattr_setpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_condattr_getpshared (&ca, &p) != 0)
|
if (pthread_condattr_getpshared (&ca, &p) != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd condattr_getpshared failed");
|
puts ("2nd condattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != PTHREAD_PROCESS_SHARED)
|
if (p != PTHREAD_PROCESS_SHARED)
|
||||||
{
|
{
|
||||||
puts ("pshared condattr still not set");
|
puts ("pshared condattr still not set");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_cond_init (cond, &ca) != 0)
|
if (pthread_cond_init (cond, &ca) != 0)
|
||||||
{
|
{
|
||||||
puts ("cond_init failed");
|
puts ("cond_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_lock (mut1) != 0)
|
if (pthread_mutex_lock (mut1) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: 1st mutex_lock failed");
|
puts ("parent: 1st mutex_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("going to fork now");
|
puts ("going to fork now");
|
||||||
|
@ -187,34 +193,34 @@ main (void)
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
puts ("fork failed");
|
puts ("fork failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
else if (pid == 0)
|
else if (pid == 0)
|
||||||
{
|
{
|
||||||
if (pthread_mutex_lock (mut2) != 0)
|
if (pthread_mutex_lock (mut2) != 0)
|
||||||
{
|
{
|
||||||
puts ("child: mutex_lock failed");
|
puts ("child: mutex_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_unlock (mut1) != 0)
|
if (pthread_mutex_unlock (mut1) != 0)
|
||||||
{
|
{
|
||||||
puts ("child: 1st mutex_unlock failed");
|
puts ("child: 1st mutex_unlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
if (pthread_cond_wait (cond, mut2) != 0)
|
if (pthread_cond_wait (cond, mut2) != 0)
|
||||||
{
|
{
|
||||||
puts ("child: cond_wait failed");
|
puts ("child: cond_wait failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
while (*condition == 0);
|
while (*condition == 0);
|
||||||
|
|
||||||
if (pthread_mutex_unlock (mut2) != 0)
|
if (pthread_mutex_unlock (mut2) != 0)
|
||||||
{
|
{
|
||||||
puts ("child: 2nd mutex_unlock failed");
|
puts ("child: 2nd mutex_unlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("child done");
|
puts ("child done");
|
||||||
|
@ -226,19 +232,19 @@ main (void)
|
||||||
if (pthread_mutex_lock (mut1) != 0)
|
if (pthread_mutex_lock (mut1) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: 2nd mutex_lock failed");
|
puts ("parent: 2nd mutex_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_lock (mut2) != 0)
|
if (pthread_mutex_lock (mut2) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: 3rd mutex_lock failed");
|
puts ("parent: 3rd mutex_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_cond_signal (cond) != 0)
|
if (pthread_cond_signal (cond) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: cond_signal failed");
|
puts ("parent: cond_signal failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*condition = 1;
|
*condition = 1;
|
||||||
|
@ -246,7 +252,7 @@ main (void)
|
||||||
if (pthread_mutex_unlock (mut2) != 0)
|
if (pthread_mutex_unlock (mut2) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: mutex_unlock failed");
|
puts ("parent: mutex_unlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("waiting for child");
|
puts ("waiting for child");
|
||||||
|
@ -258,4 +264,8 @@ main (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -31,10 +31,16 @@
|
||||||
|
|
||||||
int *condition;
|
int *condition;
|
||||||
|
|
||||||
|
static int
|
||||||
int
|
do_test (void)
|
||||||
main (void)
|
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
size_t ps = sysconf (_SC_PAGESIZE);
|
size_t ps = sysconf (_SC_PAGESIZE);
|
||||||
char tmpfname[] = "/tmp/tst-cond6.XXXXXX";
|
char tmpfname[] = "/tmp/tst-cond6.XXXXXX";
|
||||||
char data[ps];
|
char data[ps];
|
||||||
|
@ -230,4 +236,8 @@ main (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -59,13 +59,20 @@ tf (void *arg)
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
char tmp[] = "/tmp/tst-flock2-XXXXXX";
|
char tmp[] = "/tmp/tst-flock2-XXXXXX";
|
||||||
|
|
||||||
fd = mkstemp (tmp);
|
fd = mkstemp (tmp);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
puts ("mkstemp failed");
|
puts ("mkstemp failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink (tmp);
|
unlink (tmp);
|
||||||
|
@ -80,32 +87,32 @@ do_test (void)
|
||||||
if (b == MAP_FAILED)
|
if (b == MAP_FAILED)
|
||||||
{
|
{
|
||||||
puts ("mmap failed");
|
puts ("mmap failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_barrierattr_t ba;
|
pthread_barrierattr_t ba;
|
||||||
if (pthread_barrierattr_init (&ba) != 0)
|
if (pthread_barrierattr_init (&ba) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrierattr_init failed");
|
puts ("barrierattr_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrierattr_setpshared failed");
|
puts ("barrierattr_setpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrier_init (b, &ba, 2) != 0)
|
if (pthread_barrier_init (b, &ba, 2) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrier_init failed");
|
puts ("barrier_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_barrierattr_destroy (&ba) != 0)
|
if (pthread_barrierattr_destroy (&ba) != 0)
|
||||||
{
|
{
|
||||||
puts ("barrierattr_destroy failed");
|
puts ("barrierattr_destroy failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct flock fl =
|
struct flock fl =
|
||||||
|
@ -118,14 +125,14 @@ do_test (void)
|
||||||
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
|
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
|
||||||
{
|
{
|
||||||
puts ("first fcntl failed");
|
puts ("first fcntl failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t pid = fork ();
|
pid_t pid = fork ();
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
puts ("fork failed");
|
puts ("fork failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
|
@ -137,7 +144,7 @@ do_test (void)
|
||||||
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
|
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
|
||||||
{
|
{
|
||||||
puts ("child: second flock succeeded");
|
puts ("child: second flock succeeded");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +156,7 @@ do_test (void)
|
||||||
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
|
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
|
||||||
{
|
{
|
||||||
puts ("third fcntl failed");
|
puts ("third fcntl failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,25 +168,25 @@ do_test (void)
|
||||||
if (pthread_mutex_lock (&lock) != 0)
|
if (pthread_mutex_lock (&lock) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st locking of lock failed");
|
puts ("1st locking of lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_lock (&lock2) != 0)
|
if (pthread_mutex_lock (&lock2) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st locking of lock2 failed");
|
puts ("1st locking of lock2 failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_create (&th, NULL, tf, NULL) != 0)
|
if (pthread_create (&th, NULL, tf, NULL) != 0)
|
||||||
{
|
{
|
||||||
puts ("pthread_create failed");
|
puts ("pthread_create failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_lock (&lock) != 0)
|
if (pthread_mutex_lock (&lock) != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd locking of lock failed");
|
puts ("2nd locking of lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("child locked file");
|
puts ("child locked file");
|
||||||
|
@ -193,7 +200,7 @@ do_test (void)
|
||||||
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
|
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
|
||||||
{
|
{
|
||||||
puts ("fifth fcntl succeeded");
|
puts ("fifth fcntl succeeded");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("file locked by child");
|
puts ("file locked by child");
|
||||||
|
@ -206,13 +213,13 @@ do_test (void)
|
||||||
if (pthread_mutex_unlock (&lock2) != 0)
|
if (pthread_mutex_unlock (&lock2) != 0)
|
||||||
{
|
{
|
||||||
puts ("unlock of lock2 failed");
|
puts ("unlock of lock2 failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_join (th, NULL) != 0)
|
if (pthread_join (th, NULL) != 0)
|
||||||
{
|
{
|
||||||
puts ("join failed");
|
puts ("join failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("child's thread terminated");
|
puts ("child's thread terminated");
|
||||||
|
@ -226,7 +233,7 @@ do_test (void)
|
||||||
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
|
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
|
||||||
{
|
{
|
||||||
puts ("fifth fcntl succeeded");
|
puts ("fifth fcntl succeeded");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("file still locked");
|
puts ("file still locked");
|
||||||
|
@ -243,17 +250,18 @@ do_test (void)
|
||||||
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
|
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
|
||||||
{
|
{
|
||||||
puts ("waitpid failed");
|
puts ("waitpid failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
puts ("child terminated");
|
puts ("child terminated");
|
||||||
|
|
||||||
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
|
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
|
||||||
{
|
{
|
||||||
puts ("sixth fcntl failed");
|
puts ("sixth fcntl failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_FUNCTION do_test ()
|
#define TEST_FUNCTION do_test ()
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
static void *
|
static void *
|
||||||
tf1 (void *arg)
|
tf1 (void *arg)
|
||||||
{
|
{
|
||||||
pthread_join (arg, NULL);
|
pthread_join ((pthread_t) arg, NULL);
|
||||||
|
|
||||||
puts ("1st join returned");
|
puts ("1st join returned");
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ tf1 (void *arg)
|
||||||
static void *
|
static void *
|
||||||
tf2 (void *arg)
|
tf2 (void *arg)
|
||||||
{
|
{
|
||||||
pthread_join (arg, NULL);
|
pthread_join ((pthread_t) arg, NULL);
|
||||||
|
|
||||||
puts ("2nd join returned");
|
puts ("2nd join returned");
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -28,9 +28,16 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
main (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
size_t ps = sysconf (_SC_PAGESIZE);
|
size_t ps = sysconf (_SC_PAGESIZE);
|
||||||
char tmpfname[] = "/tmp/tst-mutex4.XXXXXX";
|
char tmpfname[] = "/tmp/tst-mutex4.XXXXXX";
|
||||||
char data[ps];
|
char data[ps];
|
||||||
|
@ -47,7 +54,7 @@ main (void)
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
printf ("cannot open temporary file: %m\n");
|
printf ("cannot open temporary file: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure it is always removed. */
|
/* Make sure it is always removed. */
|
||||||
|
@ -60,14 +67,14 @@ main (void)
|
||||||
if (write (fd, data, ps) != ps)
|
if (write (fd, data, ps) != ps)
|
||||||
{
|
{
|
||||||
puts ("short write");
|
puts ("short write");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (mem == MAP_FAILED)
|
if (mem == MAP_FAILED)
|
||||||
{
|
{
|
||||||
printf ("mmap failed: %m\n");
|
printf ("mmap failed: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
|
m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
|
||||||
|
@ -77,67 +84,67 @@ main (void)
|
||||||
if (pthread_mutexattr_init (&a) != 0)
|
if (pthread_mutexattr_init (&a) != 0)
|
||||||
{
|
{
|
||||||
puts ("mutexattr_init failed");
|
puts ("mutexattr_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutexattr_getpshared (&a, &s) != 0)
|
if (pthread_mutexattr_getpshared (&a, &s) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st mutexattr_getpshared failed");
|
puts ("1st mutexattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s != PTHREAD_PROCESS_PRIVATE)
|
if (s != PTHREAD_PROCESS_PRIVATE)
|
||||||
{
|
{
|
||||||
puts ("default pshared value wrong");
|
puts ("default pshared value wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
{
|
{
|
||||||
puts ("mutexattr_setpshared failed");
|
puts ("mutexattr_setpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutexattr_getpshared (&a, &s) != 0)
|
if (pthread_mutexattr_getpshared (&a, &s) != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd mutexattr_getpshared failed");
|
puts ("2nd mutexattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s != PTHREAD_PROCESS_SHARED)
|
if (s != PTHREAD_PROCESS_SHARED)
|
||||||
{
|
{
|
||||||
puts ("pshared value after setpshared call wrong");
|
puts ("pshared value after setpshared call wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_init (m, &a) != 0)
|
if (pthread_mutex_init (m, &a) != 0)
|
||||||
{
|
{
|
||||||
puts ("mutex_init failed");
|
puts ("mutex_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_lock (m) != 0)
|
if (pthread_mutex_lock (m) != 0)
|
||||||
{
|
{
|
||||||
puts ("mutex_lock failed");
|
puts ("mutex_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutexattr_destroy (&a) != 0)
|
if (pthread_mutexattr_destroy (&a) != 0)
|
||||||
{
|
{
|
||||||
puts ("mutexattr_destroy failed");
|
puts ("mutexattr_destroy failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pthread_mutex_trylock (m);
|
err = pthread_mutex_trylock (m);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
puts ("mutex_trylock succeeded");
|
puts ("mutex_trylock succeeded");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
else if (err != EBUSY)
|
else if (err != EBUSY)
|
||||||
{
|
{
|
||||||
puts ("mutex_trylock didn't return EBUSY");
|
puts ("mutex_trylock didn't return EBUSY");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
@ -147,7 +154,7 @@ main (void)
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
puts ("fork failed");
|
puts ("fork failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
else if (pid == 0)
|
else if (pid == 0)
|
||||||
{
|
{
|
||||||
|
@ -155,13 +162,13 @@ main (void)
|
||||||
if ((*p)++ != 0)
|
if ((*p)++ != 0)
|
||||||
{
|
{
|
||||||
puts ("child: *p != 0");
|
puts ("child: *p != 0");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_unlock (m) != 0)
|
if (pthread_mutex_unlock (m) != 0)
|
||||||
{
|
{
|
||||||
puts ("child: 1st mutex_unlock failed");
|
puts ("child: 1st mutex_unlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("child done");
|
puts ("child done");
|
||||||
|
@ -171,17 +178,22 @@ main (void)
|
||||||
if (pthread_mutex_lock (m) != 0)
|
if (pthread_mutex_lock (m) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: 2nd mutex_lock failed");
|
puts ("parent: 2nd mutex_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p != 1)
|
if (*p != 1)
|
||||||
{
|
{
|
||||||
puts ("*p != 1");
|
puts ("*p != 1");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("parent done");
|
puts ("parent done");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit (0);
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TIMEOUT 4
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -28,9 +28,16 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
main (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
size_t ps = sysconf (_SC_PAGESIZE);
|
size_t ps = sysconf (_SC_PAGESIZE);
|
||||||
char tmpfname[] = "/tmp/tst-rwlock4.XXXXXX";
|
char tmpfname[] = "/tmp/tst-rwlock4.XXXXXX";
|
||||||
char data[ps];
|
char data[ps];
|
||||||
|
@ -47,7 +54,7 @@ main (void)
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
printf ("cannot open temporary file: %m\n");
|
printf ("cannot open temporary file: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure it is always removed. */
|
/* Make sure it is always removed. */
|
||||||
|
@ -60,14 +67,14 @@ main (void)
|
||||||
if (write (fd, data, ps) != ps)
|
if (write (fd, data, ps) != ps)
|
||||||
{
|
{
|
||||||
puts ("short write");
|
puts ("short write");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (mem == MAP_FAILED)
|
if (mem == MAP_FAILED)
|
||||||
{
|
{
|
||||||
printf ("mmap failed: %m\n");
|
printf ("mmap failed: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = (pthread_rwlock_t *) (((uintptr_t) mem + __alignof (pthread_rwlock_t))
|
r = (pthread_rwlock_t *) (((uintptr_t) mem + __alignof (pthread_rwlock_t))
|
||||||
|
@ -77,67 +84,67 @@ main (void)
|
||||||
if (pthread_rwlockattr_init (&a) != 0)
|
if (pthread_rwlockattr_init (&a) != 0)
|
||||||
{
|
{
|
||||||
puts ("rwlockattr_init failed");
|
puts ("rwlockattr_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_rwlockattr_getpshared (&a, &s) != 0)
|
if (pthread_rwlockattr_getpshared (&a, &s) != 0)
|
||||||
{
|
{
|
||||||
puts ("1st rwlockattr_getpshared failed");
|
puts ("1st rwlockattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s != PTHREAD_PROCESS_PRIVATE)
|
if (s != PTHREAD_PROCESS_PRIVATE)
|
||||||
{
|
{
|
||||||
puts ("default pshared value wrong");
|
puts ("default pshared value wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_rwlockattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_rwlockattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
{
|
{
|
||||||
puts ("rwlockattr_setpshared failed");
|
puts ("rwlockattr_setpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_rwlockattr_getpshared (&a, &s) != 0)
|
if (pthread_rwlockattr_getpshared (&a, &s) != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd rwlockattr_getpshared failed");
|
puts ("2nd rwlockattr_getpshared failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s != PTHREAD_PROCESS_SHARED)
|
if (s != PTHREAD_PROCESS_SHARED)
|
||||||
{
|
{
|
||||||
puts ("pshared value after setpshared call wrong");
|
puts ("pshared value after setpshared call wrong");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_rwlock_init (r, &a) != 0)
|
if (pthread_rwlock_init (r, &a) != 0)
|
||||||
{
|
{
|
||||||
puts ("rwlock_init failed");
|
puts ("rwlock_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_rwlock_rdlock (r) != 0)
|
if (pthread_rwlock_rdlock (r) != 0)
|
||||||
{
|
{
|
||||||
puts ("rwlock_rdlock failed");
|
puts ("rwlock_rdlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_rwlockattr_destroy (&a) != 0)
|
if (pthread_rwlockattr_destroy (&a) != 0)
|
||||||
{
|
{
|
||||||
puts ("rwlockattr_destroy failed");
|
puts ("rwlockattr_destroy failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pthread_rwlock_trywrlock (r);
|
err = pthread_rwlock_trywrlock (r);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
puts ("rwlock_trywrlock succeeded");
|
puts ("rwlock_trywrlock succeeded");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
else if (err != EBUSY)
|
else if (err != EBUSY)
|
||||||
{
|
{
|
||||||
puts ("rwlock_trywrlock didn't return EBUSY");
|
puts ("rwlock_trywrlock didn't return EBUSY");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
@ -147,7 +154,7 @@ main (void)
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
puts ("fork failed");
|
puts ("fork failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
else if (pid == 0)
|
else if (pid == 0)
|
||||||
{
|
{
|
||||||
|
@ -155,13 +162,13 @@ main (void)
|
||||||
if ((*p)++ != 0)
|
if ((*p)++ != 0)
|
||||||
{
|
{
|
||||||
puts ("child: *p != 0");
|
puts ("child: *p != 0");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_rwlock_unlock (r) != 0)
|
if (pthread_rwlock_unlock (r) != 0)
|
||||||
{
|
{
|
||||||
puts ("child: 1st rwlock_unlock failed");
|
puts ("child: 1st rwlock_unlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("child done");
|
puts ("child done");
|
||||||
|
@ -171,17 +178,21 @@ main (void)
|
||||||
if (pthread_rwlock_wrlock (r) != 0)
|
if (pthread_rwlock_wrlock (r) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: rwlock_wrlock failed");
|
puts ("parent: rwlock_wrlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p != 1)
|
if (*p != 1)
|
||||||
{
|
{
|
||||||
puts ("*p != 1");
|
puts ("*p != 1");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("parent done");
|
puts ("parent done");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit (0);
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -94,6 +94,13 @@ receiver (void)
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
char tmp[] = "/tmp/tst-signal1-XXXXXX";
|
char tmp[] = "/tmp/tst-signal1-XXXXXX";
|
||||||
|
|
||||||
int fd = mkstemp (tmp);
|
int fd = mkstemp (tmp);
|
||||||
|
@ -183,6 +190,7 @@ do_test (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_FUNCTION do_test ()
|
#define TEST_FUNCTION do_test ()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
@ -28,9 +28,15 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
main (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
#if ! _POSIX_THREAD_PROCESS_SHARED
|
||||||
|
|
||||||
|
puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
size_t ps = sysconf (_SC_PAGESIZE);
|
size_t ps = sysconf (_SC_PAGESIZE);
|
||||||
char tmpfname[] = "/tmp/tst-spin2.XXXXXX";
|
char tmpfname[] = "/tmp/tst-spin2.XXXXXX";
|
||||||
char data[ps];
|
char data[ps];
|
||||||
|
@ -45,7 +51,7 @@ main (void)
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
printf ("cannot open temporary file: %m\n");
|
printf ("cannot open temporary file: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure it is always removed. */
|
/* Make sure it is always removed. */
|
||||||
|
@ -58,14 +64,14 @@ main (void)
|
||||||
if (write (fd, data, ps) != ps)
|
if (write (fd, data, ps) != ps)
|
||||||
{
|
{
|
||||||
puts ("short write");
|
puts ("short write");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (mem == MAP_FAILED)
|
if (mem == MAP_FAILED)
|
||||||
{
|
{
|
||||||
printf ("mmap failed: %m\n");
|
printf ("mmap failed: %m\n");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = (pthread_spinlock_t *) (((uintptr_t) mem
|
s = (pthread_spinlock_t *) (((uintptr_t) mem
|
||||||
|
@ -76,39 +82,39 @@ main (void)
|
||||||
if (pthread_spin_init (s, PTHREAD_PROCESS_SHARED) != 0)
|
if (pthread_spin_init (s, PTHREAD_PROCESS_SHARED) != 0)
|
||||||
{
|
{
|
||||||
puts ("spin_init failed");
|
puts ("spin_init failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_spin_lock (s) != 0)
|
if (pthread_spin_lock (s) != 0)
|
||||||
{
|
{
|
||||||
puts ("spin_lock failed");
|
puts ("spin_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pthread_spin_trylock (s);
|
err = pthread_spin_trylock (s);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
puts ("1st spin_trylock succeeded");
|
puts ("1st spin_trylock succeeded");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
else if (err != EBUSY)
|
else if (err != EBUSY)
|
||||||
{
|
{
|
||||||
puts ("1st spin_trylock didn't return EBUSY");
|
puts ("1st spin_trylock didn't return EBUSY");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pthread_spin_unlock (s);
|
err = pthread_spin_unlock (s);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: spin_unlock failed");
|
puts ("parent: spin_unlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pthread_spin_trylock (s);
|
err = pthread_spin_trylock (s);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
puts ("2nd spin_trylock failed");
|
puts ("2nd spin_trylock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
@ -118,7 +124,7 @@ main (void)
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
puts ("fork failed");
|
puts ("fork failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
else if (pid == 0)
|
else if (pid == 0)
|
||||||
{
|
{
|
||||||
|
@ -126,13 +132,13 @@ main (void)
|
||||||
if ((*p)++ != 0)
|
if ((*p)++ != 0)
|
||||||
{
|
{
|
||||||
puts ("child: *p != 0");
|
puts ("child: *p != 0");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_spin_unlock (s) != 0)
|
if (pthread_spin_unlock (s) != 0)
|
||||||
{
|
{
|
||||||
puts ("child: 1st spin_unlock failed");
|
puts ("child: 1st spin_unlock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("child done");
|
puts ("child done");
|
||||||
|
@ -142,7 +148,7 @@ main (void)
|
||||||
if (pthread_spin_lock (s) != 0)
|
if (pthread_spin_lock (s) != 0)
|
||||||
{
|
{
|
||||||
puts ("parent: 2nd spin_lock failed");
|
puts ("parent: 2nd spin_lock failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("waiting for child");
|
puts ("waiting for child");
|
||||||
|
@ -151,6 +157,10 @@ main (void)
|
||||||
|
|
||||||
puts ("parent done");
|
puts ("parent done");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
exit (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Tests for non-unloading of libpthread.
|
/* Tests for non-unloading of libpthread.
|
||||||
Copyright (C) 2000, 2002 Free Software Foundation, Inc.
|
Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -22,24 +22,27 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gnu/lib-names.h>
|
#include <gnu/lib-names.h>
|
||||||
|
|
||||||
int
|
static int
|
||||||
main (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
void *p = dlopen (PREFIX LIBPTHREAD_SO, RTLD_LAZY);
|
void *p = dlopen (PREFIX LIBPTHREAD_SO, RTLD_LAZY);
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
puts ("failed to load " LIBPTHREAD_SO);
|
puts ("failed to load " LIBPTHREAD_SO);
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dlclose (p) != 0)
|
if (dlclose (p) != 0)
|
||||||
{
|
{
|
||||||
puts ("dlclose (" LIBPTHREAD_SO ") failed");
|
puts ("dlclose (" LIBPTHREAD_SO ") failed");
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("seems to work");
|
puts ("seems to work");
|
||||||
|
|
||||||
exit (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
Loading…
Reference in New Issue