struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / sieve.c
blobd4a4a75d2c7978cb4431b7ba9aca52ae64091770
1 /*
2 sieve.c
4 This variant of the sieve of Eratosthenes was, following its 1981 publication in Byte Magazine,
5 a popular benchmark for array acces throughout the 1980s and 1990s.
6 */
8 #include <testfwk.h>
10 #if !defined (__SDCC_mcs51) && !defined (__SDCC_sm83) && !defined (__SDCC_pdk13) && !defined (__SDCC_pdk14) && !defined (__SDCC_pdk15) && !defined (__SDCC_pdk16) && !defined (__SDCC_stm8) && !defined (__SDCC_f8) // Lack of data memory
11 #define true 1
12 #define false 0
13 #define size 8190
14 #define sizepl 8191
15 char flags[sizepl];
16 #endif
17 void testSieve() {
18 #if !defined (__SDCC_mcs51) && !defined (__SDCC_sm83) && !defined (__SDCC_pdk13) && !defined (__SDCC_pdk14) && !defined (__SDCC_pdk15) && !defined (__SDCC_pdk16) && !defined (__SDCC_stm8) && !defined (__SDCC_f8) // Lack of data memory
19 int i, prime, k, count, iter;
20 for (iter = 1; iter <= 10; iter ++) {
21 count=0 ;
22 for (i = 0; i <= size; i++)
23 flags[i] = true;
24 for (i = 0; i <= size; i++) {
25 if (flags[i]) {
26 prime = i + i + 3;
27 k = i + prime;
28 while (k <= size) {
29 flags[k] = false;
30 k += prime;
32 count = count + 1;
36 ASSERT (count == 1899);
37 #endif