Commit Graph

309 Commits

Author SHA1 Message Date
Rich Felker
f8ac55516d missing limit LOGIN_NAME_MAX 2012-05-14 00:01:48 -04:00
Rich Felker
e68c51ac46 use __h_errno_location for h_errno
we do not bother making h_errno thread-local since the only interfaces
that use it are inherently non-thread-safe. but still use the
potentially-thread-local ABI to access it just to avoid lock-in.
2012-05-12 23:45:07 -04:00
Rich Felker
3777f5b90d susv4 removed gethostbyname, etc. legacy cruft. 2012-05-12 23:38:04 -04:00
Rich Felker
20052b9815 namespace cleanup - NI_* is NOT reserved by netdb.h 2012-05-12 23:34:39 -04:00
Rich Felker
7db6a871ca some gnu junk in netdb.h 2012-05-12 23:31:52 -04:00
Rich Felker
c3dbe9b22c fix missing va_list for vsyslog 2012-05-12 22:18:34 -04:00
nsz
d197d6421c search: add tdestroy (gnu extension) 2012-05-13 01:34:20 +02:00
Rich Felker
b47fdcdef8 add missing IN6_ARE_ADDR_EQUAL
written to avoid multiple conditional jumps and avoid ugly repetitive
lines in the header file.
2012-05-11 11:05:41 -04:00
Rich Felker
e700e59a90 add one more bogus legacy header
this one is for program(s|ers) who haven't heard of uint16_t and
uint32_t (which are obviously the correct types for use in such
situations, as they're the argument/return types for ntohs/htons and
ntohl/htonl).
2012-05-10 23:32:28 -04:00
Rich Felker
c8b01e73ca move vsyslog out of SYSLOG_NAMES conditional 2012-05-10 22:41:54 -04:00
Rich Felker
bfb29b666e fix missing parens in bit op macros (param.h) 2012-05-10 12:10:44 -04:00
Rich Felker
2e41887f54 and another bug in setbit, etc. macros.. 2012-05-10 11:59:07 -04:00
Rich Felker
e0ff0d34dc fix typo in sys/param.h that broke setbit, etc. macros
this is all junk, but some programs use it.
2012-05-10 11:55:16 -04:00
Rich Felker
37bb3cce45 omit declaration of basename wrongly interpreted as prototype in C++
the non-prototype declaration of basename in string.h is an ugly
compromise to avoid breaking 2 types of broken software:

1. programs which assume basename is declared in string.h and thus
would suffer from dangerous pointer-truncation if an implicit
declaration were used.

2. programs which include string.h with _GNU_SOURCE defined but then
declare their own prototype for basename using the incorrect GNU
signature for the function (which would clash with a correct
prototype).

however, since C++ does not have non-prototype declarations and
interprets them as prototypes for a function with no arguments, we
must omit it when compiling C++ code. thankfully, all known broken
apps that suffer from the above issues are written in C, not C++.
2012-05-09 11:47:06 -04:00
Rich Felker
4a99440571 some extra legacy header stuff 2012-05-06 16:35:32 -04:00
Rich Felker
a3b20f67b3 take byte order from gcc if gcc has defined it
this only works with gcc 4.6 and later, but it allows us to support
non-default endianness on archs like arm, mips, ppc, etc. that can do
both without having separate header sets for both variants, and it
saves one #include even on fixed-endianness archs like x86.
2012-05-06 13:40:19 -04:00
Rich Felker
106e75f712 add isastream (obsolete STREAMS junk)
apparently some packages see stropts.h and want to be able to use
this. the implementation checks that the file descriptor is valid by
using fcntl/F_GETFD so it can report an error if not (as specified).
2012-05-06 09:03:19 -04:00
Rich Felker
98c9af5001 fix definitions of FP_ILOGB constants
two issues: (1) the type was wrong (unsigned instead of signed int),
and (2) the value of FP_ILOGBNAN should be INT_MIN rather than INT_MAX
to match the ABI. this is also much more useful since INT_MAX
corresponds to a valid input (infinity). the standard would allow us
to set FP_ILOGB0 to -INT_MAX instead of INT_MIN, which would give us
distinct values for ilogb(0) and ilogb(NAN), but the benefit seems way
too small to justify ignoring the ABI.

