21 lines · cpp
1//===-- Implementation file for getauxval function --------------*- C++ -*-===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/sys/auxv/getauxval.h"10#include "src/__support/OSUtil/linux/auxv.h"11#include "src/__support/libc_errno.h"12 13namespace LIBC_NAMESPACE_DECL {14LLVM_LIBC_FUNCTION(unsigned long, getauxval, (unsigned long id)) {15 if (cpp::optional<unsigned long> val = auxv::get(id))16 return *val;17 libc_errno = ENOENT;18 return 0;19}20} // namespace LIBC_NAMESPACE_DECL21