From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23281 invoked by alias); 18 Aug 2010 16:12:31 -0000 Received: (qmail 23272 invoked by uid 22791); 18 Aug 2010 16:12:29 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 Aug 2010 16:12:23 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7IGBqGu018748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 18 Aug 2010 12:11:53 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7IGBpZX020533; Wed, 18 Aug 2010 12:11:52 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o7IGBphD025521; Wed, 18 Aug 2010 12:11:51 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id E0E95378196; Wed, 18 Aug 2010 10:11:50 -0600 (MDT) From: Tom Tromey To: "Pierre Muller" Cc: "'Joel Brobecker'" , Subject: Re: Your INTERMEDIATE_ENCODING patch for Solaris References: <20100731162500.32FAE5664F4@henry1.codesourcery.com> <20100817184407.GC3599@adacore.com> <20100818101406.GA2903@adacore.com> <15264.6257346079$1282142643@news.gmane.org> Date: Wed, 18 Aug 2010 16:12:00 -0000 In-Reply-To: <15264.6257346079$1282142643@news.gmane.org> (Pierre Muller's message of "Wed, 18 Aug 2010 16:43:33 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-08/txt/msg00303.txt.bz2 >>>>> "Pierre" == Pierre Muller writes: Pierre> Upon further investigation, I must confess that the OpenSolaris Pierre> situation is a real mess: Pierre> I get a working libiconv version for x86_64 solaris Pierre> using CSW libiconv version 0x10D, >From the version number, I guess this is GNU libiconv. What happens if you don't build with libiconv, but rely instead on the iconv in the Solaris libc? Pierre> libiconv_open with parameter 'wchar_t' and 'UTF-8' works. Pierre> but on my Sparc64 test machine, libiconv is Pierre> on /usr/local/lib and its version is 0x10B. Pierre> This later version fails on calls to libiconv_open Pierre> with 'wchar_t' and 'ASCII'. Ouch, but ok. We can check _LIBICONV_VERSION >= 0x10D. This actually simplifies the patch a little; I didn't know about _LIBICONV_VERSION before. Could you try this? I also fixed the INTERMEDIATE_ENCODING problem you pointed out. Tom 2010-08-17 Tom Tromey * gdb_wchar.h: Check _LIBICONV_VERSION, __STDC_ISO_10646__. Change how INTERMEDIATE_ENCODING is defined. diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h index fca3fe4..78f59a1 100644 --- a/gdb/gdb_wchar.h +++ b/gdb/gdb_wchar.h @@ -23,7 +23,11 @@ Capable systems have the full suite: wchar_t support and iconv (perhaps via GNU libiconv). On these machines, full functionality - is available. + is available. Note that full functionality is dependent on us + being able to convert from an arbitrary encoding to wchar_t. In + practice this means we look for __STDC_ISO_10646__ (where we know + the name of the wchar_t encoding) or GNU libiconv, where we can use + "wchar_t". DJGPP is known to have libiconv but not wchar_t support. On systems like this, we use the narrow character functions. The full @@ -35,8 +39,6 @@ wrappers for the wchar_t functionality we use. */ -#define INTERMEDIATE_ENCODING "wchar_t" - #if defined (HAVE_ICONV) #include #else @@ -45,9 +47,15 @@ #define PHONY_ICONV #endif -/* We use "btowc" as a sentinel to detect functioning wchar_t - support. */ -#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) +/* We use "btowc" as a sentinel to detect functioning wchar_t support. + We check for either __STDC_ISO_10646__ or a new-enough libiconv in + order to ensure we can convert to and from wchar_t. We choose + libiconv version 0x10D because it was reported that earlier + versions do not always accept "wchar_t" as an encoding argument on + Solaris. */ +#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) \ + && (defined (__STDC_ISO_10646__) \ + || defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x10D) #include #include @@ -63,6 +71,25 @@ typedef wint_t gdb_wint_t; #define LCST(X) L ## X +/* If __STDC_ISO_10646__ is defined, then the host wchar_t is UCS-4. + 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 +#elif defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x10D +#define INTERMEDIATE_ENCODING "wchar_t" +#else +/* This shouldn't happen, because the earlier #if should have filtered + out this case. */ +#error "Neither __STDC_ISO_10646__ nor _LIBICONV_VERSION defined" +#endif + #else typedef char gdb_wchar_t; @@ -80,8 +107,9 @@ typedef int gdb_wint_t; narrow encoding as our intermediate encoding. However, if we are also providing a phony iconv, we might as well just stick with "wchar_t". */ -#ifndef PHONY_ICONV -#undef INTERMEDIATE_ENCODING +#ifdef PHONY_ICONV +#define INTERMEDIATE_ENCODING "wchar_t" +#else #define INTERMEDIATE_ENCODING host_charset () #endif