Commit Graph

639 Commits

Author SHA1 Message Date
Andrew Aldridge a735975461 Sync atheros813x with FreeBSD
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #12328.
Fixed a style error (2 lines between functions).
2017-01-22 09:20:01 +01:00
Dmytro Shynkevych 0e0f49e799 libroot: Implemented pthread barriers
This is an implementation of pthread barriers pursuant to the relevant specification.

Barriers are essentially a special case of conditional variables,
such that all threads waiting on one are woken up when the number of
waiters reaches a number provided at the initialization of the barrier.
In view of that, this implementation mimics the implementation of pthread_cond,
except it is more specialized and self-contained.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2016-12-30 11:32:04 +01:00
Jérôme Duval e25f993385 complex.h: add a C++ guard. 2016-10-05 09:18:42 +02:00
Adrien Destugues 6980817672 Remove pthread.h include from netdb.h
- It is not needed in the .h, and makes gawk build fail.
2016-08-27 09:04:22 +02:00
François Revol 47a20cd6d1 M68K: turn #warnings into comments in public headers
The warnings made those headers and those including them not detectable
by libiberty's configure because of the way it checked for them.

This fixes the gcc build.
2016-07-20 20:26:29 +02:00
Adrien Destugues 93ea83e53d Allow custom baud rates for FTDI serial ports
- Termios: cf{get,set}{i,o}speed can handle arbitrary speed values.
- The value is stored in the appropriate fields of the termios structure
  in this case. The old constants (stored in the flags) are preserved
  for BeOS binary compatibility.
- Adjust the FTDI FT232* driver to accept custom rates, by replacing the
  hardcoded regster values with a function that will compute it
  according to FTDI documentation (confirmed giving the same values for
  the existing baudrates).
2016-02-27 19:08:53 +01:00
Augustin Cavalier 6984b8554c Revert "libroot: Undefine constants for unsupported POSIX features"
This reverts commit 7aebec8db1.
As per the discussion on the mailing list.
2015-12-21 12:16:33 -05:00
Simon South 7aebec8db1 libroot: Undefine constants for unsupported POSIX features
Haiku does not yet support certain features related to POSIX threads.
Constants used to test for the presence of these features should
therefore be left undefined, according to the POSIX spec, but are
currently set to -1. This can cause software built on Haiku to
incorrectly detect the presence of these features.

* unistd.h: Undefine _POSIX_THREAD_ATTR_STACKADDR,
  _POSIX_THREAD_PRIORITY_SCHEDULING feature constants.
* conf.cpp: __sysconf: Return -1 for unsupported features.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-21 11:09:34 -05:00
Simon South dbf060a3f7 libroot: Add brk() and sbrk().
This commit replaces the placeholder implementation of sbrk(), which
operated on a process' heap, with real implementations of brk() and
sbrk() that adjust a process' program break.

* unistd.h: Add standard definitions of brk() and sbrk(); include
  stdint.h for intptr_t.
* thread.cpp: Recognize RLIMIT_AS and RLIMIT_DATA resource limits
  (both currently unlimited); order limit identifiers alphabetically.
* arch-specific.cpp: Remove sbrk_hook().
* malloc_debug_api.cpp: Remove sbrk_hook().
* unistd/Jamfile: Build brk.c instead of sbrk.c.
* unistd/brk.c: Add.
* unistd/sbrk.c: Delete (placeholder implementation).
* libroot_stubs.c: Remove sbrk_hook().
* libroot_stubs_legacy.c: Remove sbrk_hook().
* src/tests/.../posix/Jamfile: Build brk_test.c.
* brk_test.c: Add (simple unit test that demonstrates behaviour of
  sbrk()).

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2015-11-22 17:59:22 +01:00
Adrien Destugues 75d1eb3a59 assert.h: reintroduce headers guard for function declarations.
The POSIX standard requires us to allow assert.h to be included multiple
times with differnt values of NDEBUG. So we can't have a global header
guard on the files. However, we must also make sure that we don't
declare functions multiple times in that case. Re-introduce an header
guard on the part of the file where we declare functions, only.

