From 5ed31456fd60cc8c8d29770f554a837a6e7d19db Mon Sep 17 00:00:00 2001
From: Mattias Andrée <maandree@operamail.com>
Date: Thu, 24 Apr 2014 09:04:21 +0200
Subject: remove x86 dependency but add unix dependency
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Mattias Andrée <maandree@operamail.com>
---
 hungarian.c | 14 ++++++++++----
 1 file 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;
-- 
cgit v1.2.3-70-g09d2