Commit Graph

1005 Commits

Author SHA1 Message Date
Szabolcs Nagy
0b026bbd69 netinet/in.h add IPV6_MULTICAST_ALL from linux v4.20
ipv6 analogue of IP_MULTICAST_ALL sockopt.

added in linux commit 15033f0457dca569b284bef0c8d3ad55fb37eacb
2019-03-13 12:32:59 -04:00
Szabolcs Nagy
c6a61df183 add PACKET_IGNORE_OUTGOING sockopt from linux v4.20
new in linux commit fa788d986a3aac5069378ed04697bd06f83d3488
2019-03-13 12:32:19 -04:00
Szabolcs Nagy
db8b53f207 sys/mman.h: add new hugetlb mmap flags from linux v4.19
aarch64 supports 32MB and 512MB hugetlb page sizes too.
added in linux commit 20916d4636a9b3c1bf562b305f91d126771edaf9
2019-03-13 12:32:14 -04:00
Szabolcs Nagy
5640bc5bd5 elf.h: add new mips core dump note values from linux v4.19
NT_MIPS_FP_MODE is new in linux commit
1ae22a0e35636efceab83728ba30b013df761592

NT_MIPS_DSP is new in linux commit
44109c60176ae73924a42a6bef64ef151aba9095
2019-03-13 12:31:13 -04:00
Szabolcs Nagy
3e52f99308 netinet/udp.h: add UDP_ENCAP_RXRPC from linux v4.19
used for optimizing the rxrpc protocol
added in linux commit 5271953cad31b97dea80f848c16e96ad66401199
2019-03-13 12:30:21 -04:00
Szabolcs Nagy
b47723ab3b netinet/tcp.h: add tcp_info fields from linux v4.19
new fields for RFC 4898 tcp stats in linux
tcpi_bytes_sent added in commit ba113c3aa79a7f941ac162d05a3620bdc985c58d
tcpi_bytes_retrans added in commit fb31c9b9f6c85b1bad569ecedbde78d9e37cd87b
tcpi_dsack_dups added in commit 7e10b6554ff2ce7f86d5d3eec3af5db8db482caa
tcpi_reord_seen added in commit 7ec65372ca534217b53fd208500cf7aac223a383

The new fields change the size of a public struct and thus an ABI break,
but this is how the getsockopt TCP_INFO api is designed: the tcp_info
type must only be used with a length parameter in extern interfaces.
2019-03-13 12:30:12 -04:00
Szabolcs Nagy
df4b017bcd sys/inotify.h: add IN_MASK_CREATE from linux v4.19
inotify_add_watch flag to prevent modifying existing watch descriptors,
when used on an already watched inode it fails with EEXIST.
added in linux commit 4d97f7d53da7dc830dbf416a3d2a6778d267ae68
2019-03-13 12:29:27 -04:00
Szabolcs Nagy
31b3efbf3e sys/socket.h: add SO_TXTIME from linux v4.19
added in linux commit 80b14dee2bea128928537d61c333f24cb8cbb62f
2019-03-13 12:29:23 -04:00
Jonathan Neuschäfer
4b125dd408 fix POSIX_FADV_DONTNEED/_NOREUSE on s390x
On s390x, POSIX_FADV_DONTNEED and POSIX_FADV_NOREUSE have different
values than on all other architectures that Linux supports.

Handle this difference by wrapping their definitions in
include/fcntl.h in #ifdef, so that arch/s390x/bits/fcntl.h can
override them.
2019-03-13 11:37:29 -04:00
Rich Felker
81221e13f9 expose TSVTX unconditionally in tar.h
as noted in Austin Group issue #1236, the XSI shading for TSVTX is
misplaced in the html version of the standard; it was only supposed to
be on the description text. the intent was that the definition always
be visible, which is reflected in the pdf version of the standard.

this reverts commits d93c0740d8 and
729fef0a93.
2019-03-13 10:42:57 -04:00
Rich Felker
f368d9fd26 make FILE a complete type for pre-C11 standard profiles
C11 removed the requirement that FILE be a complete type, which was
deemed erroneous, as part of the changes introduced by N1439 regarding
completeness of types (see footnote 6 for specific mention of FILE).
however the current version of POSIX is still based on C99 and
incorporates the old requirement that FILE be a complete type.

expose an arbitrary, useless complete type definition because the
actual object used to represent FILE streams cannot be public/ABI.

thanks to commit 13d1afa46f, we now have
a framework for suppressing the public complete-type definition of FILE
when stdio.h is included internally, so that a different internal
definition can be provided. this is perfectly well-defined, since the
same struct tag can refer to different types in different translation
units. it would be a problem if the implementation were accessing the
application's FILE objects or vice versa, but either would be
undefined behavior.
2019-03-12 15:24:00 -04:00
Rich Felker
ba18c1ecc6 add membarrier syscall wrapper, refactor dynamic tls install to use it
the motivation for this change is twofold. first, it gets the fallback
logic out of the dynamic linker, improving code readability and
organization. second, it provides application code that wants to use
the membarrier syscall, which depends on preregistration of intent
before the process becomes multithreaded unless unbounded latency is
acceptable, with a symbol that, when linked, ensures that this
registration happens.
2019-02-22 03:25:39 -05:00
Bobby Bingham
1dd915c370 update line discipline constants 2019-02-07 12:43:22 -05:00
Bobby Bingham
3517d74a5e move arch-invariant definitions out of bits/ioctl.h 2019-02-07 12:43:19 -05:00
Szabolcs Nagy
1de4788610 add NT_VMCOREDD to elf.h from linux v4.18
used for device driver dump in /proc/vmcore
new in linux commit 2724273e8fd00b512596a77ee063f49b25f36507
2018-12-09 22:30:05 -05:00
Szabolcs Nagy
836022b1c3 add AT_MINSIGSTKSZ to elf.h from linux v4.18
new in linux commit 94b07c1f8c39c6d839df35fa28ffd1785d385897

currently only supported on aarch64
2018-12-09 22:29:44 -05:00
Szabolcs Nagy
ca73bea05d add TRAP_UNK si_code to signal.h from linux v4.18
used for undiagnosed trap exceptions where linux previously set si_code
to 0. new in linux commit db78e6a0a6f9f7d7277965600eeb1a5b3a6f55a8
2018-12-09 22:29:07 -05:00
Szabolcs Nagy
a71276e258 add SIGSYS support to sys/signalfd.h from linux v4.18
new in linux commit 76b7f670730e87974f71df9f6129811e2769666e

in struct signalfd_siginfo the pad member is changed to __pad to keep
the namespace clean, it's not part of the public api.
2018-12-09 22:25:21 -05:00
Szabolcs Nagy
0a9a5c20c7 add AF_XDP to sys/socket.h from linux v4.18
new address family and related macros were added in linux commit
68e8b849b221b37a78a110a0307717d45e3593a0
2018-12-09 22:24:12 -05:00
Szabolcs Nagy
4b9b8c8ee6 update netinet/udp.h for linux v4.18
add UDP_NO_CHECK6_* to restrict zero UDP6 checksums, new in linux commit
1c19448c9ba6545b80ded18488a64a7f3d8e6998 (pre-v4.18 change, was missed)
add UDP_SEGMENT to support generic segmentation offload for udp datagrams,
bec1f6f697362c5bc635dacd7ac8499d0a10a4e7 (new in v4.18)
2018-12-09 22:23:48 -05:00
Szabolcs Nagy
ac1af87e1d update netinet/tcp.h for linux v4.18
add packet delivery info to tcp_info,
new in linux commit feb5f2ec646483fb66f9ad7218b1aad2a93a2a5c
add TCP_ZEROCOPY_RECEIVE socket option for zerocopy receive,
new in linux commit 05255b823a6173525587f29c4e8f1ca33fd7677d
add TCP_INQ socket option and TCP_CM_INQ cmsg to get in-queue bytes in cmsg
upon read, new in linux commit b75eba76d3d72e2374fac999926dafef2997edd2
add TCP_REPAIR_* to fix repair socket window probe patch,
new in linux commit 31048d7aedf31bf0f69c54a662944632f29d82f2
2018-12-09 22:23:30 -05:00
Rich Felker
bf453d6839 restore attribute((const)) to pthread_self and errno location decls
revert commit a603a75a72.

as a result of commit 1c84c99913 this is
now safe, assuming an interpretation of the somewhat-underspecified
attribute((const)) consistent with real-world usage.
2018-10-16 14:10:27 -04:00
Khem Raj
7d7f44253f define MAX_HANDLE_SZ for use with name_to_handle_at
MAX_HANDLE_SZ is described in name_to_handle_at() to contain maximum
expected size for a file handle
2018-09-13 11:46:46 -04:00
Khem Raj
3e14bbcd19 wireup linux/name_to_handle_at and name_to_handle_at syscalls 2018-09-12 21:28:39 -04:00
Rich Felker
fe61a7aa53 rework mechanism for posix_spawnp calling posix_spawn
previously, a common __posix_spawnx backend was used that accepted an
additional argument for the execve variant to call in the child. this
moderately bloated up the posix_spawn function, shuffling arguments
between stack and/or registers to call a 7-argument function from a
6-argument one.

instead, tuck the exec function pointer in an unused part of the
(large) pthread_spawnattr_t structure, and have posix_spawnp duplicate
the attributes and fill in a pointer to __execvpe. the net code size
change is minimal, but the weight is shifted to the "heavier" function
which already pulls in more dependencies.

as a bonus, we get rid of an external symbol (__posix_spawnx) that had
no really good place for a declaration because it shouldn't have
existed to begin with.
2018-09-12 14:34:32 -04:00
Rich Felker
cdbbcfb8f5 fix dubious char signedness check in limits.h
commit 201995f382 introduced a hack
utilizing the signedness of character constants at the preprocessor
level to avoid depending on the gcc-specific __CHAR_UNSIGNED__ predef.
while this trick works on gcc and presumably other compilers being
used, it's not clear that the behavior it depends on is actually
conforming. C11 6.4.4.4 ¶10 defines character constants as having type
int, and 6.10.1 ¶4 defines preprocessor #if arithmetic to take place
in intmax_t or uintmax_t, depending on the signedness of the integer
operand types, and it is specified that "this includes interpreting
character constants".

if character literals had type char and just promoted to int, it would
be clear that when char is unsigned they should behave as uintmax_t at
the preprocessor level. however, as written the text of the standard
seems to require that character constants always behave as intmax_t,
corresponding to int, at the preprocessor level.

since there is a good deal of ambiguity about the correct behavior and
a risk that compilers will disagree or that an interpretation may
mandate a change in the behavior, do not rely on it for defining
CHAR_MIN and CHAR_MAX correctly. instead, use the signedness of the
value (as opposed to the type) of '\xff', which will be positive if
and only if plain char is unsigned. this behavior is clearly
specified, and the specific case '\xff' is even used in an example,
under 6.4.4.4 of the standard.
2018-08-28 13:54:50 -04:00
Rich Felker
184ef36f85 fix FP_ILOGB0 and FP_ILOGBNAN definitions to be valid for use in #if
commit 98c9af5001 wrongly claimed they
do not need to be valid for such usage, but the last sentence of C11
7.1.4 ¶1 imposes a broad requirement that all macros specified as
integer constant expressions also need to be valid for #if.

simply write the value out explicitly. there is no value here in
pretending that the width of int will vary.
2018-08-22 19:11:58 -04:00
Rich Felker
767f7a1091 remove erroneous SYMLINK_MAX definition from limits.h, pathconf
POSIX requires the symlink function to fail with ENAMETOOLONG if the
link contents to be written exceed SYMLINK_MAX in length, but neither
Linux nor our syscall wrapper code enforce this. the value 255 for
SYMLINK_MAX is not meaningful and does not seem to have been motivated
by anything except perhaps a wrong assumption that a definition was
mandatory. it has been present (though moving through bits to
top-level limits.h) since the beginning of the project history.

