diff mbox

[02/14] S390: Mention s390-specific gconv-modues before common ones.

Message ID 5718E880.1090200@linux.vnet.ibm.com
State New
Headers show

Commit Message

Stefan Liebler April 21, 2016, 2:49 p.m. UTC
On 04/15/2016 12:27 PM, Florian Weimer wrote:
> On 02/23/2016 10:21 AM, Stefan Liebler wrote:
>> +    ${AWK} 'BEGIN { emitted = 0 } \
>> +    emitted || NF == 0 || $$1 ~ /^#/ { print; next; } \
>> +    !emitted { emit_s390_modules(); emitted = 1; print; } \
>
> I would like to suggest to put the awk script into a separate file (and
> reflect it in the makefile dependencies).
>
> Florian
>
Okay. Done.

Here is the updated ChangeLog:

	* sysdeps/s390/s390-64/Makefile ($(objpfx)gconv-modules-s390):
	Mention s390-specific gconv-modules before common ones.
	* sysdeps/s390/gconv-modules-s390.awk: New file.
diff mbox

Patch

From d72d7ed0480722727350c29b2dcd5a202d532c19 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.vnet.ibm.com>
Date: Thu, 21 Apr 2016 12:42:48 +0200
Subject: [PATCH 02/14] S390: Mention s390-specific gconv-modues before common
 ones.

This patch changes the order in gconv-modules. Now the s390-specific
modules are mentioned before the common ones, because these modules
aren't used in all possible conversions. E.g. the converting-step from
INTERNAL to UTF-16 used the common UTF-16.so module instead of
UTF16_UTF32_Z9.so.

The awk script is parsing the source gconv-modules file and copies it
line by line. The s390 modules are emitted between the header-comments
and the first common-code-module.

ChangeLog:

	* sysdeps/s390/s390-64/Makefile ($(objpfx)gconv-modules-s390):
	Mention s390-specific gconv-modules before common ones.
	* sysdeps/s390/gconv-modules-s390.awk: New file.
---
 sysdeps/s390/gconv-modules-s390.awk | 81 +++++++++++++++++++++++++++++++++++++
 sysdeps/s390/s390-64/Makefile       | 36 +----------------
 2 files changed, 83 insertions(+), 34 deletions(-)
 create mode 100644 sysdeps/s390/gconv-modules-s390.awk

diff --git a/sysdeps/s390/gconv-modules-s390.awk b/sysdeps/s390/gconv-modules-s390.awk
new file mode 100644
index 0000000..344c7b3
--- /dev/null
+++ b/sysdeps/s390/gconv-modules-s390.awk
@@ -0,0 +1,81 @@ 
+# Emit s390 modules at top of gconv-modules file.
+# Copyright (C) 2016 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+BEGIN {
+    emitted = 0
+}
+
+emitted || NF == 0 || $1 ~ /^#/ {
+    print;
+    next;
+}
+
+!emitted {
+    emit_s390_modules();
+    emitted = 1;
+    print;
+}
+
+function emit_s390_modules() {
+    # Emit header line.
+    print "# S/390 hardware accelerated modules";
+    print_val("#", 8);
+    print_val("from", 24);
+    print_val("to", 24);
+    print_val("module", 24);
+    printf "cost\n";
+    # Emit s390-specific modules.
+    modul("ISO-8859-1//", "IBM037//", "ISO-8859-1_CP037_Z900");
+    modul("IBM037//", "ISO-8859-1//", "ISO-8859-1_CP037_Z900");
+    modul("ISO-10646/UTF8/", "UTF-32//", "UTF8_UTF32_Z9");
+    modul("UTF-32BE//", "ISO-10646/UTF8/", "UTF8_UTF32_Z9");
+    modul("ISO-10646/UTF8/", "UTF-32BE//", "UTF8_UTF32_Z9");
+    modul("UTF-16BE//", "UTF-32//", "UTF16_UTF32_Z9");
+    modul("UTF-32BE//", "UTF-16//", "UTF16_UTF32_Z9");
+    modul("INTERNAL", "UTF-16//", "UTF16_UTF32_Z9");
+    modul("UTF-32BE//", "UTF-16BE//", "UTF16_UTF32_Z9");
+    modul("INTERNAL", "UTF-16BE//", "UTF16_UTF32_Z9");
+    modul("UTF-16BE//", "UTF-32BE//", "UTF16_UTF32_Z9");
+    modul("UTF-16BE//", "INTERNAL", "UTF16_UTF32_Z9");
+    modul("UTF-16BE//", "ISO-10646/UTF8/", "UTF8_UTF16_Z9");
+    modul("ISO-10646/UTF8/", "UTF-16//", "UTF8_UTF16_Z9");
+    modul("ISO-10646/UTF8/", "UTF-16BE//", "UTF8_UTF16_Z9");
+    printf "\n# Default glibc modules\n";
+}
+
+function modul(from, to, file, cost) {
+    print_val("module", 8);
+    print_val(from, 24);
+    print_val(to, 24);
+    print_val(file, 24);
+    if (cost == 0) cost = 1;
+    printf "%d\n", cost;
+}
+
+function print_val(val, width) {
+    # Emit value followed by tabs.
+    printf "%s", val;
+    len = length(val);
+    if (len < width) {
+	len = width - len;
+	nr_tabs = len / 8;
+	if (len % 8 != 0) nr_tabs++;
+    }
+    else nr_tabs = 1;
+    for (i = 1; i <= nr_tabs; i++) printf "\t";
+}
diff --git a/sysdeps/s390/s390-64/Makefile b/sysdeps/s390/s390-64/Makefile
index de249a7..094b1e9 100644
--- a/sysdeps/s390/s390-64/Makefile
+++ b/sysdeps/s390/s390-64/Makefile
@@ -39,40 +39,8 @@  $(patsubst %, $(inst_gconvdir)/%.so, $(s390x-iconv-modules)) : \
 $(inst_gconvdir)/%.so: $(objpfx)%.so $(+force)
 	$(do-install-program)
 
-$(objpfx)gconv-modules-s390: gconv-modules
-	cp $< $@
-	echo >> $@
-	echo "# S/390 hardware accelerated modules" >> $@
-	echo -n "module	ISO-8859-1//		IBM037//	" >> $@
-	echo "	ISO-8859-1_CP037_Z900	1" >> $@
-	echo -n "module	IBM037//		ISO-8859-1//	" >> $@
-	echo "	ISO-8859-1_CP037_Z900	1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-32//	" >> $@
-	echo "	UTF8_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-32BE//		ISO-10646/UTF8/	" >> $@
-	echo "	UTF8_UTF32_Z9		1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-32BE//	" >> $@
-	echo "	UTF8_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		UTF-32//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-32BE//		UTF-16//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	INTERNAL		UTF-16//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-32BE//		UTF-16BE//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	INTERNAL		UTF-16BE//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		UTF-32BE//	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		INTERNAL	" >> $@
-	echo "	UTF16_UTF32_Z9		1" >> $@
-	echo -n "module	UTF-16BE//		ISO-10646/UTF8/	" >> $@
-	echo "	UTF8_UTF16_Z9		1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-16//	" >> $@
-	echo "	UTF8_UTF16_Z9		1" >> $@
-	echo -n "module	ISO-10646/UTF8/		UTF-16BE//	" >> $@
-	echo "	UTF8_UTF16_Z9		1" >> $@
+$(objpfx)gconv-modules-s390: ../sysdeps/s390/gconv-modules-s390.awk gconv-modules
+	${AWK} -f $^ > $@
 
 GCONV_MODULES = gconv-modules-s390
 
-- 
2.5.5