Commit Graph

684 Commits

Author SHA1 Message Date
Szabolcs Nagy e1f1df9c74 math: fix comparision macros (isless etc) when FLT_EVAL_METHOD!=0
This is a change in ISO C11 annex F (F.10.11p1), comparision macros
can't round their arguments to their semantic type when the evaluation
format has wider range and precision. (ie. they must be consistent with
the builtin relational operators)
2013-09-27 13:55:29 +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 268375c1c0 update include/elf.h following glibc changes
the changes were verified using various sources:
linux: include/uapi/linux/elf.h
binutils: include/elf/common.h
glibc: elf/elf.h
sysv gabi: http://www.sco.com/developers/gabi/latest/contents.html
sun linker docs: http://docs.oracle.com/cd/E18752_01/pdf/817-1984.pdf
and platform specific docs

- fixed:
EF_MIPS_* E_MIPS_* e_flags: fixed accoding to glibc and binutils

- added:
ELFOSABI_GNU for EI_OSABI entry: glibc, binutils and sysv gabi
EM_* e_machine values: updated according to linux and glibc
PN_XNUM e_phnum value: from glibc and linux, see oracle docs
NT_* note types: updated according to linux and glibc
DF_1_* flags for DT_FLAGS_1 entry: following glibc and oracle docs
AT_HWCAP2 auxv entry for more hwcap bits accoding to linux and glibc
R_386_SIZE32 relocation according to glibc and binutils
EF_ARM_ABI_FLOAT_* e_flags: added following glibc and binutils
R_AARCH64_* relocs: added following glibc and aarch64 elf specs
R_ARM_* relocs: according to glibc, binutils and arm elf specs
R_X86_64_* relocs: added missing relocs following glibc

- removed:
HWCAP_SPARC_* flags were moved to arch specific header in glibc
R_ARM_SWI24 reloc is marked as obsolete in glibc, not present in binutils
  not specified in arm elf spec, R_ARM_TLS_DESC reused its number
  see http://www.codesourcery.com/publications/RFC-TLSDESC-ARM.txt

- glibc changes not pulled in:
ELFOSABI_ARM_AEABI (bare-metal system, binutils and glibc disagrees about the name)
R_68K_* relocs for unsupported platform
R_SPARC_* ditto
EF_SH* ditto (e_flags)
EF_S390* ditto (e_flags)
R_390* ditto
R_MN10300* ditto
R_TILE* ditto
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
Szabolcs Nagy 2607e39a04 net/if_arp.h: add missing ARP hardware identifiers from linux uapi headers
the removed ARPHRD_IEEE802154_PHY was only present in the kernel api
in v2.6.31 (by accident), but it got into the glibc headers (in 2009)
and remained there since this header was not updated since then.
2013-09-15 02:42:29 +00:00
Szabolcs Nagy 0dc630ec95 netinet/in.h: add missing IP protocol numbers from the linux uapi headers 2013-09-15 02:41:36 +00:00
Szabolcs Nagy b20760c023 support configurable page size on mips, powerpc and microblaze
PAGE_SIZE was hardcoded to 4096, which is historically what most
systems use, but on several archs it is a kernel config parameter,
user space can only know it at execution time from the aux vector.

PAGE_SIZE and PAGESIZE are not defined on archs where page size is
a runtime parameter, applications should use sysconf(_SC_PAGE_SIZE)
to query it. Internally libc code defines PAGE_SIZE to libc.page_size,
which is set to aux[AT_PAGESZ] in __init_libc and early in __dynlink
as well. (Note that libc.page_size can be accessed without GOT, ie.
before relocations are done)

Some fpathconf settings are hardcoded to 4096, these should be actually
queried from the filesystem using statfs.
2013-09-15 02:00:32 +00:00
Rich Felker c2d3fd3aad add workaround header for wait.h remapping to sys/wait.h 2013-09-01 01:01:31 -04:00
Rich Felker da19f88659 only expose struct tcphdr under _GNU_SOURCE
the BSD and GNU versions of this structure differ, so exposing it in
the default _BSD_SOURCE profile is possibly problematic. both versions
could be simultaneously supported with anonymous unions if needed in
the future, but for now, just omitting it except under _GNU_SOURCE
should be safe.
2013-08-30 17:06:17 -04:00
Rich Felker 09b2995bcb add struct tcphdr in netinet/tcp.h 2013-08-30 16:50:00 -04:00
Rich Felker 38e6acbf89 stdbool.h should define __bool_true_false_are_defined even for C++
while the incorporation of this requirement from C99 into C++11 was
likely an accident, some software expects it to be defined, and it
doesn't hurt. if the requirement is removed, then presumably
__bool_true_false_are_defined would just be in the implementation
namespace and thus defining it would still be legal.
2013-08-28 00:41:00 -04: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 fcc522c923 de-duplicate dn_expand, fix return value and signature, clean up
the duplicate code in dn_expand and its incorrect return values are
both results of the history of the code: the version in __dns.c was
originally written with no awareness of the legacy resolver API, and
was later copy-and-paste duplicated to provide the legacy API.

this commit is the first of a series that will restructure the
internal dns code to share as much code as possible with the legacy
resolver API functions.

