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]

Re: [Patch,AVR]: Use tr instead of set to canonicalize line endings for cmp


Joerg Wunsch wrote:
> As Georg-Johann Lay wrote:
> 
>> If it's appropriate I would also set svn:mime-type to something
>> like application/foo but that seems bit odd.
> 
> Rather set the svn:eol-style attribute to "LF" instead, I'd say.
> 
> But wait a moment, why not setting the svn:eol-style to "native", and
> the generator utility to also use native line endings (fopen(...,
> "w"))?  That way, Windows should be able to use CR-LF for both, Unix
> just LF, and MacOS just CR.

Thanks for pointing to eol-style. I didn't know that one.

So here is the next version of the patch, returning to printf again :-)

It also sets svn:eol-style to native; I actually don't know how the svn
server hooks are configured.

Ok to install?

Johann

	* config/avr/t-avr: Correct avr-mmcu.texi dependencies.
	(s-avr-mmcu-texi): Don't sed on gen-avr-mmcu-texi output.
	* config/avr/gen-avr-mmcu-texi.c: Sort MCUs.
	* doc/avr-mmcu.texi: Regenerate.



Index: config/avr/gen-avr-mmcu-texi.c
===================================================================
--- config/avr/gen-avr-mmcu-texi.c	(revision 188005)
+++ config/avr/gen-avr-mmcu-texi.c	(working copy)
@@ -20,10 +20,38 @@
 
 #include "avr-devices.c"
 
+static const char*
+mcu_name[sizeof avr_mcu_types / sizeof avr_mcu_types[0]];
+
+static int
+comparator (const void *va, const void *vb)
+{
+  const char* const *a = (const char* const*) va;
+  const char* const *b = (const char* const*) vb;
+
+  return strcmp (*a, *b);
+} 
+
+static void
+print_mcus (size_t n_mcus)
+{
+  size_t i;
+    
+  if (!n_mcus)
+    return;
+    
+  qsort (mcu_name, n_mcus, sizeof (char*), comparator);
+
+  printf ("@*@var{mcu}@tie{}=");
+
+  for (i = 0; i < n_mcus; i++)
+    printf (" @code{%s}%s", mcu_name[i], i == n_mcus-1 ? ".\n\n" : ",");
+}
+
 int main (void)
 {
   enum avr_arch arch = 0;
-  unsigned i, first = 1;
+  size_t i, n_mcus = 0;
   const struct mcu_type_s *mcu;
 
   printf ("@c Copyright (C) 2012 Free Software Foundation, Inc.\n");
@@ -46,27 +74,22 @@ int main (void)
         {
           arch = mcu->arch;
 
+          /* Start a new architecture:  Flush the MCUs collected so far.  */
+
+          print_mcus (n_mcus);
+          n_mcus = 0;
+
           for (i = 0; i < sizeof (avr_texinfo) / sizeof (*avr_texinfo); i++)
-            {
-              if (arch == avr_texinfo[i].arch)
-                {
-                  if (mcu != avr_mcu_types)
-                    printf (".\n\n");
-                  printf ("@item %s\n%s\n", mcu->name, avr_texinfo[i].texinfo);
-                  printf ("@*@var{mcu}@tie{}=");
-                  first = 1;
-                  break;
-                }
-            }
+            if (arch == avr_texinfo[i].arch)
+              printf ("@item %s\n%s\n", mcu->name, avr_texinfo[i].texinfo);
         }
       else if (arch == (enum avr_arch) mcu->arch)
         {
-          printf ("%s @code{%s}", first ? "" : ",", mcu->name);
-          first = 0;
+          mcu_name[n_mcus++] = mcu->name;
         }
     }
 
-  printf (".\n\n");
+  print_mcus (n_mcus);
   printf ("@end table\n");
 
   return EXIT_SUCCESS;
