Nullability check for mman module.

Bugs: b/245972273
Test: adb shell
Change-Id: Ib5c4887d89581eaedcf4a3e128811a6a374a8d1b
diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h
index bcf856d..cbe6a75 100644
--- a/libc/include/sys/mman.h
+++ b/libc/include/sys/mman.h
@@ -50,9 +50,9 @@
  * and returns `MAP_FAILED` and sets `errno` on failure.
  */
 #if defined(__USE_FILE_OFFSET64)
-void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset) __RENAME(mmap64);
+void* _Nonnull mmap(void* _Nullable __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset) __RENAME(mmap64);
 #else
-void* mmap(void* __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset);
+void* _Nonnull mmap(void* _Nullable __addr, size_t __size, int __prot, int __flags, int __fd, off_t __offset);
 #endif
 
 /**
@@ -62,7 +62,7 @@
  *
  * Available since API level 21.
  */
-void* mmap64(void* __addr, size_t __size, int __prot, int __flags, int __fd, off64_t __offset) __INTRODUCED_IN(21);
+void* _Nonnull mmap64(void* _Nullable __addr, size_t __size, int __prot, int __flags, int __fd, off64_t __offset) __INTRODUCED_IN(21);
 
 /**
  * [munmap(2)](http://man7.org/linux/man-pages/man2/munmap.2.html)
@@ -70,7 +70,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int munmap(void* __addr, size_t __size);
+int munmap(void* _Nonnull __addr, size_t __size);
 
 /**
  * [msync(2)](http://man7.org/linux/man-pages/man2/msync.2.html)
@@ -78,7 +78,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int msync(void* __addr, size_t __size, int __flags);
+int msync(void* _Nonnull __addr, size_t __size, int __flags);
 
 /**
  * [mprotect(2)](http://man7.org/linux/man-pages/man2/mprotect.2.html)
@@ -86,7 +86,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int mprotect(void* __addr, size_t __size, int __prot);
+int mprotect(void* _Nonnull __addr, size_t __size, int __prot);
 
 /** Flag for mremap(). */
 #define MREMAP_MAYMOVE  1
@@ -101,7 +101,7 @@
  * Returns the address of the mapping on success,
  * and returns `MAP_FAILED` and sets `errno` on failure.
  */
-void* mremap(void* __old_addr, size_t __old_size, size_t __new_size, int __flags, ...);
+void* _Nonnull mremap(void* _Nonnull __old_addr, size_t __old_size, size_t __new_size, int __flags, ...);
 
 /**
  * [mlockall(2)](http://man7.org/linux/man-pages/man2/mlockall.2.html)
@@ -129,7 +129,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int mlock(const void* __addr, size_t __size);
+int mlock(const void* _Nonnull __addr, size_t __size);
 
 /**
  * [mlock2(2)](http://man7.org/linux/man-pages/man2/mlock.2.html)
@@ -139,7 +139,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int mlock2(const void* __addr, size_t __size, int __flags) __INTRODUCED_IN(30);
+int mlock2(const void* _Nonnull __addr, size_t __size, int __flags) __INTRODUCED_IN(30);
 
 /**
  * [munlock(2)](http://man7.org/linux/man-pages/man2/munlock.2.html)
@@ -147,7 +147,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int munlock(const void* __addr, size_t __size);
+int munlock(const void* _Nonnull __addr, size_t __size);
 
 /**
  * [mincore(2)](http://man7.org/linux/man-pages/man2/mincore.2.html)
@@ -155,7 +155,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int mincore(void* __addr, size_t __size, unsigned char* __vector);
+int mincore(void* _Nonnull __addr, size_t __size, unsigned char* _Nonnull __vector);
 
 /**
  * [madvise(2)](http://man7.org/linux/man-pages/man2/madvise.2.html)
@@ -163,7 +163,7 @@
  *
  * Returns 0 on success, and returns -1 and sets `errno` on failure.
  */
-int madvise(void* __addr, size_t __size, int __advice);
+int madvise(void* _Nonnull __addr, size_t __size, int __advice);
 
 /**
  * [process_madvise(2)](http://man7.org/linux/man-pages/man2/process_madvise.2.html)
@@ -177,7 +177,7 @@
  *
  * Returns the number of bytes advised on success, and returns -1 and sets `errno` on failure.
  */
-ssize_t process_madvise(int __pid_fd, const struct iovec* __iov, size_t __count, int __advice, unsigned __flags) __INTRODUCED_IN(31);
+ssize_t process_madvise(int __pid_fd, const struct iovec* _Nonnull __iov, size_t __count, int __advice, unsigned __flags) __INTRODUCED_IN(31);
 
 #if defined(__USE_GNU)
 
@@ -189,7 +189,7 @@
  *
  * Returns an fd on success, and returns -1 and sets `errno` on failure.
  */
-int memfd_create(const char* __name, unsigned __flags) __INTRODUCED_IN(30);
+int memfd_create(const char* _Nonnull __name, unsigned __flags) __INTRODUCED_IN(30);
 
 #endif
 
@@ -226,6 +226,6 @@
  *
  * Returns 0 on success, and returns a positive error number on failure.
  */
-int posix_madvise(void* __addr, size_t __size, int __advice) __INTRODUCED_IN(23);
+int posix_madvise(void* _Nonnull __addr, size_t __size, int __advice) __INTRODUCED_IN(23);
 
 __END_DECLS
diff --git a/tests/sys_mman_test.cpp b/tests/sys_mman_test.cpp
index e403ea5..803852a 100644
--- a/tests/sys_mman_test.cpp
+++ b/tests/sys_mman_test.cpp
@@ -218,7 +218,10 @@
 }
 
 TEST(sys_mman, mremap) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnonnull"
   ASSERT_EQ(MAP_FAILED, mremap(nullptr, 0, 0, 0));
+#pragma clang diagnostic pop
 }
 
 constexpr size_t kHuge = size_t(PTRDIFF_MAX) + 1;