I have also removed the loop detection logic, since the output buffer
length limit naturally prevents loops. in order to avoid long runtime
when encountering a loop if the caller provided a ridiculously long
buffer, the caller-provided length is clamped at the maximum dns name
length.
2013-08-14 17:58:20 -04:00
Rich Felker 4ce6bd8345 add missing MSG_EXCEPT in sys/msg.h 2013-08-14 02:48:11 -04:00
Rich Felker 35eb1a1a9b provide declarations for strtod_l and family
these aliases were originally intended to be for ABI compatibility
only, but their presence caused regressions in broken gnulib-based
software whose configure scripts detect the existing of these
functions then use them without declarations, resulting in bogus
return values.
2013-08-13 18:18:44 -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
Rich Felker 7406fdf5a1 add pthread_setaffinity_np and pthread_getaffinity_np functions 2013-08-10 21:41:05 -04:00
Rich Felker eeb0328f20 add cpu affinity interfaces
this first commit just includes the CPU_* and sched_* interfaces, not
the pthread_* interfaces, which may be added later. simple
sanity-check testing has been done for the basic interfaces, but most
of the macros have not yet been tested.
2013-08-10 21:15:11 -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 14012b91f2 add some new linux AT_* flags 2013-08-03 03:20:56 -04:00
Rich Felker f0ceb5abd9 add prototypes for euidaccess/eaccess 2013-08-03 02:18:19 -04:00
Rich Felker 2e5dfa515f fix feature test macro logic for _BSD_SOURCE
in several places, _BSD_SOURCE was not even implying POSIX, resulting
in it being subtractive rather than additive (compared to the default
features).
2013-08-02 18:14:44 -04:00
Rich Felker feff6b43e5 add missing c++ extern "C" wrapping to link.h 2013-08-02 16:52:17 -04:00
Rich Felker 78c6d30fd3 provide useless 64-bit fcntl macros with _LARGEFILE64_SOURCE
this is all useless but part of the API, which is part of the
_GNU_SOURCE API, so something may need them.
2013-08-02 10:00:09 -04: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
Rich Felker bf7b7282f5 a few more fixes for unistd/sysconf feature reporting 2013-07-27 00:02:39 -04:00
Rich Felker a6d39fdfa4 report presence of ADV and MSG options in unistd.h and sysconf 2013-07-26 23:07:54 -04:00
Rich Felker 77830507be report that posix_spawn is supported in unistd.h and sysconf 2013-07-26 15:51:28 -04:00
Rich Felker a926fe26c1 fix incorrect type for new si_call_addr in siginfo_t
apparently the original kernel commit's i386 version of siginfo.h
defined this field as unsigned int, but the asm-generic file always
had void *. unsigned int is obviously not a suitable type for an
address, in a non-arch-specific file, and glibc also has void * here,
so I think void * is the right type for it.

also fix redundant type specifiers.
2013-07-24 23:17:21 -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 b54f169bfd update siginfo according to linux headers
linux commit a0727e8ce513fe6890416da960181ceb10fbfae6 (2012-04-12)
added siginfo fields for SIGSYS (seccomp uses it)

linux commit ad5fa913991e9e0f122b021e882b0d50051fbdbc (2009-09-16)
added siginfo field and si_code values for SIGBUS (hwpoison signal)
2013-07-24 23:56:13 +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 b5c07e45fc add if_ether.h constants ETH_P_802_3_MIN and ETH_P_BATMAN
see linux commits 4f99ad51292078cc47343c17d3870764588cff73 and
e5c5d22e8dcf7c2d430336cbf8e180bd38e8daf1
2013-07-24 22:17:24 +00:00
Szabolcs Nagy d74e462a76 add CLOCK_TAI (and CLOCK_SGI_CYCLE) clock ids to time.h
added in linux-v3.10 commit 1ff3c9677bff7e468e0c487d0ffefe4e901d33f4
2013-07-24 22:17:24 +00:00
Szabolcs Nagy b5e409df70 remove TCP_COOKIE_TRANSACTIONS from tcp.h
removed in linux-v3.10 in commit 1a2c6181c4a1922021b4d7df373bba612c3e5f04
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 9693501c15 change jmp_buf to share an underlying type and struct tag with sigjmp_buf
this is necessary to meet the C++ ABI target. alternatives were
considered to avoid the size increase for non-sig jmp_buf objects, but
they seemed to have worse properties. moreover, the relative size
increase is only extreme on x86[_64]; one way of interpreting this is
that, if the size increase from this patch makes jmp_buf use too much
memory, then the program was already using too much memory when built
for non-x86 archs.
2013-07-24 02:17:02 -04:00
Rich Felker 9578f0530a undefine internal-use type macros at the end of alltypes.h
this patch is something of a compromise for a compatibility
regression discovered after the header refactoring: libtiff uses
_Int64 for its own use. this is absolutely wrong, invalid C, and
should not be supported, but it's also frustrating for users when code
that used to work suddenly breaks.

rather than leave the breakage in place or change musl internals to
accommodate broken software, I've found a change that makes the
problem go away and improves musl. by undefining these macros at the
end of alltypes.h, the temptation to use them in other headers is
removed. (for example, I almost used _Int64 in sys/types.h to define
u_int64_t rather than adding it back to alltypes.h.) by confining use
of these macros to alltypes.h, we keep it easy to go back and change
the implementation of alltypes later, if needed.
2013-07-22 20:58:04 -04: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 1c6cace0bf fix regression in size of nlink_t (broken stat struct) on x86_64
rather than moving nlink_t back to the arch-specific file, I've added
a macro _Reg defined to the canonical type for register-size values on
the arch. this is not the same as _Addr for (not-yet-supported)
32-on-64 pseudo-archs like x32 and mips n32, so a new macro was
needed.
2013-07-22 15:45:28 -04:00
Rich Felker 8327ae0cb2 make regoff_t and regex_t match C++ ABI
for regoff_t, it's impossible to match on 64-bit archs because glibc
defined the type in a non-conforming way. however this change makes
the type match on 32-bit archs.
2013-07-22 14:39:59 -04:00
Rich Felker 4e3c6b4303 make pthread_key_t unsigned to match ABI 2013-07-22 14:03:25 -04:00
Rich Felker 0109d950e6 make pthread attribute types structs, even when they just have one field
this change is to get the right tags for C++ ABI matching. it should
have no other effects.
2013-07-22 13:57:02 -04:00
Rich Felker c4dd0c98ba change wint_t to unsigned
aside from the obvious C++ ABI purpose for this change, it also brings
musl into alignment with the compiler's idea of the definition of
wint_t (use in -Wformat), and makes the situation less awkward on ARM,
where wchar_t is unsigned.

