@@ -127,6 +127,7 @@ namespace snmalloc
127127
128128 static void notify_not_using (void * p, size_t size) noexcept
129129 {
130+ KeepErrno k;
130131 SNMALLOC_ASSERT (is_aligned_block<page_size>(p, size));
131132
132133 // Fill memory so that when we switch the pages back on we don't make
@@ -147,6 +148,7 @@ namespace snmalloc
147148 */
148149 static void notify_do_dump (void * p, size_t size) noexcept
149150 {
151+ KeepErrno k;
150152 madvise (p, size, MADV_DODUMP);
151153 }
152154
@@ -155,11 +157,14 @@ namespace snmalloc
155157 */
156158 static void notify_do_not_dump (void * p, size_t size) noexcept
157159 {
160+ KeepErrno k;
158161 madvise (p, size, MADV_DONTDUMP);
159162 }
160163
161164 static uint64_t get_entropy64 ()
162165 {
166+ KeepErrno k;
167+
163168 // TODO: If the system call fails then the POSIX PAL calls libc
164169 // functions that can require malloc, which may result in deadlock.
165170
@@ -249,7 +254,7 @@ namespace snmalloc
249254 template <class T >
250255 static void wait_on_address (stl::Atomic<T>& addr, T expected)
251256 {
252- int backup = errno ;
257+ KeepErrno k ;
253258 static_assert (
254259 sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
255260 " T must be the same size and alignment as WaitingWord" );
@@ -273,12 +278,12 @@ namespace snmalloc
273278 syscall (
274279 SYS_futex, &addr, FUTEX_WAIT_PRIVATE, expected, nullptr , nullptr , 0 );
275280 }
276- errno = backup;
277281 }
278282
279283 template <class T >
280284 static void notify_one_on_address (stl::Atomic<T>& addr)
281285 {
286+ KeepErrno k;
282287 static_assert (
283288 sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
284289 " T must be the same size and alignment as WaitingWord" );
@@ -288,6 +293,7 @@ namespace snmalloc
288293 template <class T >
289294 static void notify_all_on_address (stl::Atomic<T>& addr)
290295 {
296+ KeepErrno k;
291297 static_assert (
292298 sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
293299 " T must be the same size and alignment as WaitingWord" );
0 commit comments