mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-01 02:16:14 +01:00
gutf8: Factor out ifunc attribute checks
It looks like these might get more complex in future, as compilers claim to support the attribute (`__has_attribute(ifunc)` is true) but then raise errors at compile time if the target architecture doesn’t support ifuncs. For example, see #3511. This doesn’t fix #3511 (I don’t have time to test on musl right now), but it should make it easier to update the platform preprocessor conditions in future. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3511
This commit is contained in:
parent
e9902a66a9
commit
05fb05b49b
10
glib/gutf8.c
10
glib/gutf8.c
@ -42,6 +42,10 @@
|
||||
#include "glibintl.h"
|
||||
#include "gvalgrind.h"
|
||||
|
||||
#if g_macro__has_attribute(ifunc) && !defined(G_OS_WIN32)
|
||||
#define HAVE_WORKING_IFUNC_ATTRIBUTE 1
|
||||
#endif
|
||||
|
||||
#define UTF8_COMPUTE(Char, Mask, Len) \
|
||||
if (Char < 128) \
|
||||
{ \
|
||||
@ -1841,7 +1845,7 @@ g_utf8_validate_native (const char *str,
|
||||
return *str == 0;
|
||||
}
|
||||
|
||||
#if g_macro__has_attribute(ifunc) && !defined(G_OS_WIN32)
|
||||
#ifdef HAVE_WORKING_IFUNC_ATTRIBUTE
|
||||
/* The fast implementation of UTF-8 validation in `utf8_verify()` technically
|
||||
* uses undefined behaviour when the string length is not provided (i.e. when
|
||||
* it’s looking for a trailing nul terminator): when doing word-sized reads of
|
||||
@ -1889,7 +1893,7 @@ static gboolean (*resolve_g_utf8_validate (void)) (const char *, gssize, const c
|
||||
else
|
||||
return g_utf8_validate_native;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_WORKING_IFUNC_ATTRIBUTE */
|
||||
|
||||
/**
|
||||
* g_utf8_validate:
|
||||
@ -1924,7 +1928,7 @@ gboolean
|
||||
g_utf8_validate (const char *str,
|
||||
gssize max_len,
|
||||
const gchar **end)
|
||||
#if g_macro__has_attribute(ifunc) && !defined(G_OS_WIN32)
|
||||
#ifdef HAVE_WORKING_IFUNC_ATTRIBUTE
|
||||
__attribute__((ifunc ("resolve_g_utf8_validate")));
|
||||
#else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user