mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 16:32:18 +01:00 
			
		
		
		
	Enable the endianness test.
2005-08-08 Matthias Clasen <mclasen@redhat.com> * tests/convert-test.c: Enable the endianness test. * glib/gconvert.c: Make the caching of iconv descriptors optional. * configure.in: Add an --enable-iconv-cache option, and default to disabling iconv caching on new enough glibc. Somebody with access to Solaris systems will need to test if opening/closing of iconv descriptors is enough of a performance problem to warrant the caching on that platform. Note that the caching is causing correctness problems in some corner cases, thus turning it off is desirable unless it has severe performance implications.
This commit is contained in:
		
				
					committed by
					
						 Matthias Clasen
						Matthias Clasen
					
				
			
			
				
	
			
			
			
						parent
						
							81b6a73938
						
					
				
				
					commit
					717f3d4abb
				
			
							
								
								
									
										14
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								ChangeLog
									
									
									
									
									
								
							| @@ -1,5 +1,19 @@ | ||||
| 2005-08-08  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* tests/convert-test.c: Enable the endianness test. | ||||
|  | ||||
| 	* glib/gconvert.c: Make the caching of iconv descriptors | ||||
| 	optional. | ||||
|  | ||||
| 	* configure.in: Add an --enable-iconv-cache option, and | ||||
| 	default to disabling iconv caching on new enough glibc. | ||||
| 	Somebody with access to Solaris systems will need to test | ||||
| 	if opening/closing of iconv descriptors is enough of | ||||
| 	a performance problem to warrant the caching on that  | ||||
| 	platform. Note that the caching is causing correctness | ||||
| 	problems in some corner cases, thus turning it off | ||||
| 	is desirable unless it has severe performance implications. | ||||
|  | ||||
| 	* tests/convert-test.c: Add a test for  | ||||
| 	endianness handling. | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,19 @@ | ||||
| 2005-08-08  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* tests/convert-test.c: Enable the endianness test. | ||||
|  | ||||
| 	* glib/gconvert.c: Make the caching of iconv descriptors | ||||
| 	optional. | ||||
|  | ||||
| 	* configure.in: Add an --enable-iconv-cache option, and | ||||
| 	default to disabling iconv caching on new enough glibc. | ||||
| 	Somebody with access to Solaris systems will need to test | ||||
| 	if opening/closing of iconv descriptors is enough of | ||||
| 	a performance problem to warrant the caching on that  | ||||
| 	platform. Note that the caching is causing correctness | ||||
| 	problems in some corner cases, thus turning it off | ||||
| 	is desirable unless it has severe performance implications. | ||||
|  | ||||
| 	* tests/convert-test.c: Add a test for  | ||||
| 	endianness handling. | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,19 @@ | ||||
| 2005-08-08  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* tests/convert-test.c: Enable the endianness test. | ||||
|  | ||||
| 	* glib/gconvert.c: Make the caching of iconv descriptors | ||||
| 	optional. | ||||
|  | ||||
| 	* configure.in: Add an --enable-iconv-cache option, and | ||||
| 	default to disabling iconv caching on new enough glibc. | ||||
| 	Somebody with access to Solaris systems will need to test | ||||
| 	if opening/closing of iconv descriptors is enough of | ||||
| 	a performance problem to warrant the caching on that  | ||||
| 	platform. Note that the caching is causing correctness | ||||
| 	problems in some corner cases, thus turning it off | ||||
| 	is desirable unless it has severe performance implications. | ||||
|  | ||||
| 	* tests/convert-test.c: Add a test for  | ||||
| 	endianness handling. | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,19 @@ | ||||
| 2005-08-08  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* tests/convert-test.c: Enable the endianness test. | ||||
|  | ||||
| 	* glib/gconvert.c: Make the caching of iconv descriptors | ||||
| 	optional. | ||||
|  | ||||
| 	* configure.in: Add an --enable-iconv-cache option, and | ||||
| 	default to disabling iconv caching on new enough glibc. | ||||
| 	Somebody with access to Solaris systems will need to test | ||||
| 	if opening/closing of iconv descriptors is enough of | ||||
| 	a performance problem to warrant the caching on that  | ||||
| 	platform. Note that the caching is causing correctness | ||||
| 	problems in some corner cases, thus turning it off | ||||
| 	is desirable unless it has severe performance implications. | ||||
|  | ||||
| 	* tests/convert-test.c: Add a test for  | ||||
| 	endianness handling. | ||||
|  | ||||
|   | ||||
							
								
								
									
										28
									
								
								configure.in
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								configure.in
									
									
									
									
									
								
							| @@ -396,6 +396,34 @@ if test "x$found_iconv" = "xno" ; then | ||||
