Commit Graph

350 Commits

Author SHA1 Message Date
Andreas Kling
39d1a9ae66 Meta: Tweak .clang-format to not wrap braces after enums. 2019-06-07 17:13:23 +02:00
Andreas Kling
46527b72d7 LibC: Run clang-format on everything. 2019-06-07 11:49:03 +02:00
Andreas Kling
98eeb8f22d AK: Rename printf.cpp to PrintfImplementation.h. 2019-06-07 11:41:11 +02:00
Andreas Kling
69a6ce90df AK: Add a ScopeGuard helper that invokes a callback when destroyed.
This is useful when you want to ensure some little thing happens when you
exit a certain scope.

This patch makes use of it in LibC's netdb code to make sure we close the
connection to the LookupServer.
2019-06-07 09:19:15 +02:00
Andreas Kling
01f1333856 LookupServer+LibC: Add support for reverse DNS lookups via gethostbyaddr().
LookupServer can now take two types of requests:

* L: Lookup
* R: Reverse lookup

The /bin/host program now does a reverse lookup if the input string is a
valid IPv4 address. :^)
2019-06-06 05:35:03 +02:00
Andreas Kling
d03505bc29 LibC: inet_pton() should return 1 on success, 0 or -1 on failure. 2019-06-06 05:25:18 +02:00
Andreas Kling
ccc6e69a29 LibC: Implement popen() and pclose().
I feel reasonably confident that I might have gotten these right. :^)
2019-06-03 21:17:58 +02:00
Christopher Dumas
e92fe52031 Terminal: Use Vectors and OwnPtrs for Terminal lines. Adjust scroll
region behavior
2019-06-03 20:48:34 +02:00
Christopher Dumas
ce15a4021d Terminal: Implement scroll region termcodes 2019-06-03 20:48:34 +02:00
Andreas Kling
8af495495b LibC: Implement dirfd(). 2019-06-03 18:42:40 +02:00
Andreas Kling
93d3d1ede1 Kernel: Add fchown() syscall. 2019-06-01 20:31:36 +02:00
Andreas Kling
07c3cc01ec LibC: Move wait-related stuff to <sys/wait.h>. #POSIX 2019-05-30 15:12:09 +02:00
Andreas Kling
96db775ac1 LibC: Add setenv().
If I'm understanding the standard C library correctly, setenv() copies while
putenv() does not. That's really confusing and putenv() basically sucks.
To know which environment variables to free on replacement and which ones to
leave alone, we keep track of the ones malloced by setenv in a side table.

This patch also moves Shell to using setenv() instead of putenv().

Fixes #29.
2019-05-30 03:22:18 +02:00
Robin Burchell
9cd0f6ffac Kernel/LibC: Implement sched_* functionality to set/get process priority
Right now, we allow anything inside a user to raise or lower any other process's
priority. This feels simple enough to me. Linux disallows raising, but
that's annoying in practice.
2019-05-30 02:57:15 +02:00
Andreas Kling
b160677e9e LibC: Add malloc_size() to tell you how big an allocation might be.
It can't be 100% precise but it doesn't really matter. Use this to implement
realloc() nicely. This also fixes a bug in realloc() where we didn't take
the size of the allocation metadata into account when computing the size of
an allocation backed by a BigAllocationBlock.
2019-05-30 02:37:40 +02:00
Mustafa Ali CAN
3ffb2ad4e0 LibM LibC: add fixes for Lua port. 2019-05-29 16:03:51 +02:00
Andreas Kling
6785250f8c LibC: realloc() should reuse the existing allocation more often.
We were only reusing the existing allocation if the new requested size
was exactly the same as the fudged size of the block. This meant that
realloc() could allocate a new block even though the new block would be
identical to the old block.
2019-05-29 06:31:28 +02:00
Andreas Kling
c1f8df5f86 LibC: Don't define ALWAYS_INLINE if it's already defined.
This makes building GCC a bit quieter.
2019-05-28 21:04:47 +02:00
Andreas Kling
f6680d58db LibC: fcntl.h should define F_RDLCK. 2019-05-28 21:02:31 +02:00
Robin Burchell
0dc9af5f7e Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
2019-05-28 17:31:20 +02:00
Andreas Kling
631894279b LibC: Make dlfcn stubs extern "C" like the outside world expects. 2019-05-28 14:30:55 +02:00
Andreas Kling
ab9db3a717 LibC: Move size_t, ptrdiff_t and NULL to stddef.h. #POSIX 2019-05-28 14:29:51 +02:00
Andreas Kling
cbd858544d LibC: Move struct timeval to sys/time.h. #POSIX 2019-05-28 13:48:06 +02:00
Andreas Kling
cde3274ffb LibC: Implement abort() as raise(SIGABRT). 2019-05-26 02:35:25 +02:00
Andreas Kling
7c37ffd9d8 LibC: Let the string for SIGFPE be "Division by zero".
That's really what we send this signal for, so let's call it that.
2019-05-26 02:35:25 +02:00
Robin Burchell
5b3c4afff2 LibC: Stub out dlfcn 2019-05-23 16:57:34 +02:00
Andreas Kling
709893364d LibC: The "install" target should depend on the "startfiles" target.
This ensures that crt0.o is built during the Toolchain bootstrap.
2019-05-23 14:10:37 +02:00
Robin Burchell
a04a58b7eb LibC: Port setjmp syntax to avoid nasm dependency 2019-05-23 13:06:59 +02:00
Andreas Kling
e388808479 LibC: Some compat fixes for GNU make. 2019-05-22 13:21:49 +02:00
Andreas Kling
f490ce0fb5 LibC: Implement wait() as a wrapper around waitpid(). 2019-05-22 13:21:17 +02:00
Andreas Kling
4aef87a9a4 LibC: First pass of compat work / stubs while trying to build OpenSSL. 2019-05-21 21:36:08 +02:00
Andreas Kling
e383bc6fd8 LibC: Oops, forgot to commit sigsuspend() prototype. 2019-05-21 12:31:14 +02:00
Andreas Kling
3c7b46a85a LibC: Add htonl() and ntohl(). 2019-05-21 02:22:21 +02:00
Andreas Kling
02033873b7 LibC: Add sigsuspend() stub. 2019-05-21 02:22:02 +02:00
Andreas Kling
ae470ec955 Kernel: Add getpeername() syscall, and fix getsockname() behavior.
We were copying the raw IPv4 addresses into the wrong part of sockaddr_in,
and we didn't set sa_family or sa_port.
2019-05-20 20:33:03 +02:00
Andreas Kling
b3a1671f1a Kernel: Add support for recv() with MSG_DONTWAIT.
Passing this flag to recv() temporarily puts the file descriptor into
non-blocking mode.

