1 /* 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 arm64 ifunc resolvers. 44 * 45 * 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. 52 */ 53 typedef 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 /** 65 * 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. 73 */ 74 #define _IFUNC_ARG_HWCAP (1ULL << 62) 75 76 #endif 77 78 __END_DECLS 79