This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Initialization of __WCHAR_TYPE__ in cppinit.c


	I've got some good news and some bad news.

	The good news: AIX V5 addresses wchar_t previously having been
defined as 16-bit "unsigned short int" in earlier versions of AIX when
32-bit "unsigned int" now is the norm.

	The bad news: AIX V5 only defines wchar_t as 32-bits in 64-bit
mode; it remains 16-bits in 32-bit mode for backward compatibility.  This
means the type is now runtime-dependent.

	The tm.h definition of WCHAR_TYPE_SIZE can handle this
variability, but one of the uses of the WCHAR_TYPE definition cannot.  I
need to define WCHAR_TYPE as:

#define WCHAR_TYPE (!TARGET_64BIT ? "short unsigned int" : "unsigned int")

The following patch makes the definition dynamic, but I am not sure if
this is how you want to handle it.

David


2001-01-04  David Edelsohn  <edelsohn@gnu.org>

	* cppinit.c (builtin_array): Move static __WCHAR_TYPE__ definition ...
	(cpp_start_read): ... to dynamic definition here.

Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppinit.c,v
retrieving revision 1.128
diff -c -p -r1.128 cppinit.c
*** cppinit.c	2001/01/04 10:25:53	1.128
--- cppinit.c	2001/01/04 20:58:00
*************** static const struct builtin builtin_arra
*** 631,639 ****
  #ifndef NO_BUILTIN_PTRDIFF_TYPE
    C("__PTRDIFF_TYPE__",		PTRDIFF_TYPE),
  #endif
- #ifndef NO_BUILTIN_WCHAR_TYPE
-   C("__WCHAR_TYPE__",		WCHAR_TYPE),
- #endif
  #ifndef NO_BUILTIN_WINT_TYPE
    C("__WINT_TYPE__",		WINT_TYPE),
  #endif
--- 631,636 ----
*************** initialize_builtins (pfile)
*** 712,718 ****
  
  	      /* Allocate enough space for "name value\n\0".  */
  	      str = alloca (b->len + strlen (val) + 3);
! 	      sprintf(str, "%s %s\n", b->name, val);
  	    }
  
  	  _cpp_define_builtin (pfile, str);
--- 709,715 ----
  
  	      /* Allocate enough space for "name value\n\0".  */
  	      str = alloca (b->len + strlen (val) + 3);
! 	      sprintf (str, "%s %s\n", b->name, val);
  	    }
  
  	  _cpp_define_builtin (pfile, str);
*************** cpp_start_read (pfile, fname)
*** 959,964 ****
--- 956,974 ----
  
    /* Install __LINE__, etc.  */
    initialize_builtins (pfile);
+ 
+   /* __WCHAR_TYPE__ can be runtime-dependent, so define it specially.  */
+ #ifndef NO_BUILTIN_WCHAR_TYPE
+   {
+     char *str;
+ 
+     /* Allocate enough space for "__WCHAR_TYPE__ value\n\0".  */
+     str = alloca (14 + strlen (WCHAR_TYPE) + 3);
+     sprintf (str, "__WCHAR_TYPE__ %s\n", WCHAR_TYPE);
+ 
+     _cpp_define_builtin (pfile, str);
+   }
+ #endif
  
    /* Do -U's, -D's and -A's in the order they were seen.  */
    p = CPP_OPTION (pfile, pending)->directive_head;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]