Home | History | Annotate | Download | only in lite_base
      1 /*
      2  * Copyright (C) 2018 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 // Basic integer type definitions.
     18 
     19 #ifndef NLP_SAFT_COMPONENTS_COMMON_MOBILE_LITE_BASE_INTEGRAL_TYPES_H_
     20 #define NLP_SAFT_COMPONENTS_COMMON_MOBILE_LITE_BASE_INTEGRAL_TYPES_H_
     21 
     22 namespace libtextclassifier3 {
     23 namespace mobile {
     24 
     25 typedef unsigned int uint32;
     26 typedef unsigned long long uint64;
     27 
     28 #ifndef SWIG
     29 typedef int int32;
     30 typedef unsigned char uint8;    // NOLINT
     31 typedef unsigned short uint16;  // NOLINT
     32 
     33 // A type to represent a Unicode code-point value. As of Unicode 4.0,
     34 // such values require up to 21 bits.
     35 // (For type-checking on pointers, make this explicitly signed,
     36 // and it should always be the signed version of whatever int32 is.)
     37 typedef signed int char32;
     38 #endif  // SWIG
     39 
     40 #ifdef COMPILER_MSVC
     41 typedef __int64 int64;
     42 #else
     43 typedef long long int64;  // NOLINT
     44 #endif  // COMPILER_MSVC
     45 
     46 // Some compile-time assertions that our new types have the intended size.
     47 static_assert(sizeof(int) == 4, "Our typedefs depend on int being 32 bits");
     48 static_assert(sizeof(uint32) == 4, "wrong size");
     49 static_assert(sizeof(int32) == 4, "wrong size");
     50 static_assert(sizeof(uint8) == 1, "wrong size");
     51 static_assert(sizeof(uint16) == 2, "wrong size");
     52 static_assert(sizeof(char32) == 4, "wrong size");
     53 static_assert(sizeof(int64) == 8, "wrong size");
     54 
     55 }  // namespace mobile
     56 }  // namespace nlp_saft
     57 
     58 #endif  // NLP_SAFT_COMPONENTS_COMMON_MOBILE_LITE_BASE_INTEGRAL_TYPES_H_
     59