Commit Graph

329 Commits

Author SHA1 Message Date
Rich Felker 997ba92a0f add linux tee syscall 2012-09-08 01:03:01 -04:00
Rich Felker 00e6bbcc05 add linux sync_file_range syscall 2012-09-08 00:58:25 -04:00
Rich Felker 90f770523f add linux readahead syscall 2012-09-08 00:40:37 -04:00
Rich Felker adb88e773b add fallocate (nonstandardized) function
this is equivalent to posix_fallocate except that it has an extra
mode/flags argument to control its behavior, and stores the error in
errno rather than returning an error code.
2012-09-08 00:33:04 -04:00
Rich Felker 231b9d1880 add timerfd interfaces (untested) 2012-09-08 00:21:02 -04:00
Rich Felker f0f17b5b70 add stdnoreturn.h (C11)
features.h contains the fallback logic for pre-C11 compilers
2012-09-08 00:14:25 -04:00
Rich Felker 3cd084bb03 TCP_* is in the reserved namespace for tcp.h; make use of that 2012-09-07 23:56:32 -04:00
Rich Felker 6951110368 remove unneeded judgemental commentary from ftw.h 2012-09-07 23:55:11 -04:00
Rich Felker c1a9658bd1 default features: make musl usable without feature test macros
the old behavior of exposing nothing except plain ISO C can be
obtained by defining __STRICT_ANSI__ or using a compiler option (such
as -std=c99) that predefines it. the new default featureset is POSIX
with XSI plus _BSD_SOURCE. any explicit feature test macros will
inhibit the default.

installation docs have also been updated to reflect this change.
2012-09-07 23:13:55 -04:00
Rich Felker c4ea0e3f8e provide loff_t for splice syscall
so far, this is the only actual use of loff_t i've found. some
software, including glib, assumes loff_t must exist if splice exists;
this is a reasonable assumption since the official prototype for
splice uses loff_t, as it always works with 64-bit offsets regardless
of the selected libc off_t size. i'm using #define for now rather than
a typedef to make it easy to define in other headers if necessary
(like the LFS64 ugliness), but it may be necessary to add it to
alltypes.h eventually if other functions end up needing it.
2012-09-06 23:49:44 -04:00
Rich Felker 0c05bd3a9c further use of _Noreturn, for non-plain-C functions
note that POSIX does not specify these functions as _Noreturn, because
POSIX is aligned with C99, not the new C11 standard. when POSIX is
eventually updated to C11, it will almost surely give these functions
the _Noreturn attribute. for now, the actual _Noreturn keyword is not
used anyway when compiling with a c99 compiler, which is what POSIX
requires; the GCC __attribute__ is used instead if it's available,
however.

in a few places, I've added infinite for loops at the end of _Noreturn
functions to silence compiler warnings. presumably
__buildin_unreachable could achieve the same thing, but it would only
work on newer GCCs and would not be portable. the loops should have
near-zero code size cost anyway.

