From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16534 invoked by alias); 16 Apr 2011 21:29:07 -0000 Received: (qmail 16522 invoked by uid 22791); 16 Apr 2011 21:29:04 -0000 X-SWARE-Spam-Status: No, hits=0.0 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,RCVD_IN_PSBL X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 16 Apr 2011 21:28:50 +0000 Received: from md1.u-strasbg.fr (md1.u-strasbg.fr [IPv6:2001:660:2402::186]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id p3GLSc0T012009 ; Sat, 16 Apr 2011 23:28:38 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms8.u-strasbg.fr [130.79.204.17]) by md1.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p3GLSbvZ072780 ; Sat, 16 Apr 2011 23:28:37 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p3GLSZlS032562 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Sat, 16 Apr 2011 23:28:36 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Jan Kratochvil'" Cc: "'Tom Tromey'" , References: <5928.31498147479$1302882967@news.gmane.org> <005101cbfc50$193136b0$4b93a410$@muller@ics-cnrs.unistra.fr> <20110416162455.GA5599@host1.jankratochvil.net> In-Reply-To: <20110416162455.GA5599@host1.jankratochvil.net> Subject: [RFA-v2] Handle cygwin wchar_t specifics Date: Sat, 16 Apr 2011 21:29:00 -0000 Message-ID: <000001cbfc7d$3f67f440$be37dcc0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00257.txt.bz2 Thanks Jan, I was able thanks to your code to generate a patch that seems to work for me. Goal of the patch is to generate for INTERMEDIATE_ENCODING a name that is "UCS-XYY" where YY is LE or BE (which was already handled before but where X is either 4 or 2 depending of the size of type wchar_t type. I don't know if the configure change is completely generated by the small configure.ac change. If this is true, the ChangeLog entry should probably just say Regenerate for configure. Is this patch OK? Should it be include in 7.3 branch? Pierre 2011-04-16 Pierre Muller Correct INTERMEDIATE_ENCODING macro setup for systems using 2 byte "wchar_t" type. * gdb_wchar.h: Use new SIZEOF_WCHAR_T macro to set INTERMEDIATE_ENCODING macro value. * config.in: Add SIZEOF_WCHAR_T macro. * configure.ac: Add rule for SIZEOF_WCHAR_T. * configure: Likewise. Index: config.in =================================================================== RCS file: /cvs/src/src/gdb/config.in,v retrieving revision 1.125 diff -u -p -r1.125 config.in --- config.in 17 Mar 2011 13:19:09 -0000 1.125 +++ config.in 16 Apr 2011 21:19:47 -0000 @@ -804,6 +804,9 @@ /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG +/* The size of `wchar_t', as computed by sizeof. */ +#undef SIZEOF_WCHAR_T + /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'size_t'. */ #undef SIZE_T_SUFFIX Index: configure =================================================================== RCS file: /cvs/src/src/gdb/configure,v retrieving revision 1.329 diff -u -p -r1.329 configure --- configure 17 Mar 2011 13:19:09 -0000 1.329 +++ configure 16 Apr 2011 21:19:52 -0000 @@ -11637,6 +11637,44 @@ _ACEOF fi +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5 +$as_echo_n "checking size of wchar_t... " >&6; } +if test "${ac_cv_sizeof_wchar_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" " +#include +#include + +"; then : + +else + if test "$ac_cv_type_wchar_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ as_fn_set_status 77 +as_fn_error "cannot compute sizeof (wchar_t) +See \`config.log' for more details." "$LINENO" 5; }; } + else + ac_cv_sizeof_wchar_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_wchar_t" >&5 +$as_echo "$ac_cv_sizeof_wchar_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t +_ACEOF + + # ------------------------------------- # # Checks for compiler characteristics. # Index: configure.ac =================================================================== RCS file: /cvs/src/src/gdb/configure.ac,v retrieving revision 1.144 diff -u -p -r1.144 configure.ac --- configure.ac 17 Mar 2011 13:19:10 -0000 1.144 +++ configure.ac 16 Apr 2011 21:19:52 -0000 @@ -976,6 +976,10 @@ AC_CHECK_TYPES(socklen_t, [], [], [#include #include ]) +AC_CHECK_SIZEOF([wchar_t], 4, [ +#include +#include +]) # ------------------------------------- # # Checks for compiler characteristics. # Index: gdb_wchar.h =================================================================== RCS file: /cvs/src/src/gdb/gdb_wchar.h,v retrieving revision 1.6 diff -u -p -r1.6 gdb_wchar.h --- gdb_wchar.h 1 Jan 2011 15:33:05 -0000 1.6 +++ gdb_wchar.h 16 Apr 2011 21:19:57 -0000 @@ -60,6 +60,7 @@ #include #include +#include "config.h" typedef wchar_t gdb_wchar_t; typedef wint_t gdb_wint_t; @@ -71,20 +72,26 @@ typedef wint_t gdb_wint_t; #define gdb_WEOF WEOF #define LCST(X) L ## X +/* Transform SIZEOF_WCHAR_T into a string. This requires a two-level + macro. This macro is used to generate INTERMEDIATE_ENCODING below. */ +#define STR_VAL1(X) #X +#define STR_VAL(X) STR_VAL1(X) +#define SIZEOF_WCHAR_T_STR STR_VAL(SIZEOF_WCHAR_T) -/* If __STDC_ISO_10646__ is defined, then the host wchar_t is UCS-4. +/* If __STDC_ISO_10646__ is defined, then the host wchar_t is UCS-4 or UCS-2. + We use the version having the same size as "wchar_t" type. We exploit this fact in the hope that there are hosts that define this but which do not support "wchar_t" as an encoding argument to iconv_open. We put the endianness into the encoding name to avoid hosts that emit a BOM when the unadorned name is used. */ #if defined (__STDC_ISO_10646__) -#if WORDS_BIGENDIAN -#define INTERMEDIATE_ENCODING "UCS-4BE" -#else -#define INTERMEDIATE_ENCODING "UCS-4LE" -#endif +# if WORDS_BIGENDIAN +# define INTERMEDIATE_ENCODING "UCS-" SIZEOF_WCHAR_T_STR "BE" +# else +# define INTERMEDIATE_ENCODING "UCS-" SIZEOF_WCHAR_T_STR "LE" +# endif #elif defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108 -#define INTERMEDIATE_ENCODING "wchar_t" +# define INTERMEDIATE_ENCODING "wchar_t" #else /* This shouldn't happen, because the earlier #if should have filtered out this case. */