1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <cstdint> 18 19 #include "berberis/guest_abi/guest_function_wrapper_signature.h" 20 21 namespace berberis { 22 23 namespace { 24 25 static_assert('z' == kGuestFunctionWrapperSignatureChar<bool>); 26 static_assert('b' == kGuestFunctionWrapperSignatureChar<char>); 27 static_assert('s' == kGuestFunctionWrapperSignatureChar<int16_t>); 28 static_assert('c' == kGuestFunctionWrapperSignatureChar<uint16_t>); 29 static_assert('i' == kGuestFunctionWrapperSignatureChar<int>); 30 static_assert('l' == kGuestFunctionWrapperSignatureChar<long long>); 31 static_assert('p' == kGuestFunctionWrapperSignatureChar<void*>); 32 33 static_assert('i' == kGuestFunctionWrapperSignatureChar<int32_t>); 34 static_assert('l' == kGuestFunctionWrapperSignatureChar<int64_t>); 35 36 static_assert('f' == kGuestFunctionWrapperSignatureChar<float>); 37 static_assert(sizeof(int32_t) == sizeof(float)); 38 static_assert('d' == kGuestFunctionWrapperSignatureChar<double>); 39 static_assert(sizeof(int64_t) == sizeof(double)); 40 41 using f1 = void(); 42 static_assert(2 == sizeof(kGuestFunctionWrapperSignature<f1>)); 43 static_assert('v' == kGuestFunctionWrapperSignature<f1>[0]); 44 static_assert('\0' == kGuestFunctionWrapperSignature<f1>[1]); 45 46 using pf1 = void (*)(); 47 static_assert(2 == sizeof(kGuestFunctionWrapperSignature<pf1>)); 48 static_assert('v' == kGuestFunctionWrapperSignature<pf1>[0]); 49 static_assert('\0' == kGuestFunctionWrapperSignature<pf1>[1]); 50 51 using f2 = int(double, double); 52 static_assert(4 == sizeof(kGuestFunctionWrapperSignature<f2>)); 53 static_assert('i' == kGuestFunctionWrapperSignature<f2>[0]); 54 static_assert('d' == kGuestFunctionWrapperSignature<f2>[1]); 55 static_assert('d' == kGuestFunctionWrapperSignature<f2>[2]); 56 static_assert('\0' == kGuestFunctionWrapperSignature<f2>[3]); 57 58 } // namespace 59 60 } // namespace berberis 61