Commit Graph

519 Commits

Author SHA1 Message Date
asynts
59e7ffa86d AK: Make the return type of dbgputstr consistent. 2020-10-04 19:18:32 +02:00
Emanuele Torre
4e86c34ef0 LibC: Remove unnecessary fallthrough comments.
A "fallthrough comment" or `[[fallthrough]]` is only required after
non-empty `case`s.
2020-10-03 12:35:40 +02:00
Nico Weber
ef1b21004f Everywhere: Fix typos
Mostly in comments, but sprintf() now prints "August" instead of
"Auguest" so that's something.
2020-10-02 16:03:17 +02:00
Benoit Lormeau
f158cb27ea LibC: Remove an unneeded string.h include in ctype.h/cpp
And include string.h in the files that actually needed it
2020-09-27 21:15:25 +02:00
Luke
bf809226de LibC: Add SCM_RIGHTS to sockets.h and caddr_t to types.h 2020-09-27 01:02:11 +02:00
Luke
1ec59f28ce LibC: Make isalum/isalpha/etc. functions instead of macros
These are supposed to be both functions and macros. I'm not sure
how to provide the functions at the same time as the macros,
as they collide with each other and cause compile errors.

However, some ports fully expect them to be functions.
For example, OpenSSH stores them into structures as function
pointers.
2020-09-27 01:02:11 +02:00
Luke
9266006349 LibC: Add ss_family to sockaddr_storage
I'm not exactly sure if this is in the right spot in the structure,
especially since I read that this is supposed to be cast into other
structures.
2020-09-27 01:02:11 +02:00
Luke
9d8f1032b7 LibC: Add missing utmp backwards compatibility hacks and user/dead process macros
The user/dead process macros are not used anywhere in Serenity right now,
but are required for OpenSSH.
2020-09-27 01:02:11 +02:00
Luke
721788943d Kernel: Implement _SC_OPEN_MAX 2020-09-27 01:02:11 +02:00
Luke
db31452bc2 LibC: Made mbtowc return int instead of size_t 2020-09-27 01:02:11 +02:00
Luke
5fbb8f9c6a LibC: Add FIXME for vsscanf 2020-09-27 01:02:11 +02:00
Luke
7a558d16b0 LibC: Add some missing netinet macros required by OpenSSH
Not used anywhere in Serenity right now, but required for OpenSSH.
2020-09-27 01:02:11 +02:00
Luke
f2cc565670 LibC: Add SSIZE_MAX limit 2020-09-27 01:02:11 +02:00
Luke
83849f0ef3 LibC: Include cdefs.h in getopt.h
Required for __BEGIN_DECLS
2020-09-27 01:02:11 +02:00
Luke
7334f21ef7 LibC: Add EPFNOSUPPORT error number
Not used anywhere in Serenity currently, but required for OpenSSH.
2020-09-27 01:02:11 +02:00
Luke
93b9929391 LibC: Add paths.h with some default mail directory for now 2020-09-27 01:02:11 +02:00
Ben Wiederhake
ede5dbd7b3 Meta+LibC through LibHTTP: Make clang-format-10 clean
Why break at LibHTTP? Because "Meta+Libraries" would be insanely large,
and breaking between LibHTTP and LibJS makes the commits roughly evenly large.
2020-09-25 21:18:17 +02:00
Nico Weber
47b3e98af8 Kernel+LibC+UserspaceEmulator: Add SO_TIMESTAMP, and cmsg definitions
When SO_TIMESTAMP is set as an option on a SOCK_DGRAM socket, then
recvmsg() will return a SCM_TIMESTAMP control message that
contains a struct timeval with the system time that was current
when the socket was received.
2020-09-17 17:23:01 +02:00
Nico Weber
ae5ba4074d LibC: Convert SO_ constants to enum
I want to add another entry to this list and don't want to
have to think of a number for it.
2020-09-17 17:23:01 +02:00
Nico Weber
b36a2d6686 Kernel+LibC+UserspaceEmulator: Mostly add recvmsg(), sendmsg()
The implementation only supports a single iovec for now.
Some might say having more than one iovec is the main point of
recvmsg() and sendmsg(), but I'm interested in the control message
bits.
2020-09-17 17:23:01 +02:00
Tom
c8d9f1b9c9 Kernel: Make copy_to/from_user safe and remove unnecessary checks
Since the CPU already does almost all necessary validation steps
for us, we don't really need to attempt to do this. Doing it
ourselves doesn't really work very reliably, because we'd have to
account for other processors modifying virtual memory, and we'd
have to account for e.g. pages not being able to be allocated
due to insufficient resources.

