summaryrefslogtreecommitdiffstats
path: root/lib/next_prime.c
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:22 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:22 -0800
commit7a80622f69812ca3262d2027c07a4ed0c0242945 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /lib/next_prime.c
parentee6008996aa701ad2a50d5d6b1529c9e2c2724c1 (diff)
downloadandroid_external_elfutils-7a80622f69812ca3262d2027c07a4ed0c0242945.tar.gz
android_external_elfutils-7a80622f69812ca3262d2027c07a4ed0c0242945.tar.bz2
android_external_elfutils-7a80622f69812ca3262d2027c07a4ed0c0242945.zip
auto import from //depot/cupcake/@135843
Diffstat (limited to 'lib/next_prime.c')
-rw-r--r--lib/next_prime.c54
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/next_prime.c b/lib/next_prime.c
deleted file mode 100644
index 5d608046..00000000
--- a/lib/next_prime.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Determine prime number.
- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@redhat.com>, 2000.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stddef.h>
-
-
-/* Test whether CANDIDATE is a prime. */
-static int
-is_prime (size_t candidate)
-{
- /* No even number and none less than 10 will be passed here. */
- size_t divn = 3;
- size_t sq = divn * divn;
-
- while (sq < candidate && candidate % divn != 0)
- {
- size_t old_sq = sq;
- ++divn;
- sq += 4 * divn;
- if (sq < old_sq)
- return 1;
- ++divn;
- }
-
- return candidate % divn != 0;
-}
-
-
-/* We need primes for the table size. */
-size_t
-next_prime (size_t seed)
-{
- /* Make it definitely odd. */
- seed |= 1;
-
- while (!is_prime (seed))
- seed += 2;
-
- return seed;
-}