1 //===-- sanitizer_getauxval.h -----------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Common getauxval() guards and definitions.
10 // getauxval() is not defined until glibc version 2.16, or until API level 21
13 //===----------------------------------------------------------------------===//
15 #ifndef SANITIZER_GETAUXVAL_H
16 #define SANITIZER_GETAUXVAL_H
18 #include "sanitizer_platform.h"
20 #if SANITIZER_LINUX || SANITIZER_FUCHSIA
22 # include <features.h>
24 # ifndef __GLIBC_PREREQ
25 # define __GLIBC_PREREQ(x, y) 0
28 # if __GLIBC_PREREQ(2, 16) || (SANITIZER_ANDROID && __ANDROID_API__ >= 21) || \
30 # define SANITIZER_USE_GETAUXVAL 1
32 # define SANITIZER_USE_GETAUXVAL 0
35 # if SANITIZER_USE_GETAUXVAL
36 # include <sys/auxv.h>
38 // The weak getauxval definition allows to check for the function at runtime.
39 // This is useful for Android, when compiled at a lower API level yet running
40 // on a more recent platform that offers the function.
41 extern "C" SANITIZER_WEAK_ATTRIBUTE
42 unsigned long getauxval(unsigned long type); // NOLINT
45 #endif // SANITIZER_LINUX || SANITIZER_FUCHSIA
47 #endif // SANITIZER_GETAUXVAL_H