internal code using wint_t and WEOF was checked against this change,
and while a few cases of storing WEOF into wchar_t were found, they
all seem to operate properly with the natural conversion from unsigned
to signed.
2013-07-22 13:05:41 -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 b823ef2db1 fix FILENAME_MAX to match PATH_MAX
POSIX is not clear on whether it includes the termination, but ISO C
requires that it does. the whole concept of this macro is rather
useless, but it's better to be correct anyway.
2013-07-18 14:15:48 -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
rofl0r 0636d5977a add legacy scsi/scsi_ioctl.h header 2013-07-03 18:07:50 +02:00
rofl0r f206fec1c8 paths.h: remove cruft
a research in debian codesearch and grepping over the pkgsrc
directory tree have shown that these macros are all either unused,
or defined by programs in case they need them.
2013-07-03 18:07:50 +02:00
Rich Felker fbcd82040c add stubs for additional legacy ether.h functions
these would not be expensive to actually implement, but reading
/etc/ethers does not sound like a particularly useful feature, so for
now I'm leaving them as stubs.
2013-07-01 13:50:02 -04: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 780cbbe63a implement minimal dlinfo function 2013-06-29 12:46:46 -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
Rich Felker 1e2281b835 minor compatibility fixes in utmp.h and fixing mismatch with paths.h
the pathnames prefixed with /dev/null/ are guaranteed never to be
valid. the previous use of /dev/null alone was mildly dangerous in
that bad software might attempt to unlink the name when it found a
non-regular file there and create a new file.
2013-06-27 20:00:29 -04:00
Rich Felker f03db4bdff document in sysconf and unistd.h that per-thread cpu clocks exist 2013-06-26 19:43:24 -04:00
Rich Felker a3e2f3c2b1 respect iso c namespace in stdio.h and wchar.h regarding va_list
despite declaring functions that take arguments of type va_list, these
headers are not permitted by the c standard to expose the definition
of va_list, so an alias for the type must be used. the name
__isoc_va_list was chosen to convey that the purpose of this alternate
name is for iso c conformance, and to avoid the multitude of names
which gcc mangles with its hideous "fixincludes" monstrosity, leading
to serious header breakage if these "fixes" are run.
2013-06-25 22:26:20 -04:00
Rich Felker e40f48a421 implement inet_lnaof, inet_netof, and inet_makeaddr
also move all legacy inet_* functions into a single file to avoid
wasting object file and compile time overhead on them.

