As this is part of POSIX since 2024, WCOREDUMP is the new default name.
WIFCORED is retained under _DEFAULT_SOURCE.
Fixes#19735.
Change-Id: Ic3f65e47b436bae92fe82ef73c3094be6bc9f29d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9622
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Add the following:
- CS and SS registers
- For 32bit: DS, ES, FS, GS registers (on 64 bit these are not part of
the iframe structure)
- CR2 register (fault address)
- Hardware interrupt number
- Hardware error code
The hardware error code, interrupt number and fault address are not
modifiable by the signal handlers. The other registers can be modified.
This is used for example in dosemu to intercept errors from JIT generated
code and resume execution. Wine can also make use of it.
In order to not change the size of struct mcontext, these are inserted
in a region of the FXSAVE structure that is available for the OS to
store some data (as documented by Intel) and that we didn't use before.
Fixes#7867
Change-Id: Ia3c27a2c728e32995196c646c1d78adf40e793ed
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9456
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
The RTLD_GROUP flag to dlopen comes from Solaris. It makes the symbol
resolution for dlopen not use the global symbols from the current team
(anything that's already loaded). The loaded object must be explicitly
linked against any symbol it needs to use (or it can use dlsym to search
symbols in the global scope explicitly).
This is also how symbol resolution worked in BeOS, meaning we already
have the code to do this, and just need to enable it.
This can be used in dosemu, where DOS-like executable are linked against
their own C library and should not use symbols from libroot.
Fixes#19674.
Change-Id: I8d127c7812a31e231edb1e44edf70b868c2670e7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9450
Reviewed-by: waddlesplash <[email protected]>
To allow consumers to cause the "don't fragment" bit to be set in
all IPv4 packet headers.
There is no standard way of doing this, and different OSes expose
this option in different ways. Linux has "IP_MTU_DISCOVER", but it
takes an enum, not a boolean. NetBSD and OpenBSD appear to have
no socket option, instead they have "IP_MTUDISC", an option for
the "ip_output()" kernel-level network stack method.
"IP_DONTFRAG" sockopt originates on FreeBSD, and it seems macOS now
also supports it in version 11+. Windows has "IP_DONTFRAGMENT",
which, at a glance, appears to do the same thing. So this looks
like the one that makes the most sense to adopt.
This doesn't add any code to process MTU changes yet, though.
Change-Id: I492d22dbd0ee5f4ab35c600396ad3d3ec9f4f200
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9401
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
* POSIX also specifies in6 availability in in.h, not just RFCs.
* Drop IPPORT_USERRESERVED. It's in RFC 1700, but FreeBSD and musl
do not define it, and OpenBSD and NetBSD disagree on its value
(the RFC says 5000, while OpenBSD used this "49151" starting
in 1998.)
* Organize the remainder with clear indications of what RFC defined them
(if indeed they were specified in an RFC.)
* Drop "helpful macros"; they're guarded by _KERNEL on OpenBSD.
Change-Id: Ia20be56398130ee22d70b38ee25a3f609b567c3b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9398
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This way, they are available by default when not using a strict
language standard version.
The change is applied to all architectures (except m68k, which doesn't
define them at all).
Fixes#19534
Change-Id: I71238919e50518abaa65fa20365c912a577e3455
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9196
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Add support for using `RTLD_NOLOAD` with `dlopen` on Haiku.
While not specified in POSIX, this option is widely available (both
GNU/Linux and BSD) and is the only way to atomically check if a shared
object has been loaded.
Change-Id: I061332307d76c84f6a2abb6f92c4ed964bd90a1e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9161
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This is unused but defined in Darwin, BSD, and Linux.
It allows developers to feel good about specifying that they want to map
a file (which is the default behavior anyway). The value is 0, so
specifying this flag does not have any effect.
This allows to more easily compile code that uses the flag.
Change-Id: I7a880a3090d90b7e8cef5144e82f71beb61147a8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9152
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Otherwise it needs to use libio internals to implement these,
which we don't want. musl also exports all these methods for
the same reason.
Implementations taken from glibc 2.15, current gnulib (5077f67), and
in a few cases tweaked for better Haiku support.
Should fix#19479.
* Take it from upstream glibc 2.15, much closer to the version we use.
* Drop fpurge from stdio.h, it's nonstandard. Keep it around for
ABI compatibility for now (BeOS didn't have it.) __fpurge is left
in stdio_ext.h.
It's in POSIX-2024. Remove the libgnu implementation and just import
the changes from latest FreeBSD (dc36d6f9bb1753f3) instead.
While at it, put the non-standard sort functions behind
_DEFAULT_SOURCE.
It's needed by GCC2 stdc++, but we shouldn't be including it
for all consumers of <stdio.h>, which we were. Drop it,
and adjust all the things that were relying on <stdio_pre.h>'s
definition of __PRINTFLIKE to use the _PRINTFLIKE defined
in BeBuild.h instead.
Hopefully should not cause any breakage; the libroot
implementation of __freading depended on this, but
I didn't see anything else which did.
Fixes the code I introduced in hrev50114 for custom serial port
baudrates. The idea there was based on FreeBSD implementation, but I
missed a key detail: speed_t in BeOS (and Haiku) is only an 8 bit value.
Note that BeOS does not have c_ispeed and c_ospeed fields, instead they
are named c_ixxxxx and c_oxxxxx with a comment in termios.h saying that
they are not used. So the renaming and moving of these fields isn't a problem.
This means the previous code worked only for speed between 20 and 255
baud, quite the opposite of what I wanted to do, which is to enable
access to fast baudrates.
This new implementation exploits the fact that tcflag_t is 32 bit, but
we never actually use more than 16 bits. Therefore, the high bits of
each value were unused, and can be reclaimed to store the speed,
by changing tcflag_t to 16 bits. The speed is then inserted as two 16
bit values that can be combined as a 32 bit one. The flag bits are not
moved (on little endian systems), and the extra values are guaranteed to
be set to 0 by any previous code that was compiled with 32 bit tcflag_t.
Support for different speeds for input and output is now also possible
(POSIX specifies separate functions for setting the input and output
speeds, which is useful for some old terminals and modems, where it was
useful to have a high baudrate for data to display on the screen, but
things typed on the keyboard aren't quite as fast). If desired, we could
now properly implement this in our serial drivers, but it isn't done
here yet.
Additional changes:
- speed_t is now a 32bit type, allowing to pass large values to
cfset(i,o)speed
- fix some places where a baudrate enum value was incorrectly put in the
c_ispeed and c_ospeed fields, this is not how they were meant to be
used (it meant the default was to use a speed of 0, that means "hangup"
the line, which I think no serial driver really implemented).
- do not put baudrate enumeration values in c_iflag and c_oflag, they
are meant to be used in c_cflag only, and conflict with other bits.
Separate speeds for input and output can be done by setting the
c_cflag value to CBAUD (indicating custom baudrates) and then setting
the values in c_ispeed and c_ospeed.
Fixes#18483
Change-Id: If63a24b5ced5edf6d051d921197db194def0c614
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7068
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
These were declared in this header on BeOS, so we need to keep
them around for ABI compatibility, but they are nonstandard
and no other C library besides glibc appears to provide them
at all (not even musl, and none of the BSDs.)
- Convert libroot from a page to a group, so that it can list the
included file and functions in the generated book (like the kits)
- Add unistd.dox and move the relevant part of ioctl details there
- Make sure to use C89-compatible comments only in POSIX headers
Change-Id: I8f0412e4c75de6f48018a0436909f8b0076342a4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6369
Reviewed-by: Adrien Destugues <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
Based on X512's original change, but with more modifications:
* Don't use _ in macro parameter names to appease GCC 2.
* Get rid of ioctl_args struct. We don't need it anymore,
and just adding parameters of the same types has the
exact same ABI on x86 and x86_64, so this doesn't break
any existing compiled code.
* Add (void*) cast to third parameter.
* Enable for _KERNEL_MODE also.
Change-Id: Id4ad8b85f54836fd26dc6278226954d0a081d5f0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8533
Reviewed-by: waddlesplash <[email protected]>
* add SOCK_NONBLOCK and SOCK_CLOEXEC
* also extends the type parameter on socketpair() and socket()
Change-Id: I73570d5bfb57c2da00c1086149c9f07547ba61ce
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8515
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
* Always declare FD_SET rather than conditionally. This matches
the behavior of the glibc, musl, FreeBSD headers.
* Simplify comments.
* Leave the custom FD_SETSIZE possibility in place for now. Neither
glibc nor musl permit this, but FreeBSD still does.
* Minor tweaks to POSIX sys/param.h for style.
* Don't redefine alignment macros in BSD sys/param.h even conditionally.
And add a few more macros from the real BSD sys/param.h, for convenience.
(Most of these are also declared in musl and glibc's sys/param.h)
We automatically enable _DEFAULT_SOURCE if _GNU_SOURCE is defined.
Rather than having even more optional methods undefined unless
_GNU_SOURCE manually is, just change all remaining guarts to
use _DEFAULT_SOURCE instead.
Fixes#19095.
Change-Id: I5c7baf40b7fb37913e24279589fc1ae706448a45
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8330
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
* our ip modules don't support connect()/send(). Just use sendto().
* ping6 disappears, ping supports -4 or -6 to force IPv4 or IPv6
Change-Id: I1e982e354cc75d3a314c5bbbfffa0373e8f4d9af
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7427
Reviewed-by: waddlesplash <[email protected]>
Change the value of `AT_FDCWD` from -1 to -100. Either value should work,
since the Haiku implementation currently interprets any negative value as
`AT_FDCWD`, however -100 is preferable to -1 since -1 is used for error
return values.
fixes#18809
Change-Id: I53f273dd595c39ea9e4576b90adbbf7f555107cf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7423
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
In our C library we try to provide a "clean" POSIX/ISO-C set of include
files that strictly conforming applications can use. However, we also
want to provide some extensions that are commonly available in BSD or
GNU systems.
These are normally provided in a separate directory
(headers/compatibility/bsd) and additionally guarded by compiler defines
that can either be explicitly set, or enabled by default if the language
standard (selected from the compiler command line) is one with GNU
extensions (this is the default for GCC). This is controlled by a header
file called features.h.
However, for some headers it is not so simple to split the GNU
extensions apart from the other parts of the file, because it's not just
extra functions, but additional flags and defines.
So, we need the "features.h" mechanism to be available even in the base
set of headers, but not enable anything if the BSD headers are not in
the search path. The simplest way to achieve this is to have an empty
features.h in the base set of headers, that can then be overriden by the
one in headers/compatibility/bsd if needed.
Fixes#18732
Change-Id: Ia54d1206c2fba378ae276ed4232aee8443180afb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7287
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This file was imported from glibx and uses __USE_GNU as defined by
glibc(s features.h. Our implementation of features.h is simpler, just
defining _DEFAULT_SOURCE directly and that's what we use in other
headers.
As a result, using GNU extensions to regex.h required defining __USE_GNU
directly in applications (for example in TraX).
Fixes#11818
Change-Id: I11e4cf2e88c330cf58083852c4b33aedb8a3a9ea
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7238
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>