Ayee, missed a file.
[official-gcc.git] / gcc / gcov-iov.c
blobd6b39de3da1a95616f15babe79d8f127b17fee0a
1 /* Generate gcov version string from version.c. See gcov-io.h for
2 description of how the version string is generated.
3 Copyright (C) 2002, 2003 Free Software Foundation, Inc.
4 Contributed by Nathan Sidwell <nathan@codesourcery.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 02111-1307, USA. */
23 #include "bconfig.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "version.c" /* We want the actual string. */
29 int main (int, char **);
31 int
32 main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
34 unsigned version = 0;
35 unsigned char v[4];
36 unsigned ix;
37 char const *ptr = version_string;
38 unsigned major, minor = 0;
39 char s = 0;
41 major = atoi (ptr);
42 while (*ptr && *ptr != '.')
43 ptr++;
44 if (*ptr)
45 minor = atoi (ptr + 1);
46 while (*ptr)
47 if (*ptr++ == '(')
49 s = *ptr;
50 break;
53 v[0] = (major < 10 ? '0' : 'A' - 10) + major;
54 v[1] = (minor / 10) + '0';
55 v[2] = (minor % 10) + '0';
56 v[3] = s ? s : '*';
58 for (ix = 0; ix != 4; ix++)
59 version = (version << 8) | v[ix];
61 printf ("/* Generated automatically by the program `%s'\n", argv[0]);
62 printf (" from `%s'. */\n", version_string);
63 printf ("\n");
64 printf ("#define GCOV_VERSION ((gcov_unsigned_t)%#08x) /* %.4s */\n",
65 version, v);
67 return 0;