Portál AbcLinuxu, 1. května 2025 12:08
Glibc6 používá thread safe funkce, gettext je součást této knihovny, takže by na tom měl být v současné době stejně, s vyjímkou volání fce setlocale(), která z důvodů náročnosti není thread safe:
3.19. bonnie reports that char i/o with glibc 2 is much slower than with libc5. What can be done?
4.2 Triggering gettext Operations
Díky makru HAVE_PER_THREAD_LOCALE
lze od roku 2005 používat v různých vláknech různé nastavení locales:
fix for multithreaded gettext() tests
Funkce gettext() vrací ukazatel na string, který je staticky alokovaný a nesmí se tedy měnit ani uvolňovat (man 3 gettext
):
If a translation was found in one of the specified catalogs, it is converted to the locale’s codeset and returned. The resulting string is statically allocated and must not be modified or freed. Otherwise msgid is returned.
Pro podrobnosti mrkni do zdrojáků glibc...
mmap()
a soubor *.mo se namapuje do paměti, viz glibc-2.7/locale/loadlocale.c
a fce _nl_load_locale()
.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.