Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Handle cygwin wchar_t specifics
@ 2011-04-15 15:55 Pierre Muller
  0 siblings, 0 replies; 6+ messages in thread
From: Pierre Muller @ 2011-04-15 15:55 UTC (permalink / raw)
  To: gdb-patches

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.  */


^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <5928.31498147479$1302882967@news.gmane.org>]

end of thread, other threads:[~2011-04-18 20:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-15 15:55 [RFA] Handle cygwin wchar_t specifics Pierre Muller
     [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox