src/java.desktop/macosx/native/libsplashscreen/libpng/zlibwrapper/zlib.h
author ihse
Fri, 08 Jun 2018 18:11:32 +0200
changeset 50471 f0aeede1b855
parent 48752 src/java.desktop/macosx/native/libsplashscreen/libpng/zlib.h@0b1138ce244f
permissions -rw-r--r--
8204572: SetupJdkLibrary should setup SRC and -I flags automatically Reviewed-by: erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48752
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     1
/*
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     4
 *
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    10
 *
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    15
 * accompanied this code).
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    16
 *
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    20
 *
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    23
 * questions.
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    24
 */
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    25
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    26
/*
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    27
 * This header file is used to hijack the include of "zlib.h" from libpng on
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    28
 * Macos. We do that to be able to build on macos 10.13 or later, but still
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    29
 * keep binary compatibility with older versions (as specified to configure).
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    30
 *
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    31
 * The problem is that in 10.13, Macos shipped with a newer version of zlib,
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    32
 * which exports the function inflateValidate. There is a call to this
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    33
 * function in pngrutil.c, guarded by a preprocessor check of ZLIB_VERNUM being
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    34
 * high enough. If we compile this call in and link to the newer version of
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    35
 * zlib, we will get link errors if the code is executed on an older Mac with
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    36
 * an older version of zlib.
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    37
 *
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    38
 * The zlib.h header in Macos has been annotated with Macos specific macros that
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    39
 * guard these kinds of version specific APIs, but libpng is not using those
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    40
 * checks in its conditionals, just ZLIB_VERNUM. To fix this, we check for the
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    41
 * MAC_OS_X_VERSION_MIN_REQUIRED macro here and adjust the ZLIB_VERNUM to the
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    42
 # known version bundled with that release. This solution is certainly a hack,
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    43
 * but it seems the affected versions of zlib.h are compatible enough for this
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    44
 * to work.
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    45
 */
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    46
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    47
#include <zlib.h>
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    48
#include <AvailabilityMacros.h>
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    49
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    50
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    51
#  undef ZLIB_VERNUM
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    52
#  define ZLIB_VERNUM 0x1250
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    53
#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    54
#  undef ZLIB_VERNUM
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    55
#  define ZLIB_VERNUM 0x1280
0b1138ce244f 8196879: Forgot to add file in JDK-8196803
erikj
parents:
diff changeset
    56
#endif