summaryrefslogtreecommitdiff
path: root/include/alltypes.h.in
AgeCommit message (Collapse)AuthorLines
2020-08-30fix regression with applications that expect struct winsize in ioctl.hRich Felker-0/+2
putting the (simple) definition in alltypes.h seems like the best solution here. making sys/ioctl.h implicitly include termios.h is probably excess namespace pollution.
2019-12-17signal to kernel headers that time_t is 64-bitRich Felker-0/+1
linux/input.h and perhaps others use this macro to determine whether the userspace time_t is 64-bit when potentially defining types in terms of time_t and derived structures. the name __USE_TIME_BITS64 is unfortunate; it really should have been in the __UAPI namespace. but this is what was chosen back in v4.16 when first preparing input.h for time64 userspace, presumably based on expectations about what the glibc-internal features.h macro for time64 would be, and changing it now would just put a new minimum version requirement on kernel headers. the __USE_TIME_BITS64 macro is not intended as a public interface. it is purely an internal contract between libc and Linux uapi headers.
2019-11-02move time_t and suseconds_t definitions to common alltypes.h.inRich Felker-0/+2
now that all 32-bit archs have 64-bit time_t (and suseconds_t), the arch-provided _Int64 macro (long or long long, as appropriate) can be used to define them, and arch-specific definitions are no longer needed.
2019-10-20adjust struct timespec definition to be time64-readyRich Felker-1/+1
for time64 support on 32-bit archs, the kernel interfaces use a timespec layout padded to match the representation of a pair of 64-bit values, which requires endian-specific padding. use of an ordinary, non-bitfield, named member for the padding is undesirable because, on big endian archs, it would alter the interpretation of traditional (non-designated) initializers of the form {s,ns}, initializing the padding instead of the tv_nsec member. unnamed bitfield members solve this problem by not taking part in initialization, and were the expected solution when the kernel interfaces were designed. however, they also have further advantages which we take advantage of here: positioning of the padding could be controlled by having a preprocessor conditional with separate definitions of struct timespec for little and big endian, but whether padding should appear at all is a function of whether time_t is larger than long. this condition is not something the preprocessor can determine unless we were to define a new macro specifically for that purpose. by using unnamed bitfield members instead of ordinary named members, we can arrange for the size of the padding to collapse to zero when it should not be present, just by using sizeof(time_t) and sizeof(long) in the bitfield width expression, which can be any integer constant expression.
2019-10-17move pthread types out of per-arch alltypes.hRich Felker-0/+8
policy has long been that these definitions are purely a function of whether long/pointer is 32- or 64-bit, and that they are not allowed to vary per-arch. move the definition to the shared alltypes.h.in fragment, using integer constant expressions in terms of sizeof to vary the array dimensions appropriately. I'm not sure whether this is more or less ugly than using preprocessor conditionals and two sets of definitions here, but either way is a lot less ugly than repeating the same thing for every arch.
2019-10-17move __BYTE_ORDER definition to alltypes.hRich Felker-0/+3
this change is motivated by the intersection of several factors. presently, despite being a nonstandard header, endian.h is exposing the unprefixed byte order macros and functions only if _BSD_SOURCE or _GNU_SOURCE is defined. this is to accommodate use of endian.h from other headers, including bits headers, which need to define structure layout in terms of endianness. with time64 switch-over, even more headers will need to do this. at the same time, the resolution of Austin Group issue 162 makes endian.h a standard header for POSIX-future, requiring that it expose the unprefixed macros and the functions even in standards-conforming profiles. changes to meet this new requirement would break existing internal usage of endian.h by causing it to violate namespace where it's used. instead, have the arch's alltypes.h define __BYTE_ORDER, either as a fixed constant or depending on the right arch-specific predefined macros for determining endianness. explicit literals 1234 and 4321 are used instead of __LITTLE_ENDIAN and __BIG_ENDIAN so that there's no danger of getting the wrong result if a macro is undefined and implicitly evaluates to 0 at the preprocessor level. the powerpc (32-bit) bits/endian.h being removed had logic for varying endianness, but our powerpc arch has never supported that and has always been big-endian-only. this logic is not carried over to the new __BYTE_ORDER definition in alltypes.h.
2019-10-17remove per-arch definitions for va_listRich Felker-0/+3
now that commit f7f1079796abc6f97c69521d2334e9c7d3945dd8 removed the legacy i386 conditional definition, va_list is in no way arch-specific, and has no reason to be in the future. move it to the shared part of alltypes.h.in
2019-03-12make FILE a complete type for pre-C11 standard profilesRich Felker-0/+1
C11 removed the requirement that FILE be a complete type, which was deemed erroneous, as part of the changes introduced by N1439 regarding completeness of types (see footnote 6 for specific mention of FILE). however the current version of POSIX is still based on C99 and incorporates the old requirement that FILE be a complete type. expose an arbitrary, useless complete type definition because the actual object used to represent FILE streams cannot be public/ABI. thanks to commit 13d1afa46f8098df290008c681816c9eb89ffbdb, we now have a framework for suppressing the public complete-type definition of FILE when stdio.h is included internally, so that a different internal definition can be provided. this is perfectly well-defined, since the same struct tag can refer to different types in different translation units. it would be a problem if the implementation were accessing the application's FILE objects or vice versa, but either would be undefined behavior.
2018-03-12explicitly use signed keyword to define intNN_t and derivative typesRich Felker-4/+4
standing alone, both the signed and int keywords identify the same type, a (signed) int. however the C language has an exception where, when the lone keyword int is used to declare a bitfield, it's implementation-defined whether the bitfield is signed or unsigned. C11 footnote 125 extends this implementation-definedness to typedefs, and DR#315 extends it to other integer types (for which support with bitfields is implementation-defined). while reasonable ABIs (all the ones we support) define bitfields as signed by default, GCC and compatible compilers offer an option -funsigned-bitfields to change the default. while any signed types defined without explicit use of the signed keyword are affected, the stdint.h types, especially intNN_t, have a natural use in bitfields. ensure that bitfields defined with these types always have the correct signedness regardless of compiler & flags used. see also GCC PR 83294.
2014-12-21move wint_t definition to the shared part of alltypes.h.inRich Felker-0/+1
2014-10-13implement uchar.h (C11 UTF-16/32 conversion) interfacesRich Felker-0/+2
2013-07-22undefine internal-use type macros at the end of alltypes.hRich Felker-0/+4
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-22move register_t and u_int64_t (back) to alltypesRich Felker-0/+2
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-22fix regression in size of nlink_t (broken stat struct) on x86_64Rich Felker-1/+1
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-22make regoff_t and regex_t match C++ ABIRich Felker-0/+1
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-22make pthread_key_t unsigned to match ABIRich Felker-1/+1
2013-07-22make pthread attribute types structs, even when they just have one fieldRich Felker-3/+3
this change is to get the right tags for C++ ABI matching. it should have no other effects.
2013-07-22refactor headers, especially alltypes.h, and improve C++ ABI compatRich Felker-0/+65
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