Some applications like keydb that use jmalloc, call sbrk()
on startup even though later fall back to mmap().

So this patch provides simple stubs of those 2 functions
that set errno to ENOMEM and return error.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
 libc/mman.cc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libc/mman.cc b/libc/mman.cc
index add8ef15..895b9b28 100644
--- a/libc/mman.cc
+++ b/libc/mman.cc
@@ -13,6 +13,7 @@
 #include "osv/trace.hh"
 #include "osv/dentry.h"
 #include "osv/mount.h"
+#include <osv/stubbing.hh>
 #include "libc/libc.hh"
 #include <safe-ptr.hh>
 
@@ -234,3 +235,17 @@ int madvise(void *addr, size_t length, int advice)
     auto err = mmu::advise(addr, length, libc_madvise_to_advise(advice));
     return err.to_libc();
 }
+
+int brk(void *addr)
+{
+    WARN_STUBBED();
+    errno = ENOMEM;
+    return -1;
+}
+
+void *sbrk(intptr_t increment)
+{
+    WARN_STUBBED();
+    errno = ENOMEM;
+    return (void *)-1;
+}
-- 
2.30.2

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20210525050253.1141211-3-jwkozaczuk%40gmail.com.

Reply via email to