1 /* 2 * Copyright (c) Facebook, Inc. and its affiliates. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9 #pragma once 10 11 12 #define CPUINFO_COUNT_OF(array) (sizeof(array) / sizeof(0[array])) 13 14 #if defined(__GNUC__) 15 #define CPUINFO_LIKELY(condition) (__builtin_expect(!!(condition), 1)) 16 #define CPUINFO_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) 17 #else 18 #define CPUINFO_LIKELY(condition) (!!(condition)) 19 #define CPUINFO_UNLIKELY(condition) (!!(condition)) 20 #endif 21 22 #ifndef CPUINFO_INTERNAL 23 #if defined(__ELF__) 24 #define CPUINFO_INTERNAL __attribute__((__visibility__("internal"))) 25 #elif defined(__MACH__) 26 #define CPUINFO_INTERNAL __attribute__((__visibility__("hidden"))) 27 #else 28 #define CPUINFO_INTERNAL 29 #endif 30 #endif 31 32 #ifndef CPUINFO_PRIVATE 33 #if defined(__ELF__) 34 #define CPUINFO_PRIVATE __attribute__((__visibility__("hidden"))) 35 #elif defined(__MACH__) 36 #define CPUINFO_PRIVATE __attribute__((__visibility__("hidden"))) 37 #else 38 #define CPUINFO_PRIVATE 39 #endif 40 #endif 41