Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wim Lewis
nettle
Commits
9f7da3eb
Commit
9f7da3eb
authored
Oct 24, 2007
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Introduced OUTPUT macro.
Rev: nettle/examples/eratosthenes.c:1.6
parent
2138baab
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/eratosthenes.c
+8
-4
8 additions, 4 deletions
examples/eratosthenes.c
with
8 additions
and
4 deletions
examples/eratosthenes.c
+
8
−
4
View file @
9f7da3eb
...
@@ -176,6 +176,10 @@ vector_find_next (const unsigned long *vector, unsigned long bit, unsigned long
...
@@ -176,6 +176,10 @@ vector_find_next (const unsigned long *vector, unsigned long bit, unsigned long
return
i
*
BITS_PER_LONG
+
find_first_one
(
word
);
return
i
*
BITS_PER_LONG
+
find_first_one
(
word
);
}
}
/* For benchmarking, define to do nothing (otherwise, most of the time
will be spent converting the output to decimal). */
#define OUTPUT(n) printf("%lu\n", (n))
int
int
main
(
int
argc
,
char
**
argv
)
main
(
int
argc
,
char
**
argv
)
{
{
...
@@ -242,7 +246,7 @@ main (int argc, char **argv)
...
@@ -242,7 +246,7 @@ main (int argc, char **argv)
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
printf
(
"2
\n
"
);
OUTPUT
(
2UL
);
bit
=
0
;
bit
=
0
;
...
@@ -255,7 +259,7 @@ main (int argc, char **argv)
...
@@ -255,7 +259,7 @@ main (int argc, char **argv)
{
{
unsigned
long
n
=
3
+
2
*
bit
;
unsigned
long
n
=
3
+
2
*
bit
;
printf
(
"%lu
\n
"
,
n
);
OUTPUT
(
n
);
/* First bit to clear corresponds to n^2, which is bit
/* First bit to clear corresponds to n^2, which is bit
...
@@ -270,7 +274,7 @@ main (int argc, char **argv)
...
@@ -270,7 +274,7 @@ main (int argc, char **argv)
for
(;
bit
<
block_size
;
for
(;
bit
<
block_size
;
bit
=
vector_find_next
(
vector
,
bit
+
1
,
size
))
bit
=
vector_find_next
(
vector
,
bit
+
1
,
size
))
printf
(
"%lu
\n
"
,
3
+
2
*
bit
);
OUTPUT
(
3
+
2
*
bit
);
for
(
block
=
block_size
;
block
<
size
;
block
+=
block_size
)
for
(
block
=
block_size
;
block
<
size
;
block
+=
block_size
)
{
{
...
@@ -302,7 +306,7 @@ main (int argc, char **argv)
...
@@ -302,7 +306,7 @@ main (int argc, char **argv)
for
(
bit
=
vector_find_next
(
vector
,
block
,
block
+
block_size
);
for
(
bit
=
vector_find_next
(
vector
,
block
,
block
+
block_size
);
bit
<
block
+
block_size
;
bit
<
block
+
block_size
;
bit
=
vector_find_next
(
vector
,
bit
+
1
,
block
+
block_size
))
bit
=
vector_find_next
(
vector
,
bit
+
1
,
block
+
block_size
))
printf
(
"%lu
\n
"
,
3
+
2
*
bit
);
OUTPUT
(
3
+
2
*
bit
);
}
}
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment