Commit Graph

713 Commits

Author SHA1 Message Date
François Revol
425515d0ac m68k: really add fenv from musl-1.1.24
Somehow the first review merged only the commit log.

FreeBSD doesn't have m68k anyway, so use fenv from musl with as less
changes as possible.

Change-Id: I6372af6679e6773fbb6bf4c8b5b30512971a97a6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3161
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
2020-08-19 15:23:47 +00:00
rofl0r
7de1ebe0d6 netdb.h: fix prototype of gethostbyaddr()
first parameter should be const void*, in line with freebsd and linux etc.

https://xref.landonf.org/source/xref/freebsd-current/include/netdb.h#232

Change-Id: I5e953e8e7e49a6f09cd1143de6ca57eb98f77d73
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3147
Reviewed-by: Michael Lotz <mmlr@mlotz.ch>
2020-08-17 00:08:02 +00:00
Michael Lotz
b3bd66961a libroot/kernel: Implement MADV_FREE madvise() extension.
It allows an application to signal that it no longer needs the data in
the given address range and the underlying pages can be discarded and
reused elsewhere. This is finer grained than working with full areas
or mappings at a time and enables unmapping sections of partially used
mappings without giving up its address space.

Compared with punching holes into a mapping by "mapping over" with
PROT_NONE and MAP_NORESERVE, this has the obvious advantage of not
producing a lot of unused extra areas and saves the corresponding
resources. It is also a lot "lighter" of an operation than cutting
existing areas.

This introduces madvise() alongside the existing posix_madvise() to
allow for OS specific extensions. The constants for both functions are
aliased, the POSIX_MADV_* being a subset of the MADV_* ones without the
non-POSIX extensions. Internally posix_madvise() simply calls madvise().

MADV_FREE is commonly supported in other OSes with various subtle
semantic differences as to when pages are actually freed/cleared and how
or whether the pages are counted against the memory use of a process.
In the variant implemented here, pages are always immediately discarded
and memory counting is not altered. This behaviour should be considered
an implementation detail and may be altered later. The actual unmap and
discard could for example be delayed until pages are needed elsewhere to
reduce overhead in case of repeated discarding and remapping.

Note that MADV_FREE doesn't really align with the rest of the madvise()
API as it works like a command (i.e. discard these pages) and does not
add an attribute to the pages in the given range (i.e. mark these pages
for quick access from now on). As such, an MADV_FREE does not need to be
undone by setting a different advice later on, unlike how the other
flags work. This discrepancy may be the reason why it is not part of
POSIX.

Change-Id: Icc093379125a43e465dc4409d8f5ae0f64e107e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2844
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-08-01 19:23:27 +00:00
Adrien Destugues
4bfc0072e3 limits.h: ncrease ARG_MAX
The limit was set when creating limits.h back in hrev88. It seems to be
used only in glob(). The limit is quite low by today standards and
prevents building icu 67.

I guess the liit was put at 32K because that's what BeOS did, but I see
no reason to keep it that way.

Change-Id: I74f95d9b56891dd90c79b7ced35ca8d1ec81d6ab
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3117
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-08-01 17:37:01 +00:00
Augustin Cavalier
8da1468de6 arpa/nameser.h: Fix build on GCC8.
ssize_t comes from sys/types.h.
2020-07-03 15:30:00 -04:00
Augustin Cavalier
657f041aee fnmatch: Replace BSD implementation with musl one.
The BSD implementation was under the Advertising Clause,
so we might as well take the opportunity to replace the
implementation entirely with musl's.

Header also rewritten to be a Haiku one; the constants
are left unchanged of course.
2020-07-03 15:09:33 -04:00
Augustin Cavalier
6996e5b271 headers: More removal of the BSD Advertising Clause.
Taken from FreeBSD; some minor cleanup elsewhere.

