Fix macOS build: nil macro clash and gli packed formats

The tr1 shared_ptr shim names its shared null counter null_counter, so
it survives MacTypes.h defining nil as an object-like macro. That
header arrives through apple_compat.h on every Apple build.

gl_texture2d.inl uses the unsuffixed GL 3.0 names GL_RGB9_E5 and
GL_R11F_G11F_B10F, with fallbacks to the EXT spellings or the literal
values when a header supplies neither. Apple keeps the EXT names in the
legacy <OpenGL/glext.h>, which the gl3.h path this tree takes never
pulls in.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-09-01 19:38:31 +02:00
1 parent 3ed03e0719
commit c404b20663
2 files changed
+24 -12

No files matched your search

+19 -8
View File
@@ -28,6 +28,25 @@
#include "../../gl.hpp"
/* GL 3.0 core spells these without a suffix. Apple only exposes the EXT
* names from the legacy <OpenGL/glext.h>, which the gl3.h header path
* this tree uses never pulls in. */
#ifndef GL_RGB9_E5
#ifdef GL_RGB9_E5_EXT
#define GL_RGB9_E5 GL_RGB9_E5_EXT
#else
#define GL_RGB9_E5 0x8C3D
#endif
#endif
#ifndef GL_R11F_G11F_B10F
#ifdef GL_R11F_G11F_B10F_EXT
#define GL_R11F_G11F_B10F GL_R11F_G11F_B10F_EXT
#else
#define GL_R11F_G11F_B10F 0x8C3A
#endif
#endif
namespace gli{
namespace detail
{
@@ -135,17 +154,9 @@ namespace detail
// Packed
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
#if defined(__APPLE__) && !defined(IOS)
{GL_RGB9_E5_EXT, GL_RGB9_E5_EXT,
#else
{GL_RGB9_E5, GL_RGB9_E5,
#endif
GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
#if defined(__APPLE__) && !defined(IOS)
{GL_R11F_G11F_B10F_EXT, GL_R11F_G11F_B10F_EXT,
#else
{GL_R11F_G11F_B10F, GL_R11F_G11F_B10F,
#endif
GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_RGBA4, GL_RGBA4, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
+5 -4
View File
@@ -27,8 +27,9 @@ class shared_ptr {
private:
T* ptr;
unsigned* count; //
/* special case, null pointer (nil-code) */
static unsigned* nil() { static unsigned nil_counter(1); return &nil_counter; }
/* Shared counter for the null pointer case. Not named nil:
* Apple's MacTypes.h defines that as an object-like macro. */
static unsigned* null_counter() { static unsigned counter(1); return &counter; }
void decref() { if (--(*count) == 0) { delete ptr; delete count; }}
void incref() { ++(*count); }
@@ -37,7 +38,7 @@ class shared_ptr {
public:
shared_ptr() : ptr(0), count(nil()) { incref(); }
shared_ptr() : ptr(0), count(null_counter()) { incref(); }
~shared_ptr() { decref(); }
shared_ptr(const shared_ptr<T>& o) : ptr(o.ptr), count(o.count) { incref(); }
@@ -80,7 +81,7 @@ class weak_ptr {
public:
weak_ptr() : ptr(0), count(shared_ptr<T>::nil()) {}
weak_ptr() : ptr(0), count(shared_ptr<T>::null_counter()) {}
explicit weak_ptr( const shared_ptr<T>& s) : ptr(s.ptr), count(s.count) {}
shared_ptr<T> lock() const { return shared_ptr<T>(*this); }