Index: config/avr/t-avr
===================================================================
--- config/avr/t-avr	(revision 188005)
+++ config/avr/t-avr	(working copy)
@@ -47,10 +47,18 @@ gen-avr-mmcu-texi$(build_exeext): $(srcd
   $(TM_H) $(AVR_MCUS) $(srcdir)/config/avr/avr-devices.c
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< -o $@
 
-avr-devices.o: s-avr-mmcu-texi
+# Make sure that the -mmcu= documentation is in sync with the compiler.
+$(srcdir)/doc/avr-mmcu.texi: s-avr-mmcu-texi; @true
 
+# invoke.texi @includes avr-mmcu.texi.  Put this dependency here instead
+# of in the global Makefile so that developers of other backends are not
+# bothered with AVR stuff. 
+$(srcdir)/doc/invoke.texi: $(srcdir)/doc/avr-mmcu.texi
+
+# Ensure that device support is in sync with -mmcu= documentation.
 s-avr-mmcu-texi: gen-avr-mmcu-texi$(build_exeext)
-	$(RUN_GEN) ./$< | sed -e 's:\r::g' > avr-mmcu.texi
+	$(RUN_GEN) ./$< > tmp-avr-mmcu.texi
+	$(SHELL) $(srcdir)/../move-if-change tmp-avr-mmcu.texi avr-mmcu.texi
 	@if cmp -s $(srcdir)/doc/avr-mmcu.texi avr-mmcu.texi; then \
 	  $(STAMP) $@;		\
 	else			\
Index: doc/avr-mmcu.texi
===================================================================
--- doc/avr-mmcu.texi	(revision 187704)
+++ doc/avr-mmcu.texi	(working copy)
@@ -13,11 +13,11 @@
 
 @item avr2
 ``Classic'' devices with up to 8@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{at90s2313}, @code{at90s2323}, @code{at90s2333}, @code{at90s2343}, @code{attiny22}, @code{attiny26}, @code{at90s4414}, @code{at90s4433}, @code{at90s4434}, @code{at90s8515}, @code{at90c8534}, @code{at90s8535}.
+@*@var{mcu}@tie{}= @code{at90c8534}, @code{at90s2313}, @code{at90s2323}, @code{at90s2333}, @code{at90s2343}, @code{at90s4414}, @code{at90s4433}, @code{at90s4434}, @code{at90s8515}, @code{at90s8535}, @code{attiny22}, @code{attiny26}.
 
 @item avr25
 ``Classic'' devices with up to 8@tie{}KiB of program memory and with the @code{MOVW} instruction.
-@*@var{mcu}@tie{}= @code{ata6289}, @code{attiny13}, @code{attiny13a}, @code{attiny2313}, @code{attiny2313a}, @code{attiny24}, @code{attiny24a}, @code{attiny4313}, @code{attiny44}, @code{attiny44a}, @code{attiny84}, @code{attiny84a}, @code{attiny25}, @code{attiny45}, @code{attiny85}, @code{attiny261}, @code{attiny261a}, @code{attiny461}, @code{attiny461a}, @code{attiny861}, @code{attiny861a}, @code{attiny43u}, @code{attiny87}, @code{attiny48}, @code{attiny88}, @code{at86rf401}.
+@*@var{mcu}@tie{}= @code{at86rf401}, @code{ata6289}, @code{attiny13}, @code{attiny13a}, @code{attiny2313}, @code{attiny2313a}, @code{attiny24}, @code{attiny24a}, @code{attiny25}, @code{attiny261}, @code{attiny261a}, @code{attiny4313}, @code{attiny43u}, @code{attiny44}, @code{attiny44a}, @code{attiny45}, @code{attiny461}, @code{attiny461a}, @code{attiny48}, @code{attiny84}, @code{attiny84a}, @code{attiny85}, @code{attiny861}, @code{attiny861a}, @code{attiny87}, @code{attiny88}.
 
 @item avr3
 ``Classic'' devices with 16@tie{}KiB up to 64@tie{}KiB of  program memory.
@@ -25,23 +25,23 @@
 
 @item avr31
 ``Classic'' devices with 128@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega103}, @code{at43usb320}.
+@*@var{mcu}@tie{}= @code{at43usb320}, @code{atmega103}.
 
 @item avr35
 ``Classic'' devices with 16@tie{}KiB up to 64@tie{}KiB of program memory and with the @code{MOVW} instruction.
-@*@var{mcu}@tie{}= @code{at90usb82}, @code{at90usb162}, @code{atmega8u2}, @code{atmega16u2}, @code{atmega32u2}, @code{attiny167}.
+@*@var{mcu}@tie{}= @code{at90usb162}, @code{at90usb82}, @code{atmega16u2}, @code{atmega32u2}, @code{atmega8u2}, @code{attiny167}.
 
 @item avr4
 ``Enhanced'' devices with up to 8@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega8}, @code{atmega48}, @code{atmega48a}, @code{atmega48p}, @code{atmega88}, @code{atmega88a}, @code{atmega88p}, @code{atmega88pa}, @code{atmega8515}, @code{atmega8535}, @code{atmega8hva}, @code{at90pwm1}, @code{at90pwm2}, @code{at90pwm2b}, @code{at90pwm3}, @code{at90pwm3b}, @code{at90pwm81}.