note that the macro is just a "portable" (to any twos complement
system where signed and unsigned int have the same width) way to write
INT_MIN without needing limits.h. it's valid to use this method since
these macros are not required to work in #if directives.
2012-05-05 22:22:46 -04:00
Rich Felker
f0b85fd926 add *64 junk for sys/*.h headers 2012-05-04 00:31:25 -04:00
Rich Felker
2dd8d5e1b8 add support for ugly *64 functions with _LARGEFILE64_SOURCE
musl does not support legacy 32-bit-off_t whatsoever. off_t is always
64 bit, and correct programs that use off_t and the standard functions
will just work out of the box. (on glibc, they would require
-D_FILE_OFFSET_BITS=64 to work.) however, some programs instead define
_LARGEFILE64_SOURCE and use alternate versions of all the standard
types and functions with "64" appended to their names.

we do not want code to actually get linked against these functions
(it's ugly and inconsistent), so macros are used instead of prototypes
with weak aliases in the library itself. eventually the weak aliases
may be added at the library level for the sake of using code that was
originally built against glibc, but the macros will still be the
desired solution in the headers.
2012-05-04 00:13:23 -04:00
Rich Felker
b959d04644 uglify headers for the sake of junk that compiles with gcc -std=c89/-ansi 2012-05-03 22:27:36 -04:00
Rich Felker
ca2d3c6ef4 add additional compatibility union member for ipv6 addresses
in6_* is in the reserved namespace, so this is valid
2012-05-03 22:12:46 -04:00
Rich Felker
6f0cf3061b remove minimal linux kernel headers
these were at best of limited usefulness (for bootstrapping new
systems, mainly) and at worst caused real kernel headers to get
overwritten when upgrading libc.

in case they're needed by anyone, the exact same files are now
available in a new git repository:

git://git.etalabs.net/mini-lkh
2012-05-01 21:20:06 -04:00
Rich Felker
a917c03706 support alternate glibc name pow10 for exp10 2012-05-01 00:07:37 -04:00
Rich Felker
f681975577 first try at writing an efficient and "correct" exp10
this is a nonstandard function so it's not clear what conditions it
should satisfy. my intent is that it be fast and exact for positive
integral exponents when the result fits in the destination type, and
fast and correctly rounded for small negative integral exponents.
otherwise we aim for at most 1ulp error; it seems to differ from pow
by at most 1ulp and it's often 2-5 times faster than pow.
2012-04-30 03:26:53 -04:00
Rich Felker
50da5c264f add linux-specific unshare syscall wrapper 2012-04-29 19:54:03 -04:00
Rich Felker
90da74ef51 implement getusershell, etc. legacy functions
I actually wrote these a month ago but forgot to integrate them. ugly,
probably-harmful-to-use functions, but some legacy apps want them...
2012-04-22 14:41:54 -04:00
Rich Felker
431a4cd4df getdtablesize is not standard; move it to its correct spot in unistd.h 2012-04-22 14:39:07 -04:00
Rich Felker
3f4de355ba fix breakage in endian.h 2012-04-22 11:19:17 -04:00
Rich Felker
8705a0f1af add some ugly byte swapping cruft in endian.h 2012-04-22 11:08:01 -04:00
Rich Felker
b1b3d3525b add getresuid and getresgid syscall wrappers 2012-04-22 10:37:19 -04:00
Rich Felker
769d3d3498 fix header typo 2012-04-18 13:11:35 -04:00
Rich Felker
ba6a9e7734 legacy junk compatibility grab-bag
- add the rest of the junk traditionally in sys/param.h
- add prototypes for some nonstandard functions
- add _GNU_SOURCE to their source files so the compiler can check proto
2012-04-18 12:22:24 -04:00
Rich Felker
ed0e3a357e fix incorrect macro name for MATH_ERREXCEPT in math.h 2012-04-18 11:41:04 -04:00
Rich Felker
67b25fe0a8 move F_DUPFD_CLOEXEC out of bits
fcntl values 1024 and up are universal, arch-independent. later I'll
add some of the other linux-specific ones for notify, leases, pipe
size, etc. here too.
2012-04-15 17:05:10 -04:00
Rich Felker
0115a6ed96 rename __sa_restorer to sa_restorer in struct sigaction
this is legal since sa_* is in the reserved namespace for signal.h,
per posix. note that the sa_restorer field is not used anywhere, so
programs that are trying to use it may still break, but at least
they'll compile. if it turns out such programs actually need to be
able to set their own sa_restorer to function properly, i'll add the
necessary code to sigaction.c later.
2012-04-13 23:06:54 -04:00
Rich Felker
3be616c1df fix alloca issue in stdlib.h too
I forgot _GNU_SOURCE also has it declared here...
2012-04-09 16:22:05 -04:00
Rich Felker
d71d0805f9 alloca cannot be a function. #define it to the gcc builtin if possible
gcc makes this mapping by default anyway, but it will be disabled by
-fno-builtin (and presumably by -std=c99 or similar). for the main
program the error will be reported by the linker, and the issue can
easily be fixed, but for dynamic-loaded so files, the error cannot be
detected until dlopen time, at which point it has become very obscure.
2012-04-09 15:06:58 -04:00
Rich Felker
450f2c4a85 remove useless (at best, harmful) feature test checks in aio.h 2012-04-03 19:16:51 -04:00
Rich Felker
4dbd94112f optimize signbit macro 2012-03-30 23:41:43 -04:00
Rich Felker
93a18a15e4 make math.h more c++-friendly 2012-03-30 23:33:00 -04:00
Rich Felker
494ba80e9a simplify creal and cimag macros 2012-03-22 20:00:58 -04:00
Rich Felker
13e400b355 add creal/cimag macros in complex.h (and use them in the functions defs) 2012-03-22 15:54:55 -04:00
Rich Felker
132f0a0083 tgmath.h: suppress any existing macro definitions before defining macros
this is necessary so that we can freely add macro versions of some of
the math/complex functions without worrying about breaking tgmath.
2012-03-22 15:36:56 -04:00
Rich Felker
47db8903f6 fix DECIMAL_DIG definitions
DECIMAL_DIG is not the same as LDBL_DIG

type_DIG is the maximimum number of decimal digits that can survive a
round trip from decimal to type and back to decimal.

DECIMAL_DIG is the minimum number of decimal digits required in order
for any floating point type to survive the round trip to decimal and
back, and it is generally larger than LDBL_DIG. since the exact
formula is non-trivial, and defining it larger than necessary may be
legal but wasteful, just define the right value in bits/float.h.
2012-03-21 12:42:48 -04:00
Rich Felker
25501c1079 initial, very primitive strfmon 2012-03-21 00:47:37 -04:00
Rich Felker
80949ccdc6 limits.h: support gcc's -funsigned-char
some software apparently uses this and breaks with musl due to
mismatching definitions...
2012-03-20 21:10:06 -04:00
Rich Felker
8e092217dd move nonstandard gamma() etc. to _GNU_SOURCE only
it's not even provided in the library at the moment, but could easily
be provided with weak aliases if desired.
2012-03-17 21:48:48 -04:00
Rich Felker
65db6bf5ea c++ seems to want some casts in the float representation-access macros 2012-03-17 21:40:10 -04:00
nsz
40305f74bd in math.h make lgamma_r and non-double bessel _GNU_SOURCE only
long double and float bessel functions are no longer xsi extensions
2012-03-15 09:29:53 +01:00
nsz
0144b45b71 efficient sincos based on sin and cos 2012-03-15 08:17:28 +01:00
Rich Felker
b69f695ace first commit of the new libm!
thanks to the hard work of Szabolcs Nagy (nsz), identifying the best
(from correctness and license standpoint) implementations from freebsd
and openbsd and cleaning them up! musl should now fully support c99
float and long double math functions, and has near-complete complex
math support. tgmath should also work (fully on gcc-compatible
compilers, and mostly on any c99 compiler).

based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from
nsz's libm git repo, with some additions (dummy versions of a few
missing long double complex functions, etc.) by me.

various cleanups still need to be made, including re-adding (if
they're correct) some asm functions that were dropped.
2012-03-13 01:17:53 -04:00
Rich Felker
405ce58dcf fix nan/infinity macros in math.h, etc.
the previous version not only failed to work in c++, but also failed
to produce constant expressions, making the macros useless as
initializers for objects of static storage duration.

gcc 3.3 and later have builtins for these, which sadly seem to be the
most "portable" solution. the alternative definitions produce
exceptions (for NAN) and compiler warnings (for INFINITY) on newer
versions of gcc.
2012-03-02 22:35:37 -05:00
Rich Felker
9fcecd7b34 typo in math.h c version check 2012-03-02 11:38:39 -05:00
Rich Felker
db3e78cee5 make math.h compatibe with c89 2012-03-02 00:36:26 -05:00
Rich Felker
e0614f7cd4 add all missing wchar functions except floating point parsers
these are mostly untested and adapted directly from corresponding byte
string functions and similar.
2012-03-01 23:24:45 -05:00
Rich Felker
051175d4fe add memory.h, bogus legacy alias for string.h 2012-03-01 01:34:58 -05:00
Rich Felker
d36751943a use c++-friendly initializers for pthread initializer definitions
these will also avoid obnoxious warnings with gcc -Wbraces.
2012-02-29 22:55:08 -05:00
Rich Felker
4ce6766a32 add <syscall.h> as an alias for <sys/syscall.h>
apparently some broken stuff (libstdc++) needs this.
2012-02-29 22:36:06 -05:00
Rich Felker
06aec8d715 replace prototype for basename in string.h with non-prototype declaration
GNU programs may expect the GNU version of basename, which has a
different prototype (argument is const-qualified) and prototype it
themselves too. of course if they're expecting the GNU behavior for
the function, they'll still run into problems, but at least this
eliminates some compile-time failures.
2012-02-24 23:23:47 -05:00
Rich Felker
1611ab0d9b add get_current_dir_name function 2012-02-17 23:10:00 -05:00
Rich Felker
414a4cdebc add float_t and double_t to math.h 2012-02-15 21:47:55 -05:00
Rich Felker
afc35d5efd replace bad cancellation cleanup abi with a sane one
the old abi was intended to duplicate glibc's abi at the expense of
being ugly and slow, but it turns out glib was not even using that abi
except on non-gcc-compatible compilers (which it doesn't even support)
and was instead using an exceptions-in-c/unwind-based approach whose
abi we could not duplicate anyway without nasty dwarf2/unwind
integration.

the new abi is copied from a very old glibc abi, which seems to still
be supported/present in current glibc. it avoids all unwinding,
whether by sjlj or exceptions, and merely maintains a linked list of
cleanup functions to be called from the context of pthread_exit. i've
made some care to ensure that longjmp out of a cleanup function should
work, even though it is not required to.

this change breaks abi compatibility with programs which were using
pthread cancellation, which is unfortunate, but that's why i'm making
the change now rather than later. considering that most pthread
features have not been usable until recently anyway, i don't see it as
a major issue at this point.
2012-02-09 02:33:08 -05:00
Rich Felker
570edb19d1 fix typo in inotify.h 2012-02-07 22:48:58 -05:00
Rich Felker
1ba28b90d6 declare basename in string.h when _GNU_SOURCE is defined
note that it still will have the standards-conformant behavior, not
the GNU behavior. but at least this prevents broken code from ending
up with truncated pointers due to implicit declarations...
2012-02-07 13:10:30 -05:00
Rich Felker
a591e0383a revert hacks for types of stdint.h integer constant macros
per 7.18.4: Each invocation of one of these macros shall expand to an
integer constant expression suitable for use in #if preprocessing
directives. The type of the expression shall have the same type as
would an expression of the corresponding type converted according to
the integer promotions. The value of the expression shall be that of
the argument.

the key phrase is "converted according to the integer promotions".
thus there is no intent or allowance that the expression have
smaller-than-int types.
2012-02-07 12:08:27 -05:00
Rich Felker
36bf56940a more locale_t interfaces (string stuff) and header updates
this should be everything except for some functions where the non-_l
version isn't even implemented yet (mainly some non-ISO-C wcs*
functions).
2012-02-06 21:51:02 -05:00
Rich Felker
c09b6f8ab6 fix some omissions and mistakes in locale_t interface definitions 2012-02-06 21:33:40 -05:00
Rich Felker
e5a7f14c81 add more of the locale_t interfaces, all dummied out to ignore the locale 2012-02-06 21:29:31 -05:00
Rich Felker
f4ad36c4bf add deprecated (removed from posix) [efg]cvt() functions
these have not been heavily tested, but they should work as described
in the old standards. probably broken for non-finite values...
2012-02-06 01:14:23 -05:00
Rich Felker
147f355cb6 apparently gnu caddr_t is supposed to be char *, not unsigned long
this type should never be used anyway, but some old junk uses it..
2012-02-01 14:12:19 -05:00
Rich Felker
96e0aca4d5 fix utmp.h mess, try 2 2012-02-01 14:10:38 -05:00
Rich Felker
108fdd3318 fix previous utmp.h junk commit 2012-01-31 17:10:02 -05:00
Rich Felker
fa3bbbd453 add some missing junk in utmp.h 2012-01-31 14:39:17 -05:00
Rich Felker
5e9314ff03 add fgetpwent (nonstandard function)
based on patch by Jeremy Huntwork
2012-01-29 11:54:18 -05:00
Rich Felker
4619901ec4 add linux setfs[ug]id syscall wrappers
patch by Jeremy Huntwork
2012-01-28 21:09:50 -05:00
Rich Felker
c3db56c4cb remove useless "extern" keywords in headers 2012-01-26 10:53:37 -05:00
Rich Felker
8eb9a3afba fix typo in FPE_FLTUND definition, signal.h 2012-01-25 15:30:42 -05:00
Rich Felker
6a193804a8 add MIN/MAX macros to sys/param.h
this is a nonstandard junk header anyway, so just do what apps expect..
2012-01-24 22:51:27 -05:00
Rich Felker
477e72ac4a add legacy futimes and lutimes functions
based on patch by sh4rm4. these functions are deprecated; futimens and
utimensat should be used instead in new programs.
2012-01-24 19:50:44 -05:00
Rich Felker
26f38328d6 add prlimit syscall wrapper 2012-01-20 22:10:47 -05:00
Rich Felker
4e3df7be8f fix __cplusplus extern "C" closing brace in pty.h (typo?) 2011-11-10 21:01:24 -05:00
Rich Felker
3ed8c9f2df fix all missing instances of __cplusplus checks/extern "C" in headers
patch by Arvid Picciani (aep)
2011-11-10 20:40:06 -05:00
Rich Felker
42976cee2d add some missing GNU FNM_* extensions to the header
note that none of these are implemented, and programs depending on
them may break... patch by sh4rm4
2011-10-17 12:24:23 -04:00
Rich Felker
03860303c2 fix some details in ugly stuff that doesn't belong in libc
patches by sh4rm4, presumably needed to make gdb or some similar junk
happy...
2011-10-17 12:23:04 -04:00
Rich Felker
73f5ff4e86 make [U]INTn_C() macros have the right type...
...and still be valid in #if directives.
2011-10-04 11:50:35 -04:00
Rich Felker
f0a8d60d32 stupid typo (caused by rather ugly spelling in POSIX..) in aio 2011-09-28 11:36:11 -04:00
Rich Felker
7e14ed1360 fix ctype macros to cast argument to (unsigned) first
issue reported by nsz, but it's actually not just pedantic. the
functions can take input of any arithmetic type, including floating
point, and the behavior needs to be as if the conversion implicit in
the function call took place.
2011-09-26 18:56:56 -04:00
Rich Felker
fd142e5ec4 cleanup various minor issues reported by nsz
the changes to syscall_ret are mostly no-ops in the generated code,
just cleanup of type issues and removal of some implementation-defined
behavior. the one exception is the change in the comparison value,
which is fixed so that 0xf...f000 (which in principle could be a valid
return value for mmap, although probably never in reality) is not
treated as an error return.
2011-09-26 00:59:28 -04:00
Rich Felker
c41a76f58c FD_ISSET must return an int. this is the easiest way.
casting to int would not be correct because high bits could be lost.
mapping the high bits down onto low bits would be costlier in the
common case where the result is just used in a conditional. changing
the type of the bit array elements to int would permute the order of
the bit array on 64-bit big endian systems, so that's not an option
either.
2011-09-23 22:24:33 -04:00
Rich Felker
1587224ed6 sys/user.h may need stdint.h 2011-09-23 14:24:57 -04:00
Rich Felker
81a5577a86 fix missing SIG_DFL, SIG_IGN, SIG_ERR without posix in signal.h 2011-09-21 22:25:31 -04:00
Rich Felker
319df20bc9 gnu search.h has struct qelem... 2011-09-21 21:01:56 -04:00
Rich Felker
fd9e01e92a fix some header typos 2011-09-20 20:02:48 -04:00
Rich Felker
d23a543d8a make stdbool.h conform to c99 2011-09-20 14:51:56 -04:00
Rich Felker
2318207adc fix incorrect include guard in mqueue.h 2011-09-20 12:14:06 -04:00
Rich Felker
32b82cf5cd fix the fsid_t structure to match name of __val
this is a case of poorly written man pages not matching the actual
implementation, and why i hate implementing nonstandard interfaces
with no actual documentation of how they're intended to work.
2011-09-20 11:16:27 -04:00
Rich Felker
03a8362930 fix broken siginfo_t with _GNU_SOURCE defined
this bug was introduced in a recent patch. the problem we're working
around is that broken GNU software wants to use "struct siginfo"
rather than "siginfo_t", but "siginfo" is not in the reserved
namespace and thus not legal for the standard header to use.
2011-09-20 10:58:18 -04:00
Rich Felker
114c80f141 fix the definition of struct statvfs to match lsb abi
at the same time, make struct statfs match the traditional definition
and make it more useful, especially the fsid_t stuff.
2011-09-19 23:35:48 -04:00
Rich Felker
8c07f6eac8 add some more siginfo aliases broken software expects... 2011-09-19 22:27:02 -04:00