Author: stefanct Date: Mon Feb 4 05:38:42 2013 New Revision: 1648 URL: http://flashrom.org/trac/flashrom/changeset/1648
Log: Fix building for MacOSX.
- Add a new macro named IS_MACOSX to hwaccess.c and use it to enable iopl(). This was broken since r1638. This fix does *not* restore the very permissive concept where iopl() was activated in an #else branch that was inplace before r1638. - Make printing the image file's size in flashrom.c platform independent.
Bonus: remove definitions of off64_t and lseek64 which are not necessary anymore for about 1000 commits.
Thanks to SJ for reporting the issue and testing the solution.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at Acked-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
Modified: trunk/flashrom.c trunk/hwaccess.c trunk/hwaccess.h
Modified: trunk/flashrom.c ============================================================================== --- trunk/flashrom.c Sat Feb 2 16:35:44 2013 (r1647) +++ trunk/flashrom.c Mon Feb 4 05:38:42 2013 (r1648) @@ -1121,8 +1121,8 @@ return 1; } if (image_stat.st_size != size) { - msg_gerr("Error: Image size (%ld B) doesn't match the flash chip's size (%ld B)!\n", - image_stat.st_size, size); + msg_gerr("Error: Image size (%jd B) doesn't match the flash chip's size (%ld B)!\n", + (intmax_t)image_stat.st_size, size); fclose(image); return 1; }
Modified: trunk/hwaccess.c ============================================================================== --- trunk/hwaccess.c Sat Feb 2 16:35:44 2013 (r1647) +++ trunk/hwaccess.c Mon Feb 4 05:38:42 2013 (r1648) @@ -28,7 +28,8 @@
#define IS_BSD (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__OpenBSD__)) #define IS_LINUX (defined(__gnu_linux__) || defined(__linux__)) -#if !(IS_BSD || IS_LINUX || defined(__DJGPP__) || defined(__LIBPAYLOAD__) || defined(__sun)) +#define IS_MACOSX (defined(__APPLE__) && defined(__MACH__)) +#if !(IS_BSD || IS_LINUX || IS_MACOSX || defined(__DJGPP__) || defined(__LIBPAYLOAD__) || defined(__sun)) #error "Unknown operating system" #endif
@@ -72,7 +73,7 @@ sysi86(SI86V86, V86SC_IOPL, 0); #elif IS_BSD close(io_fd); -#elif IS_LINUX +#elif IS_LINUX || IS_MACOSX iopl(0); #endif return 0; @@ -87,7 +88,7 @@ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) { #elif IS_BSD if ((io_fd = open("/dev/io", O_RDWR)) < 0) { -#elif IS_LINUX +#elif IS_LINUX || IS_MACOSX if (iopl(3) != 0) { #endif msg_perr("ERROR: Could not get I/O privileges (%s).\n"
Modified: trunk/hwaccess.h ============================================================================== --- trunk/hwaccess.h Sat Feb 2 16:35:44 2013 (r1647) +++ trunk/hwaccess.h Mon Feb 4 05:38:42 2013 (r1648) @@ -189,8 +189,6 @@ * versions. Use machine/cpufunc.h only for plain FreeBSD/DragonFlyBSD. */ #include <machine/cpufunc.h> - #define off64_t off_t - #define lseek64 lseek #define OUTB(x, y) do { u_int outb_tmp = (y); outb(outb_tmp, (x)); } while (0) #define OUTW(x, y) do { u_int outw_tmp = (y); outw(outw_tmp, (x)); } while (0) #define OUTL(x, y) do { u_int outl_tmp = (y); outl(outl_tmp, (x)); } while (0) @@ -201,8 +199,6 @@ #if defined(__MACH__) && defined(__APPLE__) /* Header is part of the DirectHW library. */ #include <DirectHW/DirectHW.h> - #define off64_t off_t - #define lseek64 lseek #endif #if defined (__sun) && (defined(__i386) || defined(__amd64)) /* Note different order for outb */ @@ -241,8 +237,6 @@ #endif
#if defined(__NetBSD__) || defined (__OpenBSD__) - #define off64_t off_t - #define lseek64 lseek #if defined(__i386__) || defined(__x86_64__) #include <sys/types.h> #include <machine/sysarch.h>