]> git.wh0rd.org Git - fontconfig.git/commitdiff
Dominic Lachowicz <cinamod@hotmail.com>
authorPatrick Lam <plam@MIT.EDU>
Wed, 19 Apr 2006 16:53:50 +0000 (16:53 +0000)
committerPatrick Lam <plam@MIT.EDU>
Wed, 19 Apr 2006 16:53:50 +0000 (16:53 +0000)
Implement mmap-like code for Windows using MapViewOfFile.

ChangeLog
src/fccache.c

index 15b36623c75d7237bc3631cc4a5d8da37eb21700..0f83c24e9213335af3f098fb0fbf790bf142d93c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,13 @@
 
        Bump version to 2.3.95.
 
+2006-04-19  Patrick Lam         <plam@mit.edu>
+           Dominic Lachowicz  <cinamod@hotmail.com>
+
+       * src/fccache.c (FcDirCacheConsume):
+
+       Implement mmap-like code for Windows using MapViewOfFile.
+       
 2006-04-19  Patrick Lam         <plam@mit.edu>
        * src/fccache.c (FcDirCacheConsume, FcCacheNextOffset):
 
index c98c001e2893c3ae2055cc2b562461ac6058f778..8f25b2cef6a7d809cddbfa9b0d38214e38ead0c4 100644 (file)
 #include <dirent.h>
 #include <string.h>
 #include <sys/types.h>
-#include <unistd.h>
 #include "fcint.h"
-#include <unistd.h>
 #if defined(HAVE_MMAP) || defined(__CYGWIN__)
+#  include <unistd.h>
 #  include <sys/mman.h>
-#  include <sys/utsname.h>
+#elif defined(_WIN32)
+#  include <windows.h>
 #endif
 
 #define ENDIAN_TEST 0x12345678
@@ -1203,6 +1203,23 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config)
                              PROT_READ, MAP_SHARED, fd, pos);
     if (current_dir_block == MAP_FAILED)
        return FcFalse;
+#elif defined(_WIN32)
+       {
+               HANDLE hFileMap;
+
+               hFileMap = CreateFileMapping((HANDLE) _get_osfhandle(fd), NULL, PAGE_READONLY, 0, 0, NULL);
+               if (hFileMap == NULL)
+                       return FcFalse;
+
+               current_dir_block = MapViewOfFile (hFileMap, FILE_MAP_READ, 0, 0, metadata.count + pos);
+               if (current_dir_block == NULL)
+               {
+                       CloseHandle (hFileMap);
+                       return FcFalse;
+               }
+
+               current_dir_block = (void *)((char *)current_dir_block + pos);
+       }
 #else
     current_dir_block = malloc (metadata.count);
     if (!current_dir_block)