summaryrefslogtreecommitdiffstats
path: root/hwaccess.c
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-02-04 04:38:42 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-02-04 04:38:42 +0000
commite038e9082cce69f10f17747fc272ae370c9836cf (patch)
tree81738c13224127bddc2f02aa6b62e1281a820354 /hwaccess.c
parentf656e8088e95eaa9a4690529597133d0daf66c2a (diff)
downloadast2050-flashrom-e038e9082cce69f10f17747fc272ae370c9836cf.zip
ast2050-flashrom-e038e9082cce69f10f17747fc272ae370c9836cf.tar.gz
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. Corresponding to flashrom svn r1648. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'hwaccess.c')
-rw-r--r--hwaccess.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hwaccess.c b/hwaccess.c
index f0b2f63..598aa67 100644
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -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 @@ static int release_io_perms(void *p)
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 @@ int rget_io_perms(void)
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"
OpenPOWER on IntegriCloud