Fixes lots of warnings when building Netsurf.
2015-08-29 23:14:03 +02:00
Axel Dörfler 34671d601a Added execvpe().
* This closes #12114 again; while not POSIX, it's just a line away.
* Removed exect() from the header -- not sure where this came from.
  but I can't find anything about it on the net.
* Consolidated use of asterisk style in exec.cpp.
2015-07-23 13:30:30 +02:00
Jérôme Duval a83446983d libroot: added a complex.h header based on ...
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/complex.h.html
* added missing parts from glibc.
* x86_64 was already complete, x86 was missing a few functions.
* should help with #12202, provided that the gcc4 buildtools are rebuilt.
2015-07-10 22:39:21 +02:00
Adrien Destugues 50440c4220 Remove gethostbyname_r and gethostbyaddr_r from headers
* They were not in BeOS.
* They are also not in netresolv, they are deprecated and getaddrinfo
should be used.
2015-06-17 21:30:02 +02:00
Adrien Destugues 8d2aee6bc8 libbind: integrate "netresolv" patches from NetBSD.
libbind development was transferred to the NetBSD project at
http://wiki.netbsd.org/individual-software-releases/netresolv/

There isn't an official release yet, but they provide a set of patches
against the latest libbind release.

* Remove all files we don't use
* Merge the changes to the remaining files
* Add some new files we need
* Move getifaddrs implementation to libnetwork (instead of libbnetapi)
so it can be used by netresolv.

Fixes #8293 : netresolv uses getifaddrs to determine if there is a local
IPv6 address. If there is not, it will not return AAAA records.
2015-06-14 15:47:03 +02:00
Jérôme Duval 0dc6b011fe malloc: implement malloc_usable_size().
* Fix #12132
2015-06-13 14:29:11 +02:00
Adrien Destugues 4b2d018be4 Implement MSG_NOSIGNAL
* Part of latest POSIX specification, this prevents send() on a closed
socket to raise a SIGPIPE signal (but EPIPE is returned).
2015-06-10 17:39:53 +02:00
Hamish Morrison d6d439f3f7 Reimplement unnamed POSIX semaphores using user_mutex
* Fixes sharing semantics, so non-shared semaphores in non-shared
  memory do not become shared after a fork.
* Adds two new system calls: _user_mutex_sem_acquire/release(),
  which reuse the user_mutex address-hashed wait mechanism.
* Named semaphores continue to use traditional sem_id semaphores.
2015-05-24 14:03:40 +01:00
François Revol 54656b39c6 stdio.h: declare fcloseall() GNU extension
Since libroot already exports it and I've found some code using it.
2015-05-08 23:46:15 +02:00
Hamish Morrison 10b4fed24f Add support for pthread_condattr_get/setclock()
* Allows use of either CLOCK_REALTIME or CLOCK_MONOTONIC as the time
  base for pthread_cond_timedwait().
2015-05-02 20:55:57 +01:00
Jessica Hamilton c7ad68f08c assert.h: add comments explaining the omission of include guards 2015-04-17 07:03:40 +12:00
Jessica Hamilton 9f17027980 assert.h: remove include guards
* including assert.h multiple times with NDEBUG varying is
  perfectly legal, and required by POSIX.
2015-04-16 23:03:40 +12:00
Michael Lotz 9bf9ee3806 Whitespace and style cleanup only. 2015-04-12 18:50:01 +02:00
Michael Lotz ec0190adb0 malloc_debug: Implement allocation dump on exit in guarded heap.
When enabled (using heap_debug_dump_allocations_on_exit(true) or
MALLOC_DEBUG=e) this causes a dump of all remaining allocations when
libroot_debug is unloaded. It uses terminate_after to be called as
late as possible.

