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]
Other format: [Raw text]

Proto-patch for "%I64" on Microsoft


Joseph --

What do you think of this patch?  

I know it's missing a ChangeLog and documentation.  

I've also not tried to be thorough about handling all of Microsoft's
print specifiers, nor worried at all about their scanf specifiers.
I'm just trying to fix the bootstrap on Windows; if the port
maintainers want to go beyond that, that's their concern.

Assuming I added the appropriate documentation, would this patch be OK
with you?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

Index: config/i386/mingw32.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/mingw32.h,v
retrieving revision 1.37
diff -c -5 -p -r1.37 mingw32.h
*** config/i386/mingw32.h	17 Oct 2004 18:09:39 -0000	1.37
--- config/i386/mingw32.h	26 Nov 2004 20:16:30 -0000
*************** do {						         \
*** 106,110 ****
--- 106,126 ----
  } while (0)
  
  /* Define as short unsigned for compatibility with MS runtime.  */
  #undef WINT_TYPE
  #define WINT_TYPE "short unsigned int"
+ 
+ /* MSVCRT does not support the "I" flag provided by GLIBC.  */
+ #undef TARGET_EXTRA_PRINTF_FLAG_CHARS
+ #define TARGET_EXTRA_PRINTF_FLAG_CHARS ""
+ 
+ /* MSVCRT supports additional length specifiers for "printf".  (In
+    fact, it does not support some of the C99 specifiers, like
+    "ll".  However, we do not presently have a mechanism for disabling
+    a specifier.)  */  
+ #define TARGET_EXTRA_PRINTF_LENGTH_SPECIFIERS	\
+   /* 32-bit integer */				\
+   { "I32", FMT_LEN_none, STD_EXT, NULL, 0, 0 },	\
+   /* 64-bit integer */				\
+   { "I64", FMT_LEN_ll,   STD_EXT, NULL, 0, 0 }, \
+   /* size_t or ptrdiff_t */			\
+   { "I",  FMT_LEN_none,  STD_EXT, NULL, 0, 0 }
Index: c-format.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-format.c,v
retrieving revision 1.68
diff -c -5 -p -r1.68 c-format.c
*** c-format.c	9 Nov 2004 10:20:09 -0000	1.68
--- c-format.c	26 Nov 2004 20:16:30 -0000
*************** static const format_length_info printf_l
*** 292,301 ****
--- 292,304 ----
    { "L", FMT_LEN_L, STD_C89, NULL, 0, 0 },
    { "z", FMT_LEN_z, STD_C99, NULL, 0, 0 },
    { "Z", FMT_LEN_z, STD_EXT, NULL, 0, 0 },
    { "t", FMT_LEN_t, STD_C99, NULL, 0, 0 },
    { "j", FMT_LEN_j, STD_C99, NULL, 0, 0 },
+ #ifdef TARGET_EXTRA_PRINTF_LENGTH_SPECIFIERS
+   TARGET_EXTRA_PRINTF_LENGTH_SPECIFIERS,
+ #endif /* TARGET_EXTRA_PRINTF_LENGTH_SPECIFIERS */
    { NULL, 0, 0, NULL, 0, 0 }
  };
  
  /* Length specifiers valid for asm_fprintf.  */
  static const format_length_info asm_fprintf_length_specs[] =
*************** static const format_char_info monetary_c
*** 649,659 ****
  };
  
  /* This must be in the same order as enum format_type.  */
  static const format_kind_info format_types_orig[] =
  {
!   { "printf",   printf_length_specs,  print_char_table, " +#0-'I", NULL, 
      printf_flag_specs, printf_flag_pairs,
      FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK,
      'w', 0, 'p', 0, 'L',
      &integer_type_node, &integer_type_node
    },
--- 652,663 ----
  };
  
  /* This must be in the same order as enum format_type.  */
  static const format_kind_info format_types_orig[] =
  {
!   { "printf",   printf_length_specs,  print_char_table, 
!     " +#0-'" TARGET_EXTRA_PRINTF_FLAG_CHARS, NULL, 
      printf_flag_specs, printf_flag_pairs,
      FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK,
      'w', 0, 'p', 0, 'L',
      &integer_type_node, &integer_type_node
    },
*************** check_format_info_main (format_check_res
*** 1656,1670 ****
        length_chars = NULL;
        length_chars_val = FMT_LEN_none;
        length_chars_std = STD_C89;
        if (fli)
  	{
! 	  while (fli->name != 0 && fli->name[0] != *format_chars)
  	    fli++;
  	  if (fli->name != 0)
  	    {
! 	      format_chars++;
  	      if (fli->double_name != 0 && fli->name[0] == *format_chars)
  		{
  		  format_chars++;
  		  length_chars = fli->double_name;
  		  length_chars_val = fli->double_index;
--- 1660,1675 ----
        length_chars = NULL;
        length_chars_val = FMT_LEN_none;
        length_chars_std = STD_C89;
        if (fli)
  	{
! 	  while (fli->name != 0 
! 		 && strncmp (fli->name, format_chars, strlen (fli->name)))
  	    fli++;
  	  if (fli->name != 0)
  	    {
! 	      format_chars += strlen (fli->name);
  	      if (fli->double_name != 0 && fli->name[0] == *format_chars)
  		{
  		  format_chars++;
  		  length_chars = fli->double_name;
  		  length_chars_val = fli->double_index;
Index: target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.106
diff -c -5 -p -r1.106 target-def.h
*** target-def.h	1 Oct 2004 05:08:55 -0000	1.106
--- target-def.h	26 Nov 2004 20:16:32 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 426,435 ****
--- 426,441 ----
  
  #ifndef TARGET_HANDLE_PRAGMA_EXTERN_PREFIX
  #define TARGET_HANDLE_PRAGMA_EXTERN_PREFIX 0
  #endif
  
+ /* This should, in the abstract, be the empty string.  However,
+    historically, GCC has accepted GLIBC's "I" flag character on all
+    systems.  */
+ #ifndef TARGET_EXTRA_PRINTF_FLAG_CHARS
+ #define TARGET_EXTRA_PRINTF_FLAG_CHARS "I"
+ #endif
  
  /* C++ specific.  */
  #ifndef TARGET_CXX_GUARD_TYPE
  #define TARGET_CXX_GUARD_TYPE default_cxx_guard_type
  #endif


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