Skip to content

Commit cab7ffe

Browse files
committed
use proxy headers for size_t/ssize_t
1 parent 11f29fe commit cab7ffe

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

libc/src/__support/OSUtil/mmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_MMAP_H
1010
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_MMAP_H
1111

12+
#include "hdr/types/off_t.h"
13+
#include "hdr/types/size_t.h"
1214
#include "src/__support/error_or.h"
1315
#include "src/__support/macros/config.h"
14-
#include <sys/mman.h> // For size_t and off_t
1516

1617
namespace LIBC_NAMESPACE_DECL {
1718
namespace internal {

libc/src/__support/OSUtil/munmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_MUNMAP_H
1010
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_MUNMAP_H
1111

12+
#include "hdr/types/off_t.h"
13+
#include "hdr/types/size_t.h"
1214
#include "src/__support/error_or.h"
1315
#include "src/__support/macros/config.h"
14-
#include <sys/mman.h> // For size_t and off_t
1516

1617
namespace LIBC_NAMESPACE_DECL {
1718
namespace internal {

libc/src/sys/mman/linux/mmap.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ LLVM_LIBC_FUNCTION(void *, mmap,
1919
off_t offset)) {
2020
auto ptr = internal::mmap(addr, size, prot, flags, fd, offset);
2121

22-
if (ptr.has_value())
23-
return ptr.value();
24-
25-
libc_errno = ptr.error();
26-
return MAP_FAILED;
22+
if (!ptr.has_value()) {
23+
libc_errno = ptr.error();
24+
return MAP_FAILED;
25+
}
26+
27+
return ptr.value();
2728
}
2829

2930
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)