[f]pathconf is entitled to return -1 as the limit for conf names for
which there is no hard limit, with the usual POSIX note that an
indefinite limit does not imply an infinite limit. in principle we
might should report a limit for filesystems that impose one, but such
functionality is not currently present for any of the pathconf limits,
and adding it is beyond the scope of fixing the incorrect limit.
2018-08-20 20:33:19 -04:00
midipix
f2c6dbe244 move inclusion of linux headers for kd.h, soundcard.h, vt.h to bits
maintainer's note: while musl does not use the linux kernel headers,
it does provide these three sys/* headers which do nothing but include
the corresponding linux/* headers, since the sys/* versions are the
ones documented for application use (and they arguably provide
interfaces that are not linux-specific but common to other unices).
these headers should probably not be provided by libc (rather by a
separate package), but as long as they are, use the bits header
framework as an aid to out-of-tree ports of musl for non-linux systems
that want to implement them in some other way.
2018-07-20 01:06:41 -04:00
midipix
2fab90a71a remove inclusion guard hacks for sys/kd.h
maintainer's note: at some point, probably long before linux separated
the uapi headers, it was the case, or at least I believed it was the
case, that linux/types.h was unsafe to include from userspace. thus,
the inclusion guard macro _LINUX_TYPES_H was defined in sys/kd.h to
prevent linux/kd.h from including linux/types.h (which it spuriously
includes but does not use). as far as I can tell, whatever problem
this was meant to solve does not seem to have been present for a long
time, and the hack was not done correctly anyway, so removing it is
the right thing to do.
2018-07-20 01:06:03 -04:00
Szabolcs Nagy
df6d9450ea add support for arch-specific ptrace command macros
sys/ptrace.h is target specific, use bits/ptrace.h to add target
specific macro definitions.

these macros are kept in the generic sys/ptrace.h even though some
targets don't support them:

PTRACE_GETREGS
PTRACE_SETREGS
PTRACE_GETFPREGS
PTRACE_SETFPREGS
PTRACE_GETFPXREGS
PTRACE_SETFPXREGS

so no macro definition got removed in this patch on any target. only
s390x has a numerically conflicting macro definition (PTRACE_SINGLEBLOCK).

the PT_ aliases follow glibc headers, otherwise the definitions come
from linux uapi headers except ones that are skipped in glibc and
there is no real kernel support (s390x PTRACE_*_AREA) or need special
type definitions (mips PTRACE_*_WATCH_*) or only relevant for linux
2.4 compatibility (PTRACE_OLDSETOPTIONS).
2018-07-17 22:25:08 -04:00
Szabolcs Nagy
7ea32a8282 sys/ptrace.h: add missing PTRACE_EVENT_STOP
new in linux v3.1 commit 3544d72a0e10d0aa1c1bd59ed77a53a59cdc12f7
changed in linux v3.4 commit 5cdf389aee90109e2e3d88085dea4dd5508a3be7

A tracer recieves this event in the waitpid status of a PTRACED_SEIZED
process.
2018-07-17 22:24:15 -04:00
Szabolcs Nagy
cbf16c4abf uchar.h: define char16_t and char32_t for old c++
including uchar.h in c++ code is only well defined in c++11 onwards
where char16_t and char32_t type definitions must be hidden since they
are keywords.  however some c++ code compiled for older c++ standard
include uchar.h too and they need the typedefs, this fix makes such
code work.
2018-07-17 22:24:03 -04:00
Rich Felker
062015204a add ST_RELATIME to statvfs.h 2018-07-12 20:41:30 -04:00
David Carlier
05ac345f89 add explicit_bzero implementation
maintainer's note: past sentiment was that, despite being imperfect
and unable to force clearing of all possible copies of sensitive data
(e.g. in registers, register spills, signal contexts left on the
stack, etc.) this function would be added if major implementations
agreed on it, which has happened -- several BSDs and glibc all include
it.
2018-06-26 16:59:12 -04:00
Rich Felker
587f5a53bc fix value of SO_PEERSEC on mips archs
adapted from patch by Matthias Schiffer.
2018-06-26 15:55:29 -04:00
Szabolcs Nagy
38f2fa3d02 add memfd_create syscall wrapper
memfd_create was added in linux v3.17 and glibc has api for it.
2018-06-20 21:36:04 -04:00
Szabolcs Nagy
b64d66d0b0 add mlock2 linux syscall wrapper
mlock2 syscall was added in linux v4.4 and glibc has api for it.
It falls back to mlock in case of flags==0, so that case works
even on older kernels.

MLOCK_ONFAULT is moved under _GNU_SOURCE following glibc.
2018-06-20 21:35:45 -04:00
Szabolcs Nagy
da9f2b2ac8 add speculation control prctls from linux v4.17
PR_{SET,GET}_SPECULATION_CTRL controls speculation related vulnerability
mitigations, new in commits
b617cfc858161140d69cc0b5cc211996b557a1c7
356e4bfff2c5489e016fdb925adbf12a1e3950ee
2018-06-19 13:27:08 -04:00
Szabolcs Nagy
5b85ed5cec add ETH_P_PREAUTH ethertype from linux v4.17
added in linux commit 4fe0de5b143762d327bfaf1d7be7c5b58041a18c
2018-06-19 13:26:41 -04:00
Szabolcs Nagy
ebeb1de288 add TCP_NLA_* from linux v4.17
new and missing netlink attributes types for SCM_TIMESTAMPING_OPT_STATS,
new ones were added in commits
7156d194a0772f733865267e7207e0b08f81b02b
be631892948060f44b1ceee3132be1266932071e
87ecc95d81d951b0984f2eb9c5c118cb68d0dce8
2018-06-19 13:26:36 -04:00
Szabolcs Nagy
af55070eae add {MSG,SEM,SHM}_STAT_ANY from linux v4.17
introduced to stat ipc objects without permission checks since the
info is available in /proc/sysvipc anyway, new in linux commits
23c8cec8cf679b10997a512abb1e86f0cedc42ba
a280d6dc77eb6002f269d58cd47c7c7e69b617b6
c21a6970ae727839a2f300cd8dd957de0d0238c3
2018-06-19 13:26:24 -04:00
Szabolcs Nagy
156a3bedb2 add MAP_FIXED_NOREPLACE from linux v4.17
to map at a fixed address without unmapping underlying mappings
(fails with EEXIST unlike MAP_FIXED), new in linux commits
4ed28639519c7bad5f518e70b3284c6e0763e650 and
a4ff8e8620d3f4f50ac4b41e8067b7d395056843.
2018-06-19 13:26:00 -04:00
Szabolcs Nagy
0f7aa600f7 sys/ptrace.h: add PTRACE_SECCOMP_GET_METADATA from linux v4.16
to get seccomp state for checkpoint restore.
added in linux commit 26500475ac1b499d8636ff281311d633909f5d20

struct tag follows the glibc api and ptrace_peeksiginfo_args
got changed too accordingly.
2018-06-19 13:25:33 -04:00
Szabolcs Nagy
3a81cbe643 netinet/if_ether.h: add ETH_TLEN from linux v4.16
octets in ethernet type field
added in linux commit 4bbb3e0e8239f9079bf1fe20b3c0cb598714ae61
2018-06-19 13:25:25 -04:00
Szabolcs Nagy
833df8675c netinet/if_ether.h: add ETH_P_ERSPAN2 from linux v4.16
protocol number for erspan v2 support
added in linux commit f551c91de262ba36b20c3ac19538afb4f4507441
2018-06-19 13:25:22 -04:00
Szabolcs Nagy
29f3202b73 sys/epoll.h: add EPOLLNVAL from linux v4.16
added to uapi in commit 65aaf87b3aa2d049c6b9fd85221858a895df3393
used since commit a9a08845e9acbd224e4ee466f5c1275ed50054e8,
which renamed POLL* to EPOLL* in the kernel.
2018-06-19 13:25:16 -04:00
Rich Felker
d5e55ba332 add missing m68k relocation types in elf.h 2018-06-12 17:02:21 -04:00
Rich Felker
729fef0a93 fix default feature profile in tar.h
commit d93c0740d8 added use of feature
test macros without including features.h, causing a definition that
should be exposed in the default profile, TSVTX, to appear only when
_XOPEN_SOURCE or higher is explicitly defined.
2018-03-28 15:53:45 -04:00
Rich Felker
919ad8d5fb explicitly use signed keyword to define intNN_t and derivative types
standing alone, both the signed and int keywords identify the same
type, a (signed) int. however the C language has an exception where,
when the lone keyword int is used to declare a bitfield, it's
implementation-defined whether the bitfield is signed or unsigned. C11
footnote 125 extends this implementation-definedness to typedefs, and
DR#315 extends it to other integer types (for which support with
bitfields is implementation-defined).

while reasonable ABIs (all the ones we support) define bitfields as
signed by default, GCC and compatible compilers offer an option
-funsigned-bitfields to change the default. while any signed types
defined without explicit use of the signed keyword are affected, the
stdint.h types, especially intNN_t, have a natural use in bitfields.
ensure that bitfields defined with these types always have the correct
signedness regardless of compiler & flags used.

see also GCC PR 83294.
2018-03-12 20:04:59 -04:00
Rich Felker
f9c2498fee remove spurious const keyword in sigqueue declaration
this must have been taken from POSIX without realizing that it was
meaningless. the resolution to Austin Group issue #844 removed it from
the standard.
2018-03-10 18:19:41 -05:00
Rich Felker
a3f7bcdeaa fix minor namespace issue in unistd.h
the F_* macros associated with the lockf function are XSI-shaded (like
the lockf function itself) and should only be exposed when the
function is.
2018-03-10 18:19:40 -05:00
Rich Felker
d93c0740d8 fix minor namespace issue in tar.h
TSVTX is XSI-shaded.
2018-03-10 18:19:40 -05:00
Rich Felker
8e1381be44 fix minor namespace issues in limits.h
PAGE_SIZE, NZERO, and NL_LANGMAX are XSI-shaded.
2018-03-10 18:18:16 -05:00
Rich Felker
c9c2cd3e69 reverse definition dependency between PAGESIZE and PAGE_SIZE
PAGESIZE is actually the version defined in POSIX base, with PAGE_SIZE
being in the XSI option. use PAGESIZE as the underlying definition to
facilitate making exposure of PAGE_SIZE conditional.
2018-03-10 17:47:14 -05:00
Rich Felker
2fae10f887 fix aliasing violations in fgetpos/fsetpos
add a member of appropriate type to the fpos_t union so that accesses
are well-defined. use long long instead of off_t since off_t is not
always exposed in stdio.h and there's no namespace-clean alias for it.

access is still performed using pointer casts rather than by naming
the union member as a matter of style; to the extent possible, the
naming of fields in opaque types defined in the public headers is not
treated as an API contract with the implementation. access via the
pointer cast is valid as long as the union has a member of matching
type.
2018-02-24 16:45:33 -05:00
Rich Felker
82f176803a add getentropy function
based loosely on patch by Hauke Mehrtens; converted to wrap the public
API of the underlying getrandom function rather than direct syscalls,
so that if/when a fallback implementation of getrandom is added it
will automatically get picked up by getentropy too.
2018-02-23 02:57:52 -05:00
Hauke Mehrtens
e206582091 add getrandom syscall wrapper
This syscall is available since Linux 3.17 and was also implemented in
glibc in version 2.25 using the same interfaces.
2018-02-22 19:34:58 -05:00
Szabolcs Nagy
74ab4b8284 elf.h: add DT_SYMTAB_SHNDX
it's a recent addition to elf gabi:
http://sco.com/developers/gabi/latest/revision.html
based on discussions at
https://sourceware.org/bugzilla/show_bug.cgi?id=15835
2018-02-22 18:51:16 -05:00
Szabolcs Nagy
dfeeeaf544 elf.h: syncronize DF_1_ flags with binutils
DF_1_STUB and DF_1_PIE were added in binutils-gdb commit
5c383f026242d25a3c21fdfda42e5ca218b346c8
2018-02-22 18:51:00 -05:00
Szabolcs Nagy
eef5e4821d elf.h: update NT_* coredump elf notes for linux v4.15
NT_ARM_SVE and NT_S390_RI_CB are new in linux commits
43d4da2c45b2f5d62f8a79ff7c6f95089bb24656 and
262832bc5acda76fd8f901d39f4da1121d951222
the rest are older.
musl missed NT_PRFPREG because it followed the glibc api:
https://sourceware.org/bugzilla/show_bug.cgi?id=14890
2018-02-22 18:49:46 -05:00
Szabolcs Nagy
5024804176 elf.h: add PPC64_OPT_LOCALENTRY
allows calling extern functions without saving r2, for details see
glibc commit 0572433b5beb636de1a49ec6b4fdab830c38cdc5
2018-02-22 18:49:42 -05:00
Szabolcs Nagy
e7bd039df2 elf.h: add AT_* auxval macros for cache geometry
AT_L1I_*, AT_L1D_*, AT_L2_* and AT_L3_* were added in linux v4.11 for
powerpc in commit 98a5f361b8625c6f4841d6ba013bbf0e80d08147.
2018-02-22 18:49:39 -05:00
Szabolcs Nagy
121d18d2f2 sys/prctl.h: add new PR_SVE_* macros from linux v4.15
PR_SVE_SET_VL and PR_SVE_GET_VL controls are new in linux commit
2d2123bc7c7f843aa9db87720de159a049839862
related PR_SVE_* macros were added in
7582e22038a266444eb87bc07c372592ad647439
2018-02-22 18:49:34 -05:00
Szabolcs Nagy
4001c51181 netinet/in.h: add new IPV6_FREEBIND from linux v4.15
new socekt option for AF_INET6 SOL_RAW sockets, added in linux commit
84e14fe353de7624872e582887712079ba0b2d56
2018-02-22 18:49:07 -05:00
Szabolcs Nagy
5f4ff22aa3 netinet/tcp.h: add TCP_* socket options from linux v4.15
TCP_FASTOPEN_KEY is new in 1fba70e5b6bed53496ba1f1f16127f5be01b5fb6
TCP_FASTOPEN_NO_COOKIE is new in 71c02379c762cb616c00fd5c4ed253fbf6bbe11b
2018-02-22 18:49:03 -05:00
Szabolcs Nagy
9b57db3f95 add MAP_SYNC and MAP_SHARED_VALIDATE from linux v4.15
for synchronous page faults, new in linux commit
1c9725974074a047f6080eecc62c50a8e840d050 and
b6fb293f2497a9841d94f6b57bd2bb2cd222da43
note that only targets that use asm-generic/mman.h have this new
flag defined, so undef it on other targets (mips*, powerpc*).
2018-02-22 18:48:58 -05:00
Szabolcs Nagy
e69608700f netinet/tcp.h: add tcp_diag_md5sig struct from linux v4.14
for querying tcp md5 signing keys.
new in linux commit c03fa9bcacd9ac04595cc13f34f3445f0a5ecf13
2018-02-22 18:48:18 -05:00
Szabolcs Nagy
abdaba8616 sys/{mman,shm}.h: add {MAP,SHM}_HUGE_ macros from linux uapi
*_HUGE_SHIFT, *_HUGE_2MB, *_HUGE_1GB are documented in the man page,
so add all of the *_HUGE_* macros from linux uapi.

if MAP_HUGETLB is set, top bits of the mmap flags encode the page size.
see the linux commit aafd4562dfee81a40ba21b5ea3cf5e06664bc7f6

if SHM_HUGETLB is set, top bits of the shmget flags encode the page size.
see the linux commit 4da243ac1cf6aeb30b7c555d56208982d66d6d33

*_HUGE_16GB is defined unsigned to avoid signed left shift ub.
2018-02-22 18:48:12 -05:00
Szabolcs Nagy
fba3059d72 netinet/if_ether.h: add new ETH_P_ macros from linux v4.14
new ethertypes in linux v4.14:
ETH_P_ERSPAN new in 84e54fe0a5eaed696dee4019c396f8396f5a908b
ETH_P_IFE new in 2804fd3af6ba5ae5737705b27146455eabe2e2f8
ETH_P_NSH new in 155e6f649757c902901e599c268f8b575ddac1f8
ETH_P_MAP new in 7373ae7e8f0bf2c0718422481da986db5058b005
2018-02-22 18:47:52 -05:00
Szabolcs Nagy
4d4a665799 net/if_arp.h: add ARPHRD_RAWIP from linux v4.14
new in linux commmit cdf4969c42a6c1a376dd03a9e846cf638d3cd4b1
2018-02-22 18:47:49 -05:00
Szabolcs Nagy
38e81ddc04 signal.h: add missing SIGTRAP si_codes
TRAP_BRANCH and TRAP_HWBKPT new in linux commit
da654b74bda14c45a7d98c731bf3c1a43b6b74e2
2018-02-22 18:46:31 -05:00
Szabolcs Nagy
5431c20040 sys/mman.h: add MADV_WIPEONFORK from linux v4.14
allows zeroing anonymous private pages inherited by a child process.
new in linux commit d2cd9ede6e193dd7d88b6d27399e96229a551b19
2018-02-22 18:45:31 -05:00
Szabolcs Nagy
986bc21713 sys/socket.h: add MSG_ZEROCOPY from linux v4.14
MSG_ZEROCOPY socket send flag avoids copy in the kernel
new in linux commit 52267790ef52d7513879238ca9fac22c1733e0e3
SO_ZEROCOPY socket option enables MSG_ZEROCOPY if availale
new in linux commit 76851d1212c11365362525e1e2c0a18c97478e6b
2018-02-22 18:45:24 -05:00
Szabolcs Nagy
404097a4ef sys/socket.h: add SOL_TLS from linux v4.13
socket option for kernel TLS support
new in linux commit 3c4d7559159bfe1e3b94df3a657b2cda3a34e218
2018-02-22 18:45:19 -05:00
Szabolcs Nagy
709bbf5175 sys/socket.h: add PF_SMC from linux v4.11
add AF_SMC and PF_SMC for the IBM shared memory communication protocol.
new in linux commit ac7138746e14137a451f8539614cdd349153e0c0
(linux socket.h is not in uapi so this update was missed earlier)
2018-02-22 18:45:16 -05:00
Rostislav Skudnov
1bc10ffeaa add _DIRENT_HAVE_D_* macros to dirent.h 2018-01-12 14:26:59 -05:00
Hauke Mehrtens
b583c5d3b4 add additional uapi guards for Linux kernel header files
With Linux kernel 4.16 it will be possible to guard more parts of the
Linux header files from a libc. Make use of this in musl to guard all
the structures and other definitions from the Linux header files which
are also defined by the header files provided by musl. This will make
it possible to compile source files which include both the libc
headers and the kernel userspace headers.

This extends the definitions done in commit 04983f2272 ("make
netinet/in.h suppress clashing definitions from kernel headers")
2018-01-09 13:08:25 -05:00
Rich Felker
d5029bb88a fix endian errors in netinet/icmp6.h due to failure to include endian.h 2017-12-15 12:58:33 -05:00
Jo-Philipp Wich
14cec8678e fix endian errors in arpa/nameser.h due to failure to include endian.h 2017-12-14 23:36:47 -05:00
Rich Felker
2488d31f5a adjust fopencookie structure tag for ABI-compat
stdio types use the struct tag names from glibc libio to match C++
ABI.
2017-12-06 13:14:22 -05:00
William Pitcock
061843340f implement the fopencookie extension to stdio
notes added by maintainer:

this function is a GNU extension. it was chosen over the similar BSD
function funopen because the latter depends on fpos_t being an
arithmetic type as part of its public API, conflicting with our
definition of fpos_t and with the intent that it be an opaque type. it
was accepted for inclusion because, despite not being widely used, it
is usually very difficult to extricate software using it from the
dependency on it.

calling pattern for the read and write callbacks is not likely to
match glibc or other implementations, but should work with any
reasonable callbacks. in particular the read function is never called
without at least one byte being needed to satisfy its caller, so that
spurious blocking is not introduced.

contracts for what callbacks called from inside libc/stdio can do are
always complicated, and at some point still need to be specified
explicitly. at the very least, the callbacks must return or block
indefinitely (they cannot perform nonlocal exits) and they should not
make calls to stdio using their own FILE as an argument.
2017-12-06 13:11:48 -05:00
Szabolcs Nagy
6651ef1f06 add new tcp.h socket options from linux v4.13
TCP_ULP is new in linux commit 734942cc4ea6478eed125af258da1bdbb4afe578
TCP_MD5SIG_EXT is new in 8917a777be3ba566377be05117f71b93a5fd909d
2017-11-05 18:41:26 -05:00
Szabolcs Nagy
14ced22830 add new fcntl.h macros from linux v4.13
for getting/setting write lifetime hints fcntl commands were
added in linux commit c75b1d9421f80f4143e389d2d50ddfc8a28c8c35

added under _GNU_SOURCE || _BSD_SOURCE, since RWH_* life time
hints are not in the POSIX reserved namespace.
2017-11-05 18:41:24 -05:00
Szabolcs Nagy
c35a8bf456 add SO_ getsockopt options from linux v4.13
SCM_TIMESTAMPING_PKTINFO is new in aad9c8c470f2a8321a99eb053630ce0e199558d6
SO_PEERGROUPS is new in 28b5ba2aa0f55d80adb2624564ed2b170c19519e
2017-11-05 18:41:21 -05:00
Szabolcs Nagy
4c81122711 add ARPHDR_VSOCKMON from linux v4.12
new in linux commit 531b374834c891ae2abf800693074df35a7d1a36
2017-11-05 18:41:14 -05:00
Szabolcs Nagy
54f04d9991 add new SO_ socket options from linux v4.12
SO_MEMINFO added in linux commit a2d133b1d465016d0d97560b11f54ba0ace56d3e
SO_INCOMING_NAPI_ID added in 6d4339028b350efbf87c61e6d9e113e5373545c9
SO_COOKIE added in 5daab9db7b65df87da26fd8cfa695fb9546a1ddb
2017-11-05 18:41:13 -05:00
Szabolcs Nagy
c519658cea add TCP_NLA_* enums from linux v4.11
two new stats for SCM_TIMESTAMPING_OPT_STATS, added in linux commit
7e98102f489775d8c000884fca8a0d995ea688a9
2017-11-05 18:41:09 -05:00
Szabolcs Nagy
ee3ae7827b add TCP_FASTOPEN_CONNECT tcp socket option from linux v4.11
new in linux commit 19f6d3f3c8422d65b5e3d2162e30ef07c6e21ea2
2017-11-05 18:41:08 -05:00
Szabolcs Nagy
3eb82f7338 add ETH_P_IBOE from linux v4.11
new in linux commit 69ae543969abeba48e04dd93277684c8c0895f3b
2017-11-05 18:41:06 -05:00
Szabolcs Nagy
d800403032 add TFD_TIMER_CANCEL_ON_SET that timerfd.h was missing
linux commit 575b1967e10a1f3038266244d2c7a3ca6b99fed8 moved timerfd
apis to a new uapi header which showed musl was missing this flag.
2017-11-05 18:40:58 -05:00
Szabolcs Nagy
f5638c22e3 add ETH_MIN_MTU and ETH_MAX_MTU from linux v4.10
min max mtu size definitions mostly for drivers.
new in linux commits a52ad514fdf3b8a57ca4322c92d2d8d5c6182485 and
d894be57ca92c8a8819ab544d550809e8731137b
2017-11-05 18:40:53 -05:00
Szabolcs Nagy
013696918b add IP_RECVFRAGSIZE and IPV6_RECVFRAGSIZE from linux v4.10
added in linux commit 70ecc24841326396a827deb55c3fefac582a729d
2017-11-05 18:39:29 -05:00
Szabolcs Nagy
5c596ed867 add SCM_TIMESTAMPING_OPT_STATS and related TCP_ enums from linux v4.10
for tcp timestamp control messages, new in linux commit
1c885808e45601b2b6f68b30ac1d999e10b6f606
and export time measurements via tcp_info, added in linux commit
efd90174167530c67a54273fd5d8369c87f9bd32
2017-11-05 18:39:25 -05:00
Rich Felker
48be5b6313 fix use of memset without declaration in sched.h cpu set macros
patch by Jörg Krause.
2017-09-28 12:57:06 -04:00
Rich Felker
5f7efb87a2 move IPPORT_RESERVED from netdb.h to netinet/in.h
it's in the reserved namespace for the latter, where it seems it was
historically defined, and some programs expect to find it there.
2017-08-29 20:50:48 -04:00
Rich Felker
947d330f68 add _NL_LOCALE_NAME extension to nl_langinfo
since setlocale(cat, NULL) is required to return the setting for the
global locale, there is no standard mechanism to obtain the name of
the currently active thread-local locale set by uselocale. this makes
it impossible for application/library software to load appropriate
translations, etc. unless using the gettext implementation provided by
libc, which has privileged access to libc internals.

to fill this gap, glibc introduced the _NL_LOCALE_NAME macro which can
be used with nl_langinfo to obtain the name. GNU gettext/gnulib code
already use this functionality on glibc, and can easily be adapted to
make use of it on non-glibc systems if it's available; for other
systems they poke at locale implementation internals, which we want to
avoid. this patch provides a compatible interface to the one glibc
introduced.
2017-07-31 23:08:27 -04:00
Alexander Monakov
bd00cc8781 remove useless declarations in string.h
The two functions str{,n}casecmp_l are specified to be declared in
<strings.h> which is already included from <string.h> under _GNU_SOURCE.
2017-07-04 17:04:21 -04:00
Rich Felker
77e895dcfa add no-op POSIX_SPAWN_USEVFORK to spawn.h
the bit is reserved anyway for ABI-compat reasons; this documents it
and makes it so we can have posix_spawnattr_setflags check for flag
validity without hard-coding an anonymous bit value.
2017-04-22 20:40:09 -04:00
Rich Felker
bb439bb171 implement new posix_spawn flag POSIX_SPAWN_SETSID
this functionality has been adopted for inclusion in the next issue of
POSIX as the result of Austin Group issue #1044.

based on patch by Daurnimator.
2017-04-22 18:39:40 -04:00
Szabolcs Nagy
60c46db80b update tcp_info struct to linux v4.9
export tcp data delivery rate in tcp_info struct.
see linux commit eb8329e0a04db0061f714f033b4454326ba147f4
2016-12-29 22:11:01 -05:00
Szabolcs Nagy
a8a8fdff96 add MS_NOREMOTELOCK mount flag from linux v4.9
for handling file locking on overlayfs.
see linux commit c568d68341be7030f5647def68851e469b21ca11
2016-12-29 22:10:44 -05:00
Quentin Rameau
bfcf5735d0 in public headers, don't assume pre-C99 compilers have __inline keyword 2016-12-16 23:12:32 -05:00
Rich Felker
ffaaa6d230 remove legacy i386 fallback stdarg implementation and framework
this has been slated for removal for a long time. there is
fundamentally no way to implement stdarg without compiler assistance;
any attempt to do so has serious undefined behavior; its working
depends not just (as a common misconception goes) on ABI, but also on
assumptions about compiler code generation internal to a translation
unit, which is not subject to external ABI constraints.
2016-12-15 12:18:24 -05:00
Rich Felker
b418ea1b66 generalize ELF hash table types not to assume 32-bit entries
alpha and s390x gratuitously use 64-bit entries (wasting 2x space and
cache utilization) despite the values always being 32-bit.

based on patch by Bobby Bingham, with changes suggested by Alexander
Monakov to use the public Elf_Symndx type from link.h (and make it
properly variable by arch) rather than adding new internal
infrastructure for handling the type.
2016-11-11 12:46:06 -05:00
Rich Felker
31fb174dd2 add limited pthread_setattr_default_np API to set stack size defaults
based on patch by Timo Teräs:

While generally this is a bad API, it is the only existing API to
affect c++ (std::thread) and c11 (thrd_create) thread stack size.
This patch allows applications only to increate stack and guard
page sizes.
2016-11-08 12:45:03 -05:00
Rich Felker
04983f2272 make netinet/in.h suppress clashing definitions from kernel headers
the linux kernel uapi headers provide their own definitions of the
structures from netinet/in.h, resulting in errors when a program
includes both the standard libc header and one or more of the
networking-related kernel headers that pull in the kernel definitions.

as before, we do not attempt to support the case where kernel headers
are included before the libc ones, since the kernel definitions may
have subtly incorrect types, namespace violations, etc. however, we
can easily support the inclusion of the kernel headers after the libc
ones, since the kernel headers provide a public interface for
suppressing their definitions. this patch adds the necessary macro
definitions for such suppression.
2016-11-07 23:19:19 -05:00
Rich Felker
c8fdcfe550 don't claim support for resolv.h APIs that aren't supported
the value 19991006 for __RES implies availability of res_ninit and
related functions that take a resolver state argument; these are not
supported since our resolver is stateless. instead claim support for
just the older API by defining __RES to 19960801.

based on patch by Dmitrij D. Czarkoff.
2016-11-07 11:55:53 -05:00
Rich Felker
7352b59d68 remove redundant feature test macro checks in sys/time.h
this header is XSI-shaded itself and thus does not need to limit
specific content to _XOPEN_SOURCE.
2016-11-07 11:49:22 -05:00
Rich Felker
7597fc25a2 fix various header namespace issues under feature-test-macro control
reported and changes suggested by Daniel Sabogal.
2016-10-20 17:20:01 -04:00
Rich Felker
2ed4e9d927 remove parameter names from public headers
inclusion of these names was unintentional and in most cases is a
namespace violation. Daniel Sabogal tracked down and reported these.
2016-10-20 17:04:37 -04:00
Rich Felker
4b8f94c250 fix misspelling of a legacy macro name in sys/param.h 2016-10-20 17:01:56 -04:00
Daniel Sabogal
71e8392765 add missing if_ether.h constants
ETH_P_HSR (IEC 62439-3 HSRv1) added in
linux 4.7 commit ee1c27977284907d40f7f72c2d078d709f15811f

ETH_P_TSN (IEEE 1722) added in
linux 4.3 commit 1ab1e895492d8084dfc1c854efacde219e56b8c1
this constant breaks the ascending order to match the kernel header

ETH_P_XDSA (Multiplexed DSA protocol) added in
linux 3.18 commit 3e8a72d1dae374cf6fc1dba97cec663585845ff9
2016-10-20 16:55:57 -04:00
Daniel Sabogal
79c7ded0ed add missing if_arp.h constant
ARPHRD_6LOWPAN (IPv6 over LoWPAN) added in
linux 3.14 commit 0abc652c796dab74d34d60473ec5594cd21620be
2016-10-20 16:55:51 -04:00
Daniel Sabogal
1fa2a32d1e fix typo in utmpx.h 2016-10-20 16:55:32 -04:00
Daniel Sabogal
104e8a0e3b add missing confstr constants
the _CS_V6_ENV and _CS_V7_ENV constants are required to be available for use
with confstr. glibc defines these constants with values 1148 and 1149,
respectively.

the only missing (and required) confstr constants are
_CS_POSIX_V7_THREADS_CFLAGS and _CS_POSIX_V7_THREADS_LDFLAGS which remain
unavailable in glibc.
2016-10-20 16:55:05 -04:00
Felix Janda
8fb28b0b3e add pthread_setname_np
the thread name is displayed by gdb's "info threads".
2016-10-20 01:48:27 -04:00
Szabolcs Nagy
87643335ac update icmphdr struct following linux v4.8
add union field that is used in the kernel for SIT/GRE tunneling ICMPv4
messages. see linux commit 20e1954fe238dbe5f8d3a979e593fe352bd703cf
2016-10-20 01:29:06 -04:00
Szabolcs Nagy
cc7c95e98e add TCP_REPAIR_WINDOW to netinet/tcp.h from linux v4.8
another kernel internal state exposure for checkpoint-restore.
see linux commit b1ed4c4fa9a5ccf325184fd90edc50978ef6e33a
2016-10-20 01:28:44 -04:00
Szabolcs Nagy
fe39aaae0e add bits/hwcap.h and include it in sys/auxv.h
aarch64, arm, mips, mips64, mipsn32, powerpc, powerpc64 and sh have
cpu feature bits defined in linux for AT_HWCAP auxv entry, so expose
those in sys/auxv.h

it seems the mips hwcaps were never exposed to userspace neither
by linux nor by glibc, but that's most likely an oversight.
2016-10-20 01:28:25 -04:00
Szabolcs Nagy
5a05f67599 elf.h: update EM_ elf machine defines and add R_BPF_ defines
sync with gabi: http://www.sco.com/developers/gabi/latest/ch4.eheader.html

EM_BPF is new in linux v4.8 and officially assigned:
https://lists.iovisor.org/pipermail/iovisor-dev/2016-June/000266.html
added related relocs too.
2016-10-20 01:27:46 -04:00
Szabolcs Nagy
9487cc5f22 add ETH_P_NCSI to netinet/if_ether.h from linux v4.8
see linux commit 6389eaa7fa9c3ee6c7d39f6087b86660d17236ac
2016-10-20 01:27:28 -04:00
Rich Felker
66570ec9c4 fix undefined behavior in sched.h cpu_set_t usage
since cpu sets can be dynamically allocated and have variable size,
accessing their contents via ->__bits is not valid; performing pointer
arithmetic outside the range of the size of the declared __bits array
results in undefined beahavior. instead, only use cpu_set_t for
fixed-size cpu set objects (instantiated by the caller) and as an
abstract pointer type for dynamically allocated ones. perform all
accesses simply by casting the abstract pointer type cpuset_t * back
to unsigned long *.
2016-09-19 11:15:51 -04:00
Daniel Sabogal
5505f6afae add missing *_unlocked and wcsftime_l prototypes to wchar.h
these functions had been implemented, but prototypes were not made available
2016-09-16 18:18:34 -04:00
Daniel Sabogal
3848a99f65 fix ifru_data and ifcu_buf types in net/if.h
glibc, freebsd, and openbsd use character pointers (caddr_t) for
these fields. only linux uses void pointer for the ifru_data type.
2016-09-16 17:59:54 -04:00
Rich Felker
e738b8cbe6 restore _Noreturn to __assert_fail
this reverts commit 2c1f8fd5da. without
the _Noreturn attribute, the compiler cannot use asserts to perform
reachability/range analysis. this leads to missed optimizations and
spurious warnings.

the original backtrace problem that prompted the removal of _Noreturn
was not clearly documented at the time, but it seems to happen only
when libc was built without -g, which also breaks many other
backtracing cases.
2016-08-30 16:39:54 -04:00
Duncan Overbruck
c1f4ed1501 fix FFSYNC by changing it to O_SYNC
O_FSYNC was never defined and is legacy/wrong, nothing seems to use it.
2016-08-30 16:01:47 -04:00
Szabolcs Nagy
9680e1d03a add SS_AUTODISARM sigaltstack ss_flags from linux v4.7 to signal.h
only matters if swapcontext is used in a signal handler running on an
altstack, new in linux commit 2a74213838104a41588d86fd5e8d344972891ace
2016-08-30 15:58:25 -04:00
Szabolcs Nagy
c6519d4a71 add UDP_ENCAP_GTP0, UDP_ENCAP_GTP1U from linux v4.7 to netinet/udp.h
for GPRS tunneling protocol, new in linux commit
459aa660eb1d8ce67080da1983bb81d716aa5a69
2016-08-30 15:58:23 -04:00
Szabolcs Nagy
0f8ad40be0 add PF_QIPCRTR, AF_QIPCRTR from linux v4.7 to sys/socket.h
macros for qualcom ip router protocol, new in linux commit
bdabad3e363d825ddf9679dd431cca0b2c30f881
2016-08-30 15:58:20 -04:00
Rich Felker
0f47367751 add stdc-predef.h for library-level predefined macros
modern compilers (for gcc, versions 4.8 and later) automatically
pre-include <stdc-predef.h> to obtain the values of certain predefined
macros specified by ISO C but which reflect properties of the library
implementation, not just the compiler. provide values indicating that
wchar_t is Unicode-encoded and that Annex F (IEEE floating point) is
supported unless the compiler indicates otherwise.

based on patch by Masanori Ogino.
2016-07-03 20:03:30 -04:00
Rich Felker
ee3f0c5516 make brace placement in public header typedef'd structs consistent
commit befa5866ee performed this change
for struct definitions that did not also involve typedef, but omitted
the latter.
2016-07-03 16:19:28 -04:00
Szabolcs Nagy
3c3b09980d add EF_SH_ sh specific macros to elf.h
last time elf.h was thoroughly updated sh was not yet supported
so these processor specific e_flags were missing.
2016-07-03 16:15:13 -04:00
Szabolcs Nagy
84fd4e4ffd add NT_ARM_SYSTEM_CALL to elf.h
new regset in linux v3.18 for ptrace.
2016-07-03 16:15:12 -04:00
Szabolcs Nagy
c3be411df7 add missing x86 relocs to elf.h
see
https://sourceware.org/ml/libc-alpha/2016-01/msg00822.html
2016-07-03 16:15:12 -04:00
Szabolcs Nagy
7c3b67234c add DT_MIPS_RLD_MAP_REL to elf.h
marks different RLD_MAP for debugging PIE binaries.
2016-07-03 16:15:12 -04:00
Szabolcs Nagy
af17dc40dd add SHF_COMPRESSED section flag to elf.h
following
http://www.sco.com/developers/gabi/latest/ch4.sheader.html
2016-07-03 16:15:12 -04:00
Szabolcs Nagy
29a96c1980 add powerpc tls optimization related definitions to elf.h
see
https://sourceware.org/ml/libc-alpha/2015-03/msg00580.html
2016-07-03 16:15:11 -04:00
Szabolcs Nagy
347d0617d1 add nios2 definitions to elf.h 2016-07-03 16:15:11 -04:00
Szabolcs Nagy
abbdf0f51d update elf.h with mips abi flags support
following
https://sourceware.org/ml/libc-alpha/2014-05/msg00332.html
2016-07-03 16:15:11 -04:00
Szabolcs Nagy
49eb322425 update elf.h with new aarch64 relocs
add ilp32 related relocs and alternative names for a few macros following
https://sourceware.org/ml/libc-alpha/2014-11/msg00455.html
2016-07-03 16:15:10 -04:00
Szabolcs Nagy
b921e0fd1f update elf.h with powerpc64 elfv2 abi related macros
see
https://sourceware.org/ml/libc-alpha/2013-11/msg00315.html
https://sourceware.org/ml/libc-alpha/2013-11/msg00314.html
2016-07-03 16:12:12 -04:00
Szabolcs Nagy
35b58194dc add new powerpc64 relocations to elf.h
following the corresponding binutils and glibc changes
https://sourceware.org/ml/binutils/2013-10/msg00372.html
2016-07-03 16:11:12 -04:00
Szabolcs Nagy
308e4bc618 add EM_OPENRISC again to elf.h
it was changed to EM_OR1K in 200d15479c
as that was meant to be the official name, but glibc and the latest
gabi spec still uses the EM_OPENRISC name:
http://www.sco.com/developers/gabi/latest/ch4.eheader.html
binutils defines both macros so we should do the same for backward
compatibility.
2016-07-03 16:11:05 -04:00
Rich Felker
befa5866ee make brace placement in public header struct definitions consistent
placing the opening brace on the same line as the struct keyword/tag
is the style I prefer and seems to be the prevailing practice in more
recent additions.

these changes were generated by the command:

find include/ arch/*/bits -name '*.h' \
-exec sed -i '/^struct [^;{]*$/{N;s/\n/ /;}' {} +