like the previous _Noreturn commit, this one is based on patches
contributed by philomath.
2012-09-06 23:34:10 -04:00
Rich Felker c8ea985748 add _Noreturn function attribute, with fallback for pre-C11 GNUC 2012-09-06 23:12:27 -04:00
Rich Felker ac5d085691 dladdr should be available under _BSD_SOURCE as well as _GNU_SOURCE 2012-09-06 22:58:34 -04:00
Rich Felker 400c5e5c83 use restrict everywhere it's required by c99 and/or posix 2008
to deal with the fact that the public headers may be used with pre-c99
compilers, __restrict is used in place of restrict, and defined
appropriately for any supported compiler. we also avoid the form
[restrict] since older versions of gcc rejected it due to a bug in the
original c99 standard, and instead use the form *restrict.
2012-09-06 22:44:55 -04:00
Rich Felker fb247fafa0 avoid "inline" in public headers for strict c89 compatibility
while musl itself requires a c99 compiler, some applications insist on
being compiled with c89 compilers, and use of "inline" in the headers
was breaking them. much of this had been avoided already by just
skipping the inline keyword in pre-c99 compilers or modes, but this
new unified solution is cleaner and may/should result in better code
generation in the default gcc configuration.
2012-09-02 12:46:06 -04:00
Rich Felker 3f62f76cab fix wrong type for poll.h nfds_t
this should not break anything since the type should never be used
except as the argument type for poll.
2012-09-01 00:20:24 -04:00
Rich Felker f419bcb9dc dladdr support for dynamic linker (nonstandard extension)
based on patches submitted by boris brezillon. this commit also fixes
the issue whereby the main application and libc don't have the address
ranges of their mappings stored, which was theoretically a problem for
RTLD_NEXT support in dlsym; it didn't actually matter because libc
never calls dlsym, and it seemed to be doing the right thing (by
chance) for symbols in the main program as well.
2012-08-26 21:09:26 -04:00
Rich Felker 9bff7c133e implement "low hanging fruit" from C11
based on Gregor's patch sent to the list. includes:
- stdalign.h
- removing gets in C11 mode
- adding aligned_alloc and adjusting other functions to use it
- adding 'x' flag to fopen for exclusive mode
2012-08-25 23:15:13 -04:00
Rich Felker b5289fd749 add c11 quick_exit and at_quick_exit functions 2012-08-25 22:49:47 -04:00
Rich Felker 7dba0494e8 type exposure fixes in sys/sem.h 2012-08-24 17:01:17 -04:00
Rich Felker d03b3e7323 stdio_ext.h needs to include stdio.h, at least to get FILE... 2012-08-24 16:16:30 -04:00
Rich Felker 43a5a00e4a fix missing uintXX_t in nameser.h 2012-08-24 15:55:36 -04:00
Rich Felker 9a470b0a6e fix dirent.h with _BSD_SOURCE 2012-08-24 14:23:16 -04:00
Rich Felker 3f80afc505 improve headers to better deal with removed-in-posix-2008 features
with this patch, setting _POSIX_SOURCE, or setting _POSIX_C_SOURCE or
_XOPEN_SOURCE to an old version, will bring back the interfaces that
were removed in POSIX 2008 - at least the ones i've covered so far,
which are gethostby*, usleep, and ualarm. if there are other functions
still in widespread use that were removed for which similar changes
would be beneficial, they can be added just like this.
2012-08-15 15:35:32 -04:00
Rich Felker 7650390de8 add missing xattr functions
not sure why these were originally omitted..
2012-08-15 08:31:44 -04:00
nsz 23e6940a2c math: fix _BSD_SOURCE namespace in math.h 2012-08-13 22:06:01 +02:00
Rich Felker ab76321c14 remove significandl
this function never existed historically; since the float/double
functions it's based on are nonstandard and deprecated, there's really
no justification for its existence except that glibc has it. it can be
added back if there's ever really a need...
2012-08-13 16:00:31 -04:00
Rich Felker 2242bf616b add significand[fl] math functions 2012-08-13 14:51:43 -04:00
Rich Felker 0c42beb5f9 publicly expose getdents api under _BSD_SOURCE 2012-08-13 14:50:30 -04:00
Rich Felker 617182734c add bsd fgetln function
optimized to avoid allocation and return lines directly out of the
stream buffer whenever possible.
2012-08-11 18:10:38 -04:00
Rich Felker 7fee5f9606 fix socket.h on mips
why does mips have to be gratuitously incompatible in every possible
imaginable way?
2012-08-05 14:23:40 -04:00
Rich Felker d426b04533 add ioperm/iopl syscalls
based on patches by orc and Isaac Dunham, with some fixes. sys/io.h
exists and contains prototypes for these functions regardless of
whether the target arch has them; this is a bit unorthodox but I don't
think it will break anything. the function definitions do not exist
unless the appropriate SYS_* syscall number macro is defined, which
should make sure configure scripts looking for these functions don't
find them on other systems.

