Commit Graph
100 Commits
Author SHA1 Message Date
Augustin Cavalier 9df77ea390 libroot: Make glibc use our math.h.
Only a few definitions (and some "hacks", to force glibc to
use __builtin_* where possible) that are not in our math.h
remain. This cuts out a lot more of the "bits" headers.

No "functional" change intended (but should help
fix the build on arches where we do not include
__fpclassify, etc. anymore.)
2020-01-18 23:44:37 -05:00
Augustin Cavalier 9e419c3092 libroot: Avoid glibc-internal math function usage in printf.
There's no reason for this, and we'd like to not export
these functions anymore (under non-x86/x86_64), so just use
the public macros.
2020-01-18 23:42:03 -05:00
Augustin Cavalier aee487519d libroot: Remove "string" directory.
The endian.hs can also go away and use our own.
No functional change intended.
2020-01-18 20:26:39 -05:00
Augustin Cavalier aa1e42a332 libroot: Replace swab() with the musl version.
This was the last function remaining in the glibc "string" directory,
so now we can remove that directory and a bunch of related files
that are no longer needed.
2020-01-18 20:26:05 -05:00
Augustin Cavalier f19586ee86 libroot: Drop a lot of glibc-internal headers that are not needed.
No functional change intended.
2020-01-18 19:17:43 -05:00
Augustin Cavalier bef1585217 Mail: Fix build following realloc() fix. 2020-01-18 18:50:23 -05:00
Augustin Cavalier f504f61099 libroot: Replace most of libm with musl's.
The glibc libm code was showing its age, and has recently been
the subject of a number of tickets about its inaccuracy.
Additionally, some developers have complained about
how convoluted the headers are, and thus how hard it is
to add support for new architectures (and how flaky
the support for the existing architectures is.)

So, with this commit, nearly the entire glibc libm has been
gutted and replaced with the one from musl 1.1.24.