and subsequently checked by hand to ensure that the regex did not pick
up any false positives.
2016-07-03 15:02:25 -04:00
Rich Felker
093288dcb3 fix misplaced indention in sys/procfs.h 2016-07-03 15:02:24 -04:00
Bobby Bingham
3d98146146 pthread: implement try/timed join variants 2016-06-30 21:47:24 -04:00
Rich Felker
5c43e1dbc8 add RUSAGE_THREAD (Linux extension) definition to sys/resource.h 2016-06-29 11:55:41 -04:00
Rich Felker
b3bbc7b160 fix incorrect definition of RUSAGE_CHILDREN in sys/resource.h
the kernel ABI value for RUSAGE_CHILDREN is -1, not 1. the latter is
actually interpreted as RUSAGE_THREAD, to obtain values for just the
calling thread and not the whole process.
2016-06-29 11:54:03 -04:00
Rich Felker
1e6fc0b690 avoid padding gaps in struct sockaddr_storage
compilers are free not to copy, or in some cases to clobber, padding
bytes in a structure. while it's an aliasing violation, and thus
undefined behavior, to copy or manipulate other sockaddr types using
sockaddr_storage, it seems likely that traditional code attempts to do
so, and the original intent of the sockaddr_storage structure was
probably to allow such usage.

