Accept 64-bit addresses on the command line

Define _FILE_OFFSET_BITS to 64, so that even 32-bit systems would accept
64-bit addresses and pass then to mmap() correctly.  It could be useful
on systems with a 64-bit kernel and 32-bit userspace.


git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3421 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
proski 2008-04-03 03:39:24 +00:00
parent c17eb8e386
commit 7006778174

View File

@ -89,6 +89,9 @@
* *
*/ */
/* Try accepting 64-bit device address even with 32-bit userspace */
#define _FILE_OFFSET_BITS 64
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -952,7 +955,7 @@ void sta_id0_id1_dump(void *mem)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
u_int32_t dev_addr; unsigned long long dev_addr;
u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz; u_int16_t eeprom_header, srev, phy_rev_5ghz, phy_rev_2ghz;
u_int16_t eeprom_version, mac_version, regdomain, has_crystal, ee_magic; u_int16_t eeprom_version, mac_version, regdomain, has_crystal, ee_magic;
u_int8_t error, has_a, has_b, has_g, has_rfkill, eeprom_size; u_int8_t error, has_a, has_b, has_g, has_rfkill, eeprom_size;
@ -1046,7 +1049,7 @@ int main(int argc, char *argv[])
return 3; return 3;
} }
dev_addr = strtoul(argv[anr], NULL, 16); dev_addr = strtoull(argv[anr], NULL, 16);
fd = open("/dev/mem", O_RDWR); fd = open("/dev/mem", O_RDWR);
if (fd < 0) { if (fd < 0) {
@ -1058,7 +1061,7 @@ int main(int argc, char *argv[])
MAP_SHARED | MAP_FILE, fd, dev_addr); MAP_SHARED | MAP_FILE, fd, dev_addr);
if (mem == MAP_FAILED) { if (mem == MAP_FAILED) {
printf("Mmap of device at 0x%08X for 0x%X bytes failed - " printf("Mmap of device at 0x%08llX for 0x%X bytes failed - "
"%s\n", dev_addr, AR5K_PCI_MEM_SIZE, strerror(errno)); "%s\n", dev_addr, AR5K_PCI_MEM_SIZE, strerror(errno));
return -3; return -3;
} }