Fix build issues regarding formatter for Win32

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/248
This commit is contained in:
Akira TAGOH 2020-08-06 12:44:39 +09:00
parent a5fd5dc471
commit a53f79b4a2
4 changed files with 15 additions and 3 deletions

View File

@ -61,6 +61,7 @@ static inline void _FCMemoryBarrier (void) {
} }
typedef LONG fc_atomic_int_t; typedef LONG fc_atomic_int_t;
#define FC_ATOMIC_INT_FORMAT "ld"
#define fc_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V)) #define fc_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V))
#define fc_atomic_ptr_get(P) (_FCMemoryBarrier (), (void *) *(P)) #define fc_atomic_ptr_get(P) (_FCMemoryBarrier (), (void *) *(P))
@ -73,6 +74,7 @@ typedef LONG fc_atomic_int_t;
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
typedef int fc_atomic_int_t; typedef int fc_atomic_int_t;
#define FC_ATOMIC_INT_FORMAT "d"
#define fc_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V)) #define fc_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
#define fc_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P)) #define fc_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P))
@ -85,6 +87,7 @@ typedef int fc_atomic_int_t;
#elif !defined(FC_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) #elif !defined(FC_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
typedef int fc_atomic_int_t; typedef int fc_atomic_int_t;
#define FC_ATOMIC_INT_FORMAT "d"
#define fc_atomic_int_add(AI, V) __sync_fetch_and_add (&(AI), (V)) #define fc_atomic_int_add(AI, V) __sync_fetch_and_add (&(AI), (V))
#define fc_atomic_ptr_get(P) (void *) (__sync_synchronize (), *(P)) #define fc_atomic_ptr_get(P) (void *) (__sync_synchronize (), *(P))
@ -97,6 +100,7 @@ typedef int fc_atomic_int_t;
#include <mbarrier.h> #include <mbarrier.h>
typedef unsigned int fc_atomic_int_t; typedef unsigned int fc_atomic_int_t;
#define FC_ATOMIC_INT_FORMAT "u"
#define fc_atomic_int_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V)) #define fc_atomic_int_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V))
#define fc_atomic_ptr_get(P) ( ({__machine_rw_barrier ();}), (void *) *(P)) #define fc_atomic_ptr_get(P) ( ({__machine_rw_barrier ();}), (void *) *(P))
@ -107,6 +111,7 @@ typedef unsigned int fc_atomic_int_t;
#define FC_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */ #define FC_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */
typedef volatile int fc_atomic_int_t; typedef volatile int fc_atomic_int_t;
#define FC_ATOMIC_INT_FORMAT "d"
#define fc_atomic_int_add(AI, V) (((AI) += (V)) - (V)) #define fc_atomic_int_add(AI, V) (((AI) += (V)) - (V))
#define fc_atomic_ptr_get(P) ((void *) *(P)) #define fc_atomic_ptr_get(P) ((void *) *(P))
@ -116,6 +121,7 @@ typedef volatile int fc_atomic_int_t;
#else /* FC_NO_MT */ #else /* FC_NO_MT */
typedef int fc_atomic_int_t; typedef int fc_atomic_int_t;
#define FC_ATOMIC_INT_FORMAT "d"
#define fc_atomic_int_add(AI, V) (((AI) += (V)) - (V)) #define fc_atomic_int_add(AI, V) (((AI) += (V)) - (V))
#define fc_atomic_ptr_get(P) ((void *) *(P)) #define fc_atomic_ptr_get(P) ((void *) *(P))

View File

@ -808,7 +808,7 @@ FcCacheFini (void)
if (fcCacheChains[i] != NULL) if (fcCacheChains[i] != NULL)
{ {
FcCacheSkip *s = fcCacheChains[i]; FcCacheSkip *s = fcCacheChains[i];
printf("Fontconfig error: not freed %p (dir: %s, refcount %d)\n", s->cache, FcCacheDir(s->cache), s->ref.count); printf("Fontconfig error: not freed %p (dir: %s, refcount %" FC_ATOMIC_INT_FORMAT ")\n", s->cache, FcCacheDir(s->cache), s->ref.count);
} }
} }
else else
@ -1157,14 +1157,14 @@ FcDirChecksum (struct stat *statb)
else if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0)) else if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
|| (errno != 0 && epoch == 0)) || (errno != 0 && epoch == 0))
fprintf (stderr, fprintf (stderr,
"Fontconfig: SOURCE_DATE_EPOCH: strtoull: %s: %llu\n", "Fontconfig: SOURCE_DATE_EPOCH: strtoull: %s: %" FC_UINT64_FORMAT "\n",
strerror(errno), epoch); strerror(errno), epoch);
else if (*endptr != '\0') else if (*endptr != '\0')
fprintf (stderr, fprintf (stderr,
"Fontconfig: SOURCE_DATE_EPOCH has trailing garbage\n"); "Fontconfig: SOURCE_DATE_EPOCH has trailing garbage\n");
else if (epoch > ULONG_MAX) else if (epoch > ULONG_MAX)
fprintf (stderr, fprintf (stderr,
"Fontconfig: SOURCE_DATE_EPOCH must be <= %lu but saw: %llu\n", "Fontconfig: SOURCE_DATE_EPOCH must be <= %lu but saw: %" FC_UINT64_FORMAT "\n",
ULONG_MAX, epoch); ULONG_MAX, epoch);
else if (epoch < ret) else if (epoch < ret)
/* Only override if directory is newer */ /* Only override if directory is newer */

View File

@ -84,6 +84,10 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
#define FC_UNUSED #define FC_UNUSED
#endif #endif
#ifndef FC_UINT64_FORMAT
#define FC_UINT64_FORMAT "llu"
#endif
#define FC_DBG_MATCH 1 #define FC_DBG_MATCH 1
#define FC_DBG_MATCHV 2 #define FC_DBG_MATCHV 2
#define FC_DBG_EDIT 4 #define FC_DBG_EDIT 4

View File

@ -51,6 +51,8 @@
typedef SSIZE_T ssize_t; typedef SSIZE_T ssize_t;
#endif #endif
#define FC_UINT64_FORMAT "I64u"
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#ifndef S_ISDIR #ifndef S_ISDIR