blob: d35600e104ba2bf39146511f8c9fc7cbd3456571 [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/**
Elliott Hughes0c50ed42023-07-10 22:32:09 +000043 * Provides information about hardware capabilities to arm64 ifunc resolvers.
Peter Collingbournee9491952019-10-28 10:57:26 -070044 *
Elliott Hughes0c50ed42023-07-10 22:32:09 +000045 * Prior to API level 30, arm64 ifunc resolvers are passed no arguments.
46 *
47 * Starting with API level 30, arm64 ifunc resolvers are passed two arguments.
48 * The first is a uint64_t whose value is equal to getauxval(AT_HWCAP) | _IFUNC_ARG_HWCAP.
49 * The second is a pointer to a data structure of this type.
50 *
51 * Code that wishes to be compatible with API levels before 30 must call getauxval() itself.
Peter Collingbournee9491952019-10-28 10:57:26 -070052 */
53typedef struct __ifunc_arg_t {
54 /** Set to sizeof(__ifunc_arg_t). */
55 unsigned long _size;
56
57 /** Set to getauxval(AT_HWCAP). */
58 unsigned long _hwcap;
59
60 /** Set to getauxval(AT_HWCAP2). */
61 unsigned long _hwcap2;
62} __ifunc_arg_t;
63
64/**
Elliott Hughes0c50ed42023-07-10 22:32:09 +000065 * If this bit is set in the first argument to an ifunc resolver, the second argument
66 * is a pointer to a data structure of type __ifunc_arg_t.
67 *
68 * This bit is always set on Android starting with API level 30.
69 * This bit is meaningless before API level 30 because ifunc resolvers are not passed any arguments.
70 * This bit has no real use on Android, but is included for glibc source compatibility;
71 * glibc used this bit to distinguish the case where the ifunc resolver received a single argument,
72 * which was an evolutionary stage Android never went through.
Peter Collingbournee9491952019-10-28 10:57:26 -070073 */
74#define _IFUNC_ARG_HWCAP (1ULL << 62)
75
76#endif
77
78__END_DECLS