From 75cc3e6ef0e451f42d3464ed4d639304ad9a4f58 Mon Sep 17 00:00:00 2001
From: Akira TAGOH <akira@tagoh.org>
Date: Thu, 3 Jul 2025 03:31:49 +0900
Subject: [PATCH] test: Fix a build issue with musl libc

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/484

Changelog: fixed
Upstream-Status: Backport [https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/75cc3e6ef0e451f42d3464ed4d639304ad9a4f58]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 test/test-mt-fccfg.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/test/test-mt-fccfg.c b/test/test-mt-fccfg.c
index 24ad7583..3b7d843d 100644
--- a/test/test-mt-fccfg.c
+++ b/test/test-mt-fccfg.c
@@ -1,9 +1,12 @@
 /* Copyright (C) 2025 fontconfig Authors */
 /* SPDX-License-Identifier: HPND */
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <fontconfig/fontconfig.h>
 
 #include <stdio.h>
-#define __USE_XOPEN
 #include <pthread.h>
 #include <stdlib.h>
 
@@ -13,6 +16,21 @@ struct thr_arg_s {
     int thr_num;
 };
 
+#ifdef _WIN32
+int
+setenv (const char *name, const char *value, int o)
+{
+    size_t len = strlen (name) + strlen (value) + 1;
+    char  *s = malloc (len + 1);
+    int    ret;
+
+    snprintf (s, len, "%s=%s", name, value);
+    ret = _putenv (s);
+    free (s);
+    return ret;
+}
+#endif
+
 static void *
 run_test_in_thread (void *arg)
 {
@@ -61,7 +79,7 @@ test (void)
     if (c1 == c2)
 	return 1;
     /* To make visible if we have any references */
-    putenv ("FC_DEBUG=16");
+    setenv ("FC_DEBUG", "16", 1);
     FcFini();
 
     return 0;
-- 
GitLab

