diff --git a/mtproto-client.c b/mtproto-client.c index 844af9c..e8e692c 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -90,14 +90,13 @@ struct connection_methods auth_methods = { }; long long precise_time; -long long precise_time_rdtsc; + double get_utime (int clock_id) { struct timespec T; my_clock_gettime (clock_id, &T); double res = T.tv_sec + (double) T.tv_nsec * 1e-9; if (clock_id == CLOCK_REALTIME) { precise_time = (long long) (res * (1LL << 32)); - precise_time_rdtsc = rdtsc (); } return res; } diff --git a/mtproto-common.c b/mtproto-common.c index 12efcca..991e6d8 100644 --- a/mtproto-common.c +++ b/mtproto-common.c @@ -67,6 +67,9 @@ int get_random_bytes (unsigned char *buf, int n) { } } close (h); + if (r < 0) { + r = 0; + } } if (r < n) { @@ -105,18 +108,15 @@ void my_clock_gettime (int clock_id UU, struct timespec *T) { #endif } - void prng_seed (const char *password_filename, int password_length) { unsigned char *a = talloc0 (64 + password_length); - long long r = rdtsc (); struct timespec T; my_clock_gettime (CLOCK_REALTIME, &T); memcpy (a, &T.tv_sec, 4); - memcpy (a+4, &T.tv_nsec, 4); - memcpy (a+8, &r, 8); + memcpy (a + 4, &T.tv_nsec, 4); unsigned short p = getpid (); - memcpy (a + 16, &p, 2); - int s = get_random_bytes (a + 18, 32) + 18; + memcpy (a + 8, &p, 2); + int s = get_random_bytes (a + 10, 32) + 10; if (password_filename) { int fd = open (password_filename, O_RDONLY); if (fd < 0) { diff --git a/mtproto-common.h b/mtproto-common.h index d15c922..011aed3 100644 --- a/mtproto-common.h +++ b/mtproto-common.h @@ -375,12 +375,6 @@ static inline void fetch_skip_str (void) { fetch_str (l); } -static __inline__ unsigned long long rdtsc(void) { - unsigned hi, lo; - __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); - return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); -} - static inline long have_prefetch_ints (void) { return in_end - in_ptr; }