Commit graph

285 commits

Author SHA1 Message Date
howar6hill
e72fb8f594 LibC: Fix a bug involving miscalculating week counts of last year 2020-03-08 13:56:01 +01:00
howar6hill
df40847c52 LibC: Reimplement asctime() in terms of strftime() 2020-03-08 13:56:01 +01:00
Andreas Kling
37fc6c117c Userspace: Add missing #includes now that AK/StdLibExtras.h is smaller 2020-03-08 13:06:51 +01:00
Andreas Kling
b1058b33fb AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it
possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-03-08 13:06:51 +01:00
Andreas Kling
7a6c4a72d5 LibWeb: Move everything into the Web namespace 2020-03-07 10:27:02 +01:00
howar6hill
4ba206b7e5 LibC: Fix a indentation problem in time.cpp 2020-03-06 20:15:07 +01:00
Andreas Kling
52954ccce6 LibC: Fix crash in free() now that mprotect() works correctly
After we mprotect(PROT_NONE) an allocation block, we can't expect to
read the m_size from that block right after. :^)
2020-03-06 10:52:36 +01:00
howar6hill
ae233c1e82 LibC: Implement time formatting functions, partially support timezone
Also fix a bug in mktime() caused by forgetting to check if the present year
is a leap year.
2020-03-06 10:32:48 +01:00
howar6hill
055344f346 AK: Move the wildcard-matching implementation to StringUtils
Provide wrappers in the String and StringView classes, and add some tests.
2020-03-02 10:38:08 +01:00
Andreas Kling
6321b6ecc0 LibC: Move shbuf_* implementations to serenity.cpp 2020-02-28 12:55:58 +01:00
Andreas Kling
dcd619bd46 Kernel: Merge the shbuf_get_size() syscall into shbuf_get()
Add an extra out-parameter to shbuf_get() that receives the size of the
shared buffer. That way we don't need to make a separate syscall to
get the size, which we always did immediately after.
2020-02-28 12:55:58 +01:00
Andreas Kling
a1514369d7 LibC: Move shbuf_* API's to <serenity.h> 2020-02-28 12:55:58 +01:00
Andreas Kling
f72e5bbb17 Kernel+LibC: Rename shared buffer syscalls to use a prefix
This feels a lot more consistent and Unixy:

    create_shared_buffer()   => shbuf_create()
    share_buffer_with()      => shbuf_allow_pid()
    share_buffer_globally()  => shbuf_allow_all()
    get_shared_buffer()      => shbuf_get()
    release_shared_buffer()  => shbuf_release()
    seal_shared_buffer()     => shbuf_seal()
    get_shared_buffer_size() => shbuf_get_size()

Also, "shared_buffer_id" is shortened to "shbuf_id" all around.
2020-02-28 12:55:58 +01:00
Andreas Kling
ceec1a7d38 AK: Make Vector use size_t for its size and capacity 2020-02-25 14:52:35 +01:00
Shannon Booth
a52b3e8f2a LibC: Implement strchrnul() 2020-02-22 21:36:54 +01:00
Andreas Kling
c4c1ad2289 Toolchain: Build demangling into LibC except during toolchain build 2020-02-21 18:54:57 +01:00
Andreas Kling
cd495786a8 LibC: Implement crappy version of pread()
This patch adds a crappy pread() just to get "git" working locally.
A proper version would be implemented in the kernel so that we don't
have to mess with the file descriptor's offset at all.
2020-02-20 06:59:23 +01:00
Andreas Kling
7c12d66f61 LibC: Stub out getpass() 2020-02-20 06:58:48 +01:00
Andreas Kling
c3b09c7242 LibC: Add h_errno and stub out getservbyname() 2020-02-20 06:58:16 +01:00
Andreas Kling
cf4da485e6 LibC: Add inet_ntoa() 2020-02-20 06:57:47 +01:00
Andreas Kling
0ba458cfa0 Kernel+LibC: Add SO_REUSEADDR macro
Note that this is not actually implemented, I'm just defining it.
2020-02-20 06:57:01 +01:00
Andreas Kling
2a1cad73fe LibC: Add an empty <netinet/tcp.h>
This is enough to placate anyone who includes it without actually using
anything from it. :^)
2020-02-20 06:51:28 +01:00
Andreas Kling
4ddae2c069 LibC: Add some missing macros to inttypes.h 2020-02-20 06:51:16 +01:00
Andreas Kling
124c588f81 LibC: Don't assert on fflush(nullptr)
We're supposed to flush all open streams when this happens, but since
we don't know how to do that yet, let's just log a FIXME and not crash.
2020-02-19 23:12:29 +01:00
Andreas Kling
e0d589c074 LibC: Add hack implementation of gmtime_r() matching gmtime() 2020-02-19 23:09:37 +01:00
Andreas Kling
4a66de580e LibC: Always inline the printf character helpers 2020-02-19 22:11:04 +01:00
Liav A
8a2dc5d188 LibC: Fix big endian definitions 2020-02-19 16:08:28 +01:00
Sergey Bugaev
e0ecfc0c92 LibC: Statically allocate allocators
These allocators take up 660 bytes, combined. Let's not waste
two physical pages for them in each process :^)
2020-02-18 11:23:27 +01:00
Andreas Kling
a6e69bda71 AK: Add basic Traits for RefPtr
This allows RefPtr to be stored in a HashTable<RefPtr<T>> :^)