The complex functions from glibc are retained (as they
are more mature than musl's), as are some glibc-internal
libm functions.

This also has the advantage that these functions are
actually using our <math.h>, whereas GCC used its own,
which was rather dangerous for obvious reasons.

Additionally, the new math functions are always compiled
with GCC 8 (even on x86_gcc2), as it seems GCC 2 does
not quite understand some of the union-aliasing they
use (a lot of which was added in C99, I suppose.)
FFmpeg on x86_gcc2 is already compiled with GCC 8
and that has so far worked out well, so there should
not be any problems caused by this.

I did verify that ARM and PPC at least still compile,
though other architectures may require a bit more work
(they are not bootstrapped so I could not do much.)

Should fix #14933 among other issues.

Change-Id: Ifeea0ddab23a8d0480fc26dece1b0192afc263bd
2020-01-18 18:10:31 -05: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 <[email protected]>
2020-01-06 07:44:30 +00:00
Augustin Cavalier a1e74397a1 build: Rework gcc2 test_app_server build logic a bit. 2020-01-05 17:17:41 -05:00
Augustin Cavalier d927a11fff Revert "x86_64: use a working implementation of atan2"
This reverts commit 230ade30261a44cd02ed689a34b953406d0cc677.i

This just causes applications that call atan2 to crash. So, clearly,
it is not working.
2020-01-04 15:51:02 -05: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
Augustin Cavalier 726445b72e XHCI: Clean up TRACE() statements. 2019-12-31 20:42:15 -05:00
Augustin Cavalier 0981cb8686 XHCI: Rework TRB size handling.
There is a section of the spec that dictates how TRBs need to be
sized within a TD, and we were not following that. This should
bring us into compliance.

See inline comments for more details.
2019-12-31 17:52:02 -05:00
Augustin Cavalier 84fc83275d XHCI: Update all references from the specification 1.1 to 1.2.
Only comments changed, no functional.
2019-12-31 17:52:02 -05:00
Augustin Cavalier c9606abe0c boot_loader: Add an error message to the "Continue booting" item.
This way, when it is disabled, at least there will be an error
message giving some indication of what has gone wrong.
2019-12-30 19:07:21 -05:00
Augustin Cavalier 94d36145df mount_server: Remove the scary warning for BFS partitions.
Even if we are still not so sure about the veracity of other
filesystem drivers, the BFS driver has had no reported corruption
bugs for quite some time (almost 2 years I think). In fact the
only real corruption issues heard of recently are from KDLs,
which are also a vanishing issue.

So, disabling the warning entirely for BFS partitions probably makes
sense at this point.

Change-Id: I5470c956d57b90ea00b647bf15299ba606ba01c4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1822
Reviewed-by: waddlesplash <[email protected]>
2019-12-27 23:04:54 +00:00
Augustin Cavalier 978182e00a sis19x: Add szharski to the copyright header.
He wrote the original version of haiku_sge_get_mac_addr_apc.
2019-12-25 19:01:50 -05:00
Augustin Cavalier ca869f7df6 sis19x: Add glue mechanism for get_mac_addr_apc.
The PCI enumeration functions are not implemented in the compat layer,
so we need a glue function that performs the Haiku equivalent here.
This code existed in the old Haiku-native driver, so it's just
copied from there.
2019-12-23 16:34:45 -05:00
Augustin Cavalier 21a5c628fb XHCI: Add buffer count to "unable to allocate" trace, fix freeing.
FreeDescriptor needs to know buffer_size and buffer_count,
so we have to initialize these for the fail-exit case to work.
2019-12-23 15:32:26 -05:00
Augustin Cavalier 93904285cf USB: Add overall timeout to the PhysicalMemoryAllocator.
The within-an-attempt timeout did not successfully break up
deadlocks that occur on a system with a lot of USB transfers
going, as we may never hit 2 seconds in between wake-ups,
but the size requested may be un-fulfillable regardless.

So, now we have a 2-second overall timeout. This fixes
the system freeze in #15569, but now attached USB disk
drives enter a Stall state, making the system unusable
anyway.
2019-12-23 15:31:34 -05:00
Augustin Cavalier a77769a549 USB: Rework the PhysicalMemoryAllocator to use MutexLocker.
No functional change, but will make some subsequent
changes easier and more fail-proof.
2019-12-23 15:29:43 -05:00
Augustin Cavalier 006add310a boot_loader: Fix initializing old package volume states.
In hrev53370, leavengood refactored this function out of
PackageVolumeInfo::SetTo(). Inside that function, there
is a "state" variable which is initialized to the first,
default state, which is always the head state.

Refactoring it out of there and changing this to NULL meant
that GetNext would always return a NULL state, so the
states would never be initialized, and booting from an
old state would thus not be possible.

Fixes #15380.
2019-12-23 14:25:02 -05:00
Augustin Cavalier 470db787dc BuildFeatures: Remove the gnuefi build feature.
Now unused since the switch to the Fuchsia EFI headers.
2019-12-23 12:38:47 -05:00
Augustin Cavalier 6302cfeda2 sis19x: Replace native driver with the one from FreeBSD 12.
As per #15550, it seems the native driver does not work and causes
the system to lock up. Hopefully the FreeBSD driver will fare better.
2019-12-16 18:43:10 -05:00
Augustin Cavalier caef66c2cd freebsd_network: Return to allocating the segments in dmamap_load.
It seems some drivers do not create dmamaps for all their bustags,
so we can't allocate the segments there. And of course, some also
do not go through dmamem_alloc, so the only option then is to revert
to where FreeBSD allocates them, inside dmamap_load.
2019-12-03 17:52:23 -05:00
waddlesplash 7100b1e1f5 freebsd_network: Move segment array allocation in bus_dma to dmamap_create().
It seems that some drivers (e.g. broadcom43xx) create a parent DMA tag
with nsegments set to BUS_SPACE_UNRESTRICTED, i.e. MAX_INT, which of
course fails allocation, expecting to never allocate memory for this
tag, only for child tags. So in order to handle this, we have to
delay allocating the segment array until we are certain that the nsegments
value is the "real deal".

Doing it in dmamap_load would be fine, but as there is more than one
entry point to that, we would have to allocate this in multiple places.
dmamap_create() must be called and there is only one way through it,
so put the allocation there.

Fixes #15500 (i.e. both the KDL and the underlying problem that
led to it; it only crashed because the wrong pointer was passed
to kernel_free, whoops.)
2019-12-02 20:37:52 -05:00
Augustin Cavalier 5de2f989bc Network: Remove TODO and "(---)" in device interface display view.
The current network is already displayed in the next field, so
displaying it here would be redundant.
2019-11-23 19:25:00 -05:00
Augustin Cavalier a3dc96a3a2 freebsd_network: Use ifmedia_baudrate to compute the link speed.
This is much more accurate than testing only 2 IFM_* types.
2019-11-23 16:28:40 -05:00
Augustin Cavalier 12ca36741e kernel/port: Do not leave the main port pointer in the local scope.
Only the reference. No functional change intended.
2019-11-23 16:02:16 -05:00
Augustin Cavalier 072b9ed0ac kernel/port: Properly release the first reference to the Port object.
Creating a BReferenceable sets its reference count to 1.
create_port() was then acquiring 2 references for the two lists
it inserts the port object into, and subsequently delete_port()
releases those.

