sparc: Implement memset/bzero ifunc selection in C
[glibc.git] / inet / tst-checks.c
blob1a4785d96e513f030847eb79b5e2f657010362eb
1 #include <stdio.h>
2 #include <string.h>
3 #include <netinet/in.h>
6 static int
7 do_test (void)
9 int result = 0;
10 char buf[16];
11 memset (buf, '\0', 16);
13 if (! IN6_IS_ADDR_UNSPECIFIED (buf))
15 puts ("positive IN6_IS_ADDR_UNSPECIFIED failed");
16 result = 1;
18 for (size_t i = 0; i < 16; ++i)
20 buf[i] = 1;
21 if (IN6_IS_ADDR_UNSPECIFIED (buf))
23 printf ("negative IN6_IS_ADDR_UNSPECIFIED with byte %zu failed\n",
24 i);
25 result = 1;
27 buf[i] = 0;
30 if (IN6_IS_ADDR_LOOPBACK (buf))
32 puts ("negative IN6_IS_ADDR_UNSPECIFIED failed");
33 result = 1;
35 buf[15] = 1;
36 if (! IN6_IS_ADDR_LOOPBACK (buf))
38 puts ("positive IN6_IS_ADDR_UNSPECIFIED failed");
39 result = 1;
41 buf[15] = 0;
43 buf[0] = 0xfe;
44 buf[1] = 0x80;
45 if (! IN6_IS_ADDR_LINKLOCAL (buf))
47 puts ("positive IN6_IS_ADDR_LINKLOCAL failed");
48 result = 1;
50 for (size_t i = 1; i < 16; ++i)
52 buf[i] ^= 1;
53 if (! IN6_IS_ADDR_LINKLOCAL (buf))
55 printf ("positive IN6_IS_ADDR_LINKLOCAL byte %zu failed\n", i);
56 result = 1;
58 buf[i] ^= 1;
60 buf[0] = 0xff;
61 buf[1] = 0x80;
62 if (IN6_IS_ADDR_LINKLOCAL (buf))
64 puts ("negative IN6_IS_ADDR_LINKLOCAL failed");
65 result = 1;
67 buf[0] = 0xfe;
68 buf[1] = 0xc0;
69 if (IN6_IS_ADDR_LINKLOCAL (buf))
71 puts ("negative IN6_IS_ADDR_LINKLOCAL #2 failed");
72 result = 1;
75 buf[0] = 0xfe;
76 buf[1] = 0xc0;
77 if (! IN6_IS_ADDR_SITELOCAL (buf))
79 puts ("positive IN6_IS_ADDR_SITELOCAL failed");
80 result = 1;
82 for (size_t i = 1; i < 16; ++i)
84 buf[i] ^= 1;
85 if (! IN6_IS_ADDR_SITELOCAL (buf))
87 printf ("positive IN6_IS_ADDR_SITELOCAL byte %zu failed\n", i);
88 result = 1;
90 buf[i] ^= 1;
92 buf[0] = 0xff;
93 buf[1] = 0x80;
94 if (IN6_IS_ADDR_SITELOCAL (buf))
96 puts ("negative IN6_IS_ADDR_SITELOCAL failed");
97 result = 1;
99 buf[0] = 0xf8;
100 buf[1] = 0xc0;
101 if (IN6_IS_ADDR_SITELOCAL (buf))
103 puts ("negative IN6_IS_ADDR_SITELOCAL #2 failed");
104 result = 1;
107 memset (buf, '\0', 16);
108 buf[10] = 0xff;
109 buf[11] = 0xff;
110 if (! IN6_IS_ADDR_V4MAPPED (buf))
112 puts ("positive IN6_IS_ADDR_V4MAPPED failed");
113 result = 1;
115 for (size_t i = 12; i < 16; ++i)
117 buf[i] ^= 1;
118 if (! IN6_IS_ADDR_V4MAPPED (buf))
120 printf ("positive IN6_IS_ADDR_V4MAPPED byte %zu failed\n", i);
121 result = 1;
123 buf[i] ^= 1;
125 for (size_t i = 0; i < 12; ++i)
127 buf[i] ^= 1;
128 if (IN6_IS_ADDR_V4MAPPED (buf))
130 printf ("negative IN6_IS_ADDR_V4MAPPED byte %zu failed\n", i);
131 result = 1;
133 buf[i] ^= 1;
136 memset (buf, '\0', 16);
137 for (size_t i = 12; i < 16; ++i)
139 buf[i] ^= 2;
140 if (! IN6_IS_ADDR_V4COMPAT (buf))
142 printf ("positive IN6_IS_ADDR_V4COMPAT byte %zu failed\n", i);
143 result = 1;
145 buf[i] ^= 2;
147 for (size_t i = 0; i < 12; ++i)
149 buf[i] ^= 1;
150 if (IN6_IS_ADDR_V4COMPAT (buf))
152 printf ("negative IN6_IS_ADDR_V4COMPAT byte %zu failed\n", i);
153 result = 1;
155 buf[i] ^= 1;
157 if (IN6_IS_ADDR_V4COMPAT (buf))
159 puts ("negative IN6_IS_ADDR_V4COMPAT #2 failed");
160 result = 1;
162 buf[15] = 1;
163 if (IN6_IS_ADDR_V4COMPAT (buf))
165 puts ("negative IN6_IS_ADDR_V4COMPAT #3 failed");
166 result = 1;
169 return result;
172 #include <support/test-driver.c>