Commit Graph

139 Commits

Author SHA1 Message Date
joerg 1631a78097 Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

Ports that support this feature provide __HAVE____LWP_GETPRIVATE_FAST in
machine/types.h and a corresponding __lwp_getprivate_fast in
machine/mcontext.h.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
2011-02-24 04:28:41 +00:00
christos c5d359be42 make pthread__sp unsigned long. 2011-01-25 19:12:04 +00:00
njoly 49931fb2d8 Restore PTHREAD__ASM_RASOPS for alpha (from _context_u.S), that was
lost in previous cleanup.

ok by ad@.
2009-05-18 13:03:35 +00:00
ad a61915e94f Remove unused code that's confusing when using cscope/opengrok. 2009-05-16 22:20:40 +00:00
ad 5c670ea686 - Make the threadreg code use _lwp_setprivate() instead of MD hooks.
XXX This must not be enabled by default because the LWP private mechanism
  is reserved for TLS. It is provided only as a test/demo.

  XXX Since ucontext_t does not contain the thread private variable, for a
  short time after threads are created their thread specific data is unset.
  If a signal arrives during that time we are screwed.

- No longer need pthread__osrev.

- Rearrange _lwp_ctl() calls slightly.
2009-03-29 09:30:05 +00:00
uwe 55247fa322 Fix typo in comment. 2008-10-27 00:52:07 +00:00
uwe 47cd7b4502 Pull down revision 1.3.6.1 by skrll@ (adapted to include reg::r_gbr).
struct mcontext != struct reg on sh3.

    Fix PTHREAD_UCONTEXT_TO_REG / PTHREAD_REG_TO_UCONTEXT to deal with this.
2008-10-27 00:47:22 +00:00
skrll 0b99767bfe Remove unnecessary include. 2008-08-11 21:45:24 +00:00
gmcgarry 5aa0bc7608 Selector registers are 16-bit and binutils 2.18 insists that only 16-bit
accesses are permitted on them.  Therefore, change movl to movw.  No change to
machine code generated.
2008-07-07 13:01:16 +00:00
ad 3e1711d6de pthread__threadreg_get: mark it const. 2008-06-23 10:39:38 +00:00
uwe c39ae7f5d7 Recycle unused _REG_EXPEVT slot in mcontext for _REG_GBR.
As the size of mcontext is not changed, we avoid the hassle of
versioning all the calls that use it.

_REG_EXPEVT was never used by any code in the tree.  Reporting EXPEVT
makes sense only for signals and in that case we pass it to userland
in ksi_trap already which is official MI way to get this (MD) information.

Old binaries running on new kernels will now have their GBR set from
new mcontext, but that's ok too, as GBR was not properly supported by
old kernels (not saved in trapframe), so old binaries couldn't have
possibly used it anyway.
2008-06-01 23:07:20 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad ecdd2c2965 Cheat and add inlines for _atomic_cas_ptr() to work around gcc emitting
unneeded PIC stuff in mutex_lock() and mutex_unlock(), when a thread
register is used.
2008-03-22 17:59:12 +00:00
ad a67e1e3475 - Remove libpthread's atomic ops.
- Remove the old spinlock-based mutex and rwlock implementations.
- Use the atomic ops from libc.
2008-02-10 18:50:54 +00:00
ad 66ac2ffaf2 Mutexes:
- Play scrooge again and chop more cycles off acquire/release.
- Spin while the lock holder is running on another CPU (adaptive mutexes).
- Do non-atomic release.

Threadreg:

- Add the necessary hooks to use a thread register.
- Add the code for i386, using %gs.
- Leave i386 code disabled until xen and COMPAT_NETBSD32 have the changes.
2007-11-13 17:20:08 +00:00
ad 15e9cec117 For PR bin/37347:
- Override __libc_thr_init() instead of using our own constructor.
- Add pthread__getenv() and use instead of getenv(). This is used before
  we are up and running and unfortunatley getenv() takes locks.

Other changes:

- Cache the spinlock vectors in pthread__st. Internal spinlock operations
  now take 1 function call instead of 3 (i386).
- Use pthread__self() internally, not pthread_self().
- Use __attribute__ ((visibility("hidden"))) in some places.
- Kill PTHREAD_MAIN_DEBUG.
2007-11-13 15:57:10 +00:00
skrll c6deb42c81 Provide PTHREAD__ASM_RASOPS for alpha.
The gcc generated lock try RAS is broken as the store needs to be the last
instruction.
2007-10-08 16:04:43 +00:00
skrll d32ed98975 Resurrect the function pointers for lock operations and allow each
architecture to provide asm versions of the RAS operations.

We do this because relying on the compiler to get the RAS right is not
sensible. (It gets alpha wrong and hppa is suboptimal)

Provide asm RAS ops for hppa.

(A slightly different version) reviewed by Andrew Doran.
2007-09-24 12:19:39 +00:00
ad 7db40473e2 Fix a dodgy bit of assembly. 2007-09-11 16:07:15 +00:00
ad f4fd6b797e - Get rid of self->pt_mutexhint and use pthread__mutex_owned() instead.
- Update some comments and fix minor bugs. Minor cosmetic changes.
- Replace some spinlocks with mutexes and rwlocks.
- Change the process private semaphores to use mutexes and condition
  variables instead of doing the synchronization directly. Spinlocks
  are no longer used by the semaphore code.
2007-09-08 22:49:50 +00:00
ad 8ccc6e060d - Don't take the mutex's spinlock (ptr_interlock) in pthread_cond_wait().
Instead, make the deferred wakeup list a per-thread array and pass down
  the lwpid_t's that way.

