summaryrefslogtreecommitdiff
path: root/src/plugins/imb/imbapi.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-05-08 22:59:06 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-05-08 22:59:06 +0200
commita7c8ed90be739a49937a229828c470f1ad01396e (patch)
tree4cd43ff357d98a1ce5afb3bb9449afcce5a299d1 /src/plugins/imb/imbapi.c
parentfa5ac2da06fae952fe1295a1e955bdb35e6d86c4 (diff)
parent342ebce798fe98ede64939a49bbc3770d8214649 (diff)
Merge tag 'upstream/1.8.17'
Upstream version 1.8.17
Diffstat (limited to 'src/plugins/imb/imbapi.c')
-rw-r--r--src/plugins/imb/imbapi.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/plugins/imb/imbapi.c b/src/plugins/imb/imbapi.c
index 899c47a..84eec2e 100644
--- a/src/plugins/imb/imbapi.c
+++ b/src/plugins/imb/imbapi.c
@@ -97,7 +97,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string.h>
#endif
#include "imbapi.h"
-#include <asm/socket.h>
+#include <sys/socket.h>
#ifdef SCO_UW
#define NO_MACRO_ARGS 1
@@ -105,9 +105,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define IMB_DEVICE "/dev/instru/mismic"
#else
#define IMB_DEVICE "/dev/imb"
-#ifndef PAGESIZE
-# define PAGESIZE EXEC_PAGESIZE
#endif
+
+#if !defined(PAGESIZE) && defined(PAGE_SIZE)
+# define PAGESIZE PAGE_SIZE
+#endif
+
+#if !defined(_SC_PAGESIZE) && defined(_SC_PAGE_SIZE)
+# define _SC_PAGESIZE _SC_PAGE_SIZE
#endif
/*Just to make the DEBUG code cleaner.*/
@@ -545,7 +550,7 @@ SendTimedI2cRequest (
if( status != TRUE ) {
DWORD error;
error = GetLastError();
- return ACCESN_ERROR;
+ return error;
}
if( respLength == 0 ) {
return ACCESN_ERROR;
@@ -1134,7 +1139,7 @@ SendTimedImbpRequest (
if( status != TRUE ) {
DWORD error;
error = GetLastError();
- return ACCESN_ERROR;
+ return error;
}
if( respLength == 0 ) {
return ACCESN_ERROR;
@@ -1211,7 +1216,7 @@ SendAsyncImbpRequest (
if( status != TRUE ) {
DWORD error;
error = GetLastError();
- return ACCESN_ERROR;
+ return error;
}
if( respLength != 2 ) {
return ACCESN_ERROR;
@@ -1985,6 +1990,16 @@ MapPhysicalMemory(int startAddress,int addressLength, int *virtualAddress )
off_t startpAddress = (off_t)startAddress;
unsigned int diff;
char *startvAddress;
+#if defined(PAGESIZE)
+ long int pagesize = PAGESIZE;
+#elif defined(_SC_PAGESIZE)
+ long int pagesize = sysconf(_SC_PAGESIZE);
+ if (pagesize < 1) {
+ perror("Invalid pagesize");
+ }
+#else
+# error PAGESIZE unsupported
+#endif
if ((startAddress == 0) || (addressLength <= 0))
return ACCESN_ERROR;
@@ -1999,7 +2014,7 @@ MapPhysicalMemory(int startAddress,int addressLength, int *virtualAddress )
}
/* aliging the offset to a page boundary and adjusting the length */
- diff = (int)startpAddress % PAGESIZE;
+ diff = (int)startpAddress % pagesize;
startpAddress -= diff;
length += diff;
@@ -2043,9 +2058,19 @@ ACCESN_STATUS
UnmapPhysicalMemory( int virtualAddress, int Length )
{
unsigned int diff = 0;
+#if defined(PAGESIZE)
+ long int pagesize = PAGESIZE;
+#elif defined(_SC_PAGESIZE)
+ long int pagesize = sysconf(_SC_PAGESIZE);
+ if (pagesize < 1) {
+ perror("Invalid pagesize");
+ }
+#else
+# error PAGESIZE unsupported
+#endif
/* page align the virtual address and adjust length accordingly */
- diff = ((unsigned int) virtualAddress) % PAGESIZE;
+ diff = ((unsigned int) virtualAddress) % pagesize;
virtualAddress -= diff;
Length += diff;
#ifndef NO_MACRO_ARGS