Also implement LocalSocket::recv() as a simple forwarding to read().
2019-05-20 03:47:02 +02:00
Andreas Kling
5b6e66195b LibC: Add an h_addr macro for old code that doesn't know about h_addr_list. 2019-05-19 19:55:49 +02:00
Andreas Kling
212a263f0a Kernel+LibC: Implement getsockname() syscall. 2019-05-19 19:55:27 +02:00
Andreas Kling
0eb788d641 LibC: Add stub for fsync(). 2019-05-19 19:54:20 +02:00
Andreas Kling
189b342e6f LibC: Add mmap_with_name() that names the allocation immediately.
This allows us to skip the separate call to set_mmap_name() in code that
we control, e.g malloc() and GraphicsBitmap.
2019-05-19 15:54:56 +02:00
Andreas Kling
29863d3815 LibC: unsetenv() should take a const char*, not a char*. 2019-05-19 15:19:48 +02:00
Andreas Kling
f5234660f6 malloc: Use a Vector with inline capacity for the big block recyclers. 2019-05-18 22:26:01 +02:00
Andreas Kling
f015798af9 LibC: Implement clock() and add CLOCKS_PER_SEC define. 2019-05-17 20:19:03 +02:00
Robin Burchell
77dfd419e9 LibCore: Move AK/ArgsParser to LibCore/CArgsParser
Also rename the classes to match LibCore naming style.
This means that it's no longer incorrectly linked into LibC and Kernel.
2019-05-17 15:49:37 +02:00
Andreas Kling
c081aae9b5 LibC: Rename beep() to sysbeep() to avoid clashing with curses. 2019-05-17 14:32:53 +02:00
Andreas Kling
e20aecefba LibC: Don't clobber errno in dbgprintf(). 2019-05-16 16:24:22 +02:00
Robin Burchell
abb7455163 LibC/Shell: Add unsetenv(), and unset builtin calling it in Shell. 2019-05-16 14:32:09 +02:00
Robin Burchell
b2dd12daac LibC: Change putenv (and getenv) to not copy, but directly return the environ values.
This is in keeping with how putenv should function. It does mean that
the shell's export command now leaks, but that's not a difficult fix.

Contributes to #29.
2019-05-16 14:32:09 +02:00
Robin Burchell
6f73a549fa LibC: Add struct timespec to time.h 2019-05-16 14:03:49 +02:00
Robin Burchell
4dad585609 LibC: Allow {AF,PF}_UNIX as well as {AF,PF}_LOCAL
Seems that these are equivilent. POSIX specifies _LOCAL, but a lot of
software uses _UNIX.
2019-05-16 14:03:49 +02:00