But that "reference 0" never was released anywhere, and so
despite being removed from hashes, etc. port objects were
just leaked, along with whatever messages remained in their
queue, never to be freed. This of course can add up pretty
quickly in systems that created and deleted ports frequently,
for instance, in long-running media playback, opening/closing
applications, etc.

As far as I can tell, this bug was introduced in the fix to
#8007 (7f64b301b1), which introduced
the ref-counting system to the port heap, so it has been with us
since 2013 (!).

Fixes #15489, and probably some of the other "media playback
memory leak" tickets.
2019-11-23 15:13:24 -05:00
Augustin Cavalier 057719ef90 kernel/port: Handle mutex_lock returning an error status code.
This can occur if the mutex in question is destroyed while
we are waiting for it.
2019-11-23 15:08:27 -05:00
Augustin Cavalier 3c47c28a67 kernel/port: Let the mutex take care of cloning the name.
This way, we can just call mutex_destroy to take care of
freeing it. No functional change intended.
2019-11-23 14:05:17 -05:00
Augustin Cavalier 0bf9e7cb16 bfs: Use StackOrHeapArray in Journal::_WriteTransactionToLog().
The number of iovecs is usually < 8 (64 bytes), so this avoids
a lot of unnecessary heap traffic. Plus, we don't have to call
free() manually anymore.
2019-11-23 12:58:06 -05:00
Augustin Cavalier cb29eafe25 headers/build: Replace StackOrHeapArray with a reference to the main one.
The files were identical. No functional change.
2019-11-23 12:57:03 -05:00
Augustin Cavalier 26b95c15f2 freebsd_network: Completely overhaul bus_dma implementation.
The old implementation was based on an ancient copy of the FreeBSD
busdma code for x86, and did not make a bunch of assumptions that
we make basically everywhere else (for instance, that we can request
arbitrarily-aligned contiguous physical memory from the VM.)

As a consequence, it had a significant amount of code devoted to
bounce pages, which are just a waste of resources on x86, and
for that matter, probably any other architecture Haiku will ever
be ported to. (Even if we do need to run on some system where
only a small portion of system memory can be accessed by devices,
likely we would reserve that memory for just this occasion anyway.)

I was initially under the impression that the bounce-pages code
never turned on, but apparently due to the "alignment" check
(and also the "Maxmem" check, which was to defined to 32KB...?!)
it does indeed activate on a variety of systems, and maybe
(in the case of drivers that do not call sync() properly) even
is the cause of some of our ported driver breakage.

The new implementation is pretty much optimized for Haiku,
and shares almost no code or structure with the old one (save
for a few functions that really only have one proper implementation.)

Tested with ipro1000 and rtl81xx. Regressions are more than possible,
so please don't hesitate to file bugs if your network driver now
fails to come up (or you get KDLs.)
2019-11-22 22:19:43 -05:00
Augustin Cavalier 56cb682b80 freebsd_network: Moderate reorganization.
* Rename device.c to device_hooks.c, as this is what it really contains.
 * Rename compat.c to device.c, as it implements the generic "device"
   related functions, both for compat layer internals and FreeBSD
   public ones.
 * Move malloc and related operations out of the now-device.c,
   and place them in a new "malloc.cpp", which also incorporates
   compat_cpp.cpp.

