File: ffsl-1.c

package info (click to toggle)
avr-libc 1%3A1.6.2.cvs20080610-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 14,848 kB
  • ctags: 55,619
  • sloc: ansic: 92,267; asm: 6,692; sh: 4,131; makefile: 2,481; python: 976; pascal: 426; perl: 116
file content (47 lines) | stat: -rw-r--r-- 807 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* $Id: ffsl-1.c,v 1.1 2007/02/06 12:29:21 dmix Exp $	*/

#ifndef	__AVR__
# define _GNU_SOURCE
#endif
#include <stdlib.h>
#include <string.h>

int main ()
{
    static struct t_s {
	long val;
	unsigned char pattern;
    } t[] = {
	{ 0, 0 },
	{ 1, 1 },
	{ 0xffffffff, 1 },
	{ 0x00000002, 2 },
	{ 0x80000002, 2 },
	{ 0xfffffff2, 2 },
	{ 0x00000040, 7 },
	{ 0xffffff40, 7 },
	{ 0x00000080, 8 },
	{ 0xffffff80, 8 },

	{ 0x00000100, 9 },
	{ 0xffffff00, 9 },
	{ 0x00008000, 16 },
	{ 0xffff8000, 16 },
	
	{ 0x00010000, 17 },
	{ 0xffff0000, 17 },
	{ 0x00800000, 24 },
	{ 0xff800000, 24 },
	
	{ 0x01000000, 25 },
	{ 0xff000000, 25 },
	{ 0x80000000, 32 },
    };
    int i;
    
    for (i = 0; i != (int)(sizeof(t)/sizeof(t[0])); i++) {
	if (ffsl (t[i].val) != t[i].pattern)
	    exit (1 + i);
    }
    return 0;
}