Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix platform check for macOS #895

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,11 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif

#if defined(MACOS) || defined(TARGET_OS_MAC)
#if TARGET_OS_OSX
# define OS_CODE 7
# ifndef Z_SOLO
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
Copy link

@glandium glandium Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The history of this code is interesting.
zlib 0.71 (the first version in git) had:

#ifdef MACOS
#  define OS_CODE  0x07
#endif

zlib 1.0.8 added the fdopen thing, but differently:

#if defined(MACOS) || defined(TARGET_OS_MAC)
#  define OS_CODE  0x07
#  ifndef fdopen
#    define fdopen(fd,mode) NULL /* No fdopen() */
#  endif
#endif
#if defined(__MWERKS__) && !defined(fdopen)
#  if __dest_os != __be_os && __dest_os != __win32_os
#    define fdopen(fd,mode) NULL
#  endif
#endif

The corresponding changelog:

  • check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
  • do not use fdopen for Metrowerks on Mac (Brad Pettit))

zlib 1.1.3 changed it to:

#if defined(MACOS) || defined(TARGET_OS_MAC)
#  define OS_CODE  0x07
#  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
#    include <unix.h> /* for fdopen */
#  else
#    ifndef fdopen
#      define fdopen(fd,mode) NULL /* No fdopen() */
#    endif
#  endif
#endif

I think the corresponding changelog entry is:

  • Support gzdopen on Mac with Metrowerks (Jason Linhart)

Presumably, Metrowerks was defining TARGET_OS_MAC, and probably didn't define TARGET_OS_OSX, so my assumption here is that this change breaks Metrowerks. However, it's also a long gone compiler, so maybe this part can go entirely, which leaves us with two different OS_CODE values for macOS, one of which was added in ce12c5c

# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
# endif
#endif
Expand Down