URL
https://opencores.org/ocsvn/pavr/pavr/trunk
[/] [pavr/] [trunk/] [test/] [sieve/] [sieve.c] - Diff between revs 4 and 6
Only display areas with differences |
Details |
Blame |
View Log
Rev 4 |
Rev 6 |
/* -*- mode: c -*-
|
/* -*- mode: c -*-
|
* $Id: sieve.c,v 1.1.1.1 2003-02-10 04:08:54 doru Exp $
|
* $Id: sieve.c,v 1.1.1.1 2003-02-10 04:08:54 doru Exp $
|
* http://www.bagley.org/~doug/shootout/
|
* http://www.bagley.org/~doug/shootout/
|
*/
|
*/
|
|
|
//#include <stdio.h>
|
//#include <stdio.h>
|
//#include <stdlib.h>
|
//#include <stdlib.h>
|
#include <string.h>
|
#include <string.h>
|
//#include <sfr2313.h>
|
//#include <sfr2313.h>
|
//#include <sfr8515.h>
|
//#include <sfr8515.h>
|
|
|
//#define LIM 8192
|
//#define LIM 8192
|
#define LIM 100
|
#define LIM 100
|
#define NR_TIMES 1
|
#define NR_TIMES 1
|
|
|
void main() {
|
void main() {
|
int NUM;
|
int NUM;
|
static char flags[LIM + 1];
|
static char flags[LIM + 1];
|
long i, k;
|
long i, k;
|
int count;
|
int count;
|
//char *txt1="Hello!";
|
//char *txt1="Hello!";
|
|
|
NUM=NR_TIMES;
|
NUM=NR_TIMES;
|
count=0;
|
count=0;
|
|
|
while (NUM--) {
|
while (NUM--) {
|
count = 0;
|
count = 0;
|
for (i=2; i <= LIM; i++) {
|
for (i=2; i <= LIM; i++) {
|
flags[i] = 0xff;
|
flags[i] = 0xff;
|
}
|
}
|
for (i=2; i <= LIM; i++) {
|
for (i=2; i <= LIM; i++) {
|
if (flags[i]) {
|
if (flags[i]) {
|
// remove all multiples of prime: i
|
// remove all multiples of prime: i
|
for (k=i+i; k <= LIM; k+=i) {
|
for (k=i+i; k <= LIM; k+=i) {
|
flags[k] = 0xaa;
|
flags[k] = 0xaa;
|
}
|
}
|
count++;
|
count++;
|
}
|
}
|
}
|
}
|
}
|
}
|
while (1) {
|
while (1) {
|
}
|
}
|
//printf("Count: %d\n", count);
|
//printf("Count: %d\n", count);
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.