Home | History | Annotate | Download | only in wtf
      1 /*
      2  * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
      3  * Copyright (C) 2007-2009 Torch Mobile, Inc.
      4  * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     22  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     23  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  */
     27 
     28 #ifndef WTF_Platform_h
     29 #define WTF_Platform_h
     30 
     31 /* Include compiler specific macros */
     32 #include "wtf/Compiler.h"
     33 
     34 /* ==== Platform adaptation macros: these describe properties of the target environment. ==== */
     35 
     36 /* HAVE() - specific system features (headers, functions or similar) that are present or not */
     37 #define HAVE(WTF_FEATURE) (defined HAVE_##WTF_FEATURE  && HAVE_##WTF_FEATURE)
     38 /* OS() - underlying operating system; only to be used for mandated low-level services like
     39    virtual memory, not to choose a GUI toolkit */
     40 #define OS(WTF_FEATURE) (defined WTF_OS_##WTF_FEATURE  && WTF_OS_##WTF_FEATURE)
     41 
     42 /* ==== Policy decision macros: these define policy choices for a particular port. ==== */
     43 
     44 /* USE() - use a particular third-party library or optional OS service */
     45 #define USE(WTF_FEATURE) (defined WTF_USE_##WTF_FEATURE  && WTF_USE_##WTF_FEATURE)
     46 /* ENABLE() - turn on a specific feature of WebKit */
     47 #define ENABLE(WTF_FEATURE) (defined ENABLE_##WTF_FEATURE  && ENABLE_##WTF_FEATURE)
     48 
     49 /* ==== OS() - underlying operating system; only to be used for mandated low-level services like
     50    virtual memory, not to choose a GUI toolkit ==== */
     51 
     52 /* OS(ANDROID) - Android */
     53 #ifdef ANDROID
     54 #define WTF_OS_ANDROID 1
     55 #endif
     56 
     57 /* OS(DARWIN) - Any Darwin-based OS, including Mac OS X and iPhone OS */
     58 #ifdef __APPLE__
     59 #define WTF_OS_DARWIN 1
     60 #endif
     61 
     62 /* OS(FREEBSD) - FreeBSD */
     63 #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
     64 #define WTF_OS_FREEBSD 1
     65 #endif
     66 
     67 /* OS(HURD) - GNU/Hurd */
     68 #ifdef __GNU__
     69 #define WTF_OS_HURD 1
     70 #endif
     71 
     72 /* OS(LINUX) - Linux */
     73 #ifdef __linux__
     74 #define WTF_OS_LINUX 1
     75 #endif
     76 
     77 /* OS(NETBSD) - NetBSD */
     78 #if defined(__NetBSD__)
     79 #define WTF_OS_NETBSD 1
     80 #endif
     81 
     82 /* OS(OPENBSD) - OpenBSD */
     83 #ifdef __OpenBSD__
     84 #define WTF_OS_OPENBSD 1
     85 #endif
     86 
     87 /* OS(SOLARIS) - Solaris */
     88 #if defined(sun) || defined(__sun)
     89 #define WTF_OS_SOLARIS 1
     90 #endif
     91 
     92 /* OS(WINDOWS) - Any version of Windows */
     93 #if defined(WIN32) || defined(_WIN32)
     94 #define WTF_OS_WINDOWS 1
     95 #endif
     96 
     97 /* OS(UNIX) - Any Unix-like system */
     98 #if OS(ANDROID)          \
     99     || OS(DARWIN)           \
    100     || OS(FREEBSD)          \
    101     || OS(HURD)             \
    102     || OS(LINUX)            \
    103     || OS(NETBSD)           \
    104     || OS(OPENBSD)          \
    105     || OS(SOLARIS)          \
    106     || defined(unix)        \
    107     || defined(__unix)      \
    108     || defined(__unix__)
    109 #define WTF_OS_UNIX 1
    110 #endif
    111 
    112 /* Operating environments */
    113 
    114 #if OS(ANDROID)
    115 #define WTF_USE_LOW_QUALITY_IMAGE_INTERPOLATION 1
    116 #define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_DITHERING 1
    117 #define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_FANCY_UPSAMPLING 1
    118 #else
    119 #define WTF_USE_ICCJPEG 1
    120 #define WTF_USE_QCMSLIB 1
    121 #endif
    122 
    123 #if OS(DARWIN)
    124 #define WTF_USE_CF 1
    125 
    126 /* We can't override the global operator new and delete on OS(DARWIN) because
    127  * some object are allocated by WebKit and deallocated by the embedder. */
    128 #else /* !OS(DARWIN) */
    129 /* On non-OS(DARWIN), the "system malloc" is actually TCMalloc anyway, so there's
    130  * no need to use WebKit's copy of TCMalloc. */
    131 #define WTF_USE_SYSTEM_MALLOC 1
    132 #endif /* OS(DARWIN) */
    133 
    134 #if !defined(HAVE_ACCESSIBILITY)
    135 #define HAVE_ACCESSIBILITY 1
    136 #endif /* !defined(HAVE_ACCESSIBILITY) */
    137 
    138 #if OS(UNIX)
    139 #define HAVE_MMAP 1
    140 #define HAVE_SIGNAL_H 1
    141 #define HAVE_SYS_TIME_H 1
    142 #define WTF_USE_PTHREADS 1
    143 #endif /* OS(UNIX) */
    144 
    145 #if !defined(HAVE_VASPRINTF)
    146 #if !COMPILER(MSVC)
    147 #define HAVE_VASPRINTF 1
    148 #endif
    149 #endif
    150 
    151 #if !OS(WINDOWS) && !OS(SOLARIS) && !OS(ANDROID)
    152 #define HAVE_TM_GMTOFF 1
    153 #define HAVE_TM_ZONE 1
    154 #define HAVE_TIMEGM 1
    155 #endif
    156 
    157 #if OS(DARWIN)
    158 #define HAVE_DISPATCH_H 1
    159 #define HAVE_MADV_FREE 1
    160 #define HAVE_PTHREAD_SETNAME_NP 1
    161 #define HAVE_MADV_FREE_REUSE 1
    162 #endif /* OS(DARWIN) */
    163 
    164 #if OS(WINDOWS)
    165 #define HAVE_ISDEBUGGERPRESENT 1
    166 #define HAVE_VIRTUALALLOC 1
    167 #endif
    168 
    169 #endif /* WTF_Platform_h */
    170