in the interest of avoiding silent and potentially dangerous breakage,
ensure that there are no actual padding bytes in sockaddr_storage by
moving and adjusting the size of the __ss_padding member so that it
fits exactly.

this change also removes a silent assumption that the alignment of
long is equal to its size.
2016-06-09 13:42:06 -04:00
Szabolcs Nagy
a0bb50a142 update sys/socket.h to linux v4.6
kernel connection multiplexor macros AF_KCM, PF_KCM, SOL_KCM were
added in linux commit ab7ac4eb9832e32a09f4e8042705484d2fb0aad3

MSG_BATCH sendmsg flag for performance optimization was added
in linux commit f092276d85b82504e8a07498f4e9e0c51f06745c

SOL_* macros are now synced with linux socket.h which is not a uapi
header and glibc did not have the macros either, but that has changed
http://sourceware.org/ml/libc-alpha/2016-05/msg00322.html
2016-06-09 13:40:22 -04:00
Szabolcs Nagy
349877755d add new tcp_info fields from linux v4.6
new fields and associated linux commit:
tcpi_notsent_bytes, tcpi_min_rtt cd9b266095f422267bddbec88f9098b48ea548fc
tcpi_data_segs_in, tcpi_data_segs_out a44d6eacdaf56f74fad699af7f4925a5f5ac0e7f
2016-06-09 13:40:20 -04:00
Szabolcs Nagy
1d561c2fa4 add CLONE_NEWCGROUP clone flag, new in linux v4.6
flag for new cgroup namespace, added in linux commit
5e2bec7c2248ae27c5b16cd97215ae05c1d39179
2016-06-09 13:40:17 -04:00
Szabolcs Nagy
19f87240d5 update siginfo struct for linux v4.6
x86 protection key faults are reported in the si_pkey field,
added in linux commit cd0ea35ff5511cde299a61c21a95889b4a71464e
2016-06-09 13:40:13 -04:00
Szabolcs Nagy
7ea37c7aa4 add ETH_P_MACSEC netinet/if_ether.h, new in linux v4.6
ethertype for macsec added in linux commit
dece8d2b78d19df7fe5e4e965f1f0d1a3e188d1b
2016-06-09 13:40:11 -04:00
Szabolcs Nagy
f6f4aa5ddb add SO_CNX_ADVICE to sys/socket.h, new in linux v4.6
new socket option so application can give advice about routing
path quality of connected udp sockets, added in linux commit
a87cb3e48ee86d29868d3f59cfb9ce1a8fa63314
2016-06-09 13:40:07 -04:00
Rich Felker
81fb75a1d7 fix undefined pointer arithmetic in CMSG_NXTHDR macro
previously, the only way the stopping condition could be met with
correct lengths in the headers invoked undefined behavior, adding
sizeof(struct cmsghdr) beyond the end of the cmsg buffer.

