aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-24 09:04:21 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-24 09:04:21 +0200
commit5ed31456fd60cc8c8d29770f554a837a6e7d19db (patch)
tree201b3c33a0e046b3c5a32bed5dbec4e75b8d7e72
parentm + enable more warnings (diff)
downloadhungarian-algorithm-n3-5ed31456fd60cc8c8d29770f554a837a6e7d19db.tar.gz
hungarian-algorithm-n3-5ed31456fd60cc8c8d29770f554a837a6e7d19db.tar.bz2
hungarian-algorithm-n3-5ed31456fd60cc8c8d29770f554a837a6e7d19db.tar.xz
remove x86 dependency but add unix dependency
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--hungarian.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/hungarian.c b/hungarian.c
index cac5211..9d6d54b 100644
--- a/hungarian.c
+++ b/hungarian.c
@@ -17,6 +17,11 @@
#include <stdlib.h>
+#ifndef RANDOM_DEVICE
+#define RANDOM_DEVICE "/dev/urandom"
+#endif
+
+
#define cell long
#define CELL_STR "%li"
@@ -135,10 +140,11 @@ void print(cell** t, long n, long m, long** assignment);
int main(int argc, char** argv)
{
- unsigned a, d;
- __asm__("cpuid");
- __asm__ __volatile__("rdtsc" : "=a" (a), "=d" (d));
- srand(((llong)a) | (((llong)d) << 32LL));
+ FILE* urandom = fopen(RANDOM_DEVICE, "r");
+ unsigned int seed;
+ fread(&seed, sizeof(unsigned int), 1, urandom);
+ srand(seed);
+ fclose(urandom);
long n = 10, m = 15;