Home | History | Annotate | Download | only in src
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 // This file contains platform-specific typedefs and defines.
     12 
     13 #ifndef WEBRTC_TYPEDEFS_H_
     14 #define WEBRTC_TYPEDEFS_H_
     15 
     16 // Reserved words definitions
     17 // TODO(andrew): Look at removing these.
     18 #define WEBRTC_EXTERN extern
     19 #define G_CONST const
     20 #define WEBRTC_INLINE extern __inline
     21 
     22 // Define WebRTC preprocessor identifiers based on the current build platform.
     23 // TODO(andrew): Clean these up. We can probably remove everything in this
     24 // block.
     25 //   - TARGET_MAC_INTEL and TARGET_MAC aren't used anywhere.
     26 //   - In the few places where TARGET_PC is used, it should be replaced by
     27 //     something more specific.
     28 //   - Do we really support PowerPC? Probably not. Remove WEBRTC_MAC_INTEL
     29 //     from build/common.gypi as well.
     30 #if defined(WIN32)
     31     // Windows & Windows Mobile.
     32     #if !defined(WEBRTC_TARGET_PC)
     33         #define WEBRTC_TARGET_PC
     34     #endif
     35 #elif defined(__APPLE__)
     36     // Mac OS X.
     37     #if defined(__LITTLE_ENDIAN__ )
     38         #if !defined(WEBRTC_TARGET_MAC_INTEL)
     39             #define WEBRTC_TARGET_MAC_INTEL
     40         #endif
     41     #else
     42         #if !defined(WEBRTC_TARGET_MAC)
     43             #define WEBRTC_TARGET_MAC
     44         #endif
     45     #endif
     46 #else
     47     // Linux etc.
     48     #if !defined(WEBRTC_TARGET_PC)
     49         #define WEBRTC_TARGET_PC
     50     #endif
     51 #endif
     52 
     53 // Derived from Chromium's build/build_config.h
     54 // Processor architecture detection.  For more info on what's defined, see:
     55 //   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
     56 //   http://www.agner.org/optimize/calling_conventions.pdf
     57 //   or with gcc, run: "echo | gcc -E -dM -"
     58 // TODO(andrew): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN?
     59 #if defined(_M_X64) || defined(__x86_64__)
     60 #define WEBRTC_ARCH_X86_FAMILY
     61 #define WEBRTC_ARCH_X86_64
     62 #define WEBRTC_ARCH_64_BITS
     63 #define WEBRTC_ARCH_LITTLE_ENDIAN
     64 #elif defined(_M_IX86) || defined(__i386__)
     65 #define WEBRTC_ARCH_X86_FAMILY
     66 #define WEBRTC_ARCH_X86
     67 #define WEBRTC_ARCH_32_BITS
     68 #define WEBRTC_ARCH_LITTLE_ENDIAN
     69 #elif defined(__ARMEL__)
     70 // TODO(andrew): We'd prefer to control platform defines here, but this is
     71 // currently provided by the Android makefiles. Commented to avoid duplicate
     72 // definition warnings.
     73 //#define WEBRTC_ARCH_ARM
     74 // TODO(andrew): Chromium uses the following two defines. Should we switch?
     75 //#define WEBRTC_ARCH_ARM_FAMILY
     76 //#define WEBRTC_ARCH_ARMEL
     77 #define WEBRTC_ARCH_32_BITS
     78 #define WEBRTC_ARCH_LITTLE_ENDIAN
     79 #elif defined(__mips__)
     80 #define WEBRTC_ARCH_32_BITS
     81 #define WEBRTC_ARCH_LITTLE_ENDIAN
     82 #else
     83 #error Please add support for your architecture in typedefs.h
     84 #endif
     85 
     86 #if defined(__SSE2__) || defined(_MSC_VER)
     87 #define WEBRTC_USE_SSE2
     88 #endif
     89 
     90 #if defined(WEBRTC_TARGET_PC)
     91 
     92 #if !defined(_MSC_VER)
     93   #include <stdint.h>
     94 #else
     95     // Define C99 equivalent types.
     96     // Since MSVC doesn't include these headers, we have to write our own
     97     // version to provide a compatibility layer between MSVC and the WebRTC
     98     // headers.
     99     typedef signed char         int8_t;
    100     typedef signed short        int16_t;
    101     typedef signed int          int32_t;
    102     typedef signed long long    int64_t;
    103     typedef unsigned char       uint8_t;
    104     typedef unsigned short      uint16_t;
    105     typedef unsigned int        uint32_t;
    106     typedef unsigned long long  uint64_t;
    107 #endif
    108 
    109 #if defined(WIN32)
    110     typedef __int64             WebRtc_Word64;
    111     typedef unsigned __int64    WebRtc_UWord64;
    112 #else
    113     typedef int64_t             WebRtc_Word64;
    114     typedef uint64_t            WebRtc_UWord64;
    115 #endif
    116     typedef int32_t             WebRtc_Word32;
    117     typedef uint32_t            WebRtc_UWord32;
    118     typedef int16_t             WebRtc_Word16;
    119     typedef uint16_t            WebRtc_UWord16;
    120     typedef char                WebRtc_Word8;
    121     typedef uint8_t             WebRtc_UWord8;
    122 
    123     // Define endian for the platform
    124     #define WEBRTC_LITTLE_ENDIAN
    125 
    126 #elif defined(WEBRTC_TARGET_MAC_INTEL)
    127     #include <stdint.h>
    128 
    129     typedef int64_t             WebRtc_Word64;
    130     typedef uint64_t            WebRtc_UWord64;
    131     typedef int32_t             WebRtc_Word32;
    132     typedef uint32_t            WebRtc_UWord32;
    133     typedef int16_t             WebRtc_Word16;
    134     typedef char                WebRtc_Word8;
    135     typedef uint16_t            WebRtc_UWord16;
    136     typedef uint8_t             WebRtc_UWord8;
    137 
    138     // Define endian for the platform
    139     #define WEBRTC_LITTLE_ENDIAN
    140 
    141 #else
    142     #error "No platform defined for WebRTC type definitions (typedefs.h)"
    143 #endif
    144 
    145 #endif  // WEBRTC_TYPEDEFS_H_
    146