# define AO_PTRDIFF_T ptrdiff_t
#endif
+#ifndef MAX_NTHREADS
+# define MAX_NTHREADS 100
+#endif
+
typedef void * (* thr_func)(void *);
typedef int (* test_func)(void); /* Returns != 0 on success */
void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
{
pthread_attr_t attr;
- pthread_t thr[100];
+ pthread_t thr[MAX_NTHREADS];
int i;
printf("Testing %s\n", name);
- if (nthreads > 100)
+ if (nthreads > MAX_NTHREADS)
{
fprintf(stderr, "run_parallel: requested too many threads\n");
abort();
#ifdef USE_VXTHREADS
void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
{
- int thr[100];
+ int thr[MAX_NTHREADS];
int i;
printf("Testing %s\n", name);
- if (nthreads > 100)
+ if (nthreads > MAX_NTHREADS)
{
fprintf(stderr, "run_parallel: requested too many threads\n");
taskSuspend(0);
void * run_parallel(int nthreads, thr_func f1, test_func t, const char *name)
{
- HANDLE thr[100];
- struct tramp_args args[100];
+ HANDLE thr[MAX_NTHREADS];
+ struct tramp_args args[MAX_NTHREADS];
int i;
printf("Testing %s\n", name);
- if (nthreads > 100)
+ if (nthreads > MAX_NTHREADS)
{
fprintf(stderr, "run_parallel: requested too many threads\n");
abort();
#include <stdio.h>
#include "atomic_ops_malloc.h"
-#ifndef MAX_NTHREADS
-# define MAX_NTHREADS 100
-#endif
-
#ifndef DEFAULT_NTHREADS
# ifdef HAVE_MMAP
# define DEFAULT_NTHREADS 10
if (1 == argc) {
nthreads = DEFAULT_NTHREADS;
+ assert(nthreads <= MAX_NTHREADS);
} else if (2 == argc) {
nthreads = atoi(argv[1]);
if (nthreads < 1 || nthreads > MAX_NTHREADS) {
# define MAX_NTHREADS 100
#endif
+#ifndef DEFAULT_NTHREADS
+# define DEFAULT_NTHREADS 4 /* must be <= MAX_NTHREADS */
+#endif
+
#ifdef NO_TIMES
# define get_msecs() 0
#elif (defined(USE_WINTHREADS) || defined(AO_USE_WIN32_PTHREADS)) \
int exper_n;
if (1 == argc)
- max_nthreads = 4;
+ {
+ max_nthreads = DEFAULT_NTHREADS;
+ assert(max_nthreads <= MAX_NTHREADS);
+ }
else if (2 == argc)
{
max_nthreads = atoi(argv[1]);