Commit Graph

379 Commits

Author SHA1 Message Date
Rich Felker
feee98903c 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.
2011-04-17 11:43:03 -04:00
Rich Felker
90f09a0dde remove stupid debug code in wordexp 2011-04-15 12:07:26 -04:00
Rich Felker
d251c2645c implement wordexp. first try, may be buggy. intended to be safe. 2011-04-15 12:06:34 -04:00
Rich Felker
69cf09c821 avoid setting errno when checking for tty
setting errno here is completely valid, but some programs, notably
busybox printf, assume that errno will not be set during output and
treat this as an error condition. in any case, skipping it slightly
reduces code size and saves time.
2011-04-15 12:04:13 -04:00
Rich Felker
088ae5995a document some changes in the upcoming release 2011-04-14 23:33:46 -04:00
Rich Felker
a3aa89d826 fix O_SYNC definition, cleanup fcntl.h 2011-04-14 22:06:30 -04:00
Rich Felker
0a84e72c42 fix FAPPEND typo on x86_64 (previously only fixed on i386) 2011-04-14 21:50:07 -04:00
Rich Felker
c2b18f3531 fcntl.h: move macros that do not vary between archs out of bits 2011-04-14 21:49:22 -04:00
Rich Felker
ace973637f fix broken fcntl locks on x86_64 2011-04-14 21:45:26 -04:00
Rich Felker
b172dc8b58 make tmpfile slightly more efficient (use unlink syscall instead of remove) 2011-04-14 21:43:49 -04:00
Rich Felker
9b96220e5a fix typo in legacy FAPPEND definition 2011-04-14 19:14:42 -04:00
Rich Felker
33a3f202d1 add useless type fd_mask. it's in the reserved namespace. 2011-04-14 16:23:31 -04:00
Rich Felker
e983aea0ae change sem_trywait algorithm so it never has to call __wake 2011-04-14 15:10:50 -04:00
Rich Felker
ec2e50d0d7 cheap trick to further optimize locking normal mutexes 2011-04-14 14:39:57 -04:00
Rich Felker
016a5dc192 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.
2011-04-14 12:51:00 -04:00
Rich Felker
9beb6330c0 simplify cancellation point handling
we take advantage of the fact that unless self->cancelpt is 1,
cancellation cannot happen. so just increment it by 2 to temporarily
block cancellation. this drops pthread_create.o well under 1k.
2011-04-13 20:47:01 -04:00
Rich Felker
19c1830eaa simplify syslog, add vsyslog interface (nonstandard)
with datagram sockets, depending on fprintf not to flush the output
early was very fragile; the new version simply uses a small fixed-size
buffer. it could be updated to dynamic-allocate large buffers if
needed, but i can't envision any admin being happy about finding
64kb-long lines in their syslog...
2011-04-13 18:32:33 -04:00
Rich Felker
a77411a50d remove useless SIGPIPE protection from syslog
per the standard, SIGPIPE is not generated for SOCK_DGRAM.
2011-04-13 17:51:45 -04:00
Rich Felker
a444ee3410 fix syslog (corrected SIGPIPE blocking, and using dgram instead of stream)
it actually appears the hacks to block SIGPIPE are probably not
necessary, and potentially harmful. if i can confirm this, i'll remove
them.
2011-04-13 17:24:25 -04:00
Rich Felker
07e865cc5a numerous fixes to sysv ipc
some of these definitions were just plain wrong, others based on
outdated ancient "non-64" versions of the kernel interface.

as much as possible has now been moved out of bits/*

these changes break abi (the old abi for these functions was wrong),
but since they were not working anyway it can hardly matter.
2011-04-13 16:45:43 -04:00
Rich Felker
b5b43b6d62 add syslog.h cruft for syslogd to use... 2011-04-13 16:13:49 -04:00
Rich Felker
b778a2ba69 add profile for getmntent_r 2011-04-13 15:24:26 -04:00
Rich Felker
55b123b5ed add syscall wrapper for flock
it should be noted that flock does not mix well with standard fcntl
locking, but nonetheless some applications will attempt to use flock
instead of fcntl if both exist. options to configure or small patches
may be needed. debian maintainers have plenty of experience with this
unfortunate situation...
2011-04-13 14:55:26 -04:00
Rich Felker
6f0259a4fc fix bug whereby getopt_long allowed mismatch in last char of option name 2011-04-13 14:52:23 -04:00
Rich Felker
45a3219944 fix typos on RLIM_NLIMITS, remove _GNU_SOURCE test for it
RLIM_* is in the reserved namespace for this header
2011-04-13 13:22:19 -04:00
Rich Felker
cac7d837cc fix and cleanup suseconds_t/timeval stuff (broken on 64-bit)
trash in the upper 32 bits was making the kernel sleep forever in
select on 64-bit systems.
2011-04-13 13:16:49 -04:00
Rich Felker
91e836fda7 implement getgrouplist (for initgroups), formerly dummied-out 2011-04-13 09:39:47 -04:00
Rich Felker
3f44f298e4 fix prototypes/signature for setgroups, etc. 2011-04-13 09:03:22 -04:00
Rich Felker
0f5b43550c fix incorrect GNU sighandler_t typedef 2011-04-13 08:45:28 -04:00
Rich Felker
6597f9ac13 implement memrchr (nonstandard) and optimize strrchr in terms of it 2011-04-13 08:36:29 -04:00
Rich Felker
750b738e53 add ptsname_r (nonstandard) and split ptsname (standard) to separate file
this eliminates the ugly static buffer in programs that use ptsname_r.
2011-04-13 08:35:32 -04:00
Rich Felker
e2915eeeea speed up threaded fork
after fork, we have a new process and the pid is equal to the tid of
the new main thread. there is no need to make two separate syscalls to
obtain the same number.
2011-04-12 17:52:14 -04:00
Rich Felker
0913560a3f more changes for upcoming 0.7.8 2011-04-12 13:36:22 -04:00
Rich Felker
c89862660b optimize ntohl etc. in terms of bswap functions
we can do this without violating the namespace now that they are
macros/inline functions rather than extern functions. the motivation
is that gcc was generating giant, slow, horrible code for the old
functions, and now generates a single byte-swapping instruction.
2011-04-12 13:13:27 -04:00
Rich Felker
c546be175c move bswap functions to static inline in byteswap.h 2011-04-12 13:04:17 -04:00
Rich Felker
4f4ba4c02f fix broken bswap_32 2011-04-12 12:18:11 -04:00
Rich Felker
0729fd9fd9 utmpx.h is no longer under standards, so expose ut_exit structure 2011-04-12 12:03:33 -04:00
Rich Felker
7ecab79f58 add some traditional aliases to stat.h 2011-04-12 12:01:20 -04:00
Rich Felker
e514228043 fix printf("%.9g", 1.1) and similar not dropping trailing zeros 2011-04-12 11:50:52 -04:00
Rich Felker
209f2bbd95 add missing rlimit macros 2011-04-12 11:50:14 -04:00
Rich Felker
43b2e9bf26 more types cleanup
the basic idea is that the only things in alltypes.h should be types
that either vary from system to system (in practice, not just in
theoretical la-la land - this is the implementation so we choose what
constraints we want to impose on ports) or which are needed by
multiple system headers.
2011-04-11 10:48:52 -04:00
Rich Felker
28bde3b787 cleanup types stuff in headers, fix missing u_int*_t in sys/types.h 2011-04-11 10:38:00 -04:00
Rich Felker
dae17a1aaf fix errno handling in scandir:
1. saved errno was not being restored, illegally clearing errno to 0.
2. no need to backup and save errno around free; it will not touch
except perhaps when the program has already invoked UB...
2011-04-11 01:58:14 -04:00
Rich Felker
52458cfa8c fix fputwc return value 2011-04-11 01:52:23 -04:00
Rich Felker
0161244784 remove ugly warning-suppression hack from crypt - this invokes UB! 2011-04-11 01:50:26 -04:00
Rich Felker
5eaa22132b update README since we now DO have a mailing list 2011-04-11 00:10:26 -04:00
Rich Felker
2555fe1b6d add some ugly legacy type names in sys/types.h (u_char etc.) 2011-04-10 22:47:43 -04:00
Rich Felker
691b20bec0 add legacy BSD-style timer*() macros in sys/time.h 2011-04-10 22:46:46 -04:00
Rich Felker
4a19634f07 add missing UTIME_* macros in sys/stat.h 2011-04-10 18:32:59 -04:00
Rich Felker
196d6437dc add missing float.h macros
actually FLT_ROUNDS needs to expand to a static inline function that
obtains the current rounding mode and returns it, but that will be
added later with fenv.h stuff.
2011-04-10 18:27:47 -04:00