This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/4] Iconv: Add a macro allowing for alternate conversionloops


Hi,

the attached patch implements Ulrichs suggestions on how to enable an
iconv modules to provide alternate implementations of a certain
conversion.

Bye,

-Andreas-

2009-04-28  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* iconv/loop.c (BODY_SELECT_ALTERNATE, BODY_ALTERNATE): New macros
	allowing the definition of alternate conversion loops.
	(FCTNAME, SINGLE): Use the alternate conversion loop according to
	BODY_SELECT_ALTERNATE.


Index: libc/iconv/loop.c
===================================================================
--- libc.orig/iconv/loop.c
+++ libc/iconv/loop.c
@@ -167,6 +167,17 @@
 # error "Definition of BODY missing for function" LOOPFCT
 #endif
 
+/* Make sure the macros for the alternate loop body are properly
+   used.  */
+#if defined BODY_SELECT_ALTERNATE && !defined BODY_ALTERNATE
+# error "BODY_ALTERNATE has to be defined when using "\
+        "BODY_SELECT_ALTERNATE for function" LOOPFCT
+#endif
+
+#if !defined BODY_SELECT_ALTERNATE && defined BODY_ALTERNATE
+# warning "Defining BODY_ALTERNATE without BODY_SELECT_ALTERNATE "\
+          "does not have any effect for function" LOOPFCT
+#endif
 
 /* If no arguments have to passed to the loop function define the macro
    as empty.  */
@@ -329,7 +340,14 @@ FCTNAME (LOOPFCT) (struct __gconv_step *
 	 RESULT set to GCONV_INCOMPLETE_INPUT (if the size of the
 	 input characters vary in size), GCONV_ILLEGAL_INPUT, or
 	 GCONV_FULL_OUTPUT (if the output characters vary in size).  */
+#ifdef BODY_SELECT_ALTERNATE
+      if (BODY_SELECT_ALTERNATE)
+	BODY_ALTERNATE
+      else
+        BODY
+#else
       BODY
+#endif
     }
 
   /* Update the pointers pointed to by the parameters.  */
@@ -430,7 +448,14 @@ SINGLE(LOOPFCT) (struct __gconv_step *st
 
   do
     {
+#ifdef BODY_SELECT_ALTERNATE
+      if (BODY_SELECT_ALTERNATE)
+	BODY_ALTERNATE
+      else
+	BODY
+#else
       BODY
+#endif
     }
   while (0);
 
@@ -502,6 +527,8 @@ gconv_btowc (struct __gconv_step *step, 
 #undef MAX_NEEDED_OUTPUT
 #undef LOOPFCT
 #undef BODY
+#undef BODY_SELECT_ALTERNATE
+#undef BODY_ALTERNATE
 #undef LOOPFCT
 #undef EXTRA_LOOP_DECLS
 #undef INIT_PARAMS


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]