@@ -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,13 @@ 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;
163
167
// TODO: If the system call fails then the POSIX PAL calls libc
164
168
// functions that can require malloc, which may result in deadlock.
165
169
@@ -249,7 +253,7 @@ namespace snmalloc
249
253
template <class T >
250
254
static void wait_on_address (stl::Atomic<T>& addr, T expected)
251
255
{
252
- int backup = errno ;
256
+ KeepErrno k ;
253
257
static_assert (
254
258
sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
255
259
" T must be the same size and alignment as WaitingWord" );
@@ -273,12 +277,12 @@ namespace snmalloc
273
277
syscall (
274
278
SYS_futex, &addr, FUTEX_WAIT_PRIVATE, expected, nullptr , nullptr , 0 );
275
279
}
276
- errno = backup;
277
280
}
278
281
279
282
template <class T >
280
283
static void notify_one_on_address (stl::Atomic<T>& addr)
281
284
{
285
+ KeepErrno k;
282
286
static_assert (
283
287
sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
284
288
" T must be the same size and alignment as WaitingWord" );
@@ -288,6 +292,7 @@ namespace snmalloc
288
292
template <class T >
289
293
static void notify_all_on_address (stl::Atomic<T>& addr)
290
294
{
295
+ KeepErrno k;
291
296
static_assert (
292
297
sizeof (T) == sizeof (WaitingWord) && alignof (T) == alignof (WaitingWord),
293
298
" T must be the same size and alignment as WaitingWord" );
0 commit comments