+@*@var{mcu}@tie{}= @code{at90pwm1}, @code{at90pwm2}, @code{at90pwm2b}, @code{at90pwm3}, @code{at90pwm3b}, @code{at90pwm81}, @code{atmega48}, @code{atmega48a}, @code{atmega48p}, @code{atmega8}, @code{atmega8515}, @code{atmega8535}, @code{atmega88}, @code{atmega88a}, @code{atmega88p}, @code{atmega88pa}, @code{atmega8hva}.
 
 @item avr5
 ``Enhanced'' devices with 16@tie{}KiB up to 64@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega16}, @code{atmega16a}, @code{atmega161}, @code{atmega162}, @code{atmega163}, @code{atmega164a}, @code{atmega164p}, @code{atmega165}, @code{atmega165a}, @code{atmega165p}, @code{atmega168}, @code{atmega168a}, @code{atmega168p}, @code{atmega169}, @code{atmega169a}, @code{atmega169p}, @code{atmega169pa}, @code{atmega32}, @code{atmega323}, @code{atmega324a}, @code{atmega324p}, @code{atmega324pa}, @code{atmega325}, @code{atmega325a}, @code{atmega325p}, @code{atmega3250}, @code{atmega3250a}, @code{atmega3250p}, @code{atmega328}, @code{atmega328p}, @code{atmega329}, @code{atmega329a}, @code{atmega329p}, @code{atmega329pa}, @code{atmega3290}, @code{atmega3290a}, @code{atmega3290p}, @code{atmega406}, @code{atmega64}, @code{atmega640}, @code{atmega644}, @code{atmega644a}, @code{atmega644p}, @code{atmega644pa}, @code{atmega645}, @code{atmega645a}, @code{atmega645p}, @code{atmega6450}, @code{atmega6450a}, @code{atmega6450p}, @code{atmega649}, @code{atmega649a}, @code{atmega649p}, @code{atmega6490}, @code{atmega16hva}, @code{atmega16hva2}, @code{atmega16hvb}, @code{atmega32hvb}, @code{atmega64hve}, @code{at90can32}, @code{at90can64}, @code{at90pwm216}, @code{at90pwm316}, @code{atmega32c1}, @code{atmega64c1}, @code{atmega16m1}, @code{atmega32m1}, @code{atmega64m1}, @code{atmega16u4}, @code{atmega32u4}, @code{atmega32u6}, @code{at90scr100}, @code{at90usb646}, @code{at90usb647}, @code{at94k}, @code{m3000}.
+@*@var{mcu}@tie{}= @code{at90can32}, @code{at90can64}, @code{at90pwm216}, @code{at90pwm316}, @code{at90scr100}, @code{at90usb646}, @code{at90usb647}, @code{at94k}, @code{atmega16}, @code{atmega161}, @code{atmega162}, @code{atmega163}, @code{atmega164a}, @code{atmega164p}, @code{atmega165}, @code{atmega165a}, @code{atmega165p}, @code{atmega168}, @code{atmega168a}, @code{atmega168p}, @code{atmega169}, @code{atmega169a}, @code{atmega169p}, @code{atmega169pa}, @code{atmega16a}, @code{atmega16hva}, @code{atmega16hva2}, @code{atmega16hvb}, @code{atmega16m1}, @code{atmega16u4}, @code{atmega32}, @code{atmega323}, @code{atmega324a}, @code{atmega324p}, @code{atmega324pa}, @code{atmega325}, @code{atmega3250}, @code{atmega3250a}, @code{atmega3250p}, @code{atmega325a}, @code{atmega325p}, @code{atmega328}, @code{atmega328p}, @code{atmega329}, @code{atmega3290}, @code{atmega3290a}, @code{atmega3290p}, @code{atmega329a}, @code{atmega329p}, @code{atmega329pa}, @code{atmega32c1}, @code{atmega32hvb}, @code{atmega32m1}, @code{atmega32u4}, @code{atmega32u6}, @code{atmega406}, @code{atmega64}, @code{atmega640}, @code{atmega644}, @code{atmega644a}, @code{atmega644p}, @code{atmega644pa}, @code{atmega645}, @code{atmega6450}, @code{atmega6450a}, @code{atmega6450p}, @code{atmega645a}, @code{atmega645p}, @code{atmega649}, @code{atmega6490}, @code{atmega649a}, @code{atmega649p}, @code{atmega64c1}, @code{atmega64hve}, @code{atmega64m1}, @code{m3000}.
 
 @item avr51
 ``Enhanced'' devices with 128@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega128}, @code{atmega1280}, @code{atmega1281}, @code{atmega1284p}, @code{atmega128rfa1}, @code{at90can128}, @code{at90usb1286}, @code{at90usb1287}.
+@*@var{mcu}@tie{}= @code{at90can128}, @code{at90usb1286}, @code{at90usb1287}, @code{atmega128}, @code{atmega1280}, @code{atmega1281}, @code{atmega1284p}, @code{atmega128rfa1}.
 
 @item avr6
 ``Enhanced'' devices with 3-byte PC, i.e.@: with more than 128@tie{}KiB of program memory.

Property changes on: doc/avr-mmcu.texi
___________________________________________________________________
Added: svn:eol-style
   + native


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