the added functions are legacy interfaces for working with classful
ipv4 network addresses. they have no modern usefulness whatsoever, but
some programs unconditionally use them anyway, and they're tiny.
2013-06-25 21:35:49 -04:00
Rich Felker 83966b369d add ether_aton[_r] and ether_ntoa[_r] functions
based on patch by Strake with minor stylistic changes, and combined
into a single file. this patch remained open for a long time due to
some question as to whether ether_aton would be better implemented in
terms of sscanf, and it's time something was committed, so here it is.
2013-06-25 21:15:27 -04:00
Rich Felker 4191d24476 add clock id macros for a number of new(ish) Linux-specific clocks
arguably CLOCK_MONOTONIC should be redirected to CLOCK_BOOTTIME with a
fallback for old kernels that don't support it, since Linux's
CLOCK_BOOTTIME semantics seem to match the spirit of the POSIX
requirements for CLOCK_MONOTONIC better than Linux's version of
CLOCK_MONOTONIC does. however, this is a change that would require
further discussion and research, so for now, I'm simply making them
all available.
2013-06-08 11:42:52 -04:00
Rich Felker 0173990284 fix the type of CLOCKS_PER_SEC to match new clock_t type
originally it was right on 32-bit archs and wrong on 64-bit, but after
recent changes it was wrong everywhere. with this commit, it's now
right everywhere.
2013-06-08 11:40:27 -04:00
Rich Felker f7244d205f improve handling of nonstandard fields in struct tm
defining tm_gmtoff and tm_zone as macros was breaking some application
code that used these names for its own purposes.
2013-06-07 09:54:45 -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 22730d6560 add FLT_TRUE_MIN, etc. macros from C11
there was some question as to how many decimal places to use, since
one decimal place is always sufficient to identify the smallest
denormal uniquely. for now, I'm following the example in the C
standard which is consistent with the other min/max macros we already
had in place.
2013-05-17 18:38:42 -04:00
Rich Felker ec9f5353b1 remove the __STDC_FORMAT_MACROS nonsense from inttypes.h
somehow I missed this when removing the corresponding
__STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS nonsense from stdint.h.
these were all attempts by the C committee to guess what the C++
committee would want, and the guesses turned out to be wrong.
2013-05-17 14:23:41 -04: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
Szabolcs Nagy 2897bfdd60 remove compound literals from math.h to please c++
__FLOAT_BITS and __DOUBLE_BITS macros used union compound literals,
now they are changed into static inline functions. A good C compiler
generates the same code for both and the later is C++ conformant.
2013-05-06 17:52:48 +00:00
Rich Felker 43653c1250 remove __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS checks in stdint.h
C++11, the first C++ with stdint.h, requires the previously protected
macros to be exposed unconditionally by stdint.h. apparently these
checks were an early attempt by the C committee to guess what the C++
committee would want, and they guessed wrong.
2013-04-22 20:47:34 -04:00
Rich Felker 4ba3ebdcfe make ifaddrs.h expose sys/socket.h
the getifaddrs interface seems to have been invented by glibc, and
they expose socket.h, so for us not to do so is just gratuitous
incompatibility with the interface we're mimicing.
2013-04-10 22:38:46 -04:00
Rich Felker b4ea63856a add support for program_invocation[_short]_name
this is a bit ugly, and the motivation for supporting it is
questionable. however the main factors were:
1. it will be useful to have this for certain internal purposes
anyway -- things like syslog.
2. applications can just save argv[0] in main, but it's hard to fix
non-portable library code that's depending on being able to get the
invocation name without the main application's help.
2013-04-06 17:50:37 -04:00
rofl0r b3792c8891 include/ifaddrs.h: add prototypes for get/freeifaddrs 2013-04-05 19:59:40 +02:00
rofl0r 202db37a6f add getifaddrs
supports ipv4 and ipv6, but not the "extended" usage where
usage statistics and other info are assigned to ifa_data members
of duplicate entries with AF_PACKET family.
2013-04-05 19:36:51 +02:00
rofl0r 5ffe494050 net/if.h: add some missing IFF_ constants 2013-04-05 19:26:23 +02:00
Rich Felker f4ded939bf add prototype for dn_skipname 2013-04-04 22:36:49 -04:00
rofl0r baec93cb58 add arpa/tftp.h 2013-04-05 02:32:51 +02:00
Rich Felker f77bab5933 fix type issues in stdint.h so underlying types of 64-bit types match ABI 2013-04-04 20:09:50 -04:00
Rich Felker c7af271000 eliminate bits/wchar.h
the preprocessor can reliably determine the signedness of wchar_t.
L'\0' is used for 0 in the expressions so that, if the underlying type
of wchar_t is long rather than int, the promoted type of the
expression will match the type of wchar_t.
2013-04-04 19:57:23 -04:00
Rich Felker 201995f382 eliminate gcc dependency for testing char signedness in limits.h 2013-04-04 19:50:55 -04:00
Rich Felker ddfb267b0e add put*ent functions for passwd/group files and similar for shadow
since shadow does not yet support enumeration (getspent), the
corresponding FILE-based get and put versions are also subbed out for
now. this is partly out of laziness and partly because it's not clear
how they should work in the presence of TCB shadow files. the stubs
should make it possible to compile some software that expects them to
exist, but such software still may not work properly.
2013-04-04 19:23:47 -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
rofl0r 82aad3a317 add arpa/nameser_compat.h
the contents of this header are already in arpa/nameser.h
2013-04-02 04:43:53 +02:00
rofl0r da144eec54 make tm_zone etc visible under _GNU_SOURCE 2013-04-02 04:43:53 +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 46f45f7334 adding ethernet protocol ids to if_ether.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
Szabolcs Nagy 2e762105b7 add new linux tcp socket option flags to netinet/tcp.h 2013-04-01 16:24:11 +00:00
Rich Felker 0b2764d054 provide prototype for pthread_getattr_np 2013-03-31 23:27:57 -04: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 f44076181d fix missing type error in grp.h from adding fgetgrent 2013-03-06 09:32:52 -05:00
Rich Felker 8c741783fc fix some obscure header type size/alignment issues 2013-03-04 17:05:45 -05:00
Rich Felker e201d82aac fix cruft in utmp.h that was broken by changes in utmpx.h
patch by Chris Spiegel.
2013-02-26 01:46:39 -05:00
Rich Felker d1eae83a59 namespace conformance to latest standards in strings.h 2013-02-26 01:30:36 -05:00
rofl0r 8224bdbbed scsci/sg.h: fix usage of undefined macro HZ
this macro is 100 on all archs, at least in userspace, according
to kernel headers.
2013-02-21 21:35:34 +01:00
rofl0r caec662217 add arpa/ftp.h 2013-02-21 21:35:26 +01:00
Rich Felker 2cc63358cd add mkostemp, mkstemps, and mkostemps functions and reorganize temp internals
based on patch contributed by Anthony G. Basile (blueness)

some issues remain with the filename generation algorithm and other
small bugs, but this patch has been sitting around long enough that I
feel it's best to get it committed and then work out any remaining
issues.
2013-02-20 22:43:23 -05:00
Rich Felker cac872957e add fgetgrent function
based on patch by Isaac Dunham, moved to its own file to avoid
increasing bss on static linked programs not using this nonstandard
function but using the standard getgrent function, and vice versa.
2013-02-17 13:21:56 -05:00
Rich Felker d5142642b8 pthread stack treatment overhaul for application-provided stacks, etc.
the main goal of these changes is to address the case where an
application provides a stack of size N, but TLS has size M that's a
significant portion of the size N (or even larger than N), thus giving
the application less stack space than it expected or no stack at all!

the new strategy pthread_create now uses is to only put TLS on the
application-provided stack if TLS is smaller than 1/8 of the stack
size or 2k, whichever is smaller. this ensures that the application
always has "close enough" to what it requested, and the threshold is
chosen heuristically to make sure "sane" amounts of TLS still end up
in the application-provided stack.

if TLS does not fit the above criteria, pthread_create uses mmap to
obtain space for TLS, but still uses the application-provided stack
for actual call frame stack. this is to avoid wasting memory, and for
the sake of supporting ugly hacks like garbage collection based on
assumptions that the implementation will use the provided stack range.

in order for the above heuristics to ever succeed, the amount of TLS
space wasted on POSIX TSD (pthread_key_create based) needed to be
reduced. otherwise, these changes would preclude any use of
pthread_create without mmap, which would have serious memory usage and
performance costs for applications trying to create huge numbers of
threads using pre-allocated stack space. the new value of
PTHREAD_KEYS_MAX is the minimum allowed by POSIX, 128. this should
still be plenty more than real-world applications need, especially now
that C11/gcc-style TLS is now supported in musl, and most apps and
libraries choose to use that instead of POSIX TSD when available.

at the same time, PTHREAD_STACK_MIN has been decreased. it was
originally set to PAGE_SIZE back when there was no support for TLS or
application-provided stacks, and requests smaller than a whole page
did not make sense. now, there are two good reasons to support
requests smaller than a page: (1) applications could provide
pre-allocated stacks smaller than a page, and (2) with smaller stack
sizes, stack+TLS+TSD can all fit in one page, making it possible for
applications which need huge numbers of threads with minimal stack
needs to allocate exactly one page per thread. the new value of
PTHREAD_STACK_MIN, 2k, is aligned with the minimum size for
sigaltstack.
2013-02-01 22:10:40 -05:00
Rich Felker 725c55528d SOL_TCP is nonstandard and not in the reserved namespace
alternatively, we could define it in sys/socket.h since SO* is
reserved there, and tcp.h includes sys/socket.h in extensions mode.

note that SOL_TCP is simply wrong and it's only here for compatibility
with broken applications. the correct argument to pass for setting TCP
socket options is IPPROTO_TCP, which of course has the same value as
SOL_TCP but works everywhere.
2013-01-31 00:49:53 -05:00
Rich Felker 55ddbc3e5d add RTLD_NODELETE flag for dlopen
this is a trivial no-op, because dlclose never deletes libraries. thus
we might as well have it in the header in case some application wants
it, since we're already providing it anyway.
2013-01-23 22:18:45 -05:00
Rich Felker 4d07e5521e add support for RTLD_NOLOAD to dlopen
based on patch by Pierre Carrier <pierre@gcarrier.fr> that just added
the flag constant, but with minimal additional code so that it
actually works as documented. this is a nonstandard option but some
major software (reportedly, Firefox) uses it and it was easy to add
anyway.
2013-01-23 22:07:45 -05:00
Rich Felker 41d7c77d6a use a common definition of NULL as 0L for C and C++
the historical mess of having different definitions for C and C++
comes from the historical C definition as (void *)0 and the fact that
(void *)0 can't be used in C++ because it does not convert to other
pointer types implicitly. however, using plain 0 in C++ exposed bugs
in C++ programs that call variadic functions with NULL as an argument
and (wrongly; this is UB) expect it to arrive as a null pointer. on
64-bit machines, the high bits end up containing junk. glibc dodges
the issue by using a GCC extension __null to define NULL; this is
observably non-conforming because a conforming application could
observe the definition of NULL via stringizing and see that it is
neither an integer constant expression with value zero nor such an
expression cast to void.

switching to 0L eliminates the issue and provides compatibility with
broken applications, since on all musl targets, long and pointers have
the same size, representation, and argument-passing convention. we
could maintain separate C and C++ definitions of NULL (i.e. just use
0L on C++ and use (void *)0 on C) but after careful analysis, it seems
extremely difficult for a C program to even determine whether NULL has
integer or pointer type, much less depend in subtle, unintentional
ways, on whether it does. C89 seems to have no way to make the
distinction. on C99, the fact that (int)(void *)0 is not an integer
constant expression, along with subtle VLA/sizeof semantics, can be
used to make the distinction, but many compilers are non-conforming
and give the wrong result to this test anyway. on C11, _Generic can
trivially make the distinction, but it seems unlikely that code
targetting C11 would be so backwards in caring which definition of
NULL an implementation uses.

as such, the simplest path of using the same definition for NULL in
both C and C++ was chosen. the #undef directive was also removed so
that the compiler can catch and give a warning or error on
redefinition if buggy programs have defined their own versions of
NULL prior to inclusion of standard headers.
2013-01-18 20:35:26 -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 119645b6bb add missing multicast socket options to netinet/in.h
based on linux headers add the missing MCAST_* options
under _GNU_SOURCE as they are not in the reserved namespace
(this api was originally specified by RFC 3678)
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 d84923d89e setjmp.h: add struct tag for sigjmp_buf (GCC C++ compatibility)
the anonymous struct typedef with array notation breaks with
GCC in C++ mode:

error: non-local function 'static<anonymous struct>
(& boost::signal_handler::jump_buffer())[1]' uses anonymous type

this is a known GCC issue, as search results for that error msg
suggest.

since this is hard to work around in the calling C++ code, a
fix in musl is preferable.
2013-01-04 20:36:34 +01:00
rofl0r 2ba3f44db5 add legacy header values.h
some programs (procps, babl) expect it, and it doesn't seem to
cause any harm to just add it.
it's small and straightforward.

since math.h also defines MAXFLOAT, we undef it in both places,
before defining it.
2013-01-04 20:36:34 +01:00
rofl0r 87781ac64c time.h: add BSD aliases for otherwise internal struct tm members 2013-01-04 20:36:34 +01: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
rofl0r 2c1f8fd5da __assert_fail(): remove _Noreturn, to get proper stacktraces
for _Noreturn functions, gcc generates code that trashes the
stack frame, and so it makes it impossible to inspect the causes
of an assert error in gdb.

abort() is not affected (i have not yet investigated why).
2013-01-04 20:36:34 +01:00
Rich Felker 5d893e50b0 add some new-ish IPPROTO constants that were missing 2013-01-01 20:19:20 -05:00
Rich Felker d18a410bbf expose [v]asprintf under _BSD_SOURCE
reported/requested by Strake; simplified from the provided patch
2012-12-28 15:39:33 -05: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
Rich Felker 8442358d9d add linux extension POLLRDHUP to poll.h
the POLL prefix is in the reserved namespace for poll.h, so no feature
test macro checks are needed.
2012-12-26 16:55:49 -05:00
Rich Felker 5d5ab51862 merge a few fixes by sh4rm4 2012-12-19 13:07:37 -05:00
rofl0r 3159e2fc81 socket.h: add SO_(SND/RCV)BUFFORCE to generic block 2012-12-19 19:02:22 +01:00
Szabolcs Nagy 3c4214db72 math: more correct tgmath.h type cast logic
__IS_FP is a portable integer constant expression now
(uses that unsigned long long is larger than float)
the result casting logic should work now on all compilers
supporting typeof
2012-12-19 10:57:54 +01:00
rofl0r 36d7303878 add inet_network (required for wine) 2012-12-19 07:32:38 +01:00
rofl0r 26cf9c3c6b link.h: expose glibc/svr4 dynlinker debugging glue
this is already implemented in the dynliker (see struct debug),
but was not exposed.
we need it to do so to make wine happy...
2012-12-19 05:08:13 +01:00
Szabolcs Nagy e9e2b66e68 math: new type cast logic in tgmath.h
* return type logic is simplified a bit and fixed (see below)
* return type of conj and cproj were wrong on int arguments
* added comments about the pending issues
(usually we don't have comments in public headers but this is
not the biggest issue with tgmath.h)

