summaryrefslogtreecommitdiff
path: root/common/library.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert "common: Prefer __register_atfork() to pthread_atfork() if possible"Daiki Ueno2018-08-171-18/+1
| | | | This reverts commit ce3cec7f8742254b8627b9db48973b81e91cbfc8.
* Revert "build: Link to libpthread, if pthread_atfork() needs to be used"Daiki Ueno2018-08-171-6/+4
| | | | This reverts commit 541d79cb651cfd3238b9aa41fce70208df8e9496.
* build: Link to libpthread, if pthread_atfork() needs to be usedDaiki Ueno2018-08-101-4/+6
| | | | | | | | On non-glibc systems (e.g., FreeBSD), pthread_atfork() stub is provided as a nop and our fork detection mechanism doesn't work. Pull in the actual implementation from libpthread in that case. Signed-off-by: Daiki Ueno <dueno@redhat.com>
* common: Prefer __register_atfork() to pthread_atfork() if possibleDaiki Ueno2018-08-101-1/+18
|
* common: Use thread-local storage class when possibleDaiki Ueno2018-08-101-0/+22
| | | | | This eliminates the unconditional use of pthread_{get,set}specific() and pthread_key_{create,delete}(), which glibc doesn't provide the stubs.
* common, p11-kit, trust: Use pthread_once only when necessaryDaiki Ueno2018-08-101-1/+3
| | | | | | If the ELF constructor is usable, we don't really need the once-init function because it is guaranteed that the code runs only once in the constructor.
* common: Use static mutex initializer when possibleDaiki Ueno2018-08-101-4/+10
| | | | | This eliminates the use of pthread_mutexattr_* functions, which glibc doesn't provide the stubs.
* build: Don't use locale funcs if locale_t is not defined in locale.hDaiki Ueno2018-05-281-3/+3
| | | | | | On macOS, locale_t is not defined in <locale.h>. Although it is defined in <xlocale.h>, we rather not use locales at all for POSIX compliance.
* library: Use dedicated locale object for printing errorDaiki Ueno2018-05-011-0/+13
|
* library: Initialize p11_virtual_mutex for WindowsDaiki Ueno2017-02-161-0/+2
|
* library: Deinit p11_virtual_mutexDaiki Ueno2017-02-161-0/+1
| | | | | Follow-up fix for commit 4d228aa0, which forgot to clear p11_virtual_mutex on library finalization.
* virtual: Move mutex into p11_library_init()Daiki Ueno2017-02-141-0/+3
| | | | | | | | | We used to provide p11_virtual_fixed_{,un}init() to only initialize a mutex used in virtual.c. That required all the tests calling virtual functions to call p11_virtual_fixed_{,un}init() in main(). For simplicity, move the mutex variable initialization into p11_library_init().
* p11-kit: Use pthread_atfork() in a safe mannerStef Walter2014-10-031-0/+11
| | | | | | | | | | | | | Instead of trying to perform actions in pthread_atfork() which are not async-signal-safe, just increment a counter so we can later tell if the process has forked. Note this does not make it safe to mix threads and forking without immediately execing. This is a far broader problem that p11-kit, however we now do the right thing when fork+exec is used from a thread. https://bugs.freedesktop.org/show_bug.cgi?id=84567
* Fix uninitialized p11_library_oncemanphiz@gmail.com2013-05-281-1/+1
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=57714
* Don't use free() on memory allocated by LocalFree()Stef Walter2013-04-031-1/+1
| | | | ihttps://bugs.freedesktop.org/show_bug.cgi?id=63046
* Separate library init from message codeStef Walter2013-04-031-71/+14
| | | | | | | | | | | Put library init/uninit code its into their own statically linked library so that they don't get linked into the p11-kit executable. Refactor the message code so that the library initialization can plug in its per thread message buffer. https://bugs.freedesktop.org/show_bug.cgi?id=63046
* Don't use library locks from p11-kit toolStef Walter2013-04-031-4/+0
| | | | | | | The global library p11_library_mutex is for libraries to use, so don't use it from any code in common/, which is also used by the p11-kit tool https://bugs.freedesktop.org/show_bug.cgi?id=63046
* Don't shove messages into debug output if they're already displayedStef Walter2013-03-081-2/+2
|
* Fix syntax errors in OS_WIN32 ifdefsStef Walter2013-03-031-3/+3
|
* Only do shared object and DLL initialization in librariesStef Walter2013-02-201-49/+11
| | | | | | Don't do library initialization on shared object load when not running in a library. We'll want to plug into this and do different things per library in the future.
* Add internal function for turning on messagesStef Walter2013-02-051-0/+8
| | | | To be used from tests
* Use the stdbool.h C99 bool typeStef Walter2013-01-231-2/+2
| | | | | | It was getting really wild knowing whether a function returning an int would return -1 on failure or 0 or whether the int return value was actually a number etc..
* Only initialize p11-kit libraries onceStef Walter2013-01-091-4/+10
| | | | * Make the gcc constructor call p11_library_init_once()
* Move debug and library code into the common/ subdirectoryStef Walter2013-01-091-0/+286
Start using p11_ as our internal prefix rather than _p11_. We explicitly export p11_kit_ so this is fine as far as visibility. Move the threading, mutex, and module compat, dict, and array code into the common directory too. Take this opportunity to clean up a bit of internal API as well, since so many lines are being touched internally.