instead, compute and compare sizes rather than pointers.
2016-05-22 18:49:59 -04:00
Szabolcs Nagy
d578c74e67 add MADV_FREE madvise command from linux v4.5
allows the os to free the marked pages lazily on memory pressure.
expected to increase malloc performance.
new in linux commit 854e9ed09dedf0c19ac8640e91bcc74bc3f9e5c9
2016-03-19 11:31:24 -04:00
Szabolcs Nagy
b10ca0f560 add EPOLLEXCLUSIVE epoll flag from linux v4.5
new flag for exclusive wakeup mode when an event source fd is attached
to multiple epoll fds but they should not all receive the events.
new in linux commit df0108c5da561c66c333bb46bfe3c1fc65905898
2016-03-19 11:31:19 -04:00
Szabolcs Nagy
c1aabc6cac add SO_ATTACH_REUSEPORT_[CE]BPF socket options from linux v4.5
new socket options for setting classic or extended BPF program
for sockets in a SO_REUSEPORT group.  added in linux commit
538950a1b7527a0a52ccd9337e3fcd304f027f13
2016-03-19 11:31:13 -04:00
Szabolcs Nagy
8ffa0375f2 add IPV6_HDRINCL socket option from linux v4.5
new in linux commit 715f504b118998c41a2079a17e16bf5a8a114885
same as IP_HDRINCL but for SOL_IPV6 sockets.
2016-03-19 11:31:02 -04:00
Szabolcs Nagy
e9f1c7981a deduplicate bits/mman.h
currently five targets use the same mman.h constants and the rest
share most constants too, so move them to sys/mman.h before the
bits/mman.h include where the differences can be corrected by
redefinition of the macros.

