Commit Graph

2048 Commits

Author SHA1 Message Date
Rich Felker
7bec92e793 release notes for 0.9.10 2013-04-14 01:51:00 -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
rofl0r
9947ed5c20 getifaddrs: implement proper ipv6 netmasks 2013-04-09 16:52:13 +02:00
Rich Felker
23ab8c2555 mbrtowc: do not leave mbstate_t in permanent-fail state after EILSEQ
the standard is clear that the old behavior is conforming: "In this
case, [EILSEQ] shall be stored in errno and the conversion state is
undefined."

however, the specification of mbrtowc has one peculiarity when the
source argument is a null pointer: in this case, it's required to
behave as mbrtowc(NULL, "", 1, ps). no motivation is provided for this
requirement, but the natural one that comes to mind is that the intent
is to reset the mbstate_t object. for stateful encodings, such
behavior is actually specified: "If the corresponding wide character
is the null wide character, the resulting state described shall be the
initial conversion state." but in the case of UTF-8 where the
mbstate_t object contains a partially-decoded character rather than a
shift state, a subsequent '\0' byte indicates that the previous
partial character is incomplete and thus an illegal sequence.

naturally, applications using their own mbstate_t object should clear
it themselves after an error, but the standard presently provides no
way to clear the builtin mbstate_t object used when the ps argument is
a null pointer. I suspect this issue may be addressed in the future by
specifying that a null source argument resets the state, as this seems
to have been the intent all along.

for what it's worth, this change also slightly reduces code size.
2013-04-08 23:09:11 -04:00
Rich Felker
ea34b1b90c implement mbtowc directly, not as a wrapper for mbrtowc
the interface contract for mbtowc admits a much faster implementation
than mbrtowc can achieve; wrapping mbrtowc with an extra call frame
only made the situation worse.

since the regex implementation uses mbtowc already, this change should
improve regex performance too. it may be possible to improve
performance in other places internally by switching from mbrtowc to
mbtowc.
2013-04-08 23:01:32 -04:00
Rich Felker
a49e038bab optimize mbrtowc
this simple change, in my measurements, makes about a 7% performance
improvement. at first glance this change would seem like a
compiler-specific hack, since the modified code is not even used.
however, I suspect the reason is that I'm eliminating a second path
into the main body of the code, allowing the compiler more flexibility
to optimize the normal (hot) path into the main body. so even if it
weren't for the measurable (and quite notable) difference in
performance, I think the change makes sense.
2013-04-08 22:49:59 -04:00
Rich Felker
8f06ab0eb9 fix out-of-bounds access in UTF-8 decoding
SA and SB are used as the lowest and highest valid starter bytes, but
the value of SB was one-past the last valid starter. this caused
access past the end of the state table when the illegal byte '\xf5'
was encountered in a starter position. the error did not show up in
full-character decoding tests, since the bogus state read from just
past the table was unlikely to admit any continuation bytes as valid,
but would have shown up had we tested feeding '\xf5' to the
byte-at-a-time decoding in mbrtowc: it would cause the funtion to
wrongly return -2 rather than -1.

I may eventually go back and remove all references to SA and SB,
replacing them with the values; this would make the code more
transparent, I think. the original motivation for using macros was to
allow misguided users of the code to redefine them for the purpose of
enlarging the set of accepted sequences past the end of Unicode...
2013-04-08 22:29:46 -04:00
Rich Felker
bcd9302508 fix signalfd not to ignore flags
also include fallback code for broken kernels that don't support the
flags. as usual, the fallback has a race condition that can leak file
descriptors.
2013-04-07 23:19:00 -04:00
Rich Felker
cc11b42286 silence nonsensical warnings in timer_create 2013-04-06 18:32:11 -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
Rich Felker
5c5ac810c3 fix argument omission in ABI-compat weak_alias for fscanf 2013-04-06 17:15:58 -04:00
Isaac Dunham
14f0272ea1 Add ABI compatability aliases.
GNU used several extensions that were incompatible with C99 and POSIX,
so they used alternate names for the standard functions.

