From 9988b1afcdbef057f873aca04d45599b7fa12fd4 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 19 Aug 2020 02:38:07 +0000 Subject: [PATCH] added check for the u and U prefix for string literals --- hawk/configure | 53 ++++++++++++++++++++++++++++++++++++++++++ hawk/configure.ac | 15 ++++++++++++ hawk/lib/hawk-cfg.h.in | 6 +++++ hawk/lib/hawk-cmn.h | 4 ++-- 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/hawk/configure b/hawk/configure index a6f2184e..ba3d132a 100755 --- a/hawk/configure +++ b/hawk/configure @@ -18517,6 +18517,59 @@ $as_echo "#define HAWK_PREFER_PREFIX_L 1" >>confdefs.h fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for char16_t literal" >&5 +$as_echo_n "checking for char16_t literal... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +const void* x = u"ab cd ef gh"; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAWK_HAVE_PREFIX_SMALL_U 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for char32_t literal" >&5 +$as_echo_n "checking for char32_t literal... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +const void* x = U"ab cd ef gh"; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAWK_HAVE_PREFIX_BIG_U 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_memset" >&5 $as_echo_n "checking for __builtin_memset... " >&6; } diff --git a/hawk/configure.ac b/hawk/configure.ac index 06de6800..39829c81 100644 --- a/hawk/configure.ac +++ b/hawk/configure.ac @@ -169,6 +169,21 @@ else fi fi +AC_MSG_CHECKING([for char16_t literal]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([], [const void* x = u"ab cd ef gh";])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAWK_HAVE_PREFIX_SMALL_U], [1], [char16_t literal prefix])], + [AC_MSG_RESULT(no)] +) + +AC_MSG_CHECKING([for char32_t literal]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([], [const void* x = U"ab cd ef gh";])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAWK_HAVE_PREFIX_BIG_U], [1], [char32_t literal prefix])], + [AC_MSG_RESULT(no)] +) dnl check some compiler builtins AC_MSG_CHECKING([for __builtin_memset]) diff --git a/hawk/lib/hawk-cfg.h.in b/hawk/lib/hawk-cfg.h.in index 6e85f22d..02eb803e 100644 --- a/hawk/lib/hawk-cfg.h.in +++ b/hawk/lib/hawk-cfg.h.in @@ -714,6 +714,12 @@ /* Unknown Endian */ #undef HAWK_ENDIAN_UNKNOWN +/* char32_t literal prefix */ +#undef HAWK_HAVE_PREFIX_BIG_U + +/* char16_t literal prefix */ +#undef HAWK_HAVE_PREFIX_SMALL_U + /* MB_LEN_MAX */ #undef HAWK_MBLEN_MAX diff --git a/hawk/lib/hawk-cmn.h b/hawk/lib/hawk-cmn.h index b0a91cf0..11872893 100644 --- a/hawk/lib/hawk-cmn.h +++ b/hawk/lib/hawk-cmn.h @@ -510,7 +510,7 @@ typedef unsigned char hawk_bchu_t; /* unsigned version of hawk_bch_t f // gcc/g++/clang/clang++: -fshort-wchar makes wchar_t to 2 bytes. HAWK_STATIC_ASSERT (HAWK_WIDE_CHAR_SIZE == sizeof(hawk_uch_t)); -#elif defined(HAWK_WIDE_CHAR_SIZE) && (HAWK_WIDE_CHAR_SIZE >= 4) && defined(__GNUC__) && defined(__CHAR32_TYPE__) +#elif defined(HAWK_WIDE_CHAR_SIZE) && (HAWK_WIDE_CHAR_SIZE >= 4) && defined(__GNUC__) && defined(__CHAR32_TYPE__) && defined(HAWK_HAVE_PREFIX_BIG_U) typedef __CHAR32_TYPE__ hawk_uch_t; typedef hawk_uint32_t hawk_uchu_t; # define HAWK_SIZEOF_UCH_T 4 @@ -523,7 +523,7 @@ typedef unsigned char hawk_bchu_t; /* unsigned version of hawk_bch_t f typedef hawk_uint32_t hawk_uchu_t; # define HAWK_SIZEOF_UCH_T 4 -#elif defined(__GNUC__) && defined(__CHAR16_TYPE__) +#elif defined(__GNUC__) && defined(__CHAR16_TYPE__) && defined(HAWK_HAVE_PREFIX_SMALL_U) typedef __CHAR16_TYPE__ hawk_uch_t; typedef hawk_uint16_t hawk_uchu_t; # define HAWK_SIZEOF_UCH_T 2