casting the result to the right type cannot be done in c99
(c11 _Generic can solve this but that is not widely supported),
so the typeof extension of gcc is used and that the ?: operator
has special semantics when one of the operands is a null
pointer constant

the standard is very strict about the definition of null
pointer constants so typeof with ?: is still not enough so
compiler specific workaround is used for now

on gcc '!1.0' is a null pointer constant so we can use the old
__IS_FP logic (eventhough it's non-standard)

on clang (and on gcc as well) 'sizeof(void)-1' is a null
pointer constant so we can use
 !(sizeof(*(0?(int*)0:(void*)__IS_FP(x)))-1)
(this is non-standard as well), the old logic is used by
default and this new one on clang
2012-12-19 04:05:30 +01:00
Rich Felker 969ddbc423 Merge remote-tracking branch 'nsz/math' 2012-12-15 00:49:09 -05: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
Szabolcs Nagy 9346094423 fixed tgmath.h for functions with integral result
in tgmath.h the return values are casted to the appropriate
floating-point type (if the compiler supports gcc __typeof__),
this is wrong in case of ilogb, lrint, llrint, lround, llround
which do not need such cast
2012-12-14 12:49:35 +01:00
Rich Felker d50955620f add missing flags in sys/timerfd.h 2012-12-13 14:15:11 -05:00
Szabolcs Nagy 64623cd59a math: remove long double version of bessel functions from math.h
j0l,j1l,jnl,y0l,j1l,jnl are gnu extensions, bsd and posix do not
have them.
noone seems to use them and there is no plan to implement them any
time soon so we shouldn't declare them in math.h.
2012-12-11 22:57:39 +01:00
Szabolcs Nagy faea4c9937 make CMPLX macros available in complex.h in non-c11 mode as well 2012-12-11 22:44:36 +01: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
Rich Felker d1b6fc6ecc fix names of ipc_perm __key/__seq elements
previously the names were exposed as key/seq with _GNU_SOURCE and
__ipc_perm_key/__ipc_perm/seq otherwise, whereas glibc always uses
__key and __seq for the names. thus, the old behavior never matched
glibc, and the new behavior always does, regardless of feature test
macros.

for now, i'm leaving the renaming here in sys/ipc.h where it's easy to
change globally for all archs, in case something turns out to be
wrong, but eventually the names could just be incorporated directly
into the bits headers for each arch and the renaming removed.
2012-12-06 16:52:09 -05:00
rofl0r e00e07f664 fix F_DUPFD_CLOEXEC being defined twice 2012-12-06 22:45:56 +01:00
rofl0r e34d967c3e fixup for fcntl.h changes 2012-12-06 21:43:00 +01:00
rofl0r 6fb88a955a add personality syscall 2012-12-06 21:01:06 +01:00
rofl0r a1990e1e83 add sigandset and sigorset (needed for qemu) 2012-12-06 20:51:32 +01:00
rofl0r 0182c287ca add struct msgbuf to sys/msg.h 2012-12-06 20:27:54 +01:00
rofl0r 6bf0fdbdfc unistd.h: fix wrong type for gid_t argument
the prototype is defined with const gid_t* rather than const gid_t[].
it was already correctly defined in grp.h.
2012-12-06 20:27:54 +01:00
rofl0r f1bb78343a ipc.h: fix gnu aliases for key and seq in struct ipc_perm
the macro was the wrong way round, additionally GNU defines
__ prefixed versions, which are used by qemu.
2012-12-06 20:27:54 +01:00
rofl0r 7aec71c411 add obsolete futimesat()
this function is obsolete, however it's available as a syscall
and as such qemu userspace emulation tries to forward it to the
host kernel.
2012-12-06 20:27:54 +01:00
rofl0r 120e402de6 fcntl.h: add some linux-specific F_ macros
thankfully these are all generic across archs.
the DN_ macros are for usage with F_NOTIFY.
2012-12-06 17:48:16 +01:00
rofl0r 3d3903fa5b tcp.h: add SOL_TCP, analoguous to udp.h 2012-12-06 17:02:19 +01:00
Rich Felker 96b3ea53f9 fix inefficiency of math.h isless, etc. macros
previously, everything was going through an intermediate conversion to
long double, which caused the extern __fpclassifyl function to get
invoked, preventing virtually all optimizations of these operations.

with the new code, tests on constant float or double arguments compile
to a constant 0 or 1, and tests on non-constant expressions are
efficient. I may later add support for __builtin versions on compilers
that support them.
2012-12-05 14:12:57 -05:00
Rich Felker 91b0588909 add scsi headers scsi.h and sg.h
due to some historical oddity, these are considered libc headers
rather than kernel headers. the kernel used to provide them too, but
it seems modern kernels do not install them, so let's just do the
easiest thing and provide them. stripped-down versions provided by
John Spencer.
2012-12-05 12:35:24 -05:00
Rich Felker a7c1f9727a use __builtin_offsetof to implement offsetof when possible
apparently recent gcc versions have intentionally broken the
traditional definition by treating it as a non-constant expression.
the traditional definition may also be problematic for c++ programs.
2012-12-05 00:00:42 -05:00
Rich Felker b3175f5c48 add _ALL_SOURCE as an alias for _GNU_SOURCE/enable-everything
reportedly this is a semi-common practice among some BSDs and a few
other systems, and will improve application compatibility.
2012-12-03 17:02:56 -05:00
Rich Felker 769fd4ce20 feature test macros: make _GNU_SOURCE enable everything
previously, a few BSD features were enabled only by _BSD_SOURCE, not
by _GNU_SOURCE. since _BSD_SOURCE is default in the absence of other
feature test macros, this made adding _GNU_SOURCE to a project not a
purely additive feature test macro; it actually caused some features
to be suppressed.

most of the changes made by this patch actually bring musl in closer
alignment with the glibc behavior for _GNU_SOURCE. the only exceptions
are the added visibility of functions like strlcpy which were BSD-only
due to being disliked/rejected by glibc maintainers. here, I feel the
consistency of having _GNU_SOURCE mean "everything", and especially
the property of it being purely additive, are more valuable than
hiding functions which glibc does not have.
2012-12-03 16:57:01 -05:00
Rich Felker 216b706548 fix a couple issues in the inttypes.h PRI/SCN macros
most importantly, the format/scan macros for the [u]int_fast16_t and
[u]int_fast32_t types were defined incorrectly assuming these types
would match the native word/pointer size. this is incorrect on any
64-bit system; the "fast" types for 16- and 32-bit integers are simply
int.

another issue which was "only a warning" (despite being UB) is that
the choice of "l" versus "ll" was incorrect for 64-bit types on 64-bit
machines. while it would "work" to always use "long long" for 64-bit
types, we use "long" on 64-bit machines to match what glibc does and
what the ABI documents recommend. the macro definitions were probably
right in very old versions of musl, but became wrong when we aligned
most closely with the 'standard' ABI. checking UINTPTR_MAX is an easy
way to get the system wordsize without pulling in new headers.

finally, the useless __PRIPTR macro to allow the underlying type of
[u]intptr_t to vary has been removed. we are using "long" on all
targets, and thankfully this matches what glibc does, so I do not
envision ever needing to change it. thus, the "l" has just been
incorporated directly in the strings.
2012-12-02 15:18:05 -05:00
Rich Felker 7dcb640da3 provide NSIG under _BSD_SOURCE (default) as well as _GNU_SOURCE
this fixes a regression related to the changes made to bits/signal.h
between 0.9.7 and 0.9.8 that broke some (non-portable) software.
2012-11-30 21:00:18 -05:00
Rich Felker 1c322f2f0a fix some restrict-qualifier mismatches in newly added interfaces
these should have little/no practical impact but they're needed for
strict conformance.
2012-11-27 09:44:30 -05:00
Rich Felker b4d8a16c1a fix eventfd and inotify nonblock/cloexec flags to match arch values 2012-11-26 13:00:58 -05:00
Rich Felker 56c6943efe fix missing limits when only _BSD_SOURCE is defined
the missing check did not affect the default profile, since it has
both _XOPEN_SOURCE and _BSD_SOURCE defined, but it did break programs
which explicitly define _BSD_SOURCE, causing it to be the only feature
test macro present.
2012-11-26 12:05:33 -05:00
Rich Felker a8da6c2f28 fixup mcontext stuff to expost gregset_t/fpregset_t as appropriate 2012-11-25 23:04:23 -05:00
Rich Felker 4b75f4ed8d make sys/procfs.h mostly work on most archs
these structures are purely for use by trace/debug tools and tools
working with core files. the definition of fpregset_t, which was
previously here, has been removed because it was wrong; fpregset_t
should be the type used in mcontext_t, not the type used in
ptrace/core stuff.
2012-11-25 22:28:18 -05:00
Rich Felker 65b98213e4 add back NSIG, removed from powerpc in last commit, but for all archs
unlike the previous definition, NSIG/_NSIG is supposed to be one more
than the highest signal number. adding this will allow simplifying
libc-internal code that makes signal-related syscalls, which can be
done as a later step. some apps might use it too; while this usage is
questionable, it's at least not insane.
2012-11-21 13:41:58 -05:00
Rich Felker 0004ea613a fix breakage from introducing bits header for sys/io.h
apparently some other archs have sys/io.h and should not break just
because they don't have the x86 port io functions. provide a blank
bits/io.h everywhere for now.
2012-11-18 19:58:15 -05:00
Rich Felker 61aa6324af add port io functions to sys/io.h
based on proposal by Isaac Dunham. nonexistance of bits/io.h will
cause inclusion of sys/io.h to produce an error on archs that are not
supposed to have it. this is probably the desired behavior, but the
error message may be a bit unusual.
2012-11-18 19:31:58 -05:00
rofl0r 8d2887f884 fcntl.h: O_SEARCH was missing for powerpc
put some macros that do not differ between architectures in the
main header and remove from bits.
restructure mips header so it has the same structure as the others.
2012-11-18 05:14:40 +01:00
Rich Felker d0197ff031 add cleaned-up sys/mtio.h
this is mostly junk, but a few programs with tape-drive support
unconditionally include it, and it might be useful.
2012-11-17 19:51:49 -05:00
Rich Felker 5c6443ac42 add stub versions of some missing optional pthread interfaces
priority inheritance is not yet supported, and priority protection
probably will not be supported ever unless there's serious demand for
it (it's a fairly heavy-weight feature).

per-thread cpu clocks would be nice to have, but to my knowledge linux
is still not capable of supporting them. glibc fakes them by using the
_process_ cpu-time clock and subtracting the thread creation time,
which gives seriously incorrect semantics (worse than not supporting
the feature at all), so until there's a way to do it right, it will
remain as a stub that always fails.
2012-11-17 18:42:16 -05:00
Rich Felker 91738d0241 disable SO_REUSEPORT in sys/socket.h
although a number is reserved for it, this option is not implemented
on Linux and does not work. defining it causes some applications to
use it, and subsequently break due to its failure.
2012-11-15 19:16:10 -05:00
Szabolcs Nagy cfbaba79a2 complex: add C11 CMPLX macros and replace cpack with them 2012-11-13 01:31:49 +01:00
Rich Felker 7df42e8744 report support of TPS option in unistd.h and sysconf
also update another newish feature in sysconf, stackaddr
2012-11-11 15:54:20 -05:00
Rich Felker 1e21e78bf7 add support for thread scheduling (POSIX TPS option)
linux's sched_* syscalls actually implement the TPS (thread
scheduling) functionality, not the PS (process scheduling)
functionality which the sched_* functions are supposed to have.
omitting support for the PS option (and having the sched_* interfaces
fail with ENOSYS rather than omitting them, since some broken software
assumes they exist) seems to be the only conforming way to do this on
linux.
2012-11-11 15:38:04 -05:00
Rich Felker 32d6d77e54 fix numerous mips abi constant definition mismatches 2012-11-05 14:29:04 -05:00
Rich Felker fc5f16d182 mips cache flush/ctl syscall support and header 2012-11-04 17:06:31 -05:00
Rich Felker b367ab15fa avoid breakage if somebody wrongly defines empty feature test macros 2012-11-01 03:49:43 -04:00
Rich Felker 18c0e02e2b add dl_iterate_phdr interface
patches by Alex Caudill (npx). the dynamic-linked version is almost
identical to the final submitted patch; I just added a couple missing
lines for saving the phdr address when the dynamic linker is invoked
directly to run a program, and removed a couple to avoid introducing
another unnecessary type. the static-linked version is based on npx's
draft. it could use some improvements which are contingent on the
startup code saving some additional information for later use.
2012-10-31 21:27:48 -04:00
Rich Felker 4eb4844b31 fix issues with wait constants in stdlib.h
the W* namespace is not reserved, so the nonstandard ones must be
moved under extension features. also WNOHANG and WUNTRACED were
missing.
2012-10-21 19:15:11 -04:00
nsz 2d321fa062 complex: make _Complex_I work with gcc -std=c99 -pedantic-errors 2012-10-21 02:31:04 +02:00
Rich Felker 858df113bf assert() is supposed to have type void 2012-10-17 02:47:11 -04:00
Rich Felker c86f2974e2 add memmem function (gnu extension)
based on strstr. passes gnulib tests and a few quick checks of my own.
2012-10-15 23:02:57 -04:00
Rich Felker 21284ec75d microblaze TLS relocation support, completely untested 2012-10-15 21:01:48 -04:00
Rich Felker 030e526392 add getopt reset support
based on proposed patches by Daniel Cegiełka, with minor changes:
- use a weak symbol for optreset so it doesn't clash with namespace
- also reset optpos (position in multi-option arg like -lR)
- also make getopt_long support reset
2012-09-30 20:00:38 -04:00
Rich Felker 2e3648b85d define some _POSIX_* macros that were omitted; required for XSI conformance 2012-09-30 01:52:17 -04:00
Rich Felker 3609e019f3 always expose accept4
it will be in the next version of POSIX
2012-09-29 17:44:33 -04:00
Rich Felker 9735d50070 always expose dup3 and pipe2
they will be in the next version of POSIX
2012-09-29 17:42:21 -04:00
Rich Felker 8c0a3d9e5c microblaze port
based on initial work by rdp, with heavy modifications. some features
including threads are untested because qemu app-level emulation seems
to be broken and I do not have a proper system image for testing.
2012-09-29 01:05:31 -04:00
Rich Felker f600105eef LFS64 alias for prlimit
issue reported/requested by Justin Cormack
2012-09-21 04:05:01 -04:00
Rich Felker 662da62eb7 add clock_adjtime, remap_file_pages, and syncfs syscall wrappers
patch by Justin Cormack, with slight modification
2012-09-16 22:26:23 -04:00
Rich Felker 5a1abeeb7c fix stupid bug in updating of O_ACCMODE for O_SEARCH support
this could cause major bugs, and warrants a fix release right away.
2012-09-15 23:17:00 -04:00
Rich Felker e2f6a3257e strsep is BSD|GNU, not GNU-only; it's originally from BSD 2012-09-13 21:01:30 -04:00
Rich Felker b238b37a0f add O_PATH/O_SEARCH support to fcntl.h
I'm not 100% sure that Linux's O_PATH meets the POSIX requirements for
O_SEARCH, but it seems very close if not perfect. and old kernels
ignore it, so O_SEARCH will still work as desired as long as the
caller has read permissions to the directory.
2012-09-13 20:56:25 -04:00
Rich Felker c87584a3e9 add setdomainname syscall, fix getdomainname (previously a stub) 2012-09-09 16:50:20 -04:00
Rich Felker a660180c6a mincore syscall wrapper 2012-09-09 16:37:19 -04:00
Rich Felker 2416c63b81 fix up lfs64 junk for preadv/pwritev 2012-09-09 16:33:47 -04:00
Rich Felker ea544bfe80 add preadv/pwritev syscall wrappers 2012-09-09 16:29:33 -04:00
Rich Felker 743546a933 fix typo introduced in poll.h 2012-09-09 16:27:26 -04:00
Rich Felker 141138c41b add linux ppoll syscall wrapper 2012-09-09 16:09:29 -04:00
Rich Felker 208eb584ef syscall organization overhaul
now public syscall.h only exposes __NR_* and SYS_* constants and the
variadic syscall function. no macros or inline functions, no
__syscall_ret or other internal details, no 16-/32-bit legacy syscall
renaming, etc. this logic has all been moved to src/internal/syscall.h
with the arch-specific parts in arch/$(ARCH)/syscall_arch.h, and the
amount of arch-specific stuff has been reduced to a minimum.

changes still need to be reviewed/double-checked. minimal testing on
i386 and mips has already been performed.
2012-09-08 22:43:14 -04:00
Rich Felker 6cf8bfdb64 add acct, accept4, setns, and dup3 syscalls (linux extensions)
based on patch by Justin Cormack
2012-09-08 20:22:08 -04:00