Commit Graph

143 Commits

Author SHA1 Message Date
Szabolcs Nagy 002e8d84c5 add syscall numbers for the new renameat2 syscall
it's like rename but with flags eg. to allow atomic exchange of two files,
introduced in linux 3.15 commit 520c8b16505236fc82daa352e6c5e73cd9870cff
2014-07-20 18:42:21 +02:00
Rich Felker 4e0b4a5de7 add tlsdesc support for i386 2014-06-19 02:50:45 -04:00
Rich Felker adf94c1966 refactor to remove arch-specific relocation code from dynamic linker
this was one of the main instances of ugly code duplication: all archs
use basically the same types of relocations, but roughly equivalent
logic was duplicated for each arch to account for the different naming
and numbering of relocation types and variation in whether REL or RELA
records are used.

as an added bonus, both REL and RELA are now supported on all archs,
regardless of which is used by the standard toolchain.
2014-06-18 02:44:02 -04:00
Rich Felker bfa09700b9 dynamic linker: permit error returns from arch-specific reloc function
the immediate motivation is supporting TLSDESC relocations which
require allocation and thus may fail (unless we pre-allocate), but
this mechanism should also be used for throwing an error on
unsupported or invalid relocation types, and perhaps in certain cases,
for reporting when a relocation is not satisfiable.
2014-06-16 03:09:07 -04:00
Rich Felker 9ce2860fa3 add vdso clock_gettime acceleration support to i386 2014-06-06 03:29:36 -04:00
Szabolcs Nagy fd9571e20a add sched_{get,set}attr syscall numbers and SCHED_DEADLINE macro
linux 3.14 introduced sched_getattr and sched_setattr syscalls in
commit d50dde5a10f305253cbc3855307f608f8a3c5f73

and the related SCHED_DEADLINE scheduling policy in
commit aab03e05e8f7e26f51dee792beddcb5cca9215a5

but struct sched_attr "extended scheduling parameters data structure"
is not yet exported to userspace (necessary for using the syscalls)
so related uapi definitions are not added yet.
2014-05-30 13:06:51 -04:00
Timo Teräs fbeadd150f make socketcall types common as they are same for all architectures 2014-04-17 14:53:27 -04:00
Szabolcs Nagy fcea534e57 fix RLIMIT_ constants for mips
The mips arch is special in that it uses different RLIMIT_
numbers than other archs, so allow bits/resource.h to override
the default RLIMIT_ numbers (empty on all archs except mips).
Reported by orc.
2014-04-15 19:17:52 -04:00
Rich Felker 9505bfbc40 fix signal.h breakage from moving stack_t to arch-specific bits
in the previous changes, I missed the fact that both the prototype of
the sigaltstack function and the definition of ucontext_t depend on
stack_t.
2014-03-18 23:27:45 -04:00
Rich Felker bd5f221eaa move signal.h definition of stack_t to arch-specific bits
it's different at least on mips. mips version will be fixed in a
separate commit to show the change.
2014-03-18 23:12:40 -04:00
Rich Felker f6e2f7e13f move struct semid_ds to from shared sys/sem.h to bits
the definition was found to be incorrect at least for powerpc, and
fixing this cleanly requires making the definition arch-specific. this
will allow cleaning up the definition for other archs to make it more
specific, and reversing some of the ugliness (time_t hacks) introduced
with the x32 port.

this first commit simply copies the existing definition to each arch
without any changes. this is intentional, to make it easier to review
changes made on a per-arch basis.
2014-03-11 15:27:13 -04:00
rofl0r 0f169cbb79 sys/shm.h: move arch specific structs to bits/ 2014-02-23 11:07:18 +01:00
Rich Felker d18df33cb1 add IUTF8 to termios.h on archs that were missing it 2014-01-08 19:27:56 -05:00
Rich Felker a627eb3586 fix namespace violations in termios.h, at least mostly
the fix should be complete on archs that use the generic definitions
(i386, arm, x86_64, microblaze), but mips and powerpc have not been
checked thoroughly and may need more fixes.
2014-01-08 19:20:55 -05:00
Szabolcs Nagy f7d348ec39 add O_TMPFILE flag, new in linux 3.11
definition in linux:
 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
where __O_TMPFILE and O_DIRECTORY are arch specific
2013-11-23 23:47:48 +00:00
Rich Felker 78178542e7 add missing i386 syscall numbers
somehow the range 335-339 was missed when updating the file.
2013-09-26 14:17:36 -04:00
Szabolcs Nagy baba2630c9 remove the __mxcsr member from fenv_t on i386 to follow the glibc abi
in the previous commit sse fenv support was added, but there is no
need to save mxcsr (sse fenv register) so fix the abi incompatibility
with glibc.
2013-08-18 16:27:20 +00:00
Rich Felker c5e34dabbb new mostly-C crt1 implementation
the only immediate effect of this commit is enabling PIE support on
some archs that did not previously have any Scrt1.s, since the
existing asm files for crt1 override this C code. so some of the
crt_arch.h files committed are only there for the sake of documenting
what their archs "would do" if they used the new C-based crt1.

the expectation is that new archs should use this new system rather
than using heavy asm for crt1. aside from being easier and less
error-prone, it also ensures that PIE support is available immediately
(since Scrt1.o is generated from the same C source, using -fPIC)
rather than having to be added as an afterthought in the porting
process.
2013-07-26 01:49:14 -04: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 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 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 648c3b4e18 change uid_t, gid_t, and id_t to unsigned types
this change is both to fix one of the remaining type (and thus C++
ABI) mismatches with glibc/LSB and to allow use of the full range of
uid and gid values, if so desired.

