From 689b60e4c61d300b576fdb7007de51189d2f0f7e Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Sun, 20 Jul 2008 23:12:25 +0200 Subject: [PATCH] Libucw: Prime numbers moved from lib.h to prime.h. --- ucw/Makefile | 2 +- ucw/hashtable.h | 2 ++ ucw/lib.h | 10 ---------- ucw/prime.c | 1 + ucw/prime.h | 32 ++++++++++++++++++++++++++++++++ ucw/primetable.c | 1 + ucw/sorter/sort-test.c | 1 + ucw/url.c | 1 + 8 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 ucw/prime.h diff --git a/ucw/Makefile b/ucw/Makefile index 8cd63745..67d974e7 100644 --- a/ucw/Makefile +++ b/ucw/Makefile @@ -43,7 +43,7 @@ LIBUCW_INCLUDES= \ hashfunc.h hashtable.h \ heap.h binheap.h binheap-node.h \ redblack.h \ - binsearch.h \ + binsearch.h prime.h \ bitops.h \ conf.h getopt.h ipaccess.h \ profile.h \ diff --git a/ucw/hashtable.h b/ucw/hashtable.h index 355f83b4..afccbd06 100644 --- a/ucw/hashtable.h +++ b/ucw/hashtable.h @@ -124,6 +124,8 @@ #include "ucw/hashfunc.h" #endif +#include "ucw/prime.h" + #include /* Initial setup of parameters */ diff --git a/ucw/lib.h b/ucw/lib.h index 0dad3777..c473343c 100644 --- a/ucw/lib.h +++ b/ucw/lib.h @@ -148,16 +148,6 @@ void xfree(void *); void *xmalloc_zero(uns) LIKE_MALLOC; char *xstrdup(const char *) LIKE_MALLOC; -/* prime.c */ - -int isprime(uns x); -uns nextprime(uns x); - -/* primetable.c */ - -uns next_table_prime(uns x); -uns prev_table_prime(uns x); - /* timer.c */ timestamp_t get_timestamp(void); diff --git a/ucw/prime.c b/ucw/prime.c index 1139aa26..12655492 100644 --- a/ucw/prime.c +++ b/ucw/prime.c @@ -8,6 +8,7 @@ */ #include "ucw/lib.h" +#include "ucw/prime.h" static int /* Sequential search */ __isprime(uns x) /* We know x != 2 && x != 3 */ diff --git a/ucw/prime.h b/ucw/prime.h new file mode 100644 index 00000000..9ca2a01e --- /dev/null +++ b/ucw/prime.h @@ -0,0 +1,32 @@ +/* + * The UCW Library -- Prime numbers + * + * (c) 2008 Michal Vaner + * + * Code taken from ucw/lib.h by: + * + * (c) 1997--2008 Martin Mares + * (c) 2005 Tomas Valla + * (c) 2006 Robert Spalek + * (c) 2007 Pavel Charvat + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. + */ + +#ifndef _UCW_PRIME_H +#define _UCW_PRIME_H + +#include "ucw/lib.h" + +/* prime.c */ + +int isprime(uns x); +uns nextprime(uns x); + +/* primetable.c */ + +uns next_table_prime(uns x); +uns prev_table_prime(uns x); + +#endif // _UCW_PRIME_H diff --git a/ucw/primetable.c b/ucw/primetable.c index efece4f3..22cc1ec7 100644 --- a/ucw/primetable.c +++ b/ucw/primetable.c @@ -8,6 +8,7 @@ */ #include "ucw/lib.h" +#include "ucw/prime.h" #include "ucw/binsearch.h" /* A table of odd primes, each is about 1.2 times the previous one */ diff --git a/ucw/sorter/sort-test.c b/ucw/sorter/sort-test.c index de9bf9a0..a7515d71 100644 --- a/ucw/sorter/sort-test.c +++ b/ucw/sorter/sort-test.c @@ -15,6 +15,7 @@ #include "ucw/hashfunc.h" #include "ucw/md5.h" #include "ucw/string.h" +#include "ucw/prime.h" #include #include diff --git a/ucw/url.c b/ucw/url.c index 75b96b06..8f5073a9 100644 --- a/ucw/url.c +++ b/ucw/url.c @@ -19,6 +19,7 @@ #include "ucw/url.h" #include "ucw/chartype.h" #include "ucw/conf.h" +#include "ucw/prime.h" #include #include -- 2.39.5