No functional change intended.
2019-11-22 22:19:43 -05:00
Augustin Cavalier 5fb44dff84 Revert "btrfs: update superblock checksum on write"
This reverts commit caf05af5dd.
2019-10-26 17:48:11 -04:00
Augustin Cavalier c903bc728b freebsd_iflib: Fix usage of kobj_lookup_method.
Should solve #15441. We should probably enable -Werror=incompatible-ptr
globally to avoid this in the future...
2019-10-23 21:11:42 -04:00
Augustin Cavalier e29b7dd85a intel_extreme: Fix TRACE macro format. 2019-10-19 13:26:39 -04:00
Augustin Cavalier a26a21a5a7 usb_hid: Use user_memcpy in JoystickProtocolHandler::Read().
Also use a MutexLocker object, and fix a potential race around
fCurrentValues.data_size.

Fixes #15404.
2019-10-19 13:12:47 -04:00
Augustin Cavalier 09fafe4c95 ipro1000: Add a missing NULL check.
May help with #15402.
2019-10-19 12:57:27 -04:00
Augustin Cavalier 91cc452e90 kernel/fs: Add missing IS_USER_ADDRESS check in user_vector_io.
This reinstates commit 2b5ebfcfd5.

According to the POSIX specification, a NULL iov_base means
"do nothing." So we should treat that as such properly,
and not consider it an invalid address.

Fixes #15356.
2019-10-19 12:42:32 -04:00
waddlesplash fb8915c671 freebsd_iflib: Also NULL-check ctx. 2019-10-10 20:32:57 -04:00
Augustin Cavalier 8af29cccf5 freebsd_iflib: Add NULL check to irq_free.
Should fix #15402.
2019-10-09 20:57:00 -04:00
Augustin Cavalier e89efea747 ipro1000: Synchronize with FreeBSD trunk.
Up through Sep. 20th (yesterday.) Includes changes around IGB
device initialization.
2019-09-21 18:45:06 -04:00
Augustin Cavalier 6ad99cdddf freebsd_iflib: Synchronize with FreeBSD trunk.
Up through Sep. 20th (yesterday.) Includes some pretty substantial
fixes around MSI interrupts, among other things.
2019-09-21 18:38:35 -04:00
Augustin Cavalier 453027c1c3 kernel/scheduler: Add missing initializations to ThreadData::_InitBase().
fQuantumStart and fLastInterruptTime were not set to 0 here, so they
would default to the "malloc-cleared" data and then always overflow
the first time the interrupt time was tracked. I can't find any
reason that was supposed to be the behavior, so just set them to 0.

Also reorder the field initializations to be the same as the class
definition, which should allow some store merging optimizations.

Spotted by KUBSAN.
2019-09-21 16:30:43 -04:00
Augustin Cavalier e6ee730269 kernel/disk_device_manager: Use addr_t in UserDataWriter.
This code was not touched since 2005, and even then, that was just
a file rename. So it seems it simply predates addr_t.
2019-09-21 16:13:51 -04:00
Augustin Cavalier 0af21102ef kernel: Fix compiling the debug heap on x86_64. 2019-09-21 14:59:52 -04:00
Augustin Cavalier d46af3075e app_server: Catch drawing (AGG) allocation exceptions.
Since _DispatchViewDrawingMessage sends single B_ERROR replies
in a number of generic cases, doing so here is probably fine;
it's much better than crashing, anyway.

This is the generalized case of PulkoMandy's earlier patch,
which only applied to one drawing operation. This now affects
all AGG calls.

Change-Id: I751439e43cc300b964ac4cf41c48c1df30baf0a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1863
Reviewed-by: Stephan Aßmus <[email protected]>
2019-09-14 17:25:58 +00:00
Augustin Cavalier 7ba58efd3a Installer: Skip block, character, FIFO, and socket devices/files.
Fixes #15019.
2019-09-14 00:40:30 -04:00
Augustin Cavalier b9fc38d9a4 kernel/fs: Automatically tail syslog on "no boot partitions".
The real reason none were found is likely in the syslog.
Even if the last 15 messages do not have the real error, they
may be enough to point towards what the problem is, or at least
uniquely identify the issue.

Fixes #15348.
2019-09-14 00:26:58 -04:00
Augustin Cavalier 2b5ebfcfd5 kernel/fs: Add missing IS_USER_ADDRESS check in user_vector_io.
The iovecs themselves were checked before they were copied,
but the iov_base inside each was not, making it possible
for evil (or just broken) user applications to put kernel
addresses in here.