udp.h rewritten entirely as it contained no copyrightable
material and bears little resemblance to BSD's.
2020-07-03 15:00:37 -04:00
Augustin Cavalier
ebffd73fc5 arpa/nameser.h: Cleanup.
* Remove functions not even FreeBSD defines.
 * Remove dependency on unnecessary headers.
 * Update copyright headers to match FreeBSD's; includes
   removal of the advertising clause.
 * Move some private structs to netresolv port_before.

Unfortunately, it seems musl implements very little of this file,
so we may wind up sticking with netresolv for its implementation.
2020-07-03 14:27:17 -04:00
Augustin Cavalier
2ed1a36d4b resolv.h & netdb.h: Clean up and simplify.
* Remove all functions and a number of constants that neither
   glibc nor musl define or support (and even FreeBSD does not
   declare a good number of these anymore.)
 * Redeclare the primary flags in terms of (1 << X) instead
   of raw 0x... for readability (the constants at the end
   do NOT match up to their definitions in glibc, musl, and BSDs!)
 * Remove usage of unneeded headers, and __BEGIN/END_DECLS.
 * Replace non-Haiku license headers with the ones from FreeBSD,
   which notably contain a removal of the advertising clause.

ABIs remain unchanged, but a small set of applications that
use these esoteric APIs may not compile anymore (are there
any remaining?)
2020-07-02 19:33:51 -04:00
Augustin Cavalier
17dab0d52b inet.h: Remove "cidr" functions.
These are not in the standard and are not declared by glibc at all.
The symbols remain for any applications that are still using them,
for now.\

Change-Id: Ie6b4a6b5ec3231c304e05ce9cb38c67d9ee51ad7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2942
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-06-22 16:02:31 +00:00
Jérôme Duval
9495126984 kernel/x86_64: AVX support
xsave or xsavec are supported.
breaks vregs compatibility.
change the thread structure object cache alignment to 64
the xsave fpu_state size isn't defined, it is for instance 832 here, thus I picked 1024.

Change-Id: I4a0cab0bc42c1d37f24dcafb8259f8ff24a330d2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2849
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-06-03 06:16:48 +00:00
François Revol
8a9a366fef strings.h: s/inline/__inline__/
As suggested by http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Inline.html

This should fix building things like NBDkit.

Change-Id: I1da7fc140dd8451ff2ddaf599fe4e951401d0cb3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2794
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-05-24 13:59:57 +00:00
Augustin Cavalier
9304fbae8a uchar.h: Remove duplicate definition of mbrtoc32. 2020-05-09 16:15:55 -04:00
Adrien Destugues
22337d8f4b uchar.h: char16_t must be uint_least16_t
We attempted to make it a 32bit char type, but that is actually not allowed
unless we also make uint_least16_t a 32bit type. And even then, we
wouldn't be allowed to store or handle values wider than 16bit.

Comply more closely to the standard. As a result, mbtoc16r is not
implemented. c16rtomb is implemented by casting the char to 32bit, which
isn't really correct either (I think you're supposed to be able to feed
the two halves of a > 16bit codepoint in two separate calls and get a
meaningful result out?)

Related to #15990 but we may want an actual implementation?

Change-Id: If8198675c27dd2aa412bc44d12d3df4e31d3e8c7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2623
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-05-09 19:29:28 +00:00
Michael Lotz
b94221f3b2 mmap: Use MAP_NORESERVE to request overcommit, not PROT_NONE.
This reverts hrev54120 and instead adds the commonly supported
MAP_NORESERVE flag to request overcommit.

Using PROT_NONE for overcommit is problematic as the protection of
individual pages can still be changed via mprotect to make them
accessible, but that won't change the commitment. An application
using such a pattern may then unexpectedly run into out of memory
conditions on random writes into the address space.

With MAP_NORESERVE the overcommit can explicitly be requested by
applications that want to reserve address space without producing
memory pressure.

Change-Id: Id213d2245c5e23103e8e0857f7902e0cd8a2c65d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2611
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-05-09 02:57:48 +00:00
Adrien Destugues
2dc597d50d Optimize ffs() implementation
- Use gcc builtin
- Define as a static inline function in the .h so no function call overhead is needed
- Keep the function in libroot for backwards compatibility
- Remove a duplicate implementation in the freebsd compatibility layer