So change the copy_to/from_user (and associated helper functions)
to use the new safe_memcpy, which will return whether it succeeded
or not. The only manual validation step needed (which the CPU
can't perform for us) is making sure the pointers provided by user
mode aren't pointing to kernel mappings.

To make it easier to read/write from/to either kernel or user mode
data add the UserOrKernelBuffer helper class, which will internally
either use copy_from/to_user or directly memcpy, or pass the data
through directly using a temporary buffer on the stack.

Last but not least we need to keep syscall params trivial as we
need to copy them from/to user mode using copy_from/to_user.
2020-09-13 21:19:15 +02:00
Ben Wiederhake
8280dcfb89 LibC: Avoid write-back of unused value
This might make sleep() faster by up to pi nanoseconds, or less.
It's more about avoiding a senseless write than about optimization.
2020-09-12 13:46:15 +02:00
Ben Wiederhake
be1e4f28cc LibC: Don't advertise wrong functions
str{,n}casecmp is supposed to be *only* declared by strings.h, note the
trailing 's' in the filename.

We don't have any implementation for strlcat; using any strcat variants is
a bad idea anyway, given our implementation of AK::String.

TODO: Find a way to lint for declared-but-nowhere-defined functions.
2020-09-12 13:46:15 +02:00
Andreas Kling
f8e59addf7 Kernel+LibC+UE: Introduce SIGINFO (generated with ^T)
This signal is ignored by default, but can be caught to implement state
reporting a la BSD. :^)
2020-09-09 21:10:23 +02:00
Nico Weber
0fff4e11a6 LibC: Add settimeofday 2020-09-06 21:50:55 +02:00
Itamar
542f665b27 LibC: Avoid generating calls to__cxa_guard_* functions in netdb.cpp
g++ seems to generate calls to __cxa_guard_* functions when we use
non-trivial initialization of local statics.
Requiring these symbols breaks some ports since these symbols are
defined in libcstdc++ which we do not link against when building ports.

This commit turns some local statics into global statics in netdb.cpp so
libc wouldn't need these symbols.
2020-09-06 21:36:36 +02:00
Itamar
c5b0e0b96b LibC: Don't include things required for getopt_long in unistd.h
Previously, we were including the whole of <getopt.h> in <unistd.h>.
However according to the posix <unistd.h> doesn't have to contain
everything we had in <getopt.h>.

This fixes some symbol collisions that broke the git port.
2020-09-06 21:36:36 +02:00
Andreas Kling
386c7201d8 LibC: Move the static String in getlogin() out of the function
For some reason, this stops it from adding __cxa_guard_acquire/release
calls around its initialization. This unbreaks building ports.
2020-09-01 16:17:17 +02:00
Erlend Fagerheim
22265f1445 LibC: add getopt.h to unistd.h 2020-09-01 15:45:35 +02:00
Andreas Kling
e002cbb06b Build: Add some -Wno-unknown-warning-option flags to CXXFLAGS
Patch from Anonymous.
2020-09-01 12:00:53 +02:00
AnotherTest
9adbbff4dd LibC: Partially implement 'freopen' 2020-08-31 09:14:11 +02:00
Sergey Bugaev
f808810d00 LibC: Deprecate strcpy(), strncpy(), strcat() and strncat() :^)
And also mark strlcpy() and strlcat() with __attribute__((warn_unused_result)).

Since our code is warning-free, this ensures we never misuse those functions.
(Or are very sure about doing it when turning off the warning for a particular
piece of code.)
2020-08-30 17:35:27 +02:00
Sergey Bugaev
1cdd798ac7 LibC: Replace some strncpy() calls with memcpy()
In case we know exactly how many bytes we're copying (and not copying a string
while limiting its length to that of a buffer), memcpy() is a more appropriate
function to call.