Part of #14961.
2019-09-13 22:11:27 -04:00
Augustin Cavalier e315daa9c1 kernel/thread: Clarify permissions checking logic.
No functional change intended; but if I missed a case,
it will now be caught by the "return false" instead of
the "return true", which is a better default.
2019-09-13 22:10:23 -04:00
Augustin Cavalier 750b43405a kernel/device_manager: Add NULL checks before function calls.
Fixes #15175.
2019-09-13 22:09:53 -04:00
Augustin Cavalier 48a00c0f66 acpi: Support namespace reads into user addresses.
Fixes #15176.
2019-09-13 22:03:10 -04:00
Augustin Cavalier cf344027f8 kernel: Add padding in mutex fields for equivalent KDEBUG/non-KDEBUG sizing.
Non-KDEBUG kernels and kernel add-ons use atomic operations to acquire
and release the locks inline, so non-KDEBUG kernels/addons are only
compatible with other non-KDEBUG kernels/addons.

Following this change, though, KDEBUG kernels/addons should be able
to run under non-KDEBUG kernels/addons, too, since they always call
into the actual kernel functions and do not inline anything of
consequence.
2019-09-13 22:02:52 -04:00
Augustin Cavalier 19e017cb13 XHCI: Clarify a comment.
No functional change.
2019-09-13 21:32:58 -04:00
Augustin Cavalier a310e5e52f kernel/fs: Continue even if InitialDeviceScan returns an error.
See inline comment. Should fix #15330.
2019-09-09 20:51:58 -04:00
Augustin Cavalier 598b8e19a2 kernel/disk_device_manager: Continue scanning after invalid partitions.
As the inline comment notes, just because we could not scan one
partition does not mean we won't be able to scan the following ones.
This fixes scanning for disks on certain systems following axeld's
change in 7c2135591b.

Part of #15330.
2019-09-09 20:50:54 -04:00
Augustin Cavalier 1bdffaf427 kernel/fs: Only dump devices and partitions under KDEBUG.
Avoids a lot of noise in release kernel syslogs.
2019-09-09 20:46:45 -04:00
Augustin Cavalier 4ee6978ed7 BFS: Only compile with -O1 under GCC2.
GCC7+ does not have whatever compiler bugs plague GCC2, so we can
use -O2 there as usual.
2019-09-09 20:30:47 -04:00
Augustin Cavalier 75d2b89f76 Terminal: Fix GCC2 build. 2019-09-07 15:11:46 -04:00
Augustin Cavalier 3a3d6c4ae2 kernel/x86: Check the frame address really is a user address before copying.
On x86_64, it is possible for a frame address to be in non-canonical
form (i.e. have bits 48-63 not all zero) if one writes hand-generated
assembly which does not use registers for their intended purpose, as
there is no processor requirement about the contents of those registers
or stack portions except when using "ret" or similar such instructions.

As it turns out, OpenSSL's libcrypto has such hand-generated assembly
for cryptography routines; so on 64-bit this caused a GPE when running
the profiler on applications that used OpenSSL.

Fixes #14530.
2019-09-02 22:06:22 -04:00
Augustin Cavalier a785ea4b3a kernel: Fix logic inversion in FileDevice.
Apparently nobody ever got here in SMAP mode; otherwise this would
have caused a KDL...
2019-09-02 22:00:57 -04:00
Augustin Cavalier 81b9fd211f mount_server: Remove the scary warning for BFS partitions.
Even if we are still not so sure about the veracity of other
filesystem drivers, the BFS driver has had no reported corruption
bugs for quite some time (almost 2 years I think). In fact the
only real corruption issues heard of recently are from KDLs,
which are also a vanishing issue.

So, disabling the warning entirely for BFS partitions probably makes
sense at this point.
2019-09-02 20:59:07 -04:00
Augustin Cavalier 13249ba056 ramfs: Fix dereference before NULL check in _DoCacheIO.
Should fix a KDL extrowerk ran into.
2019-09-02 15:09:40 -04:00
Augustin Cavalier 8e8897315f ramfs: Return the number of free pages, not available ones. 2019-09-02 13:14:07 -04:00
Augustin Cavalier 0f7252ab76 ramfs: Remove unused SLList.h. 2019-09-02 12:49:26 -04:00
Augustin Cavalier 763047bfb1 NTFS: Merge changes to the utils from upstream. 2019-09-01 00:17:10 -04:00
Augustin Cavalier 29536b4c4b Mail: Don't use strtok.
That seems like a bad idea...
2019-08-31 23:01:51 -04:00
Augustin Cavalier 58a582ff22 ramfs: Set the vnode's cache object when opening files.
Now it is possible to run applications, do Git checkouts, etc.
on a ramfs (and those seem to work just fine -- a git checkout
followed by a git fsck both succeeded.)
2019-08-31 20:38:19 -04:00
Augustin Cavalier a9be0efb2e kernel/fs: Add support for setting custom VMCaches in vnodes.
This adds one (private) VFS function, and checks in all usages of
the vnode->cache as a VMVnodeCache that it really is one. (Generic
usages, for the moment just the ReleaseRef() calls in vnode
destruction, are intentionally not touched.)

This will be used by ramfs to set the cache from its own,
so that map_file() calls on a ramfs can work.
2019-08-31 20:38:18 -04:00
Augustin Cavalier 69c34116f0 ram_disk: Add note about code duplication with ramfs. 2019-08-31 20:38:18 -04:00
Augustin Cavalier 181d68fbd4 ramfs: GCC 2 fixes. 2019-08-31 20:38:18 -04:00
Augustin Cavalier d2ab19b331 ramfs: Drop now-unused Block* classes. 2019-08-31 20:38:18 -04:00
Augustin Cavalier cbc0726819 ramfs: Overhaul block allocation to use a VMCache and physical pages.
This is a massive efficiency improvement as well as a large address
space usage savings. It also paves the way for file_map() support...
2019-08-31 20:38:18 -04:00
Augustin Cavalier c8f0cc1afa ramfs: Fix bool/status mixup in DirectoryEntryTable.
Now you can actually delete files again.
2019-08-31 20:38:18 -04:00
Augustin Cavalier 677fca26d7 ramfs: Remove the Attribute::GetKey overload that accepts a ptr-ptr.
This only works because DataCollector stores its data in blocks
which are mapped into the kernel's address space. After the
next series of commits, it won't, so we can't depend on that.

This required some changes to the indexes to keep a copy of the
keys.
2019-08-31 20:38:18 -04:00
Augustin Cavalier 6d244f23b8 ramfs: Use rw_lock instead of recursive_lock for r/w locking.
Also use recursive_lock directly instead of the userlandfs shim class.
2019-08-31 20:38:18 -04:00
Augustin Cavalier 91c8637753 ramfs: Drop OpenTracker OpenHashTable and the custom AreaUtils.
Following removal of NodeChildTable, they aren't used.
2019-08-31 12:28:09 -04:00
Augustin Cavalier e583221270 ramfs: Replace the NodeChildTable with a DirectoryEntryTable.
Now that Attributes don't use a table, we can replace the generic
system with a specific DirectoryEntryTable, upgrading to BOpenHashTable
in the process.
2019-08-31 12:28:09 -04:00
Augustin Cavalier 019d327dce ramfs: Just use the linked list for attributes instead of a hash table.
This is what packagefs does; so if it's performant enough for packagefs,
it's performant enough for us. Greatly simplifies this code (and will
allow for further simplification of the NodeChildHash.)
2019-08-31 12:28:09 -04:00
Augustin Cavalier 565c58a527 ramfs: Adapt NodeTable to use BOpenHashTable. 2019-08-31 12:28:09 -04:00
Augustin Cavalier 349ab0050a ramfs: Fix miscellaneous warnings. 2019-08-30 20:53:29 -04:00
Augustin Cavalier 2914364270 ramfs: Fix debugging print macro invocations and use B_PRI*. 2019-08-30 20:53:15 -04:00
Augustin Cavalier b2c20927e8 ramfs: Fix setting the ops and an incorrect node cast.
And now ramfs works!
2019-08-30 20:31:40 -04:00
Augustin Cavalier c3e0275cc5 ramfs: Adapt to current kernel FS APIs and fully fix the build. 2019-08-30 19:54:54 -04:00
Augustin Cavalier b9795faf5d ramfs: Add MIT license header to all files lacking copyright info.
OK'ed by Ingo via email.
2019-08-30 18:48:11 -04:00
Augustin Cavalier 731be7dde1 Relicense all of Ingo's BSD/MIT+advertising clause'd code as plain MIT.
Via email:
> I'm fine with re-licensing all code using BSD license + advertising
> clause to MIT license.
2019-08-30 18:27:35 -04:00
Augustin Cavalier 47a21c5c89 s/Haiku License/MIT License/g.
They are the same thing.
2019-08-30 18:16:02 -04:00
Augustin Cavalier 128781e740 build/jam: Inline HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR where possible.
The "exec" tool can only handle one command with environs set at
the beginning of the line, so now we set the ADD_BUILD_COMPAT...
in this format. This also seems to be a general performance
improvement to builds using real shells, too.

Change-Id: If4b3117651b5475039d5e8116cd3de398582290a
2019-08-30 17:11:50 -04:00
Augustin Cavalier 12eb0e5d89 libroot: Add a private __look_up_in_path function.
Refactored out of execvpe. Originally I did this for my attempted
change to posix_spawn, but that change turned out to be wrong and
actually not that beneficial. This bit seems potentially useful,
though, so here it is.
2019-08-30 16:24:09 -04:00
Augustin Cavalier 852cf6de56 tests: Correct includes ordering.
Spotted by korli.
2019-08-30 16:16:10 -04:00
Augustin Cavalier 06f4ddb09c nvme_disk: Add missing cast to off_t.
Should fix the 64-bit build.
2019-08-28 23:36:52 -04:00
Augustin Cavalier cca88a8133 tools/exec: Implement basic environment overrides.
VAL=xxx... and VAL=$VAL:xxx... are supported; all other syntaxes
will fail with an error message.

When combined with a build/jam patch that will come in a later
commit, this makes it possible to build a large number of targets
using exec as JAMSHELL; including all of libroot. The performance
difference is extremely obvious:

jam -j2 libroot, JAMSHELL=/bin/sh (32-bit Haiku)
real 1m43.571s
user 1m10.961s
sys  1m7.965s

jam -j2 libroot, JAMSHELL=exec
real 1m28.364s
user 0m58.190s
sys  0m57.563s

So that is a savings of 15.21 seconds, or 15% of the build time.
Something that is less I/O bound and more fork-bound (e.g.
linking application catalogs) will almost certainly see
an even bigger performance difference.

Changes to add the necessary JAMSHELL overrides for those
targets which need it, in order to make it possible to
enable usage of "exec" by default, will be coming
over the next few days/weeks...
2019-08-28 22:56:43 -04:00
Augustin Cavalier 3cfe881d88 OverriddenJamRules: Remove an unneeded and erroneous ";" 2019-08-28 22:52:22 -04:00
Augustin Cavalier b9b6a688e3 tools/exec: Exit with an error upon attempting to run multiple commands.
This way, things that need a real shell will be more clear.
2019-08-28 21:17:20 -04:00
Augustin Cavalier a5f58aba57 tools: Add an "exec" tool.
This utility takes command-strings, e.g. "gcc -c file.c -D...",
parses them into an argv, and then execvp()s that. The use-case
is Jam, which cannot do this itself, but instead simply calls
JAMSHELL (usually just "/bin/sh -c") to do that for it.

Shells in general have a large amount of overhead (and bash in
particular is especially bad here), so using a utility like this
as JAMSHELL in most cases can be a significant speed-up.

For example, on Haiku (32-bit):

$ time sh -c 'for i in {1..100}; do sh -c "./exec test"; done'
real    0m3.335s
user    0m1.603s
sys     0m1.612s

$ time sh -c 'for i in {1..100}; do ./exec test; done'
real    0m1.547s
user    0m0.597s
sys     0m0.867s

So this means for every 100 executions, using bash has about 3.3s of
overhead, and this tool cuts out over half of that. Probably for
longer command strings, the overhead is significantly greater.
But that should be clear soon enough...
2019-08-28 20:18:59 -04:00
Augustin Cavalier 43895d3147 nvme_disk: Better protection against underflows.
This was using unsigned integer math and then trying to clamp to 0.
That won't work. Use off_t instead, which is an int64 and thus signed.
May fix behavior in some stranger error conditions.

While I'm at it, avoid reading in the beginning partial block
if we don't need to.
2019-08-27 23:44:35 -04:00