summaryrefslogtreecommitdiff
path: root/thread.h
Commit message (Collapse)AuthorAgeFilesLines
* Don't panic if can't destroy mutex during global destructionKarl Williamson2023-01-121-12/+19
| | | | | It's going to be destroyed anyway; this just obscures what the real failure might be.
* Switch libc per-interpreter data when tTHX changesKarl Williamson2022-10-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in the previous commit, some library functions now keep per-thread state. So far the only ones we care about are libc locale-changing ones. When perl changes threads by swapping out tTHX, those library functions need to be informed about the new value so that they remain in sync with what perl thinks the locale should be. This commit creates a function to do this, and changes the thread-changing macros to also call this as part of the change. For POSIX 2008, the function just calls uselocale() using the per-interpreter object introduced previously. For Windows, this commit adds a per-interpreter string of the current LC_ALL, and the function calls setlocale on that. We keep the same string for POSIX 2008 implementations that lack querylocale(), so this commit just enables that variable on Windows as well. The code is already in place to free the memory the string occupies when done. The commit also creates a mechanism to skip this during thread destruction. A thread in its death throes doesn't need to have accurate locale information, and the information needed to map from thread to what libc needs to know gets destroyed as part of those throes, while relics of the thread remain. I couldn't find a way to accurately know if we are dealing with a relic or not, so the solution I adopted was to just not switch during destruction. This commit completes fixing #20155.
* thread.h: White space onlyKarl Williamson2022-09-301-5/+6
|
* thread.h Save errno around lock/unlockKarl Williamson2022-09-121-0/+4
| | | | | | It may be necessary to unlock a mutext before raising a diagnostic about a failure. The unlock can then destroy the errno value needed to diagnose the original problem. This commit solves this in one place.
* thread.h: White-space, braces onlyKarl Williamson2022-09-121-17/+20
|
* PERL_SET_CONTEXT(t) needs to set PL_current_context from C++ tooNicholas Clark2022-01-121-8/+10
| | | | | | | | | | | | | | | | | | | | We want to use C11 thread local storage where possible, as its read overhead is lower. However C++ uses incompatible syntax for TLS, so we have to hide the variable from C++ extensions, and have the read code "fall back" to the pthread_getspecific() approach. However, C++ extensions also need to be able to call PERL_SET_CONTEXT(t) and have everything still work the same as C extensions. Hence they *also* need to set PL_current_context - a variable that has to be hidden from them. Hence change the version of the PERL_SET_CONTEXT macro used by C++ extensions from inline code to a call to Perl_set_context(), and have that set PL_current_context (when used). Technically this commit also fixes a bug in that Perl_set_context() is API and should have been setting PL_current_context since that variable was first introduced. In practice, likely nothing uses this API, as there is no code on CPAN that calls it, and the macro PERL_SET_CONTEXT() is much more prominent.
* For C++ extensions, use the pthreads definition of PERL_GET_CONTEXTNicholas Clark2022-01-121-2/+10
| | | | | | | | | | | | | | | | | | Configure probes the C compiler to find out whether it supports C11 thread local storage, and if found uses this for PERL_SET_CONTEXT/PERL_GET_CONTEXT, in preference to the pthread_setspecific()/pthread_getspecific() approach. However, we can come unstuck with XS extensions written in C++, as C++ and C disagree on the syntax used for thread local storage, meaning that the working token that Configure probed for C turns out to be a compiler error on C++. As Configure doesn't have a way to probe for C++ dialects, we just take the safe option and do the same as 5.34.0 and earlier - use pthreads on C++. This commit is minimal because the implementation of PERL_SET_CONTEXT for C11 thread local storage was already defensively written to *also* call pthread_setspecific().
* Remove DOS/DJGPP supportDagfinn Ilmari Mannsåker2021-11-021-6/+1
| | | | | | DJGPP is a port of the GNU toolchain to 32-bit x86 systems running DOS. The last known attempt to build Perl on it was on 5.20, which only got as far as building miniperl.
* Remove NetWare supportDagfinn Ilmari Mannsåker2021-10-081-2/+0
| | | | The build has been broken since 2009.
* If we have thread local storage, use it instead of posix_getspecific().Nicholas Clark2021-09-071-6/+26
| | | | | | | | | | | | Declare and use a variable PL_current_context to store a pointer to the thread's interpreter struct. Use this to implement implicit context undef ITHREADS, instead of a call to posix_getspecific(). For normal threaded code, this will eliminate function calls. For threaded code in shared objects (the typical configuration for Linux distribution builds) there still needs to be a function call to get the pointer to thread local variables, but there will only be one per function, not one per read of the variable.
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-86/+86
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* Make many-reader mutexes more resilientKarl Williamson2020-12-191-1/+5
| | | | | | | These mutexes rely on a counter being accurate to work. If for some reason that I can't imagine happening, the count goes below 0, this commit resets it to zero, which may be enough to cause the program to continue.
* consistently parenthesise the RW lock macro argumentsTony Cook2020-12-141-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | and fix the mixed up pointer vs non-pointer use of the mutex argument. Without the parentheses (or without the new tests in the previous commit) for code like; PERL_WRITE_LOCK(&PL_some_mutex); the MUTEX_LOCK(mutex.lock) in that code would expand to: MUTEX_LOCK(&PL_some_mutex.lock); and happen to work, even though the next line has: if ((mutex)->readers_count) treating the mutex parameter as a pointer. With the parentheses the MUTEX_LOCK(mutex.lock) becomes: MUTEX_LOCK((&PL_some_mutex).lock); which as expected fails to compile in a similar way to the pointer test code in the previous commit.
* build test for the read/write mutex macrosTony Cook2020-12-141-0/+2
| | | | This fails to compile
* many-reader mutexes: Change structure element nameKarl Williamson2020-12-121-5/+5
| | | | | The old name did not encompass all the possible reasons for the mutex signal condition to be invoked
* PERL_WRITE_UNLOCK: add missing condition signalKarl Williamson2020-12-121-1/+5
| | | | | The mutex is locked, and any contenders are awaiting a signal, which until this commit was missing.
* Add start-up/tear-down for many-reader mutexesKarl Williamson2020-12-061-0/+13
| | | | These were missed in 5640a370e8b19af74b8ca0b4694464c21a87916b.
* Change many-reader mutex API for consistencyKarl Williamson2020-12-061-13/+14
| | | | | The API for other mutexes passes the address of the lock, instead of the lock itself. It is less confusing to have the APIs be the same.
* Add mutex locking for many-reader/1-writerKarl Williamson2020-11-261-0/+54
| | | | | | The mutex macros already in perl are sufficient to allow us to emulate this type of locking, which may also be available natively, but I don't think it is worth the effort to use the native calls.
* Remove the final remnants of 5005threads supportDagfinn Ilmari Mannsåker2020-07-201-5/+0
| | | | Only THREAD_RET_TYPE is still used.
* thread.h: simplify cpp conditionalsAaron Crane2017-10-211-11/+5
|
* Properly NOOP macros in thread.hDagfinn Ilmari Mannsåker2017-07-031-12/+12
|
* clang thread safety annotationsJarkko Hietaniemi2015-11-231-2/+10
| | | | | | | | | | | | http://clang.llvm.org/docs/ThreadSafetyAnalysis.html Static (compile-time) annotations for declaring the multithreaded behavior of functions, variables, and capabilities (like mutexes). Available since about clang 3.5. ./Configure -des -Dusedevel -Dusethreads -Dcc=clang -Accflags='-Wthread-safety' clang -Wthread-safety then checks the validity of the annotations.
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* Use PERL_UNUSED_RESULT.Jarkko Hietaniemi2014-06-021-3/+1
| | | | | | | (1) Enhance its description. (2) Simplify it: define only if has warn_unused_result. (3) Make it use STMT_START { ... } STMT_END to be less GNU-extensiony. (4) Redo 04783dc7 ("fix 'ignoring return value' compiler warnings") with it.
* fix 'ignoring return value' compiler warningsDavid Mitchell2013-11-241-1/+3
| | | | | | | | | | | Various system functions like write() are marked with the __warn_unused_result__ attribute, which causes an 'ignoring return value' warning to be emitted, even if the function call result is cast to (void). The generic solution seems to be int rc = write(...); PERL_UNUSED_VAR(rc);
* silence some compiler warningsDavid Mitchell2013-11-131-1/+1
| | | | | | | Actually, most of this commit is adding (void) to various function returns where we know its ok to ignore the return value. This doesn't actually silence the -Wunused-result warning (thanks a bundle gcc), but at least it marks our intentions.
* Remove DG/UX support.Nicholas Clark2013-05-271-4/+0
| | | | | DG/UX was a Unix sold by Data General. The last release was in April 2001. It only runs on Data General's own hardware.
* Remove the VM/ESA port.Nicholas Clark2012-08-311-4/+1
| | | | | VM/ESA was a mainframe OS. IBM ended service on it in June 2003. It was superseded by Z/VM.
* update the editor hints for spaces, not tabsRicardo Signes2012-05-291-2/+2
| | | | | This updates the editor hints in our files for Emacs and vim to request that tabs be inserted as spaces.
* Remove all the 5005threads specific mutex macros, which are now vestigial.Nicholas Clark2009-05-211-40/+0
|
* Need even more stack for VMS_IA64-ithread.Craig A. Berry2009-01-171-1/+5
|
* Add MUTABLE_AV(), and remove (AV *) casts from headers.Nicholas Clark2008-10-271-1/+1
| | | p4raw-id: //depot/perl@34608
* Add editor blocks to some header files.Marcus Holland-Moritz2008-01-011-0/+10
| | | p4raw-id: //depot/perl@32793
* Removed unused var in a macroAndy Lester2006-04-161-2/+1
| | | | | Message-ID: <20060416043253.GA3438@petdance.com> p4raw-id: //depot/perl@27834
* [patch@27529] thread.h - VMS needs more stackJohn E. Malmberg2006-03-211-0/+5
| | | | | | From: "John E. Malmberg" <wb8tyw@qsl.net> Message-id: <441ADE4D.2090207@qsl.net> p4raw-id: //depot/perl@27563
* Update copyright years (including some years where we made changes butNicholas Clark2006-01-081-1/+1
| | | | | did not update) p4raw-id: //depot/perl@26732
* More copyright updatesRafael Garcia-Suarez2006-01-041-1/+1
| | | p4raw-id: //depot/perl@26652
* Get rid of hardcoded string length.Gisle Aas2006-01-041-1/+1
| | | p4raw-id: //depot/perl@26647
* Update copyrights.Rafael Garcia-Suarez2005-03-301-1/+2
| | | p4raw-id: //depot/perl@24106
* Avoid segfault when pthread_key_create failsGisle Aas2005-01-051-2/+1
| | | | | Message-ID: <lracroz1gg.fsf@caliper.activestate.com> p4raw-id: //depot/perl@23749
* Update copyright noticesRafael Garcia-Suarez2004-03-161-1/+1
| | | p4raw-id: //depot/perl@22509
* Make panics a bit more verbose to ease debugging.Marcus Holland-Moritz2004-02-291-32/+64
| | | p4raw-id: //depot/perl@22417
* Redundancy removal from Brian De Pradine;Jarkko Hietaniemi2003-06-131-1/+0
| | | | | | both the forms, pthread_mutexattr_settype() and pthread_mutexattr_setkind_np(), exist on z/OS. p4raw-id: //depot/perl@19767
* z/OS: More threaded build tweaks from Brian De Pradine--Jarkko Hietaniemi2003-05-011-5/+7
| | | | | apparently now it works! p4raw-id: //depot/perl@19368
* z/OS: changes for building threaded from "Brian De Pradine"Jarkko Hietaniemi2003-04-221-1/+5
| | | | | <PRADINE@uk.ibm.com>. p4raw-id: //depot/perl@19306
* Fix up Larry's copyright statements to my best knowledge.Jarkko Hietaniemi2003-04-161-1/+1
| | | | | | | (Lots of Perl 5 source code archaeology was involved.) Larry didn't make strangled noises when I showed him the patch, either :-) p4raw-id: //depot/perl@19242
* Reverse copyright update (#18801) for files not changed in 2003.Hugo van der Sanden2003-03-021-1/+1
| | | p4raw-id: //depot/perl@18807
* Update all copyrights to 2003, from JarkkoHugo van der Sanden2003-03-021-1/+1
| | | p4raw-id: //depot/perl@18801
* $0 mofifying part IJarkko Hietaniemi2002-12-021-0/+11
| | | | | | Subject: [PATCH] $0 modifying Message-ID: <20021130181651.GA5876@kosh.hut.fi> p4raw-id: //depot/perl@18229