Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / src / unistd / linux / sysconf.cpp
blobb16e15551fc7889e077a91403ee87a21720f0ec1
1 //===-- Linux implementation of sysconf -----------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "src/unistd/sysconf.h"
11 #include "src/__support/common.h"
13 #include "src/errno/libc_errno.h"
14 #include <linux/param.h> // For EXEC_PAGESIZE.
15 #include <unistd.h>
17 namespace LIBC_NAMESPACE {
19 LLVM_LIBC_FUNCTION(long, sysconf, (int name)) {
20 long ret = 0;
21 if (name == _SC_PAGESIZE) {
22 // TODO: get this information from the auxvector.
23 return EXEC_PAGESIZE;
25 // TODO: Complete the rest of the sysconf options.
26 if (ret < 0) {
27 libc_errno = EINVAL;
28 return -1;
30 return ret;
33 } // namespace LIBC_NAMESPACE