Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [RFA] Handle cygwin wchar_t specifics
Date: Fri, 15 Apr 2011 15:55:00 -0000	[thread overview]
Message-ID: <000f01cbfb85$81ba6650$852f32f0$@muller@ics-cnrs.unistra.fr> (raw)

See my email about a problem with GDB on Cygwin.

http://sourceware.org/ml/gdb/2011-04/msg00058.html

  I found out that the problem is related to the
fact that __STDC_ISO_10646__ is defined in:

$ grep -n ISO_10646  /usr/include/*/*
/usr/include/sys/features.h:185:#define __STDC_ISO_10646__ 200305L

because of this, GDB uses "UCS-4LE" 
for the macro INTERMEDIATE_ENCODING on Cygwin 
(while "wchar_t" it uses for mingw32, which works well).

  This assumes that wchar_t is 4 byte long, which is not true for
Cygwin at least...

The patch below fixes this by
explicitly setting the UCS size to two for Windows targets.

  It would probably be good to have this in branch too...

  

Pierre Muller
GDB pascal language maintainer


2011-04-15  Pierre Muller  <muller@ics.u-strasbg.fr>

	Correct INTERMEDIATE_ENCODING macro setup for Cygwin port.
	* gdb_wchar.h (UCS_SIZE): New macro.
	
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	15 Apr 2011 15:51:52 -0000
@@ -61,6 +61,7 @@
 #include <wchar.h>
 #include <wctype.h>
 
+#define wchar_size  (&(((wchar_t) (0)) + 1) - &((char *) 0))
 typedef wchar_t gdb_wchar_t;
 typedef wint_t gdb_wint_t;
 
@@ -73,18 +74,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.
+   This is not true for Cygwin at least. Windows OS seems to require
+   16-bit wchar_t type, so we handle those especially.
    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"
+#if defined (__CYGWIN__) || defined (__MINGW32__)
+#  define UCS_SIZE "2"
 #else
-#define INTERMEDIATE_ENCODING "UCS-4LE"
+#  define UCS_SIZE "4"
 #endif
+#if defined (__STDC_ISO_10646__)
+#  if WORDS_BIGENDIAN
+#    define INTERMEDIATE_ENCODING "UCS-" UCS_SIZE "BE"
+#  else
+#    define INTERMEDIATE_ENCODING "UCS-" UCS_SIZE "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.  */


             reply	other threads:[~2011-04-15 15:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 15:55 Pierre Muller [this message]
     [not found] <5928.31498147479$1302882967@news.gmane.org>
2011-04-15 18:16 ` Tom Tromey
2011-04-16 16:05   ` Pierre Muller
2011-04-16 16:25     ` Jan Kratochvil
2011-04-16 21:24     ` Tom Tromey
2011-04-18 20:07   ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000f01cbfb85$81ba6650$852f32f0$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox