@@ -127,6 +127,7 @@ namespace snmalloc
127
127
128
128
static void notify_not_using (void * p, size_t size) noexcept
129
129
{
130
+ KeepErrno k;
130
131
SNMALLOC_ASSERT (is_aligned_block<page_size>(p, size));
131
132
132
133
// Fill memory so that when we switch the pages back on we don't make
@@ -147,6 +148,7 @@ namespace snmalloc
147
148
*/
148
149
static void notify_do_dump (void * p, size_t size) noexcept
149
150
{
151
+ KeepErrno k;
150
152
madvise (p, size, MADV_DODUMP);
151
153
}
152
154
@@ -155,11 +157,14 @@ namespace snmalloc
155
157
*/
156
158
static void notify_do_not_dump (void * p, size_t size) noexcept
157
159
{
160
+ KeepErrno k;
158
161
madvise (p, size, MADV_DONTDUMP);
159
162
}
160
163
161
164
static uint64_t get_entropy64 ()
162
165
{
166
+ KeepErrno k;
167
+
163
168
// TODO: If the system call fails then the POSIX PAL calls libc
164
169
// functions that can require malloc, which may result in deadlock.
165
170
@@ -249,7 +254,7 @@ namespace snmalloc
249
254
template <class T >
250
255
static void wait_on_address (stl::Atomic<T>& addr, T expected)
251
256
{
252
- int backup = errno ;
257
+ KeepErrno k ;
253
258
static_assert (
254
259
sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
255
260
" T must be the same size and alignment as WaitingWord" );
@@ -273,12 +278,12 @@ namespace snmalloc
273
278
syscall (
274
279
SYS_futex, &addr, FUTEX_WAIT_PRIVATE, expected, nullptr , nullptr , 0 );
275
280
}
276
- errno = backup;
277
281
}
278
282
279
283
template <class T >
280
284
static void notify_one_on_address (stl::Atomic<T>& addr)
281
285
{
286
+ KeepErrno k;
282
287
static_assert (
283
288
sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
284
289
" T must be the same size and alignment as WaitingWord" );
@@ -288,6 +293,7 @@ namespace snmalloc
288
293
template <class T >
289
294
static void notify_all_on_address (stl::Atomic<T>& addr)
290
295
{
296
+ KeepErrno k;
291
297
static_assert (
292
298
sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
293
299
" T must be the same size and alignment as WaitingWord" );
0 commit comments