Commit 7468e0b5 by Zack Weinberg

safe-ctype.h (HC_UNKNOWN, [...]): New #defines.

include:
	* safe-ctype.h (HC_UNKNOWN, HC_ASCII, HC_EBCDIC, HOST_CHARSET):
	New #defines.
libiberty:
	* safe-ctype.c: Separate out EOF==-1 check.  Use HOST_CHARSET
	for charset determination.
gcc:
	* aclocal.m4 (gcc_AC_C_CHARSET): Delete.
	* configure.in: Don't use gcc_AC_C_CHARSET.
	* configure, config.in: Regenerate.
	* config/i370/i370.c, config/i370/i370.h: Use
	(HOST_CHARSET == HC_EBCDIC) or (HOST_CHARSET == HC_ASCII)
	instead of HOST_EBCDIC or !HOST_EBCDIC.  Clarify comments a tad.

From-SVN: r68317
parent de32c0cb
2003-06-21 Zack Weinberg <zack@codesourcery.com>
* aclocal.m4 (gcc_AC_C_CHARSET): Delete.
* configure.in: Don't use gcc_AC_C_CHARSET.
* configure, config.in: Regenerate.
* config/i370/i370.c, config/i370/i370.h: Use
(HOST_CHARSET == HC_EBCDIC) or (HOST_CHARSET == HC_ASCII)
instead of HOST_EBCDIC or !HOST_EBCDIC. Clarify comments a tad.
2003-06-21 Neil Booth <neil@daikokuya.co.uk> 2003-06-21 Neil Booth <neil@daikokuya.co.uk>
* Makefile.in: Update. * Makefile.in: Update.
......
...@@ -564,34 +564,6 @@ AC_CACHE_CHECK(for __int64, ac_cv_c___int64, ...@@ -564,34 +564,6 @@ AC_CACHE_CHECK(for __int64, ac_cv_c___int64,
fi fi
]) ])
dnl Host character set probe.
dnl The EBCDIC values match the table in config/i370/i370.c;
dnl there are other versions of EBCDIC but GCC won't work with them.
dnl
AC_DEFUN([gcc_AC_C_CHARSET],
[AC_CACHE_CHECK(execution character set, ac_cv_c_charset,
[AC_EGREP_CPP(ASCII,
[#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
&& 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
ASCII
#endif], ac_cv_c_charset=ASCII)
if test x${ac_cv_c_charset+set} != xset; then
AC_EGREP_CPP(EBCDIC,
[#if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
&& 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
EBCDIC
#endif], ac_cv_c_charset=EBCDIC)
fi
if test x${ac_cv_c_charset+set} != xset; then
ac_cv_c_charset=unknown
fi])
if test $ac_cv_c_charset = unknown; then
AC_MSG_ERROR([*** Cannot determine host character set.])
elif test $ac_cv_c_charset = EBCDIC; then
AC_DEFINE(HOST_EBCDIC, 1,
[Define if the host execution character set is EBCDIC.])
fi])
#serial AM2 #serial AM2
dnl From Bruno Haible. dnl From Bruno Haible.
......
...@@ -321,9 +321,6 @@ ...@@ -321,9 +321,6 @@
/* The number of bytes in type __int64 */ /* The number of bytes in type __int64 */
#undef SIZEOF___INT64 #undef SIZEOF___INT64
/* Define if the host execution character set is EBCDIC. */
#undef HOST_EBCDIC
/* Define if you want more run-time sanity checks. This one gets a grab /* Define if you want more run-time sanity checks. This one gets a grab
bag of miscellaneous but relatively cheap checks. */ bag of miscellaneous but relatively cheap checks. */
#undef ENABLE_CHECKING #undef ENABLE_CHECKING
......
...@@ -121,7 +121,7 @@ static bool i370_rtx_costs PARAMS ((rtx, int, int, int *)); ...@@ -121,7 +121,7 @@ static bool i370_rtx_costs PARAMS ((rtx, int, int, int *));
#ifdef TARGET_HLASM #ifdef TARGET_HLASM
#define MVS_HASH_PRIME 999983 #define MVS_HASH_PRIME 999983
#if defined(HOST_EBCDIC) #if HOST_CHARSET == HC_EBCDIC
#define MVS_SET_SIZE 256 #define MVS_SET_SIZE 256
#else #else
#define MVS_SET_SIZE 128 #define MVS_SET_SIZE 128
...@@ -156,7 +156,7 @@ static alias_node_t *alias_anchor = 0; ...@@ -156,7 +156,7 @@ static alias_node_t *alias_anchor = 0;
and must handled in a special manner. */ and must handled in a special manner. */
static const char *const mvs_function_table[MVS_FUNCTION_TABLE_LENGTH] = static const char *const mvs_function_table[MVS_FUNCTION_TABLE_LENGTH] =
{ {
#if defined(HOST_EBCDIC) /* Changed for EBCDIC collating sequence */ #if HOST_CHARSET == HC_EBCDIC /* Changed for EBCDIC collating sequence */
"ceil", "edc_acos", "edc_asin", "edc_atan", "edc_ata2", "edc_cos", "ceil", "edc_acos", "edc_asin", "edc_atan", "edc_ata2", "edc_cos",
"edc_cosh", "edc_erf", "edc_erfc", "edc_exp", "edc_gamm", "edc_lg10", "edc_cosh", "edc_erf", "edc_erfc", "edc_exp", "edc_gamm", "edc_lg10",
"edc_log", "edc_sin", "edc_sinh", "edc_sqrt", "edc_tan", "edc_tanh", "edc_log", "edc_sin", "edc_sinh", "edc_sqrt", "edc_tan", "edc_tanh",
...@@ -176,7 +176,7 @@ static const char *const mvs_function_table[MVS_FUNCTION_TABLE_LENGTH] = ...@@ -176,7 +176,7 @@ static const char *const mvs_function_table[MVS_FUNCTION_TABLE_LENGTH] =
#endif /* TARGET_HLASM */ #endif /* TARGET_HLASM */
/* ===================================================== */ /* ===================================================== */
#if defined(TARGET_EBCDIC) && !defined(HOST_EBCDIC) #if defined(TARGET_EBCDIC) && HOST_CHARSET == HC_ASCII
/* ASCII to EBCDIC conversion table. */ /* ASCII to EBCDIC conversion table. */
static const unsigned char ascebc[256] = static const unsigned char ascebc[256] =
{ {
...@@ -229,10 +229,9 @@ static const unsigned char ascebc[256] = ...@@ -229,10 +229,9 @@ static const unsigned char ascebc[256] =
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0xFF
}; };
#endif /* TARGET_EBCDIC && ! HOST_EBCDIC */ #endif /* target EBCDIC, host ASCII */
#if !defined(TARGET_EBCDIC) && HOST_CHARSET == HC_EBCDIC
#if defined(HOST_EBCDIC) && !defined(TARGET_EBCDIC)
/* EBCDIC to ASCII conversion table. */ /* EBCDIC to ASCII conversion table. */
static const unsigned char ebcasc[256] = static const unsigned char ebcasc[256] =
{ {
...@@ -301,7 +300,7 @@ static const unsigned char ebcasc[256] = ...@@ -301,7 +300,7 @@ static const unsigned char ebcasc[256] =
/*F8 8 9 */ /*F8 8 9 */
0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF 0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF
}; };
#endif /* HOST_EBCDIC && ! TARGET_EBCDIC */ #endif /* target ASCII, host EBCDIC */
/* Initialize the GCC target structure. */ /* Initialize the GCC target structure. */
#ifdef TARGET_HLASM #ifdef TARGET_HLASM
...@@ -351,11 +350,11 @@ char ...@@ -351,11 +350,11 @@ char
mvs_map_char (c) mvs_map_char (c)
int c; int c;
{ {
#if defined(TARGET_EBCDIC) && !defined(HOST_EBCDIC) #if defined(TARGET_EBCDIC) && HOST_CHARSET == HC_ASCII
fprintf (stderr, "mvs_map_char: TE & !HE: c = %02x\n", c); fprintf (stderr, "mvs_map_char: TE & !HE: c = %02x\n", c);
return ascebc[c]; return ascebc[c];
#else #else
#if defined(HOST_EBCDIC) && !defined(TARGET_EBCDIC) #if !defined(TARGET_EBCDIC) && HOST_CHARSET == HC_EBCDIC
fprintf (stderr, "mvs_map_char: !TE & HE: c = %02x\n", c); fprintf (stderr, "mvs_map_char: !TE & HE: c = %02x\n", c);
return ebcasc[c]; return ebcasc[c];
#else #else
......
...@@ -141,7 +141,7 @@ extern size_t mvs_function_name_length; ...@@ -141,7 +141,7 @@ extern size_t mvs_function_name_length;
/* but only define it if really needed, since otherwise it will break builds */ /* but only define it if really needed, since otherwise it will break builds */
#ifdef TARGET_EBCDIC #ifdef TARGET_EBCDIC
#ifdef HOST_EBCDIC #if HOST_CHARSET == HC_EBCDIC
#define MAP_CHARACTER(c) ((char)(c)) #define MAP_CHARACTER(c) ((char)(c))
#else #else
#define MAP_CHARACTER(c) ((char)mvs_map_char (c)) #define MAP_CHARACTER(c) ((char)mvs_map_char (c))
......
...@@ -259,8 +259,6 @@ if test $ac_cv_c___int64 = yes; then ...@@ -259,8 +259,6 @@ if test $ac_cv_c___int64 = yes; then
AC_COMPILE_CHECK_SIZEOF(__int64) AC_COMPILE_CHECK_SIZEOF(__int64)
fi fi
gcc_AC_C_CHARSET
# ----------------- # -----------------
# Find Ada compiler # Find Ada compiler
# ----------------- # -----------------
......
2003-06-21 Zack Weinberg <zack@codesourcery.com>
* safe-ctype.h (HC_UNKNOWN, HC_ASCII, HC_EBCDIC, HOST_CHARSET):
New #defines.
2003-06-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2003-06-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* ansidecl.h: Delete HAVE_LONG_DOUBLE GCC bootstrap support. * ansidecl.h: Delete HAVE_LONG_DOUBLE GCC bootstrap support.
......
...@@ -37,7 +37,24 @@ Boston, MA 02111-1307, USA. */ ...@@ -37,7 +37,24 @@ Boston, MA 02111-1307, USA. */
#ifdef isalpha #ifdef isalpha
#error "safe-ctype.h and ctype.h may not be used simultaneously" #error "safe-ctype.h and ctype.h may not be used simultaneously"
#endif
/* Determine host character set. */
#define HC_UNKNOWN 0
#define HC_ASCII 1
#define HC_EBCDIC 2
#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
&& 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
# define HOST_CHARSET HC_ASCII
#else #else
# if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
&& 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
# define HOST_CHARSET HC_EBCDIC
# else
# define HOST_CHARSET HC_UNKNOWN
# endif
#endif
/* Categories. */ /* Categories. */
...@@ -99,5 +116,4 @@ extern const unsigned char _sch_tolower[256]; ...@@ -99,5 +116,4 @@ extern const unsigned char _sch_tolower[256];
#define TOUPPER(c) _sch_toupper[(c) & 0xff] #define TOUPPER(c) _sch_toupper[(c) & 0xff]
#define TOLOWER(c) _sch_tolower[(c) & 0xff] #define TOLOWER(c) _sch_tolower[(c) & 0xff]
#endif /* no ctype.h */
#endif /* SAFE_CTYPE_H */ #endif /* SAFE_CTYPE_H */
2003-06-21 Zack Weinberg <zack@codesourcery.com>
* safe-ctype.c: Separate out EOF==-1 check. Use HOST_CHARSET
for charset determination.
2003-06-19 Dara Hazeghi <dhazeghi@yahoo.com> 2003-06-19 Dara Hazeghi <dhazeghi@yahoo.com>
* configure.in: Add check for malloc.h needed by * configure.in: Add check for malloc.h needed by
......
...@@ -33,6 +33,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -33,6 +33,10 @@ Boston, MA 02111-1307, USA. */
#include <safe-ctype.h> #include <safe-ctype.h>
#include <stdio.h> /* for EOF */ #include <stdio.h> /* for EOF */
#if EOF != -1
#error "<safe-ctype.h> requires EOF == -1"
#endif
/* Shorthand */ /* Shorthand */
#define bl _sch_isblank #define bl _sch_isblank
#define cn _sch_iscntrl #define cn _sch_iscntrl
...@@ -64,9 +68,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -64,9 +68,7 @@ Boston, MA 02111-1307, USA. */
#define S (const unsigned short) (nv|sp|bl|pr) /* space */ #define S (const unsigned short) (nv|sp|bl|pr) /* space */
/* Are we ASCII? */ /* Are we ASCII? */
#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \ #if HOST_CHARSET == HC_ASCII
&& 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21 \
&& EOF == -1
const unsigned short _sch_istable[256] = const unsigned short _sch_istable[256] =
{ {
...@@ -159,5 +161,9 @@ const unsigned char _sch_toupper[256] = ...@@ -159,5 +161,9 @@ const unsigned char _sch_toupper[256] =
}; };
#else #else
#error "Unsupported host character set" # if HOST_CHARSET == HC_EBCDIC
#endif /* not ASCII */ #error "FIXME: write tables for EBCDIC"
# else
#error "Unrecognized host character set"
# endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment