1*95e1ffb1Schristos /* $NetBSD: genpar.c,v 1.10 2005/12/11 12:16:28 christos Exp $ */
2e85a3c53Schopps
3e85a3c53Schopps /*
4e85a3c53Schopps * Copyright (c) 1993 Markus Wild
5e85a3c53Schopps * All rights reserved.
6e85a3c53Schopps *
7e85a3c53Schopps * Redistribution and use in source and binary forms, with or without
8e85a3c53Schopps * modification, are permitted provided that the following conditions
9e85a3c53Schopps * are met:
10e85a3c53Schopps * 1. Redistributions of source code must retain the above copyright
11e85a3c53Schopps * notice, this list of conditions and the following disclaimer.
12e85a3c53Schopps * 2. Redistributions in binary form must reproduce the above copyright
13e85a3c53Schopps * notice, this list of conditions and the following disclaimer in the
14e85a3c53Schopps * documentation and/or other materials provided with the distribution.
15e85a3c53Schopps * 3. All advertising materials mentioning features or use of this software
16e85a3c53Schopps * must display the following acknowledgement:
17e85a3c53Schopps * This product includes software developed by Markus Wild.
18e85a3c53Schopps * 4. The name of the author may not be used to endorse or promote products
19e85a3c53Schopps * derived from this software without specific prior written permission
20e85a3c53Schopps *
21e85a3c53Schopps * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22e85a3c53Schopps * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23e85a3c53Schopps * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24e85a3c53Schopps * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25e85a3c53Schopps * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26e85a3c53Schopps * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27e85a3c53Schopps * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28e85a3c53Schopps * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29e85a3c53Schopps * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30e85a3c53Schopps * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31e85a3c53Schopps */
32276eff6bSchopps
33e5511496Slukem #include <sys/cdefs.h>
34*95e1ffb1Schristos __RCSID("$NetBSD: genpar.c,v 1.10 2005/12/11 12:16:28 christos Exp $");
35e5511496Slukem
36de144261Sis #include <stdio.h>
3733e84123Smw
38de144261Sis int main(void);
39de144261Sis
40de144261Sis #define BSET(i,b) ((i & (1 << b)) ? 1 : 0)
41de144261Sis
42de144261Sis int
main(void)43de144261Sis main(void)
4433e84123Smw {
4533e84123Smw int i;
46e85a3c53Schopps unsigned char par;
4733e84123Smw
48e85a3c53Schopps printf("u_char even_parity[] = {\n\t");
49e85a3c53Schopps for (i = 0; i < 0x80; i++) {
50de144261Sis par = BSET(i,0) + BSET(i,1) + BSET(i,2) + BSET(i,3) +
51de144261Sis BSET(i,4) + BSET(i,5) + BSET(i,6) + BSET(i,7);
5233e84123Smw printf("%2d, ", par & 1);
5333e84123Smw if ((i & 15) == 15)
54e85a3c53Schopps printf("\n\t");
5533e84123Smw }
5633e84123Smw printf("};\n");
57de144261Sis exit(0);
58de144261Sis /* NOTREACHED */
5933e84123Smw }
60