Home | History | Annotate | Download | only in Source
      1 /*
      2  * Copyright (C) 2004, 2005, 2006, 2013 Apple Inc.
      3  * Copyright (C) 2009 Google Inc. All rights reserved.
      4  * Copyright (C) 2007-2009 Torch Mobile, Inc.
      5  * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Library General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Library General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Library General Public License
     18  * along with this library; see the file COPYING.LIB.  If not, write to
     19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA 02110-1301, USA.
     21  *
     22  */
     23 
     24 /* Include compiler specific macros */
     25 #include "wtf/Compiler.h"
     26 
     27 #if COMPILER(MSVC)
     28 #define _USE_MATH_DEFINES // Make math.h behave like other platforms.
     29 #endif
     30 
     31 /* ==== Platform adaptation macros: these describe properties of the target environment. ==== */
     32 
     33 /* HAVE() - specific system features (headers, functions or similar) that are present or not */
     34 #define HAVE(WTF_FEATURE) (defined HAVE_##WTF_FEATURE  && HAVE_##WTF_FEATURE)
     35 /* OS() - underlying operating system; only to be used for mandated low-level services like
     36    virtual memory, not to choose a GUI toolkit */
     37 #define OS(WTF_FEATURE) (defined WTF_OS_##WTF_FEATURE  && WTF_OS_##WTF_FEATURE)
     38 
     39 /* ==== Policy decision macros: these define policy choices for a particular port. ==== */
     40 
     41 /* USE() - use a particular third-party library or optional OS service */
     42 #define USE(WTF_FEATURE) (defined WTF_USE_##WTF_FEATURE  && WTF_USE_##WTF_FEATURE)
     43 /* ENABLE() - turn on a specific feature of WebKit */
     44 #define ENABLE(WTF_FEATURE) (defined ENABLE_##WTF_FEATURE  && ENABLE_##WTF_FEATURE)
     45 
     46 /* ==== OS() - underlying operating system; only to be used for mandated low-level services like
     47    virtual memory, not to choose a GUI toolkit ==== */
     48 
     49 /* OS(ANDROID) - Android */
     50 #ifdef ANDROID
     51 #define WTF_OS_ANDROID 1
     52 /* OS(MACOSX) - Any Darwin-based OS, including Mac OS X and iPhone OS */
     53 #elif defined(__APPLE__)
     54 #define WTF_OS_MACOSX 1
     55 /* OS(FREEBSD) - FreeBSD */
     56 #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
     57 #define WTF_OS_FREEBSD 1
     58 /* OS(LINUX) - Linux */
     59 #elif defined(__linux__)
     60 #define WTF_OS_LINUX 1
     61 /* OS(OPENBSD) - OpenBSD */
     62 #elif defined(__OpenBSD__)
     63 #define WTF_OS_OPENBSD 1
     64 /* OS(WIN) - Any version of Windows */
     65 #elif defined(WIN32) || defined(_WIN32)
     66 #define WTF_OS_WIN 1
     67 #endif
     68 
     69 /* OS(POSIX) - Any Unix-like system */
     70 #if OS(ANDROID)          \
     71     || OS(MACOSX)           \
     72     || OS(FREEBSD)          \
     73     || OS(LINUX)            \
     74     || OS(OPENBSD)          \
     75     || defined(unix)        \
     76     || defined(__unix)      \
     77     || defined(__unix__)
     78 #define WTF_OS_POSIX 1
     79 #endif
     80 
     81 /* There is an assumption in the project that either OS(WIN) or OS(POSIX) is set. */
     82 #if !OS(WIN) && !OS(POSIX)
     83 #error Either OS(WIN) or OS(POSIX) needs to be set.
     84 #endif
     85 
     86 /* Operating environments */
     87 
     88 #if OS(ANDROID)
     89 #define WTF_USE_LOW_QUALITY_IMAGE_INTERPOLATION 1
     90 #define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_DITHERING 1
     91 #define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_FANCY_UPSAMPLING 1
     92 #else
     93 #define WTF_USE_ICCJPEG 1
     94 #define WTF_USE_QCMSLIB 1
     95 #endif
     96 
     97 #if OS(MACOSX)
     98 #define WTF_USE_CF 1
     99 #define WTF_USE_RUBBER_BANDING 1
    100 #endif /* OS(MACOSX) */
    101 
    102 // On Mac, the system allocator is the real OS X system allocator.
    103 // On Android, the system allocator is the libc system allocator.
    104 // On other platforms, we've overriden the system allocator with tcmalloc.
    105 // PartitionAlloc seems to be faster than all of these, so on all platforms
    106 // we use it for a subset of performance sensitive Blink classes (tagged by
    107 // WTF_MAKE_FAST_ALLOCATED.
    108 #define WTF_USE_SYSTEM_MALLOC 0
    109 
    110 #if OS(POSIX)
    111 #define HAVE_SIGNAL_H 1
    112 #define HAVE_SYS_TIME_H 1
    113 #define WTF_USE_PTHREADS 1
    114 #endif /* OS(POSIX) */
    115 
    116 #if !OS(WIN) && !OS(ANDROID)
    117 #define HAVE_TM_GMTOFF 1
    118 #define HAVE_TM_ZONE 1
    119 #define HAVE_TIMEGM 1
    120 #endif
    121 
    122 #if OS(MACOSX)
    123 #define HAVE_PTHREAD_SETNAME_NP 1
    124 #define WTF_USE_NEW_THEME 1
    125 #endif /* OS(MACOSX) */
    126 
    127 #if OS(WIN)
    128 
    129 // If we don't define these, they get defined in windef.h.
    130 // We want to use std::min and std::max.
    131 #ifndef max
    132 #define max max
    133 #endif
    134 #ifndef min
    135 #define min min
    136 #endif
    137 
    138 #endif /* OS(WIN) */
    139 
    140 #ifdef __cplusplus
    141 
    142 // These undefs match up with defines in WebCorePrefixMac.h for Mac OS X.
    143 // Helps us catch if anyone uses new or delete by accident in code and doesn't include "config.h".
    144 #undef new
    145 #undef delete
    146 #include "wtf/FastMalloc.h"
    147 
    148 #include <ciso646>
    149 
    150 #endif
    151 
    152 #if COMPILER(MSVC)
    153 #define SKIP_STATIC_CONSTRUCTORS_ON_MSVC 1
    154 #else
    155 #define SKIP_STATIC_CONSTRUCTORS_ON_GCC 1
    156 #endif
    157 
    158 #if OS(LINUX) || OS(ANDROID) || OS(WIN)
    159 #define WTF_USE_HARFBUZZ 1
    160 #endif
    161