diff -r -u guile-1.9.8-old/libguile/deprecated.c guile-1.9.8-new/libguile/deprecated.c --- guile-1.9.8-old/libguile/deprecated.c 2010-01-22 09:16:50 +0000 +++ guile-1.9.8-new/libguile/deprecated.c 2010-02-22 17:12:20 +0000 @@ -1640,7 +1640,7 @@ /* Networking. */ -#ifdef HAVE_NETWORKING +#if defined HAVE_NETWORKING && defined HAVE_IPV6 SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0, (SCM address), diff -r -u guile-1.9.8-old/libguile/filesys.c guile-1.9.8-new/libguile/filesys.c --- guile-1.9.8-old/libguile/filesys.c 2010-01-22 09:16:50 +0000 +++ guile-1.9.8-new/libguile/filesys.c 2010-02-24 20:06:47 +0000 @@ -117,7 +117,8 @@ /* Some more definitions for the native Windows port. */ #ifdef __MINGW32__ -# define mkdir(path, mode) mkdir (path) +# undef mkdir +# define mkdir(path, mode) _mkdir (path) # define fsync(fd) _commit (fd) # define fchmod(fd, mode) (-1) #endif /* __MINGW32__ */ @@ -515,6 +516,11 @@ * under Windows. It differentiates between file, pipe and socket * descriptors. */ + +#ifndef _S_IFSOCK +#define _S_IFSOCK 0140000 +#endif + static int fstat_Win32 (int fdes, struct stat *buf) { int error, optlen = sizeof (int); diff -r -u guile-1.9.8-old/libguile/objcodes.c guile-1.9.8-new/libguile/objcodes.c --- guile-1.9.8-old/libguile/objcodes.c 2010-01-11 22:21:17 +0000 +++ guile-1.9.8-new/libguile/objcodes.c 2010-02-22 17:16:59 +0000 @@ -22,8 +22,10 @@ #include #include -#include -#include +#include +#if HAVE_SYS_MMAN_H +# include +#endif #include #include #include @@ -38,6 +40,156 @@ verify (((sizeof (SCM_OBJCODE_COOKIE) - 1) & 7) == 0); + +#ifdef _WIN32 + +/* + * Implementation of mmap()/munmap() replacement for Windows. + */ + +#define WIN32_LEAN_AND_MEAN +#include + +#define PROT_READ 0x0001 +#define PROT_WRITE 0x0002 +#define PROT_EXEC 0x0004 +#define PROT_NONE 0x0008 + +#define MAP_SHARED 0x0001 +#define MAP_PRIVATE 0x0002 +#define MAP_FIXED 0x0004 + +#define MAP_FAILED ((void *)-1) + +typedef struct { + unsigned int prot_flag; + DWORD win_flag; +} Protection_Scheme_t; + +typedef struct _MapList_t { + HANDLE hMap; + void *Base; + struct _MapList_t *Next; +} MapList_t; + +static const Protection_Scheme_t Protection_Scheme[] = { + { PROT_READ, PAGE_READONLY }, + { PROT_READ|PROT_WRITE, PAGE_READWRITE }, + { PROT_READ|PROT_WRITE|PROT_EXEC, PAGE_EXECUTE_READWRITE }, + { PROT_EXEC, PAGE_EXECUTE }, + { PROT_READ|PROT_EXEC, PAGE_EXECUTE_READ }, +}; + +static MapList_t *MapList = NULL; + +static void *mmap(unsigned int address, + unsigned int size, + unsigned int protection, + unsigned int flags, + int fd, + int offset) +{ + HANDLE hFile, hMapFile; + DWORD dwProtect, dwAccess; + void *Base; + MapList_t *Item; + unsigned int x; + + /* Check if fd is valid */ + if (fd == -1) + return MAP_FAILED; + + /* Retrieve system handle from fd */ + hFile = (HANDLE)_get_osfhandle(fd); + if (hFile == INVALID_HANDLE_VALUE) + return MAP_FAILED; + + /* Search protection schemes */ + for (dwProtect=PAGE_NOACCESS, x=0; + x < (sizeof(Protection_Scheme)/sizeof(Protection_Scheme_t)); + x++) + { + if (Protection_Scheme[x].prot_flag == protection) + { + dwProtect = Protection_Scheme[x].win_flag; + break; + } + } + + if (flags & MAP_PRIVATE) { + dwAccess = FILE_MAP_COPY; + dwProtect = PAGE_WRITECOPY; + } else + if ((protection & PROT_WRITE)) + dwAccess = FILE_MAP_WRITE; + else + dwAccess = FILE_MAP_READ; + + /* Create mapping object */ + hMapFile = CreateFileMapping(hFile, NULL, dwProtect, 0, size, NULL); + if (hMapFile == INVALID_HANDLE_VALUE) + return MAP_FAILED; + + /* Select which portions of the file we need (entire file) */ + Base = MapViewOfFile(hMapFile, dwAccess, 0, offset, size); + + if (Base == NULL) { + /* Free the mapping object */ + CloseHandle(hMapFile); + return MAP_FAILED; + } + + /* Allocate item for list mmaps... */ + Item = (MapList_t *)malloc(sizeof(MapList_t)); + if (Item == NULL) { + UnmapViewOfFile(Base); + CloseHandle(hMapFile); + + return MAP_FAILED; + } + + Item->hMap = hMapFile; + Item->Base = Base; + Item->Next = MapList; + + if (MapList == NULL) + MapList = Item; + + return Base; +} + +static int munmap(void *addr, unsigned int size) +{ + MapList_t *Item, *Prev; + + Prev = NULL; + Item = MapList; + + while (Item != NULL) { + if (Item->Base == addr) { + UnmapViewOfFile(Item->Base); + CloseHandle(Item->hMap); + + /* Delete this item from linked list */ + if (Prev != NULL) + Prev->Next = Item->Next; + else + MapList = Item->Next; + + free(Item); + + return 0; + } + Prev = Item; + Item = Item->Next; + } + + return -1; +} + +#endif /* _WIN32 */ + + /* * Objcode type */ diff -r -u guile-1.9.8-old/libguile/socket.c guile-1.9.8-new/libguile/socket.c --- guile-1.9.8-old/libguile/socket.c 2009-11-26 09:18:09 +0000 +++ guile-1.9.8-new/libguile/socket.c 2010-02-22 17:17:50 +0000 @@ -56,6 +56,7 @@ #include #ifdef HAVE_WINSOCK2_H #include +#include #else #include #ifdef HAVE_UNIX_DOMAIN_SOCKETS