Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178116769
D46954.1796014190.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D46954.1796014190.diff
View Options
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
--- a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
@@ -46,15 +46,6 @@
#include <stdlib.h>
#include <unistd.h>
-/*
- * sbrk is obsolete, and libc only provides it on a subset of
- * architectures.
- */
-#if defined(__amd64__) || defined(__arm__) || defined(__i386__) || \
- defined(__powerpc__)
-#define HAVE_SBRK
-#endif
-
#ifdef __FreeBSD__
#include <limits.h>
#define _KMEMUSER
@@ -112,9 +103,7 @@
unsigned long vmin = 0;
size_t len = sizeof(vmin);
#endif
-#ifdef HAVE_SBRK
void *invalid_ptr;
-#endif
void *buf;
#ifdef __FreeBSD__
@@ -168,12 +157,14 @@
#endif
(void)free(buf);
-#ifdef HAVE_SBRK
/*
- * Try to create a pointer to an unmapped page - first after current
- * brk will likely do.
+ * Try to create a pointer to an unmapped page - mmap and then
+ * munmap a page.
*/
- invalid_ptr = (void*)(((uintptr_t)sbrk(0)+page) & ~(page-1));
+ invalid_ptr = mmap(NULL, page, PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE, -1, 0);
+ ATF_REQUIRE(invalid_ptr != MAP_FAILED);
+ ATF_REQUIRE(munmap(invalid_ptr, page) == 0);
printf("testing with (hopefully) invalid pointer %p\n", invalid_ptr);
errno = 0;
@@ -181,7 +172,6 @@
errno = 0;
ATF_REQUIRE_ERRNO(ENOMEM, munlock(invalid_ptr, page) == -1);
-#endif
}
#ifdef __FreeBSD__
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 30, 4:49 AM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41638320
Default Alt Text
D46954.1796014190.diff (1 KB)
Attached To
Mode
D46954: mlock_test: use mmap/munmap for unmapped pointer
Attached
Detach File
Event Timeline