The result is that we need these to run standards-conformant programs
that were linked with glibc.
2013-04-05 23:20:28 -07:00
Rich Felker
ced64995c2 fix type error in pthread_create, introduced with pthread_getattr_np 2013-04-06 01:15:08 -04:00
rofl0r
338cc31c4b getifaddrs: remove unused label 2013-04-06 00:04:52 +02:00
rofl0r
4af3ea789a getifaddrs: use if_nameindex to enumerate interfaces 2013-04-05 22:47:30 +02:00
rofl0r
69a1983872 getifaddrs: one less indent level 2013-04-05 22:08:03 +02:00
rofl0r
c82f53f67c getifaddrs: less malloc 2013-04-05 22:06:35 +02: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
Rich Felker
b6f9941201 implement dn_skipname (legacy resolver function) 2013-04-04 22:36:30 -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
Rich Felker
771c6cead0 cleanup wcstombs
remove redundant headers and comments; this file is completely trivial
now. also, avoid temp var.
2013-04-04 14:55:42 -04:00
Rich Felker
b5a527f9ff cleanup mbstowcs wrapper
remove unneeded headers. this file is utterly trivial now and there's
no sense in having a comment to state that it's in the public domain.
2013-04-04 14:53:53 -04:00
Rich Felker
f62b12d051 minor optimization to mbstowcs
there is no need to zero-fill an mbstate_t object in the caller;
mbsrtowcs will automatically treat a null pointer as the initial
state.
2013-04-04 14:51:05 -04:00
Rich Felker
40b2b5fa94 fix incorrect range checks in wcsrtombs
negative values of wchar_t need to be treated in the non-ASCII case so
that they can properly generate EILSEQ rather than getting truncated
to 8bit values and stored in the output.
2013-04-04 14:48:48 -04:00
Rich Felker
50d9661d9b overhaul mbsrtowcs
these changes fix at least two bugs:
- misaligned access to the input as uint32_t for vectorized ASCII test
- incorrect src pointer after stopping on EILSEQ

in addition, the text of the standard makes it unclear whether the
mbstate_t object is to be modified when the destination pointer is
null; previously it was cleared either way; now, it's only cleared
when the destination is non-null. this change may need revisiting, but
it should not affect most applications, since calling mbsrtowcs with
non-zero state can only happen when the head of the string was already
processed with mbrtowc.

finally, these changes shave about 20% size off the function and seem
to improve performance by 1-5%.
2013-04-04 14:42:35 -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
rofl0r
a6752eb940 __time_to_tm: initialize tm_zone and tm_gmtoff 2013-04-02 04:43:53 +02:00
Szabolcs Nagy
8d3ee05754 add syscall numbers for the new kcmp and finit_module syscalls
and remove syscall todos from microblaze
2013-04-01 18:02:32 +00:00
Szabolcs Nagy
ca2300d9ac add the new SO_REUSEPORT socket option to mips and powerpc
SO_REUSEPORT implementation was merged in the linux kernel commit
c617f398edd4db2b8567a28e899a88f8f574798d 2013-01-23
2013-04-01 17:54:39 +00: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
201e6603c3 fix typo in setpriority syscall wrapper 2013-04-01 11:20:12 -04:00
Rich Felker
0b2764d054 provide prototype for pthread_getattr_np 2013-03-31 23:27:57 -04:00
Rich Felker
14a835b386 implement pthread_getattr_np
this function is mainly (purely?) for obtaining stack address
information, but we also provide the detach state since it's easy to
do anyway.
2013-03-31 23:25:55 -04:00
Rich Felker
ccc7b4c3a1 remove __SYSCALL_SSLEN arch macro in favor of using public _NSIG
the issue at hand is that many syscalls require as an argument the
kernel-ABI size of sigset_t, intended to allow the kernel to switch to
a larger sigset_t in the future. previously, each arch was defining
this size in syscall_arch.h, which was redundant with the definition
of _NSIG in bits/signal.h. as it's used in some not-quite-portable
application code as well, _NSIG is much more likely to be recognized
and understood immediately by someone reading the code, and it's also
shorter and less cluttered.

note that _NSIG is actually 65/129, not 64/128, but the division takes
care of throwing away the off-by-one part.
2013-03-26 23:07:31 -04:00
Rich Felker
00f1521fdd provide emulation of fcntl F_DUPFD_CLOEXEC on old kernels
I'm not entirely happy with the amount of ugliness here, but since
F_DUPFD_CLOEXEC is used elsewhere in code that's expected to work on
old kernels (popen), it seems necessary. reportedly even some modern
kernels went back and broke F_DUPFD_CLOEXEC (making it behave like
plain F_DUPFD), so it might be necessary to add some additional fixup
code later to deal with that issue too.
2013-03-26 22:54:57 -04:00
Rich Felker
ae7399bfd8 in pipe2, use pipe() rather than __syscall(SYS_pipe, ...) for fallback
SYS_pipe is not usable directly in general, since mips has a very
broken calling convention for the pipe syscall. instead, just call the
function, so that the mips-specific ugliness is isolated in
mips/pipe.s and not copied elsewhere.
2013-03-25 11:34:22 -04:00
Rich Felker
9cb6e6ea12 rewrite popen to use posix_spawn instead of fragile vfork hacks 2013-03-24 22:41:38 -04:00
Rich Felker
7914ce9204 remove cruft from pre-posix_spawn version of the system function 2013-03-24 22:40:54 -04:00