presently, sys/io.h does not have the inb/outb/etc. port io
macros/functions. I'd be surprised if ioperm/iopl are useful without
them, so they probably need to be added at some point in appropriate
bits/io.h files...
2012-07-23 16:54:53 -04:00
Rich Felker 53147f902b add splice and vmsplice syscalls
based on patches by orc and Isaac Dunham.
2012-07-23 16:50:56 -04:00
Rich Felker 207460d097 add extended attributes syscalls
based on patch by orc and Isaac Dunham, with some fixes.
2012-07-23 16:39:44 -04:00
Rich Felker 42f0e965c4 add pipe2 syscall
based on patch by orc and Isaac Dunham, with some details fixed.
2012-07-23 16:32:49 -04:00
Rich Felker b4f632bb27 fix namespace issue in prototypes in math.h 2012-07-22 19:02:02 -04:00
Rich Felker d646249124 fix wrong size for sigjmp_buf signal set array
128 is the size in bytes, not longs.
2012-07-22 18:58:35 -04:00
Rich Felker f07222739b fix typo in aio.h 2012-07-19 00:37:43 -04:00
Rich Felker 96107564e2 workaround another sendmsg kernel bug on 64-bit machines
the kernel wrongly expects the cmsg length field to be size_t instead
of socklen_t. in order to work around the issue, we have to impose a
length limit and copy to a local buffer. the length limit should be
more than sufficient for any real-world use; these headers are only
used for passing file descriptors and permissions between processes
over unix sockets.
2012-07-12 21:37:54 -04:00
Rich Felker 90e123f4a8 fix redef of sigprocmask constants on mips
this fix is easier than trying to reorder the header stuff
2012-07-12 16:54:43 -04:00
Rich Felker ba8a96b068 more mips bits-header fixes
signal handling was very broken because of this
2012-07-12 14:21:41 -04:00
Rich Felker 25b88f0810 add prototypes for getw/putw 2012-07-04 12:18:04 -04:00
Rich Felker d6c0efe106 jmp_buf overhaul fixing several issues
on arm, the location of the saved-signal-mask flag and mask were off
by one between sigsetjmp and siglongjmp, causing incorrect behavior
restoring the signal mask. this is because the siglongjmp code assumed
an extra slot was in the non-sig jmp_buf for the flag, but arm did not
have this. now, the extra slot is removed for all archs since it was
useless.

also, arm eabi requires jmp_buf to have 8-byte alignment. we achieve
that using long long as the type rather than with non-portable gcc
attribute tags.
2012-07-03 20:07:33 -04:00
Rich Felker cdf51506ce replace old and ugly crypt implementation
the new version is largely the work of Solar Designer, with minor
changes for integration with musl. compared to the old code, text size
is reduced by about 7k, stack space usage by about 70k, and
performance is greatly improved by avoiding expensive calculation of
constant tables on each run.

this version also adds support for extended des-based password hashes,
which allow for unlimited key (password) length and configurable
iteration counts.

i've also published the interface for crypt_r in a new crypt.h header.
especially since this is not a standard interface, i did not feel
compelled to match the glibc abi for the crypt_data structure. the
glibc structure is way too big to allocate on the stack; in fact it's
so big that the first usage may cause the main thread to exceed its
pre-committed stack size of 128k and thus could cause the program to
crash even on systems with overcommit disabled. the only legitimate
use of crypt_data for crypt_r is to store the hash string to return,
so i've reserved 256 bytes, which should be more than sufficient
(longest known password hashes are ~60 characters, and beyond that is
possibly even exceeding some implementations' passwd file field size
limit).
2012-06-29 00:56:37 -04:00
Rich Felker 9cf9c39e48 add process_vm_readv and process_vm_writev syscall wrappers
based on a patch submitted by Kristian L. <email@thexception.net>
2012-06-23 21:38:47 -04:00
Rich Felker 4e8b0938d9 proper error handling for fcntl F_GETOWN on modern kernels
on old kernels, there's no way to detect errors; we must assume
negative syscall return values are pgrp ids. but if the F_GETOWN_EX
fcntl works, we can get a reliable answer.
2012-06-20 22:16:47 -04:00
Rich Felker 5bc8e845bb include declarations for new stdio_ext functions (gnulib support) 2012-06-19 15:18:22 -04:00
Rich Felker 57d5fff5f7 header file fixes: multiple include guard consistency and correctness
one file was reusing another file's macro name, and many had
inconsistent underscores and application of SYS prefix, etc.

patch by Szabolcs Nagy (nsz)
2012-06-15 21:52:53 -04:00
Rich Felker de05a2ac22 revert one change in time.h; no evidence BSD_SOURCE should expose these.. 2012-06-13 14:46:11 -04:00
Rich Felker cf254c32ec fix feature test macros in time.h
stime is not _XOPEN_SOURCE, and some functions were missing with
_BSD_SOURCE..
2012-06-13 14:43:16 -04:00