When combined with alloc stack traces this makes for a nice if a bit
crude leak checker. Note that a lot of allocations usually remain
even at that stage due to statically, lazyly and globally allocated
stuff from the various system libraries where it isn't necessarily
worth the overhead to free them when the program terminates anyway.
2015-04-10 17:04:28 +02:00
Michael Lotz 158e20e60e malloc_debug: Implement alloc/free stack traces in guarded heap.
When configured to do so (using heap_debug_set_stack_trace_depth(depth)
or MALLOC_DEBUG=s<depth>) the guarded heap now captures stack traces on
alloc and free.

A crash due to hitting a guard page or an already freed page now dumps
these stack traces. In the case of use-after-free one can therefore see
both where the allocation was done and where it was freed.

Note that there is a hardcoded maximum stack trace depth of 50 and that
the alloc stack trace takes away space from the free stack trace which
uses up the rest of that maximum.
2015-04-10 16:28:42 +02:00
Michael Lotz 121655e9ee malloc_debug: Add default alignment option.
This allows for something similar as was implemented in 217f090 but
makes it optional and configurable.

The MALLOC_DEBUG environment variable now can take "a<size>" to set
the default alignment to the specified size. Note that not all
alignments may be supported depending on the heap implementation.
2015-04-04 22:55:57 +02:00
Michael Lotz a05bfeb4a9 Whitespace cleanup only. 2015-04-04 22:55:56 +02:00
Jérôme Duval 4a9c56f6c7 x86_64: fenv.c needs __weak_reference()
* the weak symbol feenableexcept wasn't available.
2015-03-27 20:16:57 +01:00
Timothy Gu d1dc9cf655 stdint.h: use correct type for INT64_MAX (#11647)
int64_t is signed. Although it does not make a difference by itself, because
INT64_MAX is still a valid number for uint64_t (UL), the later INT64_MIN
declaration depends on INT64_MAX, and therefore got implicitly casted to
unsigned type.

This fixes the following program on a x86_64 system:

	#include <stdint.h>

	int main() {
		int64_t test = 5;
		if (test < INT64_MIN)
			return 1;
		return 0;
	}

This is a regression since commit 1d13a609 ("stdint.h: define [U]INT64[MAX|MIN]
with [U]L on x86_64").

Signed-off-by: Jerome Duval <jerome.duval@gmail.com>
2014-12-20 10:06:21 +01:00
Puck Meerburg a5f30beaad Fix #7008: Add a64l and l64a from glibc, and add some missing definitions in wchar.h and stdlib.h
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-12-14 18:06:09 +01:00
Jérôme Duval 1d13a60901 stdint.h: define [U]INT64[MAX|MIN] with [U]L on x86_64
instead of [U]LL
2014-12-14 15:55:14 +01:00
François Revol 12533060d0 stdio.h: add missing typedefs
I should sleep more and build more :D
2014-11-19 15:45:17 +01:00
François Revol e1f303c5ec Add fopencookie() to stdio.h
We already export it in libroot, and libassuan seems to require it.
2014-11-19 15:13:45 +01:00
François Revol 1436fe7448 Add TIOCM_CAR as a synonym for TIOCM_CD
Gnokii uses it.
2014-11-09 02:28:06 +01:00
Oliver Tappe b9c8e3de1b string.h: include strings.h for compatibility.
* Partly reverting hrev47655, as the moved declarations are expected
  by many ports to be accessable via string.h. 
  Following standards is a good thing in general, but not if it causes 
  more problems than it helps ...
2014-10-30 00:20:13 +01:00
Adrien Destugues 4ad7d95bac Revert "Add sys/ucontext.h"
This reverts commit 6ddf93bfbe.

As pointed out by Ingo, those were moved to sugnal.h in the latest issue
(issue 7) of the POSIX spec. Sorry!
2014-08-09 20:18:05 +02:00
Adrien Destugues 6ddf93bfbe Add sys/ucontext.h
* Move ucontext_t and mcontext_t there as that's where POSIX says they
should be.
2014-08-09 18:37:43 +02:00
Jérôme Duval 3aeed6607c include strings.h where appriopriate...
instead or additionally to string.h, in preparation for functions move.
* moves str[n]casecmp() functions and others to strings.h.
* strings.h doesn't include string.h anymore.
* this solves #10949
2014-08-08 22:40:37 +02:00
Jérôme Duval 4dc5ce8fd8 mknod[at](): moves from unistd.h to sys/stat.h
* this solves #10883.
2014-08-04 19:03:08 +02:00
François Revol 0be89c15ee tty: Add bitmask ioctls TIOCMBIS and TIOCMBIC
Equivalent to TIOCMSET + bitmask + TIOCMGET but with a single call.

Gnokii uses that.
2014-07-23 21:36:07 +02:00
Jérôme Duval 74e1a530f8 Revert unrelated part of 17aa359b5d. 2014-07-11 22:23:21 +02:00
Akshay Jaggi 17aa359b5d XHCI USB: Fixes.
* Add support for hubs in AllocateDevice().
* Prevent page fault in FinishTransfers().
* Set fCapabilityLength
* Correct in BIOS ownership code
* Fix context errors in _InsertEndpointForPipe().
* Update constants according to latest Specification (v1.1)
* Fix SMI code (reference
http://lkml.iu.edu/hypermail/linux/kernel/1204.2/02460.html).
* Fix Memory/Device-Slot leaks.
* Fix area allocation for TRBs.
* Fix for Intel Lynx Point and Panther Point chipsets. Also move init
of xhci before ehci, to switch USB 2.0 ports before the ehci module
discovers them.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-07-11 22:14:05 +02:00
Jérôme Duval 2f32fd1dde wchar.h & string.h: use _GNU_SOURCE instead of __USE_GNU. 2014-06-07 11:22:38 +02:00
Jérôme Duval a3b79608f9 search.h: fix typo.
* Thanks diger for noticing.
2014-06-07 10:54:15 +02:00
Jessica Hamilton fad4fc59f9 Revert "ByteOrder.h: remove use of __builtin_bswap16."
This reverts commit 040dc2eebc.
2014-05-30 20:39:43 +12:00
Jessica Hamilton 040dc2eebc ByteOrder.h: remove use of __builtin_bswap16.
* Fixes the build for host compilers older than gcc-4.8
2014-05-30 08:45:57 +12:00
Adrien Destugues 8d250951a3 Fix ptrdiff_t limits introduced in r24654 (!)
* The ptrdiff_t limits are PTRDIFF_MIN and PTRDIFF_MAX, not PTDIFF_*.
* I could not find any non-Haiku reference to PTDIFF_*, so I guess
that's a mistake.
2014-04-29 10:26:23 +02:00
Jérôme Duval 53dd259b4d added tar.h posix header.
* based on http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/tar.h.html
2014-04-26 11:09:24 +02:00
Jonathan Schleifer 92bd26ce8e stdio.h: Add missing *_unlocked declarations
Configure scripts would find the symbols and thus use them and assume
our headers declare them.

This fixes building gcc_bootstrap.
2014-03-09 23:08:51 +01:00
Alexander von Gluck IV 122d1cddc9 Haiku: Fix posix INT64_C macros on x86_64
* Was causing LLVM to fail to build on x86_64
* Make XINT64 adjust based on architecture like
  config/types.h to ensure these macros match
  uint64 and int64 at all times.
* Resolves #10566
2014-02-21 01:38:54 -06:00
Pawel Dziepak d0f2d8282f Merge branch 'scheduler'
Conflicts:
	build/jam/packages/Haiku
	headers/os/kernel/OS.h
	headers/os/opengl/GLRenderer.h
	headers/private/shared/cpu_type.h
	src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.h
	src/bin/sysinfo.cpp
	src/bin/top.c
	src/system/kernel/arch/x86/arch_system_info.cpp
	src/system/kernel/port.cpp
2014-01-17 04:06:15 +01:00