aboutsummaryrefslogtreecommitdiff
path: root/src/time (follow)
Commit message (Expand)AuthorAgeFilesLines
* ditch the priority inheritance locks; use malloc's version of lock•••i did some testing trying to switch malloc to use the new internal lock with priority inheritance, and my malloc contention test got 20-100 times slower. if priority inheritance futexes are this slow, it's simply too high a price to pay for avoiding priority inversion. maybe we can consider them somewhere down the road once the kernel folks get their act together on this (and perferably don't link it to glibc's inefficient lock API)... as such, i've switch __lock to use malloc's implementation of lightweight locks, and updated all the users of the code to use an array with a waiter count for their locks. this should give optimal performance in the vast majority of cases, and it's simple. malloc is still using its own internal copy of the lock code because it seems to yield measurably better performance with -O3 when it's inlined (20% or more difference in the contention stress test). Rich Felker2012-04-241-3/+3
* remove debug cruft that was left in getdateRich Felker2012-03-021-2/+0
* first try at implementing getdate functionRich Felker2012-03-021-0/+47
* fix bugs in strptime handling of string day/month names, literalsRich Felker2012-03-021-0/+2
* implement wcsftime functionRich Felker2012-02-281-0/+32
* cleanup various minor issues reported by nsz•••the changes to syscall_ret are mostly no-ops in the generated code, just cleanup of type issues and removal of some implementation-defined behavior. the one exception is the change in the comparison value, which is fixed so that 0xf...f000 (which in principle could be a valid return value for mmap, although probably never in reality) is not treated as an error return. Rich Felker2011-09-261-1/+2
* fix assumptions that char is signedRich Felker2011-09-161-2/+2
* remove incorrectly-made-visible internal dst offset variableRich Felker2011-09-141-1/+0
* strptime: fix use of uninitialized dest field in converting integerRich Felker2011-09-051-1/+1
* partially working strptime•••it's missing at least: - derived fields - week numbers - short year (without century) support - locale modifiers Rich Felker2011-08-161-148/+149
* fix missing include in last commitRich Felker2011-08-131-0/+1
* fix clock() function•••it previously was returning the pseudo-monotonic-realtime clock returned by times() rather than process cputime. it also violated C namespace by pulling in times(). we now use clock_gettime() if available because times() has ridiculously bad resolution. still provide a fallback for ancient kernels without clock_gettime. Rich Felker2011-08-131-2/+7
* more efficient signal blocking for timer threads•••due to the barrier, it's safe just to block signals in the new thread, rather than blocking and unblocking in the parent thread. Rich Felker2011-08-121-4/+4
* normal exit from timer thread should run dtors, restore cancel stateRich Felker2011-08-111-1/+1
* block signals in timer threads•••if a timer thread leaves signals unblocked, any future attempt by the main thread to prevent the process from being terminated by blocking signals will fail, since the signal can still be delivered to the timer thread. Rich Felker2011-08-111-0/+4
* use weak aliase rather than weak reference for vdso clock_gettime•••this works around pcc's lack of working support for weak references, and in principle is nice because it gets us back to the stage where the only weak symbol feature we use is weak aliases, nothing else. having fewer dependencies on fancy linker features is a good thing. Rich Felker2011-08-071-8/+12
* workaround for gcc's optimizer breaking dynamic symbol resolutionRich Felker2011-07-241-1/+2
* const correctness on function pointerRich Felker2011-07-241-1/+1
* some preliminaries for vdso clock support•••these changes also make it so clock_gettime(CLOCK_REALTIME, &ts) works even on pre-2.6 kernels, emulated via the gettimeofday syscall. there is no cost for the fallback check, as it falls under the error case that already must be checked for storing the error code in errno, but which would normally be hidden inside __syscall_ret. Rich Felker2011-07-233-7/+35
* remove old useless timezone.s file (unused)Rich Felker2011-06-131-27/+0
* use volatile pointers for intentional-crash code.Rich Felker2011-06-061-1/+1
* optimize compound-literal sigset_t's not to contain useless hurd bitsRich Felker2011-05-071-1/+1
* overhaul implementation-internal signal protections•••the new approach relies on the fact that the only ways to create sigset_t objects without invoking UB are to use the sig*set() functions, or from the masks returned by sigprocmask, sigaction, etc. or in the ucontext_t argument to a signal handler. thus, as long as sigfillset and sigaddset avoid adding the "protected" signals, there is no way the application will ever obtain a sigset_t including these bits, and thus no need to add the overhead of checking/clearing them when sigprocmask or sigaction is called. note that the old code actually *failed* to remove the bits from sa_mask when sigaction was called. the new implementations are also significantly smaller, simpler, and faster due to ignoring the useless "GNU HURD signals" 65-1024, which are not used and, if there's any sanity in the world, never will be used. Rich Felker2011-05-071-2/+1
* overhaul pthread cancellation•••this patch improves the correctness, simplicity, and size of cancellation-related code. modulo any small errors, it should now be completely conformant, safe, and resource-leak free. the notion of entering and exiting cancellation-point context has been completely eliminated and replaced with alternative syscall assembly code for cancellable syscalls. the assembly is responsible for setting up execution context information (stack pointer and address of the syscall instruction) which the cancellation signal handler can use to determine whether the interrupted code was in a cancellable state. these changes eliminate race conditions in the previous generation of cancellation handling code (whereby a cancellation request received just prior to the syscall would not be processed, leaving the syscall to block, potentially indefinitely), and remedy an issue where non-cancellable syscalls made from signal handlers became cancellable if the signal handler interrupted a cancellation point. x86_64 asm is untested and may need a second try to get it right. Rich Felker2011-04-172-11/+2
* use a separate signal from SIGCANCEL for SIGEV_THREAD timers•••otherwise we cannot support an application's desire to use asynchronous cancellation within the callback function. this change also slightly debloats pthread_create.c. Rich Felker2011-04-141-7/+25
* run pthread tsd destructors when a timer thread pretends to exitRich Felker2011-04-091-0/+6
* greatly improve SIGEV_THREAD timers•••calling pthread_exit from, or pthread_cancel on, the timer callback thread will no longer destroy the timer. Rich Felker2011-04-092-15/+20
* consistency: change all remaining syscalls to use SYS_ rather than __NR_ prefixRich Felker2011-04-063-3/+3
* fix signal-based timers with null sigevent argument•••since timer_create is no longer allocating a structure for the timer_t and simply using the kernel timer id, it was impossible to specify the timer_t as the argument to the signal handler. the solution is to pass the null sigevent pointer on to the kernel, rather than filling it in userspace, so that the kernel does the right thing. however, that precludes the clever timerid-versus-threadid encoding we were doing. instead, just assume timerids are below 1M and thread pointers are above 1M. (in perspective: timerids are sequentially allocated and seem limited to 32k, and thread pointers are at roughly 3G.) Rich Felker2011-04-065-28/+19
* timer threads should sleep and stay asleep... a long timeRich Felker2011-04-031-1/+1
* revert to deleting kernel-level timer from cancellation handler•••this is necessary in order to avoid breaking timer_getoverrun in the last run of the timer event handler, if it has not yet finished. Rich Felker2011-04-032-7/+11
* simplify calling of timer signal handlerRich Felker2011-04-031-3/+1
* avoid all malloc/free in timer creation/destruction•••instead of allocating a userspace structure for signal-based timers, simply use the kernel timer id. we use the fact that thread pointers will always be zero in the low bit (actually more) to encode integer timerid values as pointers. also, this change ensures that the timer_destroy syscall has completed before the library timer_destroy function returns, in case it matters. Rich Felker2011-03-305-29/+20
* optimize timer creation and possibly protect against some minor races•••the major idea of this patch is not to depend on having the timer pointer delivered to the signal handler, and instead use the thread pointer to get the callback function address and argument. this way, the parent thread can make the timer_create syscall while the child thread is starting, and it should never have to block waiting for the barrier. Rich Felker2011-03-301-14/+19
* reorder timer initialization so that timer_create does not depend on free•••this allows small programs which only create times, but never delete them, to use simple_malloc instead of the full malloc. Rich Felker2011-03-292-9/+17
* implement POSIX timers•••this implementation is superior to the glibc/nptl implementation, in that it gives true realtime behavior. there is no risk of timer expiration events being lost due to failed thread creation or failed malloc, because the thread is created as time creation time, and reused until the timer is deleted. Rich Felker2011-03-295-0/+143
* overhaul cancellation to fix resource leaks and dangerous behavior with signals•••this commit addresses two issues: 1. a race condition, whereby a cancellation request occurring after a syscall returned from kernelspace but before the subsequent CANCELPT_END would cause cancellable resource-allocating syscalls (like open) to leak resources. 2. signal handlers invoked while the thread was blocked at a cancellation point behaved as if asynchronous cancellation mode wer in effect, resulting in potentially dangerous state corruption if a cancellation request occurs. the glibc/nptl implementation of threads shares both of these issues. with this commit, both are fixed. however, cancellation points encountered in a signal handler will not be acted upon if the signal was received while the thread was already at a cancellation point. they will of course be acted upon after the signal handler returns, so in real-world usage where signal handlers quickly return, it should not be a problem. it's possible to solve this problem too by having sigaction() wrap all signal handlers with a function that uses a pthread_cleanup handler to catch cancellation, patch up the saved context, and return into the cancellable function that will catch and act upon the cancellation. however that would be a lot of complexity for minimal if any benefit... Rich Felker2011-03-241-0/+1
* global cleanup to use the new syscall interfaceRich Felker2011-03-206-11/+6
* if returning errno value directly from a syscall, we need to negate it.Rich Felker2011-03-191-1/+1
* syscall overhaul part two - unify public and internal syscall interface•••with this patch, the syscallN() functions are no longer needed; a variadic syscall() macro allows syscalls with anywhere from 0 to 6 arguments to be made with a single macro name. also, manually casting each non-integer argument with (long) is no longer necessary; the casts are hidden in the macros. some source files which depended on being able to define the old macro SYSCALL_RETURNS_ERRNO have been modified to directly use __syscall() instead of syscall(). references to SYSCALL_SIGSET_SIZE and SYSCALL_LL have also been changed. x86_64 has not been tested, and may need a follow-up commit to fix any minor bugs/oversights. Rich Felker2011-03-193-6/+3
* misplaced & in times() made it fail to work, and clobber the stackRich Felker2011-03-121-1/+1
* more cancellation points: tcdrain, clock_nanosleepRich Felker2011-03-101-1/+6
* fix errno behavior in clock_* functions•••these functions are specified inconsistent in whether they're specified to return an error value, or return -1 and set errno. hopefully now they all match what POSIX requires. Rich Felker2011-03-103-3/+0
* implement the remaining clock_* interfacesRich Felker2011-02-195-0/+36
* initial check-in, version 0.5.0Rich Felker2011-02-1225-0/+874