Debian Codegraph @

libc/src/unistd/linux/getpagesize.cpp

raw
1 //===-- Linux implementation of getpagesize -------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "src/unistd/getpagesize.h"
10
11 #include "src/__support/OSUtil/linux/auxv.h"
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14
15 namespace LIBC_NAMESPACE_DECL {
16
17 LLVM_LIBC_FUNCTION(int, getpagesize, ()) {
18 cpp::optional<unsigned long> page_size =
19 (LIBC_NAMESPACE::auxv::get(AT_PAGESZ));
20 if (page_size)
21 return static_cast<int>(*page_size);
22 return -1;
23 }
24
25 } // namespace LIBC_NAMESPACE_DECL