rulimine/common/stb_image.patch

76 lines
1.8 KiB
Diff
Raw Normal View History

--- common/stb/stb_image.h 2023-02-15 11:52:01.743616847 +0100
+++ common/stb/stb_image.h 2023-02-15 11:51:52.686949866 +0100
@@ -127,6 +127,37 @@
#ifndef STBI_INCLUDE_STB_IMAGE_H
#define STBI_INCLUDE_STB_IMAGE_H
+#include <stddef.h>
+#include <lib/libc.h>
+#include <mm/pmm.h>
+
+#define INT_MAX __INT_MAX__
+#define INT_MIN (-INT_MAX - 1)
+
+#define UINT_MAX ((size_t)INT_MAX * 2 + 1)
+#define UINT_MIN (-UINT_MAX - 1)
+
+#define SHRT_MAX __SHRT_MAX__
+#define SHRT_MIN (-SHRT_MAX - 1)
+
+#define STBI_ASSERT(x)
+
+#define STBI_MALLOC(x) ext_mem_alloc(x)
+#define STBI_REALLOC(x, y) ({ \
+ void *STBI_REALLOC_new_buf = ext_mem_alloc(y); \
+ memcpy(STBI_REALLOC_new_buf, x, y); \
+ STBI_REALLOC_new_buf; \
+})
+#define STBI_FREE(x)
+
+#define STBI_NO_THREAD_LOCALS
+#define STBI_NO_STDIO
+#define STBI_NO_SIMD
+#define STBI_NO_LINEAR
+
+#define STBI_ONLY_ZLIB
+#define STBI_SUPPORT_ZLIB
+
// DOCUMENTATION
//
// Limitations:
@@ -381,7 +412,7 @@
STBI_rgb_alpha = 4
};
-#include <stdlib.h>
+// #include <stdlib.h>
typedef unsigned char stbi_uc;
typedef unsigned short stbi_us;
@@ -584,9 +615,9 @@
#include <stdarg.h>
#include <stddef.h> // ptrdiff_t on osx
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
+// #include <stdlib.h>
+// #include <string.h>
+// #include <limits.h>
#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
#include <math.h> // ldexp, pow
@@ -1574,10 +1605,12 @@
STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; }
#endif
+/*
static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f;
STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; }
STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; }
+*/
//////////////////////////////////////////////////////////////////////////////