this fixes two minor bugs: POSIX_MADV_DONTNEED was wrong on most
targets (it should be the same as MADV_DONTNEED), and sh defined
the x86-only MAP_32BIT mmap flag.
2016-03-18 22:40:28 -04:00
Nathan Zadoks
98d335735d add sched_getcpu
This is a GNU extension, but a fairly minor one, for a system call that
otherwise has no libc wrapper.
2016-03-02 21:32:36 -05:00
Rich Felker
0ed932f34f do not define static_assert macro for pre-C11 compilers
some software simply uses static_assert if the macro is defined, and
this breaks if the compiler does not recognize the _Static_assert
keyword used to define it.
2016-02-12 10:11:40 -05:00
Rich Felker
692b16d14b add declarations for utmpname/utmpxname to appropriate headers
commit 378f8cb522 added these functions
(as stubs) but left them without declarations. this broke some
autoconf based software that detected linkability of the symbols but
didn't check for a declaration.
2016-02-12 09:58:50 -05:00
Szabolcs Nagy
9a3b8f97a1 fix siginfo_t for mips
si_errno and si_code are swapped in mips siginfo_t compared to other
archs and some si_code values are different.  This fix is required
for POSIX timers to work.

based on patch by Dmitry Ivanov.
2016-01-26 22:31:21 -05:00
Szabolcs Nagy
22f84829af move bits/signal.h include close to the top of signal.h
only have code above the bits/signal.h include that is necessary.
(some types are used for the ucontext struct and mips has to
override a few macro definitions)

this way mips bits/signal.h will be able to affect siginfo_t.
2016-01-26 22:26:47 -05:00
Szabolcs Nagy
c243d6f095 add new PTRACE_SECCOMP_GET_FILTER ptrace command
allows the tracer to dump the bpf seccomp filters of the tracee,
new in linux v4.4, commit f8e529ed941ba2bbcbf310b575d968159ce7e895
2016-01-26 18:31:17 -05:00
Szabolcs Nagy
789ff6a9f8 add MCL_ONFAULT and MLOCK_ONFAULT mlockall and mlock2 flags
they lock faulted pages into memory (useful when a small part of a
large mapped file needs efficient access), new in linux v4.4, commit
b0f205c2a3082dd9081f9a94e50658c5fa906ff1

MLOCK_* is not in the POSIX reserved namespace for sys/mman.h
2016-01-26 18:31:05 -05:00
Szabolcs Nagy
aaa604052d add new PTRACE_O_SUSPEND_SECCOMP ptrace option
allows a ptracer process to disable/enable seccomp filters of the
traced process, useful for checkpoint/restore, new in v4.3 commit
13c4a90119d28cfcb6b5bdd820c233b86c2b0237
2016-01-26 18:30:30 -05:00
Szabolcs Nagy
8afd2a1d03 add new PR_CAP_AMBIENT and related defines to sys/prctl.h
ambient capability mask is new in linux v4.3, commit
58319057b7847667f0c9585b9de0e8932b0fdb08
2016-01-26 18:30:14 -05:00
Szabolcs Nagy
3934f49c01 update netpacket/packet.h to linux v4.3 2016-01-26 18:29:32 -05:00
Szabolcs Nagy
2c9acc51cd add new IP_BIND_ADDRESS_NO_PORT and IPPROTO_MPLS to netinet/in.h
IP_BIND_ADDRESS_NO_PORT is a SOL_IP socket option to delay src port
allocation until connect in case src ip is set with bind(port=0).
new in linux v4.2, commit 90c337da1524863838658078ec34241f45d8394d

IPPROTO_MPLS protocol number for mpls over ip.
new in linux v4.2, commit 730fc4371333636a00fed32c587fc1e85c5367e2
2016-01-24 19:19:29 -05:00
Szabolcs Nagy
4da2d96591 update netinet/tcp.h for linux v4.2
TCP_CC_INFO is a new socket option to get congestion control info without
netlink (union tcp_cc_info is in linux/inet_diag.h kernel header).
linux commit 6e9250f59ef9efb932c84850cd221f22c2a03c4a

TCP_SAVE_SYN, TCP_SAVED_SYN socket options are for saving and getting the
SYN headers of passive connections in a server application.
linux commit cd8ae85299d54155702a56811b2e035e63064d3d

