--- lib/internal.h.orig	2023-02-01 18:12:14.000000000 +0800
+++ lib/internal.h	2023-08-23 07:21:32.000000000 +0800
@@ -45,6 +45,10 @@
 #endif
 #endif
 
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+#endif
+
 // Typedef DWORD (defined by pcsc lib) to pcsc_word to make it clear that this
 // is not the Windows meaning of DWORD, but the PCSC library's meaning.  This
 // differs: Windows defines a DWORD as 32-bits, but pcsclite defines it as
@@ -251,7 +255,7 @@
 #elif defined(HAVE_EXPLICIT_BZERO)
 #include <strings.h>
 #define yc_memzero explicit_bzero
-#elif defined(__linux__)
+#elif defined(__linux__) || (defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED < 1090)
 #include <openssl/crypto.h>
 #define yc_memzero OPENSSL_cleanse
 #else


--- lib/ykpiv.c.orig	2023-02-01 18:12:14.000000000 +0800
+++ lib/ykpiv.c	2023-08-23 07:28:21.000000000 +0800
@@ -641,11 +641,13 @@
   rc = SCardListReaders(state->context, NULL, readers, &num_readers);
   if (rc != SCARD_S_SUCCESS) {
     DBG("SCardListReaders failed, rc=%lx", (long)rc);
+#ifdef SCARD_E_NO_READERS_AVAILABLE
     if(rc == SCARD_E_NO_READERS_AVAILABLE || rc == SCARD_E_SERVICE_STOPPED) {
       *readers = 0;
       *len = 1;
       return YKPIV_OK;
     }
+#endif
     SCardReleaseContext(state->context);
     state->context = (SCARDCONTEXT)-1;
     return pcsc_to_yrc(rc);
