From 098ef26c87b27ddac5eb41f1317fe552fe16e3a7 Mon Sep 17 00:00:00 2001 From: laforge Date: Sun, 11 Sep 2005 19:59:58 +0000 Subject: use 64bit timeout values throughout the code, since some timeouts exceeds 4.8 billion microseconds (seconds). git-svn-id: https://svn.gnumonks.org/trunk/librfid@1426 e0336214-984f-0b4b-a45f-81c69e1f0ede --- rfid_proto_tcl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'rfid_proto_tcl.c') diff --git a/rfid_proto_tcl.c b/rfid_proto_tcl.c index b8586f5..e60af55 100644 --- a/rfid_proto_tcl.c +++ b/rfid_proto_tcl.c @@ -41,6 +41,7 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h, unsigned char sfgi) { unsigned int multiplier; + unsigned int tmp; if (sfgi > 14) sfgi = 14; @@ -49,14 +50,15 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h, /* ISO 14443-4:2000(E) Section 5.2.5: * (256 * 16 / h->l2h->rh->ah->fc) * (2 ^ sfgi) */ + tmp = (unsigned int) 1000000 * 256 * 16; - return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier; + return (tmp / h->l2h->rh->ah->fc) * multiplier; } static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h, unsigned char fwi) { - unsigned int multiplier; + unsigned int multiplier, tmp; if (fwi > 14) fwi = 14; @@ -66,10 +68,13 @@ static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h, /* ISO 14443-4:2000(E) Section 7.2.: * (256*16 / h->l2h->rh->ah->fc) * (2 ^ fwi) */ - return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier; + tmp = (unsigned int) 1000000 * 256 * 16; + + return (tmp / h->l2h->rh->ah->fc) * multiplier; } -#define activation_fwt(x) (65536 / x->l2h->rh->ah->fc) +/* 4.9seconds as microseconds (4.9 billion seconds) exceeds 2^32 */ +#define activation_fwt(x) (((u_int64_t)1000000 * 65536 / x->l2h->rh->ah->fc)) #define deactivation_fwt(x) activation_fwt(x) static int -- cgit v1.2.3