diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-05-08 22:59:02 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-05-08 22:59:02 +0200 |
commit | 342ebce798fe98ede64939a49bbc3770d8214649 (patch) | |
tree | b55927f05ec0d294ababcb2b4519b7e1a628d5f8 /src/plugins/imb/imbapi.c | |
parent | 97d6a2e491c6ed08473beb2c4bac47c5cbc1201a (diff) |
Imported Upstream version 1.8.17upstream/1.8.17
Diffstat (limited to 'src/plugins/imb/imbapi.c')
-rw-r--r-- | src/plugins/imb/imbapi.c | 41 |
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 |