gcc2 does not document the builtin, but it is in fact already available
there as well.

Fixes #3281.

Change-Id: I94f8a2548637aa70e85febbfab06f07c1a427005
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2605
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-05-08 14:01:53 +00:00
Adrien Destugues
d0e1eb7a7b mark abort() function as noreturn.
It was not specified as such before C11, but that's only because there
was no C standard way to do it until then.

Fixes #15955.

Change-Id: Ied7b7fd94988ed7724460917aebc859b74eaa585
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2558
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-05-03 15:42:41 +00:00
Alexander von Gluck IV
15fb7d88e9 riscv64: Add missing (slightly modified) fenv.h from FreeBSD
* A few tips for future folks follows.
* fenv.h gets wrapped in our buildtools
* If anything in the arch fenv.h "doesn't work" buildtools
  will silently fail early on (autotools HAVE_FENV_H)

Change-Id: Icae064fde42af3bbed5ea2eadfaa8c18c677e6a6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2164
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-01-28 11:48:42 +00:00
Adrien Destugues
2de6164042 Add missing fenv.h for sparc.
Borrowed from FreeBSD with some changes to get it building.
Now we need to rebuild the gcc package...

Change-Id: I6b8dfd7fb6ca912c76e2ff10fbe01ad583a09aec
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2131
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-01-22 00:25:19 +00:00
Augustin Cavalier
dda1013cdb posix/math: Use the GCC built-ins when possible for isnan(), etc.
glibc does the same. Technically, some of these builtins did
not exist / did not work before GCC 4.4, but the source tree
cannot be compiled with a version that old anyway.

x86_64 and _x86 need to keep the old functions for now, of
course; but all other architectures can probably feel free
to drop the s_isnan, etc. functions from their glibc.

This will make upcoming patches easier...

Change-Id: Ifb76ea74076553228c9741a8ee3ecb0e1cf736a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2076
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-01-06 07:44:30 +00:00
Augustin Cavalier
d2f7af0edc Revert "deprecate gets and tmpnam"
This reverts commit 92e9211d7b.

It broke the build, and apparently cannot be fixed until GCC
has been patched.
2020-01-04 15:26:08 -05:00
Adrien Destugues
92e9211d7b deprecate gets and tmpnam
For #15515

As mentionned in the ticket, we may also want to hide the symbols
altogether from libroot for newer API/ABI versions, unless we still want
to provide C89/C99/C++98/C++11 compatibility, in which case we still
need them around.

Change-Id: I0ee267fb6c4c2f4bae9b1ba6f68e2bcefc399a7f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2061
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-01-03 03:35:04 +00:00
Jérôme Duval
af0281a8c2 POSIX: add a few constants for sysconf.
Change-Id: I400efdbccc97b287844917e21d8e08e26029f2f8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1839
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-09-07 15:04:14 +00:00
Jaroslaw Pelczar
ef21ae46d9 arm64: Update license in headers
Signed-off-by: Jaroslaw Pelczar <jarek@jpelczar.com>
Change-Id: I545722b4f499addf7be557d85ee90f9847f3bcd7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1804
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-09-01 03:02:49 +00:00
Augustin Cavalier
47a21c5c89 s/Haiku License/MIT License/g.
They are the same thing.
2019-08-30 18:16:02 -04:00
Jaroslaw Pelczar
1f52c921e2 ARM64: Initial changes so we can compile GCC toolchain
Signed-off-by: Jaroslaw Pelczar <jarek@jpelczar.com>
Change-Id: I0859d0619d601efd003472e2846d2f980ee2e457
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1799
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-08-30 19:05:16 +00:00
Adrien Destugues
03d334bbdf build fixes.
sys/types.h cannot incliude endian.h because that creates circular
include dependencies.

