Commit Graph

26 Commits

Author SHA1 Message Date
manu bba80928a8 setcontext() used to be incompatible with -lpthread since it affected
the TLS pointer, therefore wrecking the pthread environement.

Some ports had _UC_TLSBASE flag or equivalent (_UC_UNIQUE on alpha)
that controlled whether setcontext() would change the TLS pointer.
This change let libpthread override setcontext() with its own version
that unsets _UC_TLSBASE, enabling safe usage of setcontext() with
-lpthread.

We also have the following required changes here:
- rename alpha's _UC_UNIQUE into _UC_TLSBASE
- add _UC_TLSBASE definition in header file for all ports
  (powerpc, sh3, sparc and sparc64 lack the implementation for now)
- introduce a libc stub that can be overriden for setcontext()
- modify MD libcs swapcontext() implementations so that they use the
  setcontext() libc stub instead of doing a plain system call.

While we are there:
- document various MD _UC_* flags in header file
- add libc and libpthread tests for swapcontext() behavior
  (hopefully helpful to spot MD problems introduced with this change)

Future work:
- Deciding whether kernel support or _UC_TLSBASE should be added for
  powerpc, sh3, sparc and sparc64 is left to portmasters
  sparc64

Approved by core@
2012-09-12 02:00:51 +00:00
joerg e07445e070 Also exercise pthread_attr_setstacksize. 2012-03-12 20:17:16 +00:00
joerg 7baa2850f5 It is perfectly valid for sem_wait to be interrupted, so loop on EINTR. 2012-03-09 19:46:37 +00:00
joerg d1de8de689 Remove libpthread's semaphore implementation and always use the kernel
one. The implementation doesn't provide an async-safe sem_post and can't
without a lot of work on the pthread primitives.

Remove bogus time out requirement in test case, it should have been
a "known failure" if anything.
2012-03-07 23:31:44 +00:00
joerg 1b3763c684 Remove bogus check that (a) depends uninitialised memory (b) overflows a
buffer.
2011-12-12 23:54:18 +00:00
dholland ef311a878c Requires stdint.h. 2011-08-22 00:33:16 +00:00
jruoho 710017dde4 As per PR lib/44818, remove 'lib/libpthread/t_status'. It takes two minutes
to rewrite this properly if someone misses this.
2011-04-06 16:04:16 +00:00
martin b78cd4dd7c Do only set a (lower than default) timeout value if we are on powerpc and
expect to run into a real deadrun ofter.
The (too short) timeout otherwise makes slower archs fail.
2011-04-04 14:47:22 +00:00
jruoho 1b871e25a1 Add a test case for pthread_cond_timedwait(3) failures reported by
Sad Clouds in PR lib/44756. This was discussed also in:

	http://mail-index.netbsd.org/tech-userlevel/2011/03/17/msg004689.html
2011-03-27 16:45:15 +00:00
jruoho 68f3621e3d A dummy conformance-test for pthread_detach(3). I will extend this later. 2011-03-24 13:52:04 +00:00
jruoho c3917926fd A dummy conformance-test of pthread_equal(3). 2011-03-24 12:40:59 +00:00
riz 9613b94f2f mutex2/mutex3 are expected to fail on powerpc because of
PR port-powerpc/44387.

XXX the ugly sleep at the end is because ATF will mark an un-triggered
race condition (ie, the test passes unexpectedly) as a test failure otherwise.
2011-02-21 21:43:41 +00:00
jmmv 0553513a0e The mutex3 test is supposed to use a static initializer so that it differs
to the mutex2 test.  This detail was lost during the atfification of these
tests.

Spotted by pooka@ and riz@.
2011-02-20 14:37:44 +00:00
joerg 1b0b455148 Link t_fpu against libm if the compiler doesn't want to inline sin/cos. 2010-12-08 23:50:14 +00:00
joerg 236a44094d Test alignment of constructor / destructor calls as well as the stack
of new threads. Currently implement for i386 and AMD64.
2010-11-30 18:38:53 +00:00
jmmv decf2b5e0f Adjusts tests after import of atf-0.12:
- The use.fs property is gone.
- Mark the tests/fs/t_create:attrs test as broken when using the default
  unprivileged-user:_atf setting.  This probably deserves a fix somehow
  but I'm not sure at this point.
2010-11-07 17:51:16 +00:00
christos 0f10aa9dce add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)
2010-11-03 16:10:19 +00:00
hans 846cca4cda Revert to 1.1 and fix the casts by using uintptr_t. Ok jruoho. 2010-07-29 12:56:16 +00:00
jruoho f560676c53 One more cast. 2010-07-29 12:17:31 +00:00
jruoho 07456be22e Fix build failure on AMD64, noted by njoly@. 2010-07-29 12:03:10 +00:00
jruoho b226f3d0e3 Add a simple test for pthread_join(3). 2010-07-28 21:29:15 +00:00
jmmv 8a0380e301 before_start_one_thread is not racy only in amd64; my confusion. Mark it
as an xfail everywhere and, while doing so, make the test longer so that
we trigger the failure all the time -- of course, being a race this may
still happen but the chances should be pretty low.
2010-07-21 17:23:08 +00:00
jmmv 28cce38f11 Split the before_start test in two: one that does not use threads and one
that does.  The former works all the time but the latter gets consistently
stuck on amd64.  Mark the latter as an expected timeout (should be a "race
condition" test, but atf does not have such a thing yet[1]).

This clears the test failures, at least, under anita running NetBSD/i386.

From pooka@: this could well be because calling sem_post(3) from a signal
handler can't possibly do the right thing with the pthread implementation.
However, according to signal(7), sem_post(3) is signal-async safe...

While here, program alarms using a timeout shorter than 1 second to speed
up the execution of the tests.

1: Good thing is I finally understand what a "race condition" test looks
like, I believe.
2010-07-19 10:31:46 +00:00
pooka 510b2ec795 Reduce sleep time for practically the same effect. Until atf can
do parallel test execution, tests which spend 99.9999% of their
execution sleeping are not nice.
2010-07-18 22:30:55 +00:00
njoly ffa14f5342 Add missing pthread_mutex_init call in mutex3 testcase. 2010-07-16 18:16:43 +00:00
jmmv ac555471ca Convert the libpthread tests to atf.
Initial work from the GSoC 2008 project by Lukasz Strzygowski.

I think that this, together with the previous conversion of librt, obsoletes
the tests in the semaphore/ directory.  Will investigate later.
2010-07-16 15:42:53 +00:00