2 * Copyright © 2006 Keith Packard
3 * Copyright © 2005 Patrick Lam
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting documentation, and
9 * that the name of the copyright holders not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. The copyright holders make no representations
12 * about the suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
27 #define ENDIAN_TEST 0x12345678
28 #define MACHINE_SIGNATURE_SIZE (9*21 + 1)
31 FcCacheMachineSignature (void)
33 static char buf[MACHINE_SIGNATURE_SIZE];
34 int32_t magic = ENDIAN_TEST;
35 char * m = (char *)&magic;
37 sprintf (buf, "%2x%2x%2x%2x_"
38 "%08x_%08x_%08x_%08x_%08x_%08x_%08x_%08x_%08x_%08x_%08x_%08x_"
39 "%08x_%08x_%08x_%08x_%08x_%08x_%08x_%08x",
40 m[0], m[1], m[2], m[3],
41 (unsigned int)sizeof (char),
42 (unsigned int)sizeof (char *),
43 (unsigned int)sizeof (int),
44 (unsigned int)sizeof (intptr_t),
45 (unsigned int)sizeof (FcPattern),
46 (unsigned int)sizeof (FcPatternEltPtr),
47 (unsigned int)sizeof (struct FcPatternElt *),
48 (unsigned int)sizeof (FcPatternElt),
49 (unsigned int)sizeof (FcObject),
50 (unsigned int)sizeof (FcValueListPtr),
51 (unsigned int)sizeof (FcValue),
52 (unsigned int)sizeof (FcValueBinding),
53 (unsigned int)sizeof (struct FcValueList *),
54 (unsigned int)sizeof (FcCharSet),
55 (unsigned int)sizeof (FcCharLeaf **),
56 (unsigned int)sizeof (FcChar16 *),
57 (unsigned int)sizeof (FcChar16),
58 (unsigned int)sizeof (FcCharLeaf),
59 (unsigned int)sizeof (FcChar32),
60 (unsigned int)sizeof (FcCache));
66 main (int argc, char **argv)
68 static char line[1024];
76 fprintf (stderr, "Usage: %s <architecture>|auto < fcarch.tmpl.h > fcarch.h\n",
80 * Scan the input until the marker is found
83 while (fgets (line, sizeof (line), stdin))
86 if (!strncmp (line, "@@@", 3))
90 signature = FcCacheMachineSignature();
91 signature_length = strlen (signature);
93 if (strcmp (arch, "auto") == 0)
97 * Search for signature
99 while (fgets (line, sizeof (line), stdin))
105 if (!strncmp (line, "@@@", 3))
108 while (*space && !isspace (*space))
112 fprintf (stderr, "%s: malformed input on line %d\n",
117 while (isspace (*space))
119 if (!strncmp (space, signature, signature_length))
128 fprintf (stderr, "%s: unknown signature \"%s\"\n", argv[0], signature);
129 fprintf (stderr, "\tPlease update fcarch.tmpl.h and rebuild\n");
132 printf ("#define FC_ARCHITECTURE \"%s\"\n", arch);
134 exit (ferror (stdout));