Add proper multiarch grist to libcolumnlistview.
2019-08-27 20:51:51 +02:00
Adrien Destugues
261430c5ae Clarify endianness defines. 2019-08-27 17:44:57 +02:00
Jessica Hamilton
d7818b5aae sys/types: include endian.h, and fix endian definitions.
* Defining LITTLE/BIG_ENDIAN as 0 breaks some feature test macros,
  particularly in autoconf. Checking with FreeBSD, their macros
  define a non-zero value as well.

References:
- https://github.com/freebsd/freebsd/blob/master/sys/x86/include/endian.h
- http://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/c.m4#n1584
Change-Id: I61b0bbad74e2bf5248464a5c15e504b9f45bea7f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1526
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-08-27 10:02:45 +00:00
CodeforEvolution
e1a822a95f Conform putenv to POSIX standards
Discovered this while working on VLC, checked with other online sources too.

Change-Id: I114c20babda0ff0e90d0eeee299d8483700166bd
Reviewed-on: https://review.haiku-os.org/c/1628
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-07-20 16:02:00 +00:00
Augustin Cavalier
394fba6684 unistd.h: POSIX_THREAD_ATTR_STACKADDR was implemented back in March. 2019-07-11 23:05:27 -04:00
Augustin Cavalier
03c14d2989 stdlib.h: Add noreturn attribute to exit and _Exit.
Fixes #15110.
2019-06-15 12:14:06 -04:00
Jérôme Duval
38ce902686 posix: add posix_fadvise(), only error checks.
should help for ports.

Change-Id: Id504bdb79cb68db4b615f58848e0e1a86ced8d2b
Reviewed-on: https://review.haiku-os.org/c/1467
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-05-21 15:07:43 +00:00
Alexander von Gluck IV
d117379205 posix/if_types.h: Remove IFT_IEEE1394, breaks build
* Sneaky ifdef in libnetwork/netresolv/irs
* Sorry for spam.

Change-Id: I241d65b63d0bb8b281e3db0adcad2814b1476c7e
2019-04-22 13:21:50 -05:00
Alexander von Gluck IV
db3b4a3caf posix/if_types.h: Fix tun id, add a few more
* Oops, there's a standard for these. Stick to the standard.
* Add a few that could be useful someday.
* Mention iana spec.

Change-Id: I4cf75e8c1e4b25f65d10921c7075fbd53f44e14e
2019-04-22 13:06:04 -05:00
Alexander von Gluck IV
64948daae8 tun/tap: Build fixes for tun add-on 2019-04-17 14:12:59 +00:00
François Revol
b110fce124 Add sources for my original BeOS BONE tun/tap config driver
as a starting point.

Change-Id: I9c3b1027a7fda4ab1eaced486eb2455a19571fee
2019-04-17 14:12:59 +00:00
Augustin Cavalier
5ffbe7d778 Change all references to "__INTEL__" to "__i386__".
They are functionally identical, but the former is a BeOS/Haiku-specfic
macro that we include in the compiler specs, and the latter is defined
by GCC.
2019-03-30 16:54:01 -04:00
Augustin Cavalier
569791be52 headers/posix: Define the byteswap macros unconditionally.
It helps if one tests GCC4+ fixes on GCC4+...
2019-03-27 10:19:50 -04:00
Augustin Cavalier
8e309168b9 headers/posix: Use separate naming for the byte-swap macros.
This avoids a compile error on GCC4 when ByteOrder.h is included
after it.
2019-03-27 00:25:34 -04:00
Augustin Cavalier
6d5e91f0c9 headers/posix: Make casts in netinet byteswap functions uniform. 2019-03-26 22:31:33 -04:00
Augustin Cavalier
9cb15d72bd netinet/in: Use the GCC4 builtin byteswap functions for htonl.
Fixes the build breakage caused by PulkoMandy's recent commit.
Remove these from ByteOrder.h now also, as per POSIX they should
come from netinet/in.h.

This is a small source compatibility breakage, but it will only
affect a small portion of non-POSIX, partially-Be applications.
2019-03-26 19:33:43 -04:00
Jérôme Duval
901c3d44b0 pthread: implement pthread_attr_[get|set]stack.
remove pthread_attr_[get|set]stackaddr from unimplemented functions.

