Commit ca47c2af authored by Howard Chu's avatar Howard Chu
Browse files

ITS#7879 Windows build compatibility

Just use srand/rand, we don't care about the quality
of the random numbers, we just want some data.
parent 225bcae3
......@@ -5,6 +5,7 @@ mdb_copy
mdb_stat
*.[ao]
*.so
*.exe
*[~#]
*.bak
*.orig
......
/* mtest.c - memory-mapped database tester/toy */
/*
* Copyright 2011 Howard Chu, Symas Corp.
* Copyright 2011-2014 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -11,7 +11,6 @@
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
#define _XOPEN_SOURCE 500 /* srandom(), random() */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
......@@ -36,13 +35,13 @@ int main(int argc,char * argv[])
int *values;
char sval[32] = "";
srandom(time(NULL));
srand(time(NULL));
count = (random()%384) + 64;
count = (rand()%384) + 64;
values = (int *)malloc(count*sizeof(int));
for(i = 0;i<count;i++) {
values[i] = random()%1024;
values[i] = rand()%1024;
}
E(mdb_env_create(&env));
......@@ -82,7 +81,7 @@ int main(int argc,char * argv[])
j=0;
key.mv_data = sval;
for (i= count - 1; i > -1; i-= (random()%5)) {
for (i= count - 1; i > -1; i-= (rand()%5)) {
j++;
txn=NULL;
E(mdb_txn_begin(env, NULL, 0, &txn));
......
/* mtest2.c - memory-mapped database tester/toy */
/*
* Copyright 2011 Howard Chu, Symas Corp.
* Copyright 2011-2014 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -14,7 +14,6 @@
/* Just like mtest.c, but using a subDB instead of the main DB */
#define _XOPEN_SOURCE 500 /* srandom(), random() */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
......@@ -38,13 +37,13 @@ int main(int argc,char * argv[])
int *values;
char sval[32] = "";
srandom(time(NULL));
srand(time(NULL));
count = (random()%384) + 64;
count = (rand()%384) + 64;
values = (int *)malloc(count*sizeof(int));
for(i = 0;i<count;i++) {
values[i] = random()%1024;
values[i] = rand()%1024;
}
E(mdb_env_create(&env));
......@@ -82,7 +81,7 @@ int main(int argc,char * argv[])
j=0;
key.mv_data = sval;
for (i= count - 1; i > -1; i-= (random()%5)) {
for (i= count - 1; i > -1; i-= (rand()%5)) {
j++;
txn=NULL;
E(mdb_txn_begin(env, NULL, 0, &txn));
......
/* mtest3.c - memory-mapped database tester/toy */
/*
* Copyright 2011 Howard Chu, Symas Corp.
* Copyright 2011-2014 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -13,7 +13,6 @@
*/
/* Tests for sorted duplicate DBs */
#define _XOPEN_SOURCE 500 /* srandom(), random() */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -39,15 +38,15 @@ int main(int argc,char * argv[])
char sval[32];
char kval[sizeof(int)];
srandom(time(NULL));
srand(time(NULL));
memset(sval, 0, sizeof(sval));
count = (random()%384) + 64;
count = (rand()%384) + 64;
values = (int *)malloc(count*sizeof(int));
for(i = 0;i<count;i++) {
values[i] = random()%1024;
values[i] = rand()%1024;
}
E(mdb_env_create(&env));
......@@ -87,7 +86,7 @@ int main(int argc,char * argv[])
j=0;
for (i= count - 1; i > -1; i-= (random()%5)) {
for (i= count - 1; i > -1; i-= (rand()%5)) {
j++;
txn=NULL;
E(mdb_txn_begin(env, NULL, 0, &txn));
......
/* mtest4.c - memory-mapped database tester/toy */
/*
* Copyright 2011 Howard Chu, Symas Corp.
* Copyright 2011-2014 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -13,7 +13,6 @@
*/
/* Tests for sorted duplicate DBs with fixed-size keys */
#define _XOPEN_SOURCE 500 /* srandom(), random() */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -123,7 +122,7 @@ int main(int argc,char * argv[])
mdb_txn_abort(txn);
j=0;
for (i= count - 1; i > -1; i-= (random()%3)) {
for (i= count - 1; i > -1; i-= (rand()%3)) {
j++;
txn=NULL;
E(mdb_txn_begin(env, NULL, 0, &txn));
......
/* mtest5.c - memory-mapped database tester/toy */
/*
* Copyright 2011 Howard Chu, Symas Corp.
* Copyright 2011-2014 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -13,7 +13,6 @@
*/
/* Tests for sorted duplicate DBs using cursor_put */
#define _XOPEN_SOURCE 500 /* srandom(), random() */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -39,15 +38,15 @@ int main(int argc,char * argv[])
char sval[32];
char kval[sizeof(int)];
srandom(time(NULL));
srand(time(NULL));
memset(sval, 0, sizeof(sval));
count = (random()%384) + 64;
count = (rand()%384) + 64;
values = (int *)malloc(count*sizeof(int));
for(i = 0;i<count;i++) {
values[i] = random()%1024;
values[i] = rand()%1024;
}
E(mdb_env_create(&env));
......@@ -89,7 +88,7 @@ int main(int argc,char * argv[])
j=0;
for (i= count - 1; i > -1; i-= (random()%5)) {
for (i= count - 1; i > -1; i-= (rand()%5)) {
j++;
txn=NULL;
E(mdb_txn_begin(env, NULL, 0, &txn));
......
/* mtest6.c - memory-mapped database tester/toy */
/*
* Copyright 2011 Howard Chu, Symas Corp.
* Copyright 2011-2014 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -13,7 +13,6 @@
*/
/* Tests for DB splits and merges */
#define _XOPEN_SOURCE 500 /* srandom(), random() */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -41,7 +40,7 @@ int main(int argc,char * argv[])
long kval;
char *sval;
srandom(time(NULL));
srand(time(NULL));
E(mdb_env_create(&env));
E(mdb_env_set_mapsize(env, 10485760));
......@@ -90,7 +89,7 @@ int main(int argc,char * argv[])
#if 0
j=0;
for (i= count - 1; i > -1; i-= (random()%5)) {
for (i= count - 1; i > -1; i-= (rand()%5)) {
j++;
txn=NULL;
E(mdb_txn_begin(env, NULL, 0, &txn));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment