brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 4ca26b6 Raw
98 lines · c
1//===-- Utilities for testing stdbit --------------------------------------===//2//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-exception6//7//===----------------------------------------------------------------------===//8 9/*10 * Declare these BEFORE including stdbit-macros.h so that this test may still be11 * run even if a given target doesn't yet have these individual entrypoints12 * enabled.13 */14 15#include "include/__llvm-libc-common.h"16 17#include <stdbool.h> // bool in C18 19#define STDBIT_STUB_FUNCTION(FUNC_NAME, LEADING_VAL)                           \20  unsigned FUNC_NAME##_uc(unsigned char __attribute__((unused)) x) {           \21    return LEADING_VAL##AU;                                                    \22  }                                                                            \23  unsigned FUNC_NAME##_us(unsigned short __attribute__((unused)) x) {          \24    return LEADING_VAL##BU;                                                    \25  }                                                                            \26  unsigned FUNC_NAME##_ui(unsigned int __attribute__((unused)) x) {            \27    return LEADING_VAL##CU;                                                    \28  }                                                                            \29  unsigned FUNC_NAME##_ul(unsigned long __attribute__((unused)) x) {           \30    return LEADING_VAL##DU;                                                    \31  }                                                                            \32  unsigned FUNC_NAME##_ull(unsigned long long __attribute__((unused)) x) {     \33    return LEADING_VAL##EU;                                                    \34  }35 36__BEGIN_C_DECLS37 38STDBIT_STUB_FUNCTION(stdc_leading_zeros, 0xA)39STDBIT_STUB_FUNCTION(stdc_leading_ones, 0xB)40STDBIT_STUB_FUNCTION(stdc_trailing_zeros, 0xC)41STDBIT_STUB_FUNCTION(stdc_trailing_ones, 0xD)42STDBIT_STUB_FUNCTION(stdc_first_leading_zero, 0xE)43STDBIT_STUB_FUNCTION(stdc_first_leading_one, 0xF)44STDBIT_STUB_FUNCTION(stdc_first_trailing_zero, 0x0)45STDBIT_STUB_FUNCTION(stdc_first_trailing_one, 0x1)46STDBIT_STUB_FUNCTION(stdc_count_zeros, 0x2)47STDBIT_STUB_FUNCTION(stdc_count_ones, 0x3)48 49bool stdc_has_single_bit_uc(unsigned char __attribute__((unused)) x) {50  return false;51}52bool stdc_has_single_bit_us(unsigned short __attribute__((unused)) x) {53  return false;54}55bool stdc_has_single_bit_ui(unsigned __attribute__((unused)) x) {56  return false;57}58bool stdc_has_single_bit_ul(unsigned long __attribute__((unused)) x) {59  return false;60}61bool stdc_has_single_bit_ull(unsigned long long __attribute__((unused)) x) {62  return false;63}64 65STDBIT_STUB_FUNCTION(stdc_bit_width, 0x4)66 67unsigned char stdc_bit_floor_uc(unsigned char __attribute__((unused)) x) {68  return 0x5AU;69}70unsigned short stdc_bit_floor_us(unsigned short __attribute__((unused)) x) {71  return 0x5BU;72}73unsigned stdc_bit_floor_ui(unsigned __attribute__((unused)) x) { return 0x5CU; }74unsigned long stdc_bit_floor_ul(unsigned long __attribute__((unused)) x) {75  return 0x5DUL;76}77unsigned long long stdc_bit_floor_ull(unsigned long long78                                      __attribute__((unused)) x) {79  return 0x5EULL;80}81 82unsigned char stdc_bit_ceil_uc(unsigned char __attribute__((unused)) x) {83  return 0x6AU;84}85unsigned short stdc_bit_ceil_us(unsigned short __attribute__((unused)) x) {86  return 0x6BU;87}88unsigned stdc_bit_ceil_ui(unsigned __attribute__((unused)) x) { return 0x6CU; }89unsigned long stdc_bit_ceil_ul(unsigned long __attribute__((unused)) x) {90  return 0x6DUL;91}92unsigned long long stdc_bit_ceil_ull(unsigned long long93                                     __attribute__((unused)) x) {94  return 0x6EULL;95}96 97__END_C_DECLS98