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 //===----------------------------------------------------------------------===// 8 9 #include "src/unistd/sysconf.h" 10 11 #include "src/__support/common.h" 12 13 #include "src/errno/libc_errno.h" 14 #include "src/sys/auxv/getauxval.h" 15 #include <sys/auxv.h> 16 #include <unistd.h> 17 18 namespace LIBC_NAMESPACE { 19 20 LLVM_LIBC_FUNCTION(long, sysconf, (int name)) { 21 long ret = 0; 22 if (name == _SC_PAGESIZE) 23 return static_cast<long>(getauxval(AT_PAGESZ)); 24 25 // TODO: Complete the rest of the sysconf options. 26 if (ret < 0) { 27 libc_errno = EINVAL; 28 return -1; 29 } 30 return ret; 31 } 32 33 } // namespace LIBC_NAMESPACE 34