diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 15:54:56 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-19 15:54:56 +0200 |
commit | 189b342e6f372770395a764ffd88e96ab1ebc1a5 (patch) | |
tree | 7c574d48c8c03d1759f5e1556e7721fa50971528 /LibC/mman.cpp | |
parent | 5f26f83451ea046f76d1bb019510548714408de6 (diff) | |
download | serenity-189b342e6f372770395a764ffd88e96ab1ebc1a5.zip |
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.
Diffstat (limited to 'LibC/mman.cpp')
-rw-r--r-- | LibC/mman.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/LibC/mman.cpp b/LibC/mman.cpp index 174643712b..bd87e5989c 100644 --- a/LibC/mman.cpp +++ b/LibC/mman.cpp @@ -7,7 +7,18 @@ extern "C" { void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset) { - Syscall::SC_mmap_params params { (dword)addr, size, prot, flags, fd, offset }; + Syscall::SC_mmap_params params { (dword)addr, size, prot, flags, fd, offset, nullptr }; + int rc = syscall(SC_mmap, ¶ms); + if (rc < 0 && -rc < EMAXERRNO) { + errno = -rc; + return (void*)-1; + } + return (void*)rc; +} + +void* mmap_with_name(void* addr, size_t size, int prot, int flags, int fd, off_t offset, const char* name) +{ + Syscall::SC_mmap_params params { (dword)addr, size, prot, flags, fd, offset, name }; int rc = syscall(SC_mmap, ¶ms); if (rc < 0 && -rc < EMAXERRNO) { errno = -rc; |