From ca47c2af1f4d90e1a0ec7e4c6ce4937262c18c74 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 23 Jun 2014 07:39:06 -0700 Subject: [PATCH] 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. --- libraries/liblmdb/.gitignore | 1 + libraries/liblmdb/mtest.c | 11 +++++------ libraries/liblmdb/mtest2.c | 11 +++++------ libraries/liblmdb/mtest3.c | 11 +++++------ libraries/liblmdb/mtest4.c | 5 ++--- libraries/liblmdb/mtest5.c | 11 +++++------ libraries/liblmdb/mtest6.c | 7 +++---- 7 files changed, 26 insertions(+), 31 deletions(-) diff --git a/libraries/liblmdb/.gitignore b/libraries/liblmdb/.gitignore index 0d493fe188..0b4b1cba67 100644 --- a/libraries/liblmdb/.gitignore +++ b/libraries/liblmdb/.gitignore @@ -5,6 +5,7 @@ mdb_copy mdb_stat *.[ao] *.so +*.exe *[~#] *.bak *.orig diff --git a/libraries/liblmdb/mtest.c b/libraries/liblmdb/mtest.c index 01579950b1..79b4175e79 100644 --- a/libraries/liblmdb/mtest.c +++ b/libraries/liblmdb/mtest.c @@ -1,6 +1,6 @@ /* 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 * . */ -#define _XOPEN_SOURCE 500 /* srandom(), random() */ #include #include #include @@ -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 -1; i-= (random()%5)) { + for (i= count - 1; i > -1; i-= (rand()%5)) { j++; txn=NULL; E(mdb_txn_begin(env, NULL, 0, &txn)); diff --git a/libraries/liblmdb/mtest2.c b/libraries/liblmdb/mtest2.c index ebda8521e4..f1a3dbd6c8 100644 --- a/libraries/liblmdb/mtest2.c +++ b/libraries/liblmdb/mtest2.c @@ -1,6 +1,6 @@ /* 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 #include #include @@ -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 -1; i-= (random()%5)) { + for (i= count - 1; i > -1; i-= (rand()%5)) { j++; txn=NULL; E(mdb_txn_begin(env, NULL, 0, &txn)); diff --git a/libraries/liblmdb/mtest3.c b/libraries/liblmdb/mtest3.c index 95b1749688..f705c52dec 100644 --- a/libraries/liblmdb/mtest3.c +++ b/libraries/liblmdb/mtest3.c @@ -1,6 +1,6 @@ /* 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 #include #include @@ -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 -1; i-= (random()%5)) { + for (i= count - 1; i > -1; i-= (rand()%5)) { j++; txn=NULL; E(mdb_txn_begin(env, NULL, 0, &txn)); diff --git a/libraries/liblmdb/mtest4.c b/libraries/liblmdb/mtest4.c index 37f95baa24..da5a953044 100644 --- a/libraries/liblmdb/mtest4.c +++ b/libraries/liblmdb/mtest4.c @@ -1,6 +1,6 @@ /* 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 #include #include @@ -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)); diff --git a/libraries/liblmdb/mtest5.c b/libraries/liblmdb/mtest5.c index 4edfea0d4c..39a8c728ac 100644 --- a/libraries/liblmdb/mtest5.c +++ b/libraries/liblmdb/mtest5.c @@ -1,6 +1,6 @@ /* 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 #include #include @@ -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 -1; i-= (random()%5)) { + for (i= count - 1; i > -1; i-= (rand()%5)) { j++; txn=NULL; E(mdb_txn_begin(env, NULL, 0, &txn)); diff --git a/libraries/liblmdb/mtest6.c b/libraries/liblmdb/mtest6.c index 8d32e8851a..07d5758932 100644 --- a/libraries/liblmdb/mtest6.c +++ b/libraries/liblmdb/mtest6.c @@ -1,6 +1,6 @@ /* 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 #include #include @@ -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)); -- 2.39.2