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 #define CPUINFO_COUNT_OF(array) (sizeof(array) / sizeof(0 [array])) 12 13 #if defined(__GNUC__) 14 #define CPUINFO_LIKELY(condition) (__builtin_expect(!!(condition), 1)) 15 #define CPUINFO_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) 16 #else 17 #define CPUINFO_LIKELY(condition) (!!(condition)) 18 #define CPUINFO_UNLIKELY(condition) (!!(condition)) 19 #endif 20 21 #ifndef CPUINFO_INTERNAL 22 #if defined(__ELF__) 23 #define CPUINFO_INTERNAL __attribute__((__visibility__("internal"))) 24 #elif defined(__MACH__) 25 #define CPUINFO_INTERNAL __attribute__((__visibility__("hidden"))) 26 #else 27 #define CPUINFO_INTERNAL 28 #endif 29 #endif 30 31 #ifndef CPUINFO_PRIVATE 32 #if defined(__ELF__) 33 #define CPUINFO_PRIVATE __attribute__((__visibility__("hidden"))) 34 #elif defined(__MACH__) 35 #define CPUINFO_PRIVATE __attribute__((__visibility__("hidden"))) 36 #else 37 #define CPUINFO_PRIVATE 38 #endif 39 #endif 40