Home | History | Annotate | Download | only in base
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // This file overrides the inclusion of talk/base/basictypes.h to remove
      6 // collisions with Chromium's base/basictypes.h.   We then add back a few
      7 // items that Chromium's version doesn't provide, but libjingle expects.
      8 
      9 #ifndef OVERRIDES_TALK_BASE_BASICTYPES_H__
     10 #define OVERRIDES_TALK_BASE_BASICTYPES_H__
     11 
     12 #include "base/basictypes.h"
     13 #include "build/build_config.h"
     14 
     15 #ifndef INT_TYPES_DEFINED
     16 #define INT_TYPES_DEFINED
     17 #ifdef COMPILER_MSVC
     18 typedef __int64 int64;
     19 #endif /* COMPILER_MSVC */
     20 
     21 #ifdef COMPILER_MSVC
     22 typedef unsigned __int64 uint64;
     23 typedef __int64 int64;
     24 #define INT64_C(x) x ## I64
     25 #define UINT64_C(x) x ## UI64
     26 #define INT64_F "I64"
     27 #else
     28 #ifndef INT64_C
     29 #define INT64_C(x) x ## LL
     30 #endif
     31 #ifndef UINT64_C
     32 #define UINT64_C(x) x ## ULL
     33 #endif
     34 #ifndef INT64_F
     35 #define INT64_F "ll"
     36 #endif
     37 #endif /* COMPILER_MSVC */
     38 #endif  // INT_TYPES_DEFINED
     39 
     40 #ifdef WIN32
     41 typedef int socklen_t;
     42 #endif
     43 
     44 namespace talk_base {
     45 template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
     46 template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
     47 
     48 // For wait functions that take a number of milliseconds, kForever indicates
     49 // unlimited time.
     50 const int kForever = -1;
     51 }
     52 
     53 #ifdef WIN32
     54 #define alignof(t) __alignof(t)
     55 #else  // !WIN32
     56 #define alignof(t) __alignof__(t)
     57 #endif  // !WIN32
     58 #define IS_ALIGNED(p, a) (0==(reinterpret_cast<uintptr_t>(p) & ((a)-1)))
     59 #define ALIGNP(p, t) \
     60   (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
     61   ((t)-1)) & ~((t)-1))))
     62 
     63 #endif // OVERRIDES_TALK_BASE_BASICTYPES_H__
     64