passwd/group access functions were not prepared to deal with unsigned
values, so they too have been fixed with this commit.
2013-07-19 01:34:28 -04:00
Rich Felker f389c4984a make the dynamic linker find its path file relative to its own location
prior to this change, using a non-default syslibdir was impractical on
systems where the ordinary library paths contain musl-incompatible
library files. the file containing search paths was always taken from
/etc, which would either correspond to a system-wide musl
installation, or fail to exist at all, resulting in searching of the
default library path.

the new search strategy is safe even for suid programs because the
pathname used comes from the PT_INTERP header of the program being
run, rather than any external input.

as part of this change, I have also begun differentiating the names of
arch variants that differ by endianness or floating point calling
convention. the corresponding changes in the build system and and gcc
wrapper script (to use an alternate dynamic linker name) for these
configurations have not yet been made.
2013-07-18 19:29:44 -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 d926565355 Merge remote-tracking branch 'nsz/review' 2013-05-26 18:22:12 -04:00
Szabolcs Nagy 41c34d188a fix ioctl _IOR, _IOW, etc macros to avoid signed overflow (2<<30) 2013-05-26 15:49:08 +00:00
Rich Felker 5e642b5a23 change underlying type of clock_t to be uniform and match ABI
previously we were using an unsigned type on 32-bit systems so that
subtraction would be well-defined when it wrapped, but since wrapping
is non-conforming anyway (when clock() overflows, it has to return -1)
the only use of unsigned would be to buy a little bit more time before
overflow. this does not seem worth having the type vary per-arch
(which leads to more arch-specific bugs) or disagree with the ABI musl
(mostly) follows.
2013-05-23 20:38:51 -04: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 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
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
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
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 2d0f495e7b add deprecated SIGIOT alias for SIGABRT
reportedly some programs (e.g. showkeys in the kbd package) use it.
2013-03-23 20:02:31 -04:00
Rich Felker da1442c9a8 fix types for wctype_t and wctrans_t
wctype_t was incorrectly "int" rather than "long" on x86_64. not only
is this an ABI incompatibility; it's also a major design flaw if we
ever wanted wctype_t to be implemented as a pointer, which would be
necessary if locales support custom character classes, since int is
too small to store a converted pointer. this commit fixes wctype_t to
be unsigned long on all archs, matching the LSB ABI; this change does
not matter for C code, but for C++ it affects mangling.

the same issue applied to wctrans_t. glibc/LSB defines this type as
const __int32_t *, but since no such definition is visible, I've just
expanded the definition, int, everywhere.

it would be nice if these types (which don't vary by arch) could be in
wctype.h, but the OB XSI requirement in POSIX that wchar.h expose some
types and functions from wctype.h precludes doing so. glibc works
around this with some hideous hacks, but trying to duplicate that
would go against the intent of musl's headers.
2013-03-04 19:22:14 -05:00
Szabolcs Nagy 000806cde6 add missing mmap options and madvices to bits/mman.h based on linux headers 2013-01-12 19:42:39 +01:00
Szabolcs Nagy bc1a8d2ae3 add missing EXTPROC flag to bits/termios.h
mips and powerpc already had this termios flag defined
2013-01-12 19:42:39 +01:00
Szabolcs Nagy 73bb048951 add missing F_GETOWNER_UIDS flag to bits/fcntl.h 2013-01-12 19:42:39 +01:00
Szabolcs Nagy 056c8b1ab5 add missing EHWPOISON to bits/errno.h
it was already defined for mips, but was missing from other archs
2013-01-12 19:42:39 +01:00
Rich Felker 5c5e45e58b move signal.h REG_* macros under _GNU_SOURCE protection
they were accidentally exposed under just baseline POSIX, which is a
big namespace pollution issue. thankfully glibc only exposes them
under _GNU_SOURCE, not under any of its other options, so omitting
the pollution in the default _BSD_SOURCE profile does not hurt
application compatibility at all.
2012-12-06 17:05:19 -05:00
rofl0r a631c5df53 bits/signal.h: add register names for x86(_64)
glibc exposes them from ucontext.h.
since that header includes signal.h, it is safe to put them
into bits/signal.h, if _GNU_SOURCE is defined.
2012-12-06 18:14:49 +01:00
rofl0r 7e0d4fce41 add more arch-specific MAP_ macros to bits/mman.h
these are also needed by qemu.
2012-12-06 16:57:22 +01:00
rofl0r 0e10f74006 add MAP_NORESERVE to bits/mman.h
this is needed for qemu, and since it differs for each arch
it can't be circumvented easily by using a macro in CFLAGS.
2012-12-06 01:26:51 +01: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 c72fc23843 sigcontext/mcontext cleanup for arch-specific bits
with these changes, the members/types of mcontext_t and related stuff
should closely match the glibc definitions. unlike glibc, however, the
definitions here avoid using typedefs as much as possible and work
directly with the underlying types, to minimize namespace pollution
from signal.h in the default (_BSD_SOURCE) profile.

this is a first step in improving compatibility with applications
which poke at context/register information -- mainly debuggers, trace
utilities, etc. additional definitions in ucontext.h and other headers
may be needed later.

if feature test macros are used to request a conforming namespace,
mcontext_t is replaced with an opaque structure of the equivalent size
and alignment; conforming programs cannot examine its contents anyway.
2012-11-23 14:35:25 -05:00
Rich Felker 7538708f8b fix up leftover, incorrect NSIG definitions in arch-specific signal.h 2012-11-23 12:20:53 -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