Commit Graph

779 Commits

Author SHA1 Message Date
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