Simplify excluding threaded code on Windows
#endif
#define LOCAL static
+#define NO_PROTO
/* *INDENT-OFF* */
/* --prototypes automatically generated by dev-bin/regen-prototypes.pl - don't remove this comment */
@@ -43,13 +44,18 @@ LOCAL int lookup_and_print(MMDB_s *mmdb, const char *ip_address,
LOCAL int benchmark(MMDB_s *mmdb, int iterations);
LOCAL MMDB_lookup_result_s lookup_or_die(MMDB_s *mmdb, const char *ipstr);
LOCAL void random_ipv4(char *ip);
-LOCAL bool start_threaded_benchmark(
+/* --prototypes end - don't remove this comment-- */
+/* *INDENT-ON* */
+
+#ifndef _WIN32
+// These aren't with the automatically generated prototypes as we'd lose the
+// enclosing macros.
+static bool start_threaded_benchmark(
MMDB_s *const mmdb,
int const thread_count,
int const iterations);
-LOCAL void *thread(void *arg);
-/* --prototypes end - don't remove this comment-- */
-/* *INDENT-ON* */
+static void *thread(void *arg);
+#endif
int main(int argc, char **argv)
{
@@ -79,6 +85,7 @@ int main(int argc, char **argv)
srand( time(NULL) );
+#ifndef _WIN32
if (thread_count > 0) {
if (!start_threaded_benchmark(&mmdb, thread_count, iterations)) {
MMDB_close(&mmdb);
@@ -87,6 +94,7 @@ int main(int argc, char **argv)
MMDB_close(&mmdb);
exit(0);
}
+#endif
exit(benchmark(&mmdb, iterations));
}
@@ -446,16 +454,12 @@ struct thread_info {
MMDB_s *mmdb;
int iterations;
};
-#endif
-LOCAL bool start_threaded_benchmark(
+NO_PROTO static bool start_threaded_benchmark(
MMDB_s *const mmdb,
int const thread_count,
int const iterations)
{
-#ifdef _WIN32
- return false;
-#else
struct thread_info *const tinfo = calloc(thread_count,
sizeof(struct thread_info));
if (!tinfo) {
@@ -496,14 +500,10 @@ LOCAL bool start_threaded_benchmark(
(iterations * thread_count) / seconds);
return true;
-#endif
}
-LOCAL void *thread(void *arg)
+NO_PROTO static void *thread(void *arg)
{
-#ifdef _WIN32
- return NULL;
-#else
const struct thread_info *const tinfo = arg;
if (!tinfo) {
fprintf(stderr, "thread(): %s\n", strerror(EINVAL));
@@ -538,5 +538,5 @@ LOCAL void *thread(void *arg)
}
return NULL;
-#endif
}
+#endif
