diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-07 17:28:52 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-07 18:24:51 -0500 |
commit | f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch) | |
tree | 93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/sysdeps/managarm/include | |
parent | bd5969fc876a10b18613302db7087ef3c40f18e1 (diff) |
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/sysdeps/managarm/include')
46 files changed, 0 insertions, 354 deletions
diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/access.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/access.h deleted file mode 120000 index cb83931..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/access.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/access.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/auxv.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/auxv.h deleted file mode 120000 index e760d62..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/auxv.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/managarm/auxv.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/blkcnt_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/blkcnt_t.h deleted file mode 120000 index 0b0ec27..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/blkcnt_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/blkcnt_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/blksize_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/blksize_t.h deleted file mode 120000 index 7dc8d7c..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/blksize_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/blksize_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/clockid_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/clockid_t.h deleted file mode 120000 index 6a42da5..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/clockid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/clockid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/dev_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/dev_t.h deleted file mode 120000 index bca881e..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/dev_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/dev_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/epoll.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/epoll.h deleted file mode 120000 index eb4b76d..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/epoll.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/epoll.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/errno.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/errno.h deleted file mode 120000 index 6e507de..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/errno.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/errno.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/fcntl.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/fcntl.h deleted file mode 120000 index 463e2c9..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/fcntl.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/fcntl.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/fsblkcnt_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/fsblkcnt_t.h deleted file mode 120000 index 898dfb2..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/fsblkcnt_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/fsblkcnt_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/fsfilcnt_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/fsfilcnt_t.h deleted file mode 120000 index 791755c..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/fsfilcnt_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/fsfilcnt_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/gid_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/gid_t.h deleted file mode 120000 index abce6d6..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/gid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/gid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/in.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/in.h deleted file mode 120000 index 418d1d5..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/in.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/in.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/ino_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/ino_t.h deleted file mode 120000 index 4c20aca..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/ino_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/ino_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/inotify.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/inotify.h deleted file mode 120000 index b5cb282..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/inotify.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/inotify.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/ioctls.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/ioctls.h deleted file mode 120000 index 595106b..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/ioctls.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/ioctls.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/limits.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/limits.h deleted file mode 120000 index 6c88db2..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/limits.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/limits.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/mode_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/mode_t.h deleted file mode 120000 index 5d78fdf..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/mode_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/mode_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/mqueue.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/mqueue.h deleted file mode 120000 index fa87b07..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/mqueue.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/mqueue.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/msg.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/msg.h deleted file mode 120000 index f402b49..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/msg.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/msg.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/nlink_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/nlink_t.h deleted file mode 120000 index bb3b625..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/nlink_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/nlink_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/packet.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/packet.h deleted file mode 120000 index 998ef1a..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/packet.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/packet.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/pid_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/pid_t.h deleted file mode 120000 index baa90f6..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/pid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/pid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/poll.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/poll.h deleted file mode 120000 index 8ea6a0a..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/poll.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/poll.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/ptrace.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/ptrace.h deleted file mode 120000 index b2517b2..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/ptrace.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/ptrace.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/reboot.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/reboot.h deleted file mode 120000 index 77013a4..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/reboot.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/reboot.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/resource.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/resource.h deleted file mode 120000 index 88d7402..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/resource.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/resource.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/seek-whence.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/seek-whence.h deleted file mode 120000 index df7bccf..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/seek-whence.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/seek-whence.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/shm.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/shm.h deleted file mode 120000 index 067d8c4..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/shm.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/shm.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/signal.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/signal.h deleted file mode 120000 index 4dcb0b7..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/signal.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/signal.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/socket.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/socket.h deleted file mode 120000 index f1dc016..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/socket.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/socket.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/socklen_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/socklen_t.h deleted file mode 120000 index 41f3b11..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/socklen_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/socklen_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/stat.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/stat.h deleted file mode 120000 index 1f63b41..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/stat.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/stat.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/statfs.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/statfs.h deleted file mode 120000 index e3d202f..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/statfs.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/statfs.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/statvfs.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/statvfs.h deleted file mode 120000 index 1fc80c2..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/statvfs.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/statvfs.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/suseconds_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/suseconds_t.h deleted file mode 120000 index 9ed6597..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/suseconds_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/suseconds_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/termios.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/termios.h deleted file mode 120000 index ee8f0b0..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/termios.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/termios.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/time.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/time.h deleted file mode 120000 index 2a02625..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/time.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/time.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/uid_t.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/uid_t.h deleted file mode 120000 index b306777..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/uid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/uid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/utsname.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/utsname.h deleted file mode 120000 index b285754..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/utsname.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/utsname.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/vm-flags.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/vm-flags.h deleted file mode 120000 index bbe258c..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/vm-flags.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/vm-flags.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/vt.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/vt.h deleted file mode 120000 index 5798a4a..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/vt.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/vt.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/wait.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/wait.h deleted file mode 120000 index feb2840..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/wait.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/wait.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/abi-bits/xattr.h b/lib/mlibc/sysdeps/managarm/include/abi-bits/xattr.h deleted file mode 120000 index 66412d7..0000000 --- a/lib/mlibc/sysdeps/managarm/include/abi-bits/xattr.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/xattr.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/managarm/include/mlibc/posix-pipe.hpp b/lib/mlibc/sysdeps/managarm/include/mlibc/posix-pipe.hpp deleted file mode 100644 index 4bcf1cb..0000000 --- a/lib/mlibc/sysdeps/managarm/include/mlibc/posix-pipe.hpp +++ /dev/null @@ -1,300 +0,0 @@ -#ifndef MLIBC_POSIX_PIPE -#define MLIBC_POSIX_PIPE - -#include <signal.h> -#include <stdint.h> -#include <string.h> -#include <cstddef> - -#include <hel.h> -#include <hel-syscalls.h> - -struct SignalGuard { - SignalGuard(); - - SignalGuard(const SignalGuard &) = delete; - - ~SignalGuard(); - - SignalGuard &operator= (const SignalGuard &) = delete; -}; - -// We need an allocator for message structs in sysdeps functions; the "normal" mlibc -// allocator cannot be used, as the sysdeps function might be called from a signal. -MemoryAllocator &getSysdepsAllocator(); - -struct Queue; - -struct ElementHandle { - friend void swap(ElementHandle &u, ElementHandle &v) { - using std::swap; - swap(u._queue, v._queue); - swap(u._n, v._n); - swap(u._data, v._data); - } - - ElementHandle() - : _queue{nullptr}, _n{-1}, _data{nullptr} { } - - ElementHandle(Queue *queue, int n, void *data) - : _queue{queue}, _n{n}, _data{data} { } - - ElementHandle(const ElementHandle &other); - - ElementHandle(ElementHandle &&other) - : ElementHandle{} { - swap(*this, other); - } - - ~ElementHandle(); - - ElementHandle &operator= (ElementHandle other) { - swap(*this, other); - return *this; - } - - void *data() { - return _data; - } - - void advance(size_t size) { - _data = reinterpret_cast<char *>(_data) + size; - } - -private: - Queue *_queue; - int _n; - void *_data; -}; - -struct Queue { - Queue() - : _handle{kHelNullHandle} { - // We do not need to protect those allocations against signals as this constructor - // is only called during library initialization. - _chunks[0] = reinterpret_cast<HelChunk *>(getSysdepsAllocator().allocate(sizeof(HelChunk) + 4096)); - _chunks[1] = reinterpret_cast<HelChunk *>(getSysdepsAllocator().allocate(sizeof(HelChunk) + 4096)); - - recreateQueue(); - } - - Queue(const Queue &) = delete; - - Queue &operator= (const Queue &) = delete; - - void recreateQueue() { - // Reset the internal queue state. - _retrieveIndex = 0; - _nextIndex = 0; - _lastProgress = 0; - - // Setup the queue header. - HelQueueParameters params { - .flags = 0, - .ringShift = 1, - .numChunks = 2, - .chunkSize = 4096 - }; - HEL_CHECK(helCreateQueue(¶ms, &_handle)); - - auto chunksOffset = (sizeof(HelQueue) + (sizeof(int) << 1) + 63) & ~size_t(63); - auto reservedPerChunk = (sizeof(HelChunk) + params.chunkSize + 63) & ~size_t(63); - auto overallSize = chunksOffset + params.numChunks * reservedPerChunk; - - void *mapping; - HEL_CHECK(helMapMemory(_handle, kHelNullHandle, nullptr, - 0, (overallSize + 0xFFF) & ~size_t(0xFFF), - kHelMapProtRead | kHelMapProtWrite, &mapping)); - - _queue = reinterpret_cast<HelQueue *>(mapping); - auto chunksPtr = reinterpret_cast<std::byte *>(mapping) + chunksOffset; - for(unsigned int i = 0; i < 2; ++i) - _chunks[i] = reinterpret_cast<HelChunk *>(chunksPtr + i * reservedPerChunk); - - // Reset and enqueue the chunks. - _chunks[0]->progressFutex = 0; - _chunks[1]->progressFutex = 0; - _refCount[0] = 1; - _refCount[1] = 1; - - _queue->indexQueue[0] = 0; - _queue->indexQueue[1] = 1; - _queue->headFutex = 0; - _nextIndex = 2; - _wakeHeadFutex(); - } - - HelHandle getQueue() { - return _handle; - } - - void trim() { } - - ElementHandle dequeueSingle() { - while(true) { - __ensure(_retrieveIndex != _nextIndex); - - bool done; - _waitProgressFutex(&done); - - auto n = _numberOf(_retrieveIndex); - __ensure(_refCount[n]); - - if(done) { - retire(n); - - _lastProgress = 0; - _retrieveIndex = ((_retrieveIndex + 1) & kHelHeadMask); - continue; - } - - // Dequeue the next element. - auto ptr = (char *)_chunks[n] + sizeof(HelChunk) + _lastProgress; - auto element = reinterpret_cast<HelElement *>(ptr); - _lastProgress += sizeof(HelElement) + element->length; - _refCount[n]++; - return ElementHandle{this, n, ptr + sizeof(HelElement)}; - } - } - - void retire(int n) { - __ensure(_refCount[n]); - if(_refCount[n]-- > 1) - return; - - // Reset and enqueue the chunk again. - _chunks[n]->progressFutex = 0; - _refCount[n] = 1; - - _queue->indexQueue[_nextIndex & 1] = n; - _nextIndex = ((_nextIndex + 1) & kHelHeadMask); - _wakeHeadFutex(); - } - - void reference(int n) { - _refCount[n]++; - } - -private: - int _numberOf(int index) { - return _queue->indexQueue[index & 1]; - } - - HelChunk *_retrieveChunk() { - return _chunks[_numberOf(_retrieveIndex)]; - } - - void _wakeHeadFutex() { - auto futex = __atomic_exchange_n(&_queue->headFutex, _nextIndex, __ATOMIC_RELEASE); - if(futex & kHelHeadWaiters) - HEL_CHECK(helFutexWake(&_queue->headFutex)); - } - - void _waitProgressFutex(bool *done) { - while(true) { - auto futex = __atomic_load_n(&_retrieveChunk()->progressFutex, __ATOMIC_ACQUIRE); - __ensure(!(futex & ~(kHelProgressMask | kHelProgressWaiters | kHelProgressDone))); - do { - if(_lastProgress != (futex & kHelProgressMask)) { - *done = false; - return; - }else if(futex & kHelProgressDone) { - *done = true; - return; - } - - if(futex & kHelProgressWaiters) - break; // Waiters bit is already set (in a previous iteration). - } while(!__atomic_compare_exchange_n(&_retrieveChunk()->progressFutex, &futex, - _lastProgress | kHelProgressWaiters, - false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)); - - HEL_CHECK(helFutexWait(&_retrieveChunk()->progressFutex, - _lastProgress | kHelProgressWaiters, -1)); - } - } - -private: - HelHandle _handle; - HelQueue *_queue; - HelChunk *_chunks[2]; - - // Index of the chunk that we are currently retrieving/inserting next. - int _retrieveIndex; - int _nextIndex; - - // Progress into the current chunk. - int _lastProgress; - - // Number of ElementHandle objects alive. - int _refCount[2]; -}; - -inline ElementHandle::~ElementHandle() { - if(_queue) - _queue->retire(_n); -} - -inline ElementHandle::ElementHandle(const ElementHandle &other) { - _queue = other._queue; - _n = other._n; - _data = other._data; - - _queue->reference(_n); -} - - -inline HelSimpleResult *parseSimple(ElementHandle &element) { - auto result = reinterpret_cast<HelSimpleResult *>(element.data()); - element.advance(sizeof(HelSimpleResult)); - return result; -} - -inline HelInlineResult *parseInline(ElementHandle &element) { - auto result = reinterpret_cast<HelInlineResult *>(element.data()); - element.advance(sizeof(HelInlineResult) + ((result->length + 7) & ~size_t(7))); - return result; -} - -inline HelLengthResult *parseLength(ElementHandle &element) { - auto result = reinterpret_cast<HelLengthResult *>(element.data()); - element.advance(sizeof(HelLengthResult)); - return result; -} - -inline HelHandleResult *parseHandle(ElementHandle &element) { - auto result = reinterpret_cast<HelHandleResult *>(element.data()); - element.advance(sizeof(HelHandleResult)); - return result; -} - -HelHandle getPosixLane(); -HelHandle *cacheFileTable(); -HelHandle getHandleForFd(int fd); -void clearCachedInfos(); - -extern thread_local Queue globalQueue; - -// This include is here because it needs ElementHandle to be declared -#include <helix/ipc-structs.hpp> - -template <typename ...Args> -auto exchangeMsgsSync(HelHandle descriptor, Args &&...args) { - auto results = helix_ng::createResultsTuple(args...); - auto actions = helix_ng::chainActionArrays(args...); - - HEL_CHECK(helSubmitAsync(descriptor, actions.data(), - actions.size(), globalQueue.getQueue(), 0, 0)); - - auto element = globalQueue.dequeueSingle(); - void *ptr = element.data(); - - [&]<size_t ...p>(std::index_sequence<p...>) { - (results.template get<p>().parse(ptr, element), ...); - } (std::make_index_sequence<std::tuple_size_v<decltype(results)>>{}); - - return results; -} - - -#endif // MLIBC_POSIX_PIPE diff --git a/lib/mlibc/sysdeps/managarm/include/mlibc/thread-entry.hpp b/lib/mlibc/sysdeps/managarm/include/mlibc/thread-entry.hpp deleted file mode 100644 index 2dd88a6..0000000 --- a/lib/mlibc/sysdeps/managarm/include/mlibc/thread-entry.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include <mlibc/tcb.hpp> - -extern "C" void __mlibc_start_thread(void); -extern "C" void __mlibc_enter_thread(void *entry, void *user_arg, Tcb *tcb); - -namespace mlibc { - void *prepare_stack(void *entry, void *user_arg, void *tcb); -} |