It's unfortunate about the const_casts. We'll need to fix HashMap::get
to play nice with non-const Traits<T>::PeekType at some point.
2020-02-16 21:58:17 +01:00
Andreas Kling
69bb0c0246 malloc: Use 64KB blocks (instead of 4KB)
We now allocate 64KB at a time and divide them into chunks for handing
out to malloc() callers. This significantly reduces the number of
system calls made due to memory allocation.

This yields a ~15% speedup when compiling Process.cpp inside SerenityOS
(down from 24 sec to 20 sec on my machine.)

There's more performance on the table here, no doubt.
2020-02-16 14:11:14 +01:00
Andreas Kling
31e1af732f Kernel+LibC: Allow sys$mmap() callers to specify address alignment
This is exposed via the non-standard serenity_mmap() call in userspace.
2020-02-16 12:55:56 +01:00
Andreas Kling
14bd978928 Revert "LibC: Implement isblank()"
This reverts commit 4e79a60b78.

This broke the GCC port. Apparently isblank() was added in C99 and for
some reason it needs special treatment in headers.
2020-02-16 10:47:54 +01:00
Andreas Kling
3bbf4610d2 AK: Add a forward declaration header
You can now #include <AK/Forward.h> to get most of the AK types as
forward declarations.

Header dependency explosion is one of the main contributors to compile
times at the moment, so this is a step towards smaller include graphs.
2020-02-14 23:31:18 +01:00
Andreas Kling
29aa8373d4 LibC: Add localtime_r() 2020-02-11 19:36:59 +01:00
Andreas Kling
57e4410044 Revert "LibC: Remove isfoo() declarations from ctype.h"
This reverts commit 2ba06662b6.

This broke the toolchain build. Apparently libstdc++v3 depends on the
declarations of isfoo() helpers.
2020-02-11 19:36:47 +01:00
Andreas Kling
2ba06662b6 LibC: Remove isfoo() declarations from ctype.h
We'll keep the definitions in ctype.cpp so you can link against them
but there's no reason to have competing declarations and macros.
2020-02-11 17:41:16 +01:00
Andreas Kling
580a94bc44 Kernel+LibC: Merge sys$stat() and sys$lstat()
There is now only one sys$stat() instead of two separate syscalls.
2020-02-10 19:49:49 +01:00
Liav A
2a699cec98 LibC: Apply a change for the Bootstrapper environment 2020-02-09 19:38:17 +01:00
Andreas Kling
2b0b7cc5a4 Net: Add a basic sys$shutdown() implementation
Calling shutdown prevents further reads and/or writes on a socket.
We should do a few more things based on the type of socket, but this
initial implementation just puts the basic mechanism in place.

Work towards #428.
2020-02-08 00:54:43 +01:00
Andreas Kling
f2a087126c LibC: Add posix_openpt(), grantpt() and unlockpt()
This makes getting a pseudoterminal pair a little bit more portable.
Note that grantpt() and unlockpt() are currently no-ops, since we've
already granted the pseudoterminal slave to the calling user.

We also accept O_CLOEXEC to posix_openpt(), unlike some systems. :^)
2020-02-05 21:17:41 +01:00
joshua stein
868b1a24bb LibC: Move struct stat to sys/stat.h 2020-02-05 18:39:45 +01:00
Sergey Bugaev
b3a24d732d Kernel+LibC: Add sys$waitid(), and make sys$waitpid() wrap it
sys$waitid() takes an explicit description of whether it's waiting for a single
process with the given PID, all of the children, a group, etc., and returns its
info as a siginfo_t.

It also doesn't automatically imply WEXITED, which clears up the confusion in
the kernel.
2020-02-05 18:14:37 +01:00
Sergey Bugaev
a6cb7f759e Kernel+LibC: Add some Unix signal types & definitions 2020-02-05 18:14:37 +01:00
Sergey Bugaev
aafa5a9d09 LibC: Fix misplaced brace
It doesn't really make a difference since waitpid() is declared to have
extern "C" linkage in the header anyway, but still.
2020-02-05 18:14:37 +01:00
Kenzi Jeanis
6c9d66ed4b LibC: Add byteswap.h, forwarding bswap_N to GCC builtins 2020-02-03 19:53:54 +01:00
Kenzi Jeanis
e2110b633e LibC: Copy the net directory into /usr/include during build 2020-02-03 19:51:12 +01:00
Sergey Bugaev
589bd0a7de LibC: Implement getsid()
We've had a declaration, but not a definition.
2020-02-03 19:50:45 +01:00
Sergey Bugaev
a6e7797a31 LibC: Move waitpid() to sys/wait.h
That's where POSIX says it should be.
2020-02-03 19:50:45 +01:00
Sergey Bugaev
4e79a60b78 LibC: Implement isblank() 2020-02-03 19:50:45 +01:00
Andreas Kling
fa97ff1c83 LibC: Allow opting into malloc() and free() performance event logging
If a program is started with LIBC_PROFILE_MALLOC in the environment,
it will now generate PERF_EVENT_MALLOC and PERF_EVENT_FREE.
2020-02-02 20:29:50 +01:00