summaryrefslogtreecommitdiff
path: root/gcc/config/avr/gen-avr-mmcu-texi.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-01 06:14:40 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-01 06:14:40 +0000
commitfed1769821d234adee6add59bbb97dd1c83ef232 (patch)
treef2cf22c041a236c0b6a8c34b163e91103660c904 /gcc/config/avr/gen-avr-mmcu-texi.c
parent8e21b71a4f55ebda4156b75b62a9380c082ee5d4 (diff)
downloadgcc-fed1769821d234adee6add59bbb97dd1c83ef232.tar.gz
2012-06-01 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 188095 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@188099 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/avr/gen-avr-mmcu-texi.c')
-rw-r--r--gcc/config/avr/gen-avr-mmcu-texi.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/gcc/config/avr/gen-avr-mmcu-texi.c b/gcc/config/avr/gen-avr-mmcu-texi.c
index 0bbd3a30b71..b5cb3c4a8a4 100644
--- a/gcc/config/avr/gen-avr-mmcu-texi.c
+++ b/gcc/config/avr/gen-avr-mmcu-texi.c
@@ -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;