Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / glib / gprimes.c
blobc6109bf95911bdd8deae135b70dbc13583ff5426
1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GLib Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
27 /*
28 * MT safe
31 #include "glib.h"
33 static const guint g_primes[] =
35 11,
36 19,
37 37,
38 73,
39 109,
40 163,
41 251,
42 367,
43 557,
44 823,
45 1237,
46 1861,
47 2777,
48 4177,
49 6247,
50 9371,
51 14057,
52 21089,
53 31627,
54 47431,
55 71143,
56 106721,
57 160073,
58 240101,
59 360163,
60 540217,
61 810343,
62 1215497,
63 1823231,
64 2734867,
65 4102283,
66 6153409,
67 9230113,
68 13845163,
71 static const guint g_nprimes = sizeof (g_primes) / sizeof (g_primes[0]);
73 guint
74 g_spaced_primes_closest (guint num)
76 gint i;
78 for (i = 0; i < g_nprimes; i++)
79 if (g_primes[i] > num)
80 return g_primes[i];
82 return g_primes[g_nprimes - 1];