Change-Id: I58807e86c75a189a576639ae1b2e4505a63700a5
Reviewed-on: https://review.haiku-os.org/c/1152
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-07 16:55:14 +00:00
Adrien Destugues
5629675a32 sparc: add defines and minimum set of required files
Gets the stage0 bootstrap to run.
Imlementation is probably nonsense at this point.

Change-Id: I10876efbb54314b864c0ad951152757cdb2fd366
Reviewed-on: https://review.haiku-os.org/c/1061
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-02-23 16:30:50 +00:00
Alexander von Gluck IV
5ac9b50641 headers/riscv64: Fill out headers needed by buildtools
Change-Id: I131a44fbcf7b4f6471cc737cff40bd2966ec9764
2019-02-16 19:43:27 -06:00
Jérôme Duval
af61539918 posix_spawn: add POSIX_SPAWN_SETSID.
see http://austingroupbugs.net/view.php?id=1044

Change-Id: I9ae4fe07ea0fa7e20eb9a1d8c64e971e7353bcff
Reviewed-on: https://review.haiku-os.org/c/1008
Reviewed-by: Rene Gollent <rene@gollent.com>
2019-02-04 19:21:30 +00:00
Leorize
b9c25b0d0e unistd: introduce nice()
This commit implements nice() as specified in POSIX.1-2008.

Fixes #4932.

Change-Id: Ibd8d4636d9e3a8adf0f26a081d5b1180f0cbb839
Reviewed-on: https://review.haiku-os.org/c/863
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-19 18:31:58 +00:00
Timothy Gu
8ae2e95643 libroot: add [gs]etpriority implementation
Implemented against POSIX-1.2013.

The implementation POSIX requirement thats setpriority() shall affect the
priority of all system scope threads only extends to POSIX threads. This
is implemented by modifying the default attributes for newly spawned
pthreads.

It is not possible to modify the default pthread attributes for different
processes with the current implementation, as default pthread attributes
are implemented in user-space. As a result, PRIO_PROCESS for which and 0
for who is the only supported combination for setpriority().

While it is possible to move the default attributes to the kernel, it
is chosen not to so as to keep the pthread implementation user-space only.

POSIX requires that lowering the nice value (increasing priority) can be
done only by processes with appropriate privileges. However, as Haiku
currently doesn't harbor any restrictions in setting the thread priority,
this is not implemented.

It is possible to have small precision errors when converting from Unix-
style thread priority to Be-style. For example, the following program
outputs "17" instead of the expected "18":

	#include <stdio.h>
	#include <sys/resource.h>

	int
	main()
	{
		setpriority(PRIO_PROCESS, 0, 18);
		printf("%d\n", getpriority(PRIO_PROCESS, 0));
		return 0;
	}

The underlying reason is because when you setpriority() both 18 and 19
are converted to the Be-style "2". This problem should not happen with
priority levels lower than or equal to 20, when the Be notation is more
precise than the Unix-style.

Done as a part of GCI 2014. Fixes #2817.

Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Co-authored-by: Leorize <leorize+oss@disroot.org>
Change-Id: Ie14f105b00fe8563d16b3562748e1c2e56c873a6
Reviewed-on: https://review.haiku-os.org/c/78
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-19 18:31:58 +00:00
Nathan Sashihara
247414814e Fix IN6_IS_ADDR_V4MAPPED & IN6_IS_ADDR_V4COMPAT false positives
Change-Id: I71af73718667b800c416e47203f8b9924a1096c4
Reviewed-on: https://review.haiku-os.org/733
Reviewed-by: Rene Gollent <rene@gollent.com>
2018-11-27 02:43:53 +00:00
Leorize
3074920054 posix/pthread.h: mark pthread_exit as noreturn
This should prevents GCC from throwing -Werror=return-type when
pthread_exit is used in place of return

Change-Id: Ied7da58b671e77b53d859b67193259aa78ec27d6
Reviewed-on: https://review.haiku-os.org/632
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-10-17 19:23:17 +00:00