- In pthread_cond_wait(), take the mutex before dealing with early wakeup.
  In this way there should never be contention on the CV's spinlock if
  the app follows POSIX rules (there should only be contention on the
  user-provided mutex).

- Add a port of the kernel's rwlocks. The rwlock's spinlock is only taken if
  there is contention. This is enabled where atomic ops are available. Right
  now that is only i386 and amd64 because I don't have other hardware to
  test with. It's trivial to add stubs for other architectures as long as
  they have compare-and-swap. When we have proper atomic ops the old rwlock
  code can be removed.

- Add a new mutex implementation that's similar to the kernel's mutexes, but
  uses compare-and-swap to maintain the waiters list, so no spinlocks are
  involved. Same caveats apply as for the rwlocks.
2007-09-07 14:09:27 +00:00
ad a6ed47a549 Add: pthread__atomic_cas_ptr, pthread__atomic_swap_ptr, pthread__membar_full
This is a stopgap until the thorpej-atomic branch is complete.
2007-09-07 00:24:56 +00:00
scw 5764a76889 Remove support for NetBSD/{,evb}sh5. 2007-04-08 09:35:21 +00:00
ad de2138164c Remove the PTHREAD_SA option. If M:N threads is reimplemented it's
better off done with a seperate library.
2007-03-02 18:53:51 +00:00
christos d1ddfe10b1 fix warning about indirect call without * 2007-01-20 18:56:30 +00:00
ross 1a70c2f1e4 Err, restore the name of pthread__switch_return_point, it is
referenced from C code.
2006-07-09 01:07:38 +00:00
ross a228aa3de2 Revise for LP64.
Encapsulate previously copied code sections into macros.
2006-07-08 05:09:44 +00:00
ross 032dc727f7 remove unreferenced temporary label 2006-07-08 05:04:49 +00:00
cube 562d0d89a2 Instead of using hard-coded values for various registers, get them from the
current context.  Valid values can change depending on how the kernel is
setup.  i386 and amd64 happen to be setup differently.
2006-03-29 22:55:15 +00:00
skrll 2b3543128f I was a bit over zealous with my last change so revert the
locked_return_point change.

Loading the instruction at locked_return_point as a return value didn't
work so well.

Thanks to uwe, cube, and dsl.
2006-01-09 22:17:16 +00:00
uwe 6b8eb49dd6 Use PLT for PIC calls to avoid text relocs in the shared library. 2006-01-06 22:46:14 +00:00
uwe 55ad9313a6 In PIC code call setcontext(2) via PLT to avoid text reloc in the
shared library.
2006-01-04 17:44:53 +00:00
skrll 73b7bdcee7 A couple of fixes to make libpthread really shared, i.e. not have text re-
locations:

	- Don't declare pthread__switch_away global
	- Do the PIC dance for pthread__switch_return_point and
	  pthread__locked_switch. Ideally these (and other) symbols would
	  be hidden.

Thanks to uwe@, dyoung@ and elad@ for help.

XXX sh3 is still to be done.
XXX vax does strange things.
2006-01-04 12:43:43 +00:00
uwe ffaa72c2cc Adapt to new PIC macros that are now in <machine/asm.h>. Same binary
code is generated (still with text relocs, but eliminating them is the
next step).
2005-12-31 05:08:28 +00:00
perry ce666bb8ce __asm__ -> __asm 2005-12-24 23:10:08 +00:00
perry 4e11af46bc Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 21:11:15 +00:00
matt 38b7b2fcde Merge updates to algorithms from i386 switch code. 2005-04-09 20:53:19 +00:00
matt 7fa678813d Add STACKSPACE 2005-04-09 20:50:27 +00:00
matt e722e50c79 Rework and cleanup. Don't use REI, fake a call frame instead. 2005-04-09 20:49:02 +00:00
skrll 32069ca6a3 pt_sleepuc was removed a long time ago. 2004-12-01 14:27:01 +00:00
nathanw 45204d9ceb Punt to setcontext() system call if the PSL_T bit (single-step trap)
is set, so that the single-step trap happens in the thread's context
and not in the middle of _setcontext_u.

XXX might be able to do something here with iret, too, but it needs
more testing.
2004-11-30 21:05:01 +00:00
kent 63a8cde231 save&restore %fs and %gs registers for USER_LDT applications.
PR#26900
2004-11-10 01:12:57 +00:00
fvdl 5febc5eef5 Fix thread context switching to take the stack ABI into account.
From Wolfgang Solfrank.
2004-10-21 16:49:47 +00:00
rearnsha cd8021f51e Use RET macro for returning. 2004-08-21 11:31:44 +00:00
chs e348d7e175 add hppa MD libpthread bits. translated from MIPS. 2004-07-19 03:39:02 +00:00
nathanw cb111b5e34 When _SOFT_FLOAT is defined, don't save or restore user FP context.
(note: still needs some mk rules tweaking for MKSOFTFLOAT=yes to pass
-msoft-float to asm builds).
2004-07-10 20:57:00 +00:00
nathanw 821dde500e Fix a comment to say "Edit" instead of "Exit". 2004-07-07 18:21:33 +00:00
simonb b4f0be566a Catch up with changes to __fpregset_t.
In __longjmp14(), copy the FP CSR from the correct array and array slot.

Completes fix for PR port-mips/25942.
2004-07-03 05:10:06 +00:00
nathanw 44a1e00a08 Remove a comment made obsolete by the previous commit. 2004-06-02 22:39:52 +00:00
uwe 521748fbfa Fix typo in comment. 2004-05-28 22:58:25 +00:00