aboutsummaryrefslogtreecommitdiff
path: root/devel/electron13/files/patch-base_allocator_partition__allocator_address__pool__manager.cc
blob: 404e346613c431d2fdbd217bc2c3bd89f6d90ef2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--- base/allocator/partition_allocator/address_pool_manager.cc.orig	2021-04-14 01:08:36 UTC
+++ base/allocator/partition_allocator/address_pool_manager.cc
@@ -8,6 +8,13 @@
 #include <sys/mman.h>
 #endif
 
+#if defined(OS_FREEBSD)
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#include "base/posix/eintr_wrapper.h"
+#endif
+
 #include <algorithm>
 #include <limits>
 
@@ -50,6 +57,14 @@ void DecommitPages(void* address, size_t size) {
   void* ptr = mmap(address, size, PROT_NONE,
                    MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
   PA_CHECK(ptr == address);
+#elif defined(OS_FREEBSD)
+  int fd = HANDLE_EINTR(open("/dev/zero", O_RDONLY));
+  PA_CHECK(fd != -1);
+
+  void *ptr = mmap(address, size, PROT_NONE,
+                   MAP_FIXED | MAP_PRIVATE, fd, 0);
+  PA_PCHECK(ptr == address);
+  HANDLE_EINTR(close(fd));
 #else
   DecommitSystemPages(address, size, PageUpdatePermissions);
 #endif