blob: 7fbca4a4b1a4b34ea02d10c9b8656eb470e59454 [file] [log] [blame]
Peter Collingbournee9491952019-10-28 10:57:26 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#pragma once
30
31#include <sys/cdefs.h>
32
33/**
34 * @file sys/ifunc.h
35 * @brief Declarations used for ifunc resolvers. Currently only meaningful for arm64.
36 */
37
38__BEGIN_DECLS
39
40#if defined(__aarch64__)
41
42/**
43 * Provides information about hardware capabilities to ifunc resolvers.
44 *
45 * Starting with API level 30, ifunc resolvers on arm64 are passed two arguments. The first is a
46 * uint64_t whose value is equal to getauxval(AT_HWCAP) | _IFUNC_ARG_HWCAP. The second is a pointer
47 * to a data structure of this type. Prior to API level 30, no arguments are passed to ifunc
48 * resolvers. Code that wishes to be compatible with prior API levels should not accept any
49 * arguments in the resolver.
50 */
51typedef struct __ifunc_arg_t {
52 /** Set to sizeof(__ifunc_arg_t). */
53 unsigned long _size;
54
55 /** Set to getauxval(AT_HWCAP). */
56 unsigned long _hwcap;
57
58 /** Set to getauxval(AT_HWCAP2). */
59 unsigned long _hwcap2;
60} __ifunc_arg_t;
61
62/**
63 * If this bit is set in the first argument to an ifunc resolver, indicates that the second argument
64 * is a pointer to a data structure of type __ifunc_arg_t. This bit is always set on Android
65 * starting with API level 30.
66 */
67#define _IFUNC_ARG_HWCAP (1ULL << 62)
68
69#endif
70
71__END_DECLS