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