Skip to content

Commit d71389e

Browse files
committed
libschrift: Fix compile issue
Apply fix provided in issue #29 on GitHub: [guard unix-y implementation details](tomolt/libschrift#29)
1 parent 66decef commit d71389e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/src/main/jni/lib/schrift.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
# define WIN32_LEAN_AND_MEAN 1
3030
# include <windows.h>
3131
#else
32-
# define _POSIX_C_SOURCE 1
32+
# ifndef _POSIX_C_SOURCE
33+
# define _POSIX_C_SOURCE 1
34+
# endif
3335
# include <fcntl.h>
3436
# include <sys/mman.h>
3537
# include <sys/stat.h>
@@ -125,7 +127,9 @@ struct SFT_Font
125127

126128
/* function declarations */
127129
/* generic utility functions */
130+
#ifndef __USE_MISC
128131
static void *reallocarray(void *optr, size_t nmemb, size_t size);
132+
#endif
129133
static inline int fast_floor(double x);
130134
static inline int fast_ceil (double x);
131135
/* file loading */
@@ -406,6 +410,7 @@ sft_render(const SFT *sft, SFT_Glyph glyph, SFT_Image image)
406410
* if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW */
407411
#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
408412

413+
#ifndef __USE_MISC
409414
/* OpenBSD's reallocarray() standard libary function.
410415
* A wrapper for realloc() that takes two size args like calloc().
411416
* Useful because it eliminates common integer overflow bugs. */
@@ -419,6 +424,7 @@ reallocarray(void *optr, size_t nmemb, size_t size)
419424
}
420425
return realloc(optr, size * nmemb);
421426
}
427+
#endif
422428

423429
/* TODO maybe we should use long here instead of int. */
424430
static inline int

0 commit comments

Comments
 (0)