Add new tcpi_* fields to struct tcp_info implementing RFC4898 counters.
linux commit 2efd055c53c06b7e89c167c98069bab9afce7e59
2016-01-24 19:18:51 -05:00
Szabolcs Nagy
ecf02f4e8a add MS_LAZYTIME mount option to sys/mount.h
new in linux 4.0 commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8,
used to update atime/mtime/ctime only in memory when possible.
2016-01-24 19:18:41 -05:00
Szabolcs Nagy
9f52c17eb2 add AF_MPLS (PF_MPLS) address family to socket.h
new in linux 4.0 commit 0189197f441602acdca3f97750d392a895b778fd.
2016-01-24 19:18:21 -05:00
Szabolcs Nagy
ea4fc27d28 add MSG_FASTOPEN sendmsg/sendto flag to socket.h
This was new in linux 3.5 in commit cf60af03ca4e71134206809ea892e49b92a88896,
needed for tcp fastopen feature (sending data in TCP SYN packet).
2016-01-24 19:18:02 -05:00
Kylie McClain
53f41fb568 netinet/tcp: Add TCPOPT, TCPOLEN constants
Programs such as iptables depend on these constants, which can also
be found defined in other libcs.

Since only TCP_* is reserved as part of tcp.h's namespace, we hide
them behind _BSD_SOURCE (and therefore _DEFAULT_SOURCE) to expose
them by default, but keep it standard conforming.
2016-01-17 17:37:36 -05:00
Rich Felker
2f1d1f1ec5 fix mismatched parens in CMPLX def for annex-g-conforming compilers
this conditional path was never tested because there are no compilers
that conform to annex g (none with _Imaginary_I).
2015-11-02 21:44:57 -05:00
Rich Felker
a603a75a72 remove attribute((const)) from pthread_self and errno location decls
this attribute was applied to pthread_self and the functions providing
the locations for errno and h_errno as an optimization; however, it is
subtly incorrect. as specified, it means the return value will always
be the same, which is not true; it varies per-thread.

this attribute also implies that the function does not depend on any
state, and that calls to it can safely be reordered across any other
code. however such reordering is unsafe for these functions: they
break when reordered before initialization of the thread pointer. such
breakage was actually observed when compiled by libfirm/cparser.

to some extent the reordering problem could be solved with strong
compiler barriers between the stages of early startup code, but the
specified meaning of of attribute((const)) is sufficiently strong that
a compiler would theoretically be justified inserting gratuitous calls
to attribute((const)) const functions at random locations (e.g. to
save the value in static storage for later use).

this reverts commit cbf35978a9.
2015-09-17 04:45:01 +00:00
Khem Raj
ccc71e0ea8 add format argument attributes to gettext function prototypes
their absence completely breaks format string warnings in programs
with gettext message translations: -Wformat gives no results, and
-Wformat-nonliteral produces spurious warnings.

with gcc, the problem manifests only in standards-conforming profiles;
otherwise gcc sets these attributes by default for the gettext family.
with clang, the problem always manifests; clang has no such defaults.
2015-09-15 20:30:36 +00:00
Rich Felker
17cdbc4e42 add sh relocation types needed for fdpic to elf.h 2015-09-12 02:49:02 +00:00
Roman Yeryomin
29ec7677a7 socket.h: fix SO_* for mips
Signed-off-by: Roman Yeryomin <roman@ubnt.com>
2015-07-21 19:14:26 -04:00
Rich Felker
11894f6d3a fix incorrect void return type for syncfs function
being nonstandard, the closest thing to a specification for this
function is its man page, which documents it as returning int. it can
fail with EBADF if the file descriptor passed is invalid.
2015-07-09 17:07:35 +00:00
Rich Felker
f22a9edaf8 byte-based C locale, phase 3: make MB_CUR_MAX variable to activate code
this patch activates the new byte-based C locale (high bytes treated
as abstract code unit "characters" rather than decoded as multibyte
characters) by making the value of MB_CUR_MAX depend on the active
locale. for the C locale, the LC_CTYPE category pointer is null,
yielding a value of 1. all other locales yield a value of 4.
2015-06-16 06:18:00 +00:00
Rich Felker
3d7e32d28d add macro version of ctype.h isascii function
presumably internal code (ungetwc and fputwc) was written assuming a
macro implementation existed; otherwise use of isascii is just a
pessimization.
2015-06-06 18:16:22 +00:00
Rich Felker
b6e7c66467 add missing legacy LFS64 macros in sys/resource.h
based on patch by Felix Janda, with RLIM64_SAVED_CUR and
RLIM64_SAVED_MAX added for completeness.
2015-05-28 15:37:23 -04:00
Szabolcs Nagy
20de36cc89 fix netinet/ether.h for c++ 2015-05-08 08:35:16 -04:00
Rich Felker
d0040e239e improve iswdigit macro to diagnose errors
this is analogous to commit 2ca55a93f2
for the macros in ctype.h.
2015-05-02 21:19:08 -04:00
Szabolcs Nagy
7561ac45ed add IPTOS_CLASS_* macros to netinet/ip.h
These macros were introduced in glibc 2.12 to follow RFC 2474 which
deprecates "IP Precedence" in favor of "Class Selector Codepoints".
2015-05-01 13:38:44 -04:00
Rich Felker
e98a54643e fix integer overflow in elf.h macro SHF_EXCLUDE 2015-05-01 13:35:51 -04:00
Szabolcs Nagy
02e5d56421 add PR_*_FP_MODE prctl options
new in linux v4.0, commit 9791554b45a2acc28247f66a5fd5bbc212a6b8c8
used to work around a floating-point abi issue on mips
2015-04-17 22:31:44 -04:00
Szabolcs Nagy
658aefdf33 add PR_MPX_*_MANAGEMENT prctl options
new in linux v3.19, commit fe3d197f84319d3bce379a9c0dc17b1f48ad358c
used for on-demand kernel allocation of bounds tables for mpx on x86
2015-04-17 22:31:35 -04:00
Szabolcs Nagy
1bfeb1dcd0 add IP_CHECKSUM socket option to netinet/in.h
new in linux v4.0, commit ad6f939ab193750cc94a265f58e007fb598c97b7
2015-04-17 22:31:27 -04:00
Rich Felker
2ca55a93f2 improve ctype.h macros to diagnose errors
the casts of the argument to unsigned int suppressed diagnosis of
errors like passing a pointer instead of a character. putting the
actual function call in an unreachable branch restores any diagnostics
that would be present if the macros didn't exist and functions were
used.
2015-04-17 22:24:31 -04:00
Rich Felker
5e25d87b09 remove macro definition of longjmp from setjmp.h
the C standard specifies that setjmp is a macro, but longjmp is a
normal function. a macro version of it would be permitted (albeit
useless) for C (not C++), but would have to be a function-like macro,
not an object-like one.
2015-04-01 20:35:03 -04:00
Rich Felker
fd427c4eae move O_PATH definition back to arch bits
while it's the same for all presently supported archs, it differs at
least on sparc, and conceptually it's no less arch-specific than the
other O_* macros. O_SEARCH and O_EXEC are still defined in terms of
O_PATH in the main fcntl.h.
2015-04-01 19:31:06 -04:00
Rich Felker
11d1e2e2de fix FLT_ROUNDS regression in C++ applications
commit 559de8f5f0 redefined FLT_ROUNDS
to use an external function that can report the actual current
rounding mode, rather than always reporting round-to-nearest. however,
float.h did not include 'extern "C"' wrapping for C++, so C++ programs
using FLT_ROUNDS ended up with an unresolved reference to a
name-mangled C++ function __flt_rounds.
2015-03-23 11:26:51 -04:00
Rich Felker
d5a5045382 fix MINSIGSTKSZ values for archs with large signal contexts
the previous values (2k min and 8k default) were too small for some
archs. aarch64 reserves 4k in the signal context for future extensions
and requires about 4.5k total, and powerpc reportedly uses over 2k.
the new minimums are chosen to fit the saved context and also allow a
minimal signal handler to run.

since the default (SIGSTKSZ) has always been 6k larger than the
minimum, it is also increased to maintain the 6k usable by the signal
handler. this happens to be able to store one pathname buffer and
should be sufficient for calling any function in libc that doesn't
involve conversion between floating point and decimal representations.

x86 (both 32-bit and 64-bit variants) may also need a larger minimum
(around 2.5k) in the future to support avx-512, but the values on
these archs are left alone for now pending further analysis.

the value for PTHREAD_STACK_MIN is not increased to match MINSIGSTKSZ
at this time. this is so as not to preclude applications from using
extremely small thread stacks when they know they will not be handling
signals. unfortunately cancellation and multi-threaded set*id() use
signals as an implementation detail and therefore require a stack
large enough for a signal context, so applications which use extremely
small thread stacks may still need to avoid using these features.
2015-03-18 00:31:37 -04:00
Szabolcs Nagy
559de8f5f0 fix FLT_ROUNDS to reflect the current rounding mode
Implemented as a wrapper around fegetround introducing a new function
to the ABI: __flt_rounds. (fegetround cannot be used directly from float.h)
2015-03-07 12:05:28 -05:00