|    AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv]) | ||||
| fi | ||||
|  | ||||
| jm_GLIBC21 | ||||
| AC_ARG_ENABLE(iconv-cache,  | ||||
|               [AC_HELP_STRING([--enable-iconv-cache=@<:@yes/no/auto@:>@], | ||||
|                               [cache iconv descriptors [default=auto]])],, | ||||
|               [enable_iconv_cache=auto]) | ||||
|  | ||||
| AC_MSG_CHECKING([Whether to cache iconv descriptors]) | ||||
| case $enable_iconv_cache in | ||||
|   auto) | ||||
|     if test $ac_cv_gnu_library_2_1 = yes; then | ||||
|       enable_iconv_cache=no | ||||
|     else  | ||||
|       enable_iconv_cache=yes | ||||
|     fi | ||||
|   ;; | ||||
|   yes|no)  | ||||
|   ;; | ||||
|   *) AC_MSG_ERROR([Value given to --enable-iconv-cache must be one of yes, no or auto]) | ||||
|   ;; | ||||
| esac | ||||
|  | ||||
| if test $enable_iconv_cache = yes; then | ||||
|    AC_DEFINE(NEED_ICONV_CACHE,1,[Do we cache iconv descriptors]) | ||||
| fi | ||||
|  | ||||
| AC_MSG_RESULT($enable_iconv_cache) | ||||
|  | ||||
|  | ||||
| dnl | ||||
| dnl gettext support | ||||
| dnl | ||||
|   | ||||
| @@ -196,6 +196,8 @@ g_iconv_close (GIConv converter) | ||||
| } | ||||
|  | ||||
|  | ||||
| #ifdef NEED_ICONV_CACHE | ||||
|  | ||||
| #define ICONV_CACHE_SIZE   (16) | ||||
|  | ||||
| struct _iconv_cache_bucket { | ||||
| @@ -463,6 +465,47 @@ close_converter (GIConv converter) | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
| #else  /* !NEED_ICONV_CACHE */ | ||||
|  | ||||
| static GIConv | ||||
| open_converter (const gchar *to_codeset, | ||||
| 		const gchar *from_codeset, | ||||
| 		GError     **error) | ||||
| { | ||||
|   GIConv cd; | ||||
|  | ||||
|   cd = g_iconv_open (to_codeset, from_codeset); | ||||
|  | ||||
|   if (cd == (GIConv) -1) | ||||
|     { | ||||
|       /* Something went wrong.  */ | ||||
|       if (error) | ||||
| 	{ | ||||
| 	  if (errno == EINVAL) | ||||
| 	    g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION, | ||||
| 			 _("Conversion from character set '%s' to '%s' is not supported"), | ||||
| 			 from_codeset, to_codeset); | ||||
| 	  else | ||||
| 	    g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, | ||||
| 			 _("Could not open converter from '%s' to '%s'"), | ||||
| 			 from_codeset, to_codeset); | ||||
| 	} | ||||
|     } | ||||
|    | ||||
|   return cd; | ||||
| } | ||||
|  | ||||
| static int | ||||
| close_converter (GIConv cd) | ||||
| { | ||||
|   if (cd == (GIConv) -1) | ||||
|     return 0; | ||||
|    | ||||
|   return g_iconv_close (cd);   | ||||
| } | ||||
|  | ||||
| #endif /* NEED_ICONV_CACHE */ | ||||
|  | ||||
| /** | ||||
|  * g_convert_with_iconv: | ||||
|  * @str:           the string to convert | ||||
|   | ||||
| @@ -106,7 +106,6 @@ test_byte_order (void) | ||||
|   gsize bytes_read = 0; | ||||
|   gsize bytes_written = 0; | ||||
|   GError *error = NULL;   | ||||
|   int i; | ||||
|  | ||||
|   out = g_convert (in_be, sizeof (in_be),  | ||||
| 		   "UTF-8", "UTF-16", | ||||
| @@ -125,7 +124,7 @@ test_byte_order (void) | ||||
| 		   &error); | ||||
|  | ||||
|   g_assert (error == NULL); | ||||
|   g_assert (bytes_read == 2); | ||||
|   g_assert (bytes_read == 4); | ||||
|   g_assert (bytes_written == 2); | ||||
|   g_assert (strcmp (out, expected) == 0); | ||||
|   g_free (out); | ||||
| @@ -136,13 +135,7 @@ main (int argc, char *argv[]) | ||||
| { | ||||
|   test_iconv_state (); | ||||
|   test_one_half (); | ||||
|    | ||||
| #if 0 | ||||
|   /* this one currently fails due to  | ||||
|    * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=165368  | ||||
|    */ | ||||
|   test_byte_order (); | ||||
| #endif | ||||
|  | ||||
|   return 0; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user