summaryrefslogtreecommitdiff
path: root/LibC/mman.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-19 15:54:56 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-19 15:54:56 +0200
commit189b342e6f372770395a764ffd88e96ab1ebc1a5 (patch)
tree7c574d48c8c03d1759f5e1556e7721fa50971528 /LibC/mman.cpp
parent5f26f83451ea046f76d1bb019510548714408de6 (diff)
downloadserenity-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.cpp13
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, &params);
+ 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, &params);
if (rc < 0 && -rc < EMAXERRNO) {
errno = -rc;