1 // Copyright (C) 2019 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Various portability macros, type definitions, and inline functions. 16 17 #ifndef ICING_TEXT_CLASSIFIER_LIB3_UTILS_BASE_PORT_H_ 18 #define ICING_TEXT_CLASSIFIER_LIB3_UTILS_BASE_PORT_H_ 19 20 namespace libtextclassifier3 { 21 22 #if defined(__GNUC__) && \ 23 (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) 24 25 // For functions we want to force inline. 26 // Introduced in gcc 3.1. 27 #define TC3_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) 28 29 // For functions we don't want to inline, e.g., to keep code size small. 30 #define TC3_ATTRIBUTE_NOINLINE __attribute__((noinline)) 31 32 #elif defined(_MSC_VER) 33 #define TC3_ATTRIBUTE_ALWAYS_INLINE __forceinline 34 #else 35 36 // Other compilers will have to figure it out for themselves. 37 #define TC3_ATTRIBUTE_ALWAYS_INLINE 38 #define TC3_ATTRIBUTE_NOINLINE 39 #endif 40 41 } // namespace libtextclassifier3 42 43 #endif // ICING_TEXT_CLASSIFIER_LIB3_UTILS_BASE_PORT_H_ 44