From nobody Sat Jul 1 15:10:24 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QtbGT3Vdzz4kl5L; Sat, 1 Jul 2023 15:10:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QtbGT0yS7z4179; Sat, 1 Jul 2023 15:10:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688224225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tr884YOhLc3dpQEReYdLgLgaB3cboePFSZQTAZnGygc=; b=IaRSm021eBg4VtkMZR3rysTC8ybSfG+2BHoYpeG9AOC6psITNDpl0kVhqHY0tPl/rsHKmN 6GMuRxYwwoVQxEvGoGzd5CNLj/f+stwmH52VaNyqlzK6IZcX4RWv5iyFA2hzVKDe2/yTgv XVeJILAfv69lMBt6+jPtsIBAZHnvU7q5P9lzhw3aa2W8PuzZYgdvFcfP2fnjNErNUIJXxW 0aQ73QQeqYi9/au+mwZdgzm+C04r9vU0ORNiQSkCww1saP/9Yx3I0UeScgIaSW8DV186b0 woT64jRp6ZRirxgVKp0/QNRznsUF2GbvYWZQX1VCunLDQAa9PL854wFuzBDZkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688224225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tr884YOhLc3dpQEReYdLgLgaB3cboePFSZQTAZnGygc=; b=TIz0Bwy8vr6miTNblE0r7pdrDf9OQtJw/vWF7fNgMyadgifFju9deUxEL1Rg95hY3BcU33 4Dvh17OLlBsS08M03X2Sk5vY4xV4IpMkkqNV/y7hS+s6FuGFE4CZuidIqDbzSMu0Y2ddxa ByewsfT8JFS6sMKhkCl+g2aUkq09moVbvqMg0lRxzhQOgoPd1nlwD5dRUDoCUfcD/zmPAQ kYBmbnLF59YgJQM94l740dCH0EDCl0WI8PWhW6eV+sWOjtHLjpp0KA/fS9kQyGaIn7KcEM QqhxnZVTr6XfjcH8rouIts+02HBQEK4VlF35T42TV2KThiYUXJmgbdw7Fg7fbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688224225; a=rsa-sha256; cv=none; b=ZqfCQY9KKfkuiMKNFhy92a7y/kt+YhBLxBiDYyS5lm0HJNcnujqe2rgKiA3xN9O3OuFbzj 0cTeDdLw2jFnwKkenrWhNgAruiDAF8XN+cMvBn5H17iU3TvBq8yrs/tcISr7+peTs5mczT 5/Qu8vxLAxaDRijG4xtW6WFsd1ZLjSIu6IJTIk2tm0/SGEX+0SnUEkqS7swas1hxWqzmyG HnsgIHxtuAhbMkbpz/PVvS1sFuJuYT0k1l8Er6b+SKmpXJ2YuC2hhL5BR+pbYQXn+vAbFV t6v+bKn5a0rdowtLdXx+G7DoM/d8wO1bKwlwZ7ApcVRM3amSrzw/Dmbt1fAUDw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QtbGS7015zVwB; Sat, 1 Jul 2023 15:10:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 361FAOd0047419; Sat, 1 Jul 2023 15:10:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 361FAO1o047418; Sat, 1 Jul 2023 15:10:24 GMT (envelope-from git) Date: Sat, 1 Jul 2023 15:10:24 GMT Message-Id: <202307011510.361FAO1o047418@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Dirk Meyer Subject: git: 7311c841f51f - main - graphics/gd: add option to change timing of gdFontCacheMutex setup and shutdown List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dinoex X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7311c841f51fa73d3f380e2f4b270044e94a3b91 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dinoex: URL: https://cgit.FreeBSD.org/ports/commit/?id=7311c841f51fa73d3f380e2f4b270044e94a3b91 commit 7311c841f51fa73d3f380e2f4b270044e94a3b91 Author: Dirk Meyer AuthorDate: 2023-07-01 15:10:04 +0000 Commit: Dirk Meyer CommitDate: 2023-07-01 15:10:04 +0000 graphics/gd: add option to change timing of gdFontCacheMutex setup and shutdown PR: 272091 --- graphics/gd/Makefile | 4 +- graphics/gd/files/extra-patch-threads | 154 ++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 1 deletion(-) diff --git a/graphics/gd/Makefile b/graphics/gd/Makefile index 5aa0c8d80e74..686796921c90 100644 --- a/graphics/gd/Makefile +++ b/graphics/gd/Makefile @@ -24,7 +24,7 @@ SUB_FILES= gdlib-config USE_LDCONFIG= yes TEST_TARGET= check -OPTIONS_DEFINE= PNG JPEG WEBP TIFF XPM HEIF AVIF LIQ FREETYPE FONTCONFIG RAQM ICONV +OPTIONS_DEFINE= PNG JPEG WEBP TIFF XPM HEIF AVIF LIQ FREETYPE FONTCONFIG RAQM ICONV THREADS OPTIONS_DEFAULT=PNG JPEG WEBP TIFF FREETYPE FONTCONFIG ICONV NO_OPTIONS_SORT=yes OPTIONS_SUB= yes @@ -68,6 +68,8 @@ XPM_CONFIGURE_ON= --with-x XPM_CONFIGURE_OFF= --with-xpm=no ICONV_USES= iconv ICONV_CONFIGURE_ON= ${ICONV_CONFIGURE_ARG} +THREADS_EXTRA_PATCHES= ${PATCHDIR}/extra-patch-threads +THREADS_USES= autoreconf .include diff --git a/graphics/gd/files/extra-patch-threads b/graphics/gd/files/extra-patch-threads new file mode 100644 index 000000000000..d09a69ea46de --- /dev/null +++ b/graphics/gd/files/extra-patch-threads @@ -0,0 +1,154 @@ +--- configure.ac.orig 2021-09-11 04:43:11 UTC ++++ configure.ac +@@ -101,6 +101,8 @@ AC_CHECK_FUNC(sin,,[AC_CHECK_LIB(m,sin)]) + AX_PTHREAD() + AX_OPENMP() + ++AM_CONDITIONAL([HAVE_PTHREAD], [test "x$ax_pthread_ok" = "xyes"]) ++ + dnl We should default this to off in future releases. + AC_MSG_CHECKING([whether to support gd image formats]) + AC_ARG_ENABLE([gd-formats], +--- src/Makefile.am.orig 2021-09-11 04:43:11 UTC ++++ src/Makefile.am +@@ -129,4 +129,9 @@ libgd_la_LDFLAGS = -version-info $(GDLIB_LT_CURRENT):$ + + libgd_la_LIBADD = $(LTLIBICONV) + ++if HAVE_PTHREAD ++libgd_la_SOURCES += \ ++ gdinitfini.c ++endif ++ + LDADD = libgd.la $(LIBICONV) +--- src/gdft.c.orig 2021-09-11 04:43:11 UTC ++++ src/gdft.c +@@ -890,7 +890,17 @@ BGD_DECLARE(void) gdFreeFontCache () + */ + BGD_DECLARE(void) gdFontCacheShutdown () + { ++#if defined(HAVE_PTHREAD) ++ /* referring to bundled with php */ ++ gdMutexLock(gdFontCacheMutex); + if (fontCache) { ++ gdCacheDelete(fontCache); ++ fontCache = NULL; ++ FT_Done_FreeType(library); ++ } ++ gdMutexUnlock(gdFontCacheMutex); ++#else ++ if (fontCache) { + gdMutexLock(gdFontCacheMutex); + gdCacheDelete (fontCache); + /* 2.0.16: Gustavo Scotti: make sure we don't free this twice */ +@@ -899,6 +909,7 @@ BGD_DECLARE(void) gdFontCacheShutdown () + gdMutexShutdown (gdFontCacheMutex); + FT_Done_FreeType (library); + } ++#endif + } + + /** +@@ -948,11 +959,18 @@ BGD_DECLARE(int) gdFontCacheSetup (void) + /* Already set up */ + return 0; + } ++#if defined(HAVE_PTHREAD) ++ /* referring to bundled with php */ ++ if (FT_Init_FreeType (&library)) { ++ return -1; ++ } ++#else + gdMutexSetup (gdFontCacheMutex); + if (FT_Init_FreeType (&library)) { + gdMutexShutdown (gdFontCacheMutex); + return -1; + } ++#endif + fontCache = gdCacheCreate (FONTCACHESIZE, fontTest, fontFetch, fontRelease); + if (!fontCache) { + return -2; +@@ -1144,6 +1162,10 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImagePtr im, + tweenColorRelease); + + /***** initialize font library and font cache on first call ******/ ++#if defined(HAVE_PTHREAD) ++ /* referring to bundled with php */ ++ gdMutexLock(gdFontCacheMutex); ++#endif + if (!fontCache) { + if (gdFontCacheSetup () != 0) { + gdCacheDelete (tc_cache); +@@ -1151,7 +1173,11 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImagePtr im, + } + } + /*****/ ++#if defined(HAVE_PTHREAD) ++ /* referring to bundled with php */ ++#else + gdMutexLock (gdFontCacheMutex); ++#endif + /* get the font (via font cache) */ + fontkey.fontlist = fontlist; + if (strex) +--- src/gdhelpers.h.orig 2021-09-11 04:43:11 UTC ++++ src/gdhelpers.h +@@ -51,11 +51,22 @@ extern "C" { + # define gdMutexUnlock(x) LeaveCriticalSection(&x) + #elif defined(HAVE_PTHREAD) + # include ++# include "gd_errors.h" + # define gdMutexDeclare(x) pthread_mutex_t x + # define gdMutexSetup(x) pthread_mutex_init(&x, 0) + # define gdMutexShutdown(x) pthread_mutex_destroy(&x) +-# define gdMutexLock(x) pthread_mutex_lock(&x) +-# define gdMutexUnlock(x) pthread_mutex_unlock(&x) ++# define gdMutexLock(x) do {\ ++ int pten = 0;\ ++ if ((pten = pthread_mutex_lock(&x)) != 0) {\ ++ gd_error_ex(GD_DEBUG, "gdMutexLock(%s<%p>) %s\n", #x, x, strerror(pten));\ ++ }\ ++ } while (0) ++# define gdMutexUnlock(x) do {\ ++ int pten = 0;\ ++ if ((pten = pthread_mutex_unlock(&x)) != 0) {\ ++ gd_error_ex(GD_DEBUG, "gdMutexUnlock(%s<%p>) %s\n", #x, x, strerror(pten));\ ++ }\ ++ } while (0) + #else + # define gdMutexDeclare(x) + # define gdMutexSetup(x) +--- src/gdinitfini.c.orig 1970-01-01 00:00:00 UTC ++++ src/gdinitfini.c +@@ -0,0 +1,31 @@ ++#include ++#include "gd.h" ++#include "gd_errors.h" ++#include "gdhelpers.h" ++ ++#if defined(CPP_SHARP) ++#elif defined(_WIN32) ++#elif defined(HAVE_PTHREAD) ++ ++extern gdMutexDeclare(gdFontCacheMutex); ++ ++void ++_init() ++{ ++ int pten = 0; ++ if ((pten = gdMutexSetup(gdFontCacheMutex)) != 0) { ++ gd_error_ex(GD_ERROR, "%s gdMutexSetup %s\n", __func__, strerror(pten)); ++ } ++} ++ ++void ++_fini() ++{ ++ int pten = 0; ++ if ((pten = gdMutexShutdown(gdFontCacheMutex)) != 0) { ++ gd_error_ex(GD_ERROR, "%s gdMutexShutdown %s\n", __func__, strerror(pten)); ++ } ++} ++ ++#else ++#endif