Also, fix null-terminating the %c pointer.
2020-08-30 17:35:27 +02:00
Sergey Bugaev
34353e18cf LibC: Misc fixes and improvements in netdb 2020-08-30 17:35:27 +02:00
Sergey Bugaev
0817ef563e LibC: strcpy a socket address at compile time
This way, we'd get compile-time errors if the address was too long for the buffer.
2020-08-30 17:35:27 +02:00
Sergey Bugaev
852454746e Everywhere: Port to String::copy_characters_to_buffer() 2020-08-30 17:35:27 +02:00
Sergey Bugaev
17109a3a31 LibC: Use AK::String-backed buffers instead of static buffers
Also, refactor the hell out of pwd.cpp & grp.cpp
2020-08-30 17:35:27 +02:00
Andreas Kling
57dd3b66c5 Kernel+LibC+UE: Implement sleep() via sys$clock_nanosleep()
This doesn't need to be its own syscall either. :^)
2020-08-30 13:21:24 +02:00
Andreas Kling
f857f3ce4c Kernel+LibC+UE: Implement usleep() via sys$clock_nanosleep()
This doesn't need to be its own syscall. Thanks @BenWiederhake for
the idea. :^)
2020-08-30 10:45:51 +02:00
Ben Wiederhake
9f7ec33180 Meta: Force semi-colon after MAKE_AK_NONXXXABLE()
Before, we had about these occurrence counts:
COPY: 13 without, 33 with
MOVE: 12 without, 28 with

Clearly, 'with' was the preferred way. However, this introduced double-semicolons
all over the place, and caused some warnings to trigger.

This patch *forces* the usage of a semi-colon when calling the macro,
by removing the semi-colon within the macro. (And thus also gets rid
of the double-semicolon.)
2020-08-27 10:12:04 +02:00
Nico Weber
1ab8939077 AK+LibC+LibCore: Have fewer implementations of day_of_week
The implementation in LibC did a timestamp->day-of-week conversion
which looks like a valuable thing to have. But we only need it in
time_to_tm, where we already computed year/month/day -- so let's
consolidate on the day_of_week function in DateTime (which is
getting extracted to AK).
2020-08-26 08:52:07 +02:00
Nico Weber
b9cbb4fd00 LibC: Minor style tweaks to tm_to_time 2020-08-26 08:52:07 +02:00
Nico Weber
2236385e1f AK+LibC+LibCore: Add a days_in_year function 2020-08-26 08:52:07 +02:00
Nico Weber
a7a18b478e AK+LibC+LibCore: Have fewer implementations of days_in_month 2020-08-26 08:52:07 +02:00
Nico Weber
c85e679e2d AK+LibCore+Kernel: Have fewer implementations of day_of_year
The JS tests pointed out that the implementation in DateTime
had an off-by-one in the month when doing the leap year check,
so this change fixes that bug.
2020-08-26 08:52:07 +02:00
Nico Weber
9b17082899 AK+LibC+Kernel: Have fewer implementations of year_to_days_in_epoch
I believe the implementation in RTC.cpp had an off-by-one
in the year passed to is_leap_year(). If that's true, then this
fixes that too.
2020-08-26 08:52:07 +02:00
Nico Weber
84ed257959 AK+LibC+LibCore+Kernel: Have fewer implementations of is_leap_year 2020-08-26 08:52:07 +02:00
Ben Wiederhake
cd93fb9656 LibC: Deduplicate declaration of strcasecmp 2020-08-26 00:55:13 +02:00
Sergio Ahumada
9ba3862ee9 LibC: Prospective fix for openssl build
serenity/Build/Root/usr/include/sys/socket.h:93:26: error: 'sockaddr_un' undeclared here (not in a function)
   93 |         char data[sizeof(sockaddr_un)];
      |                          ^~~~~~~~~~~
make[2]: *** [<builtin>: bss_fd.o] Error 1
2020-08-26 00:46:04 +02:00
Andreas Kling
8a5ce41065 LibC: Remove unused data member in the qsort() implementation 2020-08-24 18:22:09 +02:00