Commit Graph

153 Commits

Author SHA1 Message Date
Szabolcs Nagy 10c8b7148b use 0 instead of NULL in headers where NULL is not defined
some macros in sys/mtio.h and syslog.h used NULL without defining it
2013-11-24 00:34:07 +00:00
rofl0r 8ff810d779 timeradd/timersub: cast result to void to get rid of warnings
previously:
timersub(&now, t, &diff);

warning: value computed is not used [-Wunused-value]
2013-11-23 13:01:53 +01:00
Rich Felker f5980e330a adjust sys/wait.h not to produde errors in strict ISO C feature profile
siginfo_t is not available from signal.h when the strict ISO C feature
profile (e.g. passing -std=c99 to gcc without defining any other
feature test macros) is used, but the type is needed to declare
waitid. using sys/wait.h (or any POSIX headers) in strict ISO C mode
is an application bug, but in the interest of compatibility, it's best
to avoid producing gratuitous errors. the simplest fix I could find is
suppressing the declaration of waitid (and also signal.h inclusion,
since it's not needed for anything else) in this case, while still
exposing everything else in sys/wait.h
2013-11-09 00:04:02 -05:00
Rich Felker 4b15d9f46a add legacy ftime function and sys/timeb.h
despite being marked legacy, this was specified by SUSv3 as part of
the XSI option; only the most recent version of the standard dropped
it. reportedly there's actual code using it.
2013-10-25 14:15:08 -04:00
Szabolcs Nagy 20a34af862 fix typo in socket.h (wrong macro name) 2013-10-18 15:19:49 +00:00
Szabolcs Nagy 90710df5cc sys/resource.h: add PRIO_MIN and PRIO_MAX for getpriority and setpriority
These constants are not specified by POSIX, but they are in the reserved
namespace, glibc and bsd systems seem to provide them as well.
(Note that POSIX specifies -NZERO and NZERO-1 to be the limits, but
PRIO_MAX equals NZERO)
2013-09-16 15:16:55 +00:00
Szabolcs Nagy ae51aa7534 sys/socket.h: add new SO_BUSY_POLL socket option
low latency busy poll sockets are new in linux v3.11
2013-09-15 04:54:19 +00:00
Szabolcs Nagy 0a7ecf7606 ptrace.h: add new ptrace requests to get/set sigmask
PTRACE_GETSIGMASK and PTRACE_SETSIGMASK were added in linux v3.11
and used by checkpoint/restore tools
2013-09-15 02:49:26 +00:00
Rich Felker ecf4e24d81 add SUN_LEN macro to sys/un.h under appropriate feature tests
this is ugly and useless, but it seems to be the least-ugly way to
provide it...
2013-08-21 21:46:57 -04:00
Rich Felker 4ce6bd8345 add missing MSG_EXCEPT in sys/msg.h 2013-08-14 02:48:11 -04:00
Rich Felker 41c632824c fix definitions of WIFSTOPPED and WIFSIGNALED to support up to signal 127
mips has signal numbers up to 127 (formerly, up to 128, but the last
one never worked right and caused kernel panic when used), so 127 in
the "signal number" field of the wait status is insufficient for
determining that the process was stopped. in addition, a nonzero value
in the upper bits must be present, indicating the signal number which
caused the process to be stopped.

details on this issue can be seen in the email with message id
CAAG0J9-d4BfEhbQovFqUAJ3QoOuXScrpsY1y95PrEPxA5DWedQ@mail.gmail.com on
the linux-mips mailing list, archived at:
http://www.linux-mips.org/archives/linux-mips/2013-06/msg00552.html
and in the associated thread about fixing the mips kernel bug.

commit 4a96b948687166da26a6c327e6c6733ad2336c5c fixed the
corresponding issue in uClibc, but introduced a multiple-evaluation
issue for the WIFSTOPPED macro.

for the most part, none of these issues affected pure musl systems,
since musl has up until now (incorrectly) defined SIGRTMAX as 64 on
all archs, even mips. however, interpreting status of non-musl
programs on mips may have caused problems. with this change, the full
range of signal numbers can be made available on mips.
2013-08-10 23:33:54 -04:00
rofl0r e28c2ecae4 sys/personality.h: add missing C++ compat 2013-08-08 20:57:35 +02:00
rofl0r 6a0aa82f51 sys/personality.h: add missing macros 2013-08-08 20:39:54 +02:00
Rich Felker 9a8d7bee80 add macros for new(ish) prctl commands 2013-07-30 18:15:50 -04:00
Rich Felker 9932505b68 fix some prctl macros that were incorrectly copied into this file 2013-07-30 13:04:31 -04:00
Rich Felker 54446d730c add wrapper headers, with warnings, for various incorrect names under sys
also add a warning to the existing sys/poll.h. the warning is absent
from sys/dir.h because it is actually providing a slightly different
API to the program, and thus just replacing the #include directive is
not a valid fix to programs using this one.
2013-07-27 17:11:34 -04:00
Szabolcs Nagy 3d4583c3fb add protocol families PF_IB and PF_VSOCK to socket.h
linux commit 8d36eb01da5d371feffa280e501377b5c450f5a5 (2013-05-29)
added PF_IB for InfiniBand

linux commit d021c344051af91f42c5ba9fdedc176740cbd238 (2013-02-06)
added PF_VSOCK for VMware sockets
2013-07-25 00:22:05 +00:00
Szabolcs Nagy a512c7d849 add PTRACE_PEEKSIGINFO to ptrace.h
added in linux-v3.10 commit 84c751bd4aebbaae995fe32279d3dba48327bad4
using stdint.h types for the new ptrace_peeksiginfo_args struct
2013-07-24 22:17:24 +00:00
Szabolcs Nagy 8f6ec7217f add SO_SELECT_ERR_QUEUE to socket.h
introduced in linux-v3.10 commit 7d4c04fc170087119727119074e72445f2bb192b
2013-07-24 22:17:24 +00:00
Rich Felker 009f186810 move register_t and u_int64_t (back) to alltypes
during the header refactoring, I had moved u_int64_t out of alltypes
under the assumption that we could just use long long everywhere.
however, it seems some broken applications make inconsistent mixed use
of u_int64_t and uint64_t, resulting in build errors when the
underlying type differs.
2013-07-22 16:40:35 -04:00
Rich Felker 9448b0513e refactor headers, especially alltypes.h, and improve C++ ABI compat
the arch-specific bits/alltypes.h.sh has been replaced with a generic
alltypes.h.in and minimal arch-specific bits/alltypes.h.in.

this commit is intended to have no functional changes except:
- exposing additional symbols that POSIX allows but does not require
- changing the C++ name mangling for some types
- fixing the signedness of blksize_t on powerpc (POSIX requires signed)
- fixing the limit macros for sig_atomic_t on x86_64
- making dev_t an unsigned type (ABI matching goal, and more logical)

in addition, some types that were wrongly defined with long on 32-bit
archs were changed to int, and vice versa; this change is
non-functional except for the possibility of making pointer types
mismatch, and only affects programs that were using them incorrectly,
and only at build-time, not runtime.

the following changes were made in the interest of moving
non-arch-specific types out of the alltypes system and into the
headers they're associated with, and also will tend to improve
application compatibility:
- netdb.h now includes netinet/in.h (for socklen_t and uint32_t)
- netinet/in.h now includes sys/socket.h and inttypes.h
- sys/resource.h now includes sys/time.h (for struct timeval)
- sys/wait.h now includes signal.h (for siginfo_t)
- langinfo.h now includes nl_types.h (for nl_item)

for the types in stdint.h:
- types which are of no interest to other headers were moved out of
  the alltypes system.
- fast types for 8- and 64-bit are hard-coded (at least for now); only
  the 16- and 32-bit ones have reason to vary by arch.

and the following types have been changed for C++ ABI purposes;
- mbstate_t now has a struct tag, __mbstate_t
- FILE's struct tag has been changed to _IO_FILE
- DIR's struct tag has been changed to __dirstream
- locale_t's struct tag has been changed to __locale_struct
- pthread_t is defined as unsigned long in C++ mode only
- fpos_t now has a struct tag, _G_fpos64_t
- fsid_t's struct tag has been changed to __fsid_t
- idtype_t has been made an enum type (also required by POSIX)
- nl_catd has been changed from long to void *
- siginfo_t's struct tag has been removed
- sigset_t's has been given a struct tag, __sigset_t
- stack_t has been given a struct tag, sigaltstack
- suseconds_t has been changed to long on 32-bit archs
- [u]intptr_t have been changed from long to int rank on 32-bit archs
- dev_t has been made unsigned

summary of tests that have been performed against these changes:
- nsz's libc-test (diff -u before and after)
- C++ ABI check symbol dump (diff -u before, after, glibc)
- grepped for __NEED, made sure types needed are still in alltypes
- built gcc 3.4.6
2013-07-22 11:22:36 -04:00
Rich Felker 41e2fd9d52 add UIO_MAXIOV macro in sys/uio.h
while there's no POSIX namespace provision for UIO_* in uio.h, this
exact macro name is reserved in XBD 2.2.2. apparently some
glibc-centric software expects it to exist, so let's provide it.
2013-07-19 19:57:52 -04:00
Rich Felker ca9aff6a16 add NFDBITS in sys/select.h with appropriate feature tests
the main use for this macro seems to be knowing the correct allocation
granularity for dynamic-sized fd_set objects. such usage is
non-conforming and results in undefined behavior, but it is widespread
in applications.
2013-07-06 01:12:28 -04:00
rofl0r ab72420439 add legacy sys/ttydefaults.h header 2013-07-03 18:07:51 +02:00
Rich Felker 9b732fe51b fix shifts possibly larger than type in major() macro
in theory this should not be an issue, since major() should only be
applied to type dev_t, which is 64-bit. however, it appears some
applications are not using dev_t but a smaller integer type (which
works on Linux because the kernel's dev_t is really only 32-bit). to
avoid the undefined behavior, do it as two shifts.
2013-06-29 13:57:13 -04:00
Rich Felker 062f40ef3e work around wrong kernel type for sem_nsems member of struct semid_ds
rejecting invalid values for n is fine even in the case where a new
sem will not be created, since the kernel does its range checks on n
even in this case as well.

by default, the kernel will bound the limit well below USHRT_MAX
anyway, but it's presumably possible that an administrator could
override this limit and break things.
2013-06-28 23:57:58 -04:00
Rich Felker 553d566c3f add missing type shmatt_t in sys/shm.h
this type is not really intended to be used; it's just there to allow
implementations to choose the type for the shm_nattch member of
struct shmid_sh, presumably since historical implementations disagreed
on the type. in any case, it needs to be there, so now it is.
2013-06-28 23:39:50 -04:00
Szabolcs Nagy 31ff797787 fix the prototype of settimeofday to follow the original BSD declaration 2013-05-26 16:01:38 +00:00
Rich Felker 2c184264ea support full range of dev_t major/minor numbers in makedev, etc. macros 2013-05-15 16:15:50 -04:00
rofl0r 47cf4919fc re-add useconds_t
this type was removed back in 5243e5f160 ,
because it was removed from the XSI specs.
however some apps use it.
since it's in the POSIX reserved namespace, we can expose it
unconditionally.
2013-04-02 04:58:14 +02:00
Szabolcs Nagy e82bd04cf7 add new socket options to sys/socket.h following linux 2013-04-01 16:24:12 +00:00
Szabolcs Nagy d4c04d1360 add ADJ_SETOFFSET timex mode bit (new in linux v2.6.39) 2013-04-01 16:24:12 +00:00
Rich Felker 08514d0614 fix epoll structure alignment on non-x86_64 archs
this fix is far from ideal and breaks the rule of not using
arch-specific #ifdefs, but for now we just need a solution to the
existing breakage.

the underlying problem is that the kernel folks made a very stupid
decision to make misalignment of this struct part of the kernel
API/ABI for x86_64, in order to avoid writing a few extra lines of
code to handle both 32- and 64-bit userspace on 64-bit kernels. I had
just added the packed attribute unconditionally thinking it was
harmless on 32-bit archs, but non-x86 32-bit archs have 8-byte
alignment on 64-bit types.
2013-03-06 23:57:39 -05:00
Rich Felker 8c741783fc fix some obscure header type size/alignment issues 2013-03-04 17:05:45 -05:00
Szabolcs Nagy 200f96c6a0 add MOD_TAI to sys/timex.h and update STA_RONLY 2013-01-12 19:42:39 +01:00
Szabolcs Nagy d650631dad add SWAP_FLAG_DISCARD to sys/swap.h 2013-01-12 19:42:39 +01:00
Szabolcs Nagy 645c6d99a5 add mount flags to sys/mount.h
added various MS_*, MNT_*, UMOUNT_* flags following the linux
headers, with one exception: MS_NOUSER is defined as (1U<<31)
instead of (1<<31) which invokes undefined behaviour

the S_* flags were removed following glibc
2013-01-12 19:42:39 +01:00
Szabolcs Nagy 48854dffdb add IN_EXCL_UNLINK to sys/inotify.h 2013-01-12 19:42:39 +01:00
Szabolcs Nagy ada88f6178 add EPOLLWAKEUP flag to sys/epoll.h 2013-01-12 19:42:39 +01:00
Szabolcs Nagy c7351ffe9b add RB_SW_SUSPEND and RB_KEXEC to sys/reboot.h
using the glibc names for the magic constants of the linux reboot syscall
2013-01-12 19:42:39 +01:00
Szabolcs Nagy 2010361663 add missing ptrace requests and options to sys/ptrace.h 2013-01-12 19:42:39 +01:00
Szabolcs Nagy f13a478860 add missing protocol families to sys/socket.h
missing protocol families based on current linux headers:
PF_RDS, PF_LLC, PF_CAN, PF_TIPC, PF_NFC
2013-01-12 19:42:38 +01:00
Rich Felker 2dec29741b fix another case of cloexec/nonblock flags not matching arch values 2013-01-10 17:57:30 -05:00
rofl0r e895ddc0cd wait.h: add linux specific, thread-related waitpid() flags
these flags are needed in order to be able to handle lwp id's
which the kernel returns after clone() calls for new threads
via ptrace(PTRACE_GETEVENTMSG).

fortunately, they're the same for all archs and in the reserved
namespace.
2013-01-04 20:36:34 +01:00
Rich Felker 761ebe065c align EPOLL_* flags with fcntl O_* flag definitions, which vary by arch
the old definitions were wrong on some archs. actually, EPOLL_NONBLOCK
probably should not even be defined; it is not accepted by the kernel
and it's not clear to me whether it has any use at all, even if it did
work. this issue should be revisited at some point, but I'm leaving it
in place for now in case some applications reference it.
2012-12-27 20:44:44 -05:00
rofl0r 3159e2fc81 socket.h: add SO_(SND/RCV)BUFFORCE to generic block 2012-12-19 19:02:22 +01:00
Rich Felker 9cb589939c add some missing macros to sys/shm.h
these are not specified in the standard, but in the reserved
namespace, so there is no problem with defining them unconditionally.
2012-12-15 00:43:27 -05:00
Rich Felker d50955620f add missing flags in sys/timerfd.h 2012-12-13 14:15:11 -05:00
Rich Felker 490d4a0e9e fix regressions in app compatibility from previous sys/ipc.h changes
despite glibc using __key and __seq rather than key and seq, some
applications, notably busybox, assume the names are key and seq unless
glibc is being used. and the names key and seq are really the ones
that _should_ be exposed when not attempting to present a
standards-conforming namespace; apps should not be using names that
begin with double-underscore. thus, the optimal fix is to use key and
seq as the actual names of the members when in bsd/gnu source profile,
and define macros for __key and __seq that redirect to plain key and
seq.
2012-12-10 21:36:12 -05:00
Rich Felker baf246e559 syscall() declaration belongs in unistd.h, not sys/syscall.h
traditionally, both BSD and GNU systems have it this way.
sys/syscall.h is purely syscall number macros. presently glibc exposes
the syscall declaration in unistd.h only with _GNU_SOURCE, but that
does not reflect historical practice.
2012-12-10 16:40:45 -05:00