Index: configure.in =================================================================== RCS file: /cvs/fontconfig/fontconfig/configure.in,v retrieving revision 1.66.2.8 diff -u -p -r1.66.2.8 configure.in --- configure.in 24 Mar 2006 15:21:10 -0000 1.66.2.8 +++ configure.in 6 Apr 2006 06:02:29 -0000 @@ -143,7 +143,8 @@ AC_TYPE_PID_T # Checks for library functions. AC_FUNC_VPRINTF -AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long iconv]) +AC_FUNC_MMAP +AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long iconv sysconf]) # # Checks for FreeType Index: src/fccache.c =================================================================== RCS file: /cvs/fontconfig/fontconfig/src/fccache.c,v retrieving revision 1.23.4.79 diff -u -p -r1.23.4.79 fccache.c --- src/fccache.c 6 Apr 2006 04:33:11 -0000 1.23.4.79 +++ src/fccache.c 6 Apr 2006 06:02:29 -0000 @@ -26,15 +26,19 @@ #include #include #include -#include -#include #include #include #include "fcint.h" #include +#if defined(HAVE_MMAP) || defined(__CYGWIN__) +# include +# include +#endif #define ENDIAN_TEST 0x12345678 #define MACHINE_SIGNATURE_SIZE (9 + 5*20 + 1) +/* for when we don't have sysconf: */ +#define FC_HARDCODED_PAGESIZE 8192 #ifndef O_BINARY #define O_BINARY 0 @@ -602,7 +606,11 @@ FcCacheNextOffset(off_t w) { static long pagesize = -1; if (pagesize == -1) +#ifdef HAVE_SYSCONF pagesize = sysconf(_SC_PAGESIZE); +#else + pagesize = FC_HARDCODED_PAGESIZE; +#endif if (w % pagesize == 0) return w; else @@ -1160,20 +1168,34 @@ FcDirCacheConsume (int fd, const char * } pos = FcCacheNextOffset (lseek(fd, 0, SEEK_CUR)); +#if defined(HAVE_MMAP) || defined(__CYGWIN__) current_dir_block = mmap (0, metadata.count, PROT_READ, MAP_SHARED, fd, pos); - lseek (fd, pos+metadata.count, SEEK_SET); if (current_dir_block == MAP_FAILED) return FcFalse; +#else + current_dir_block = malloc (metadata.count); + if (!current_dir_block) + return FcFalse; + + if (read (fd, current_dir_block, metadata.count) != metadata.count) + goto bail; +#endif + lseek (fd, pos+metadata.count, SEEK_SET); FcCacheAddBankDir (metadata.bank, dir); if (config) FcConfigAddFontDir (config, (FcChar8 *)dir); if (!FcFontSetUnserialize (&metadata, set, current_dir_block)) - return FcFalse; + goto bail; return FcTrue; + bail: +#if !(defined(HAVE_MMAP) || defined(__CYGWIN__)) + free (current_dir_block); +#endif + return FcFalse; } static void * @@ -1439,7 +1461,11 @@ FcCacheMachineSignature () (unsigned int)sizeof (FcCharLeaf), (unsigned int)sizeof (FcChar32), (unsigned int)sizeof (FcCache), +#ifdef HAVE_SYSCONF (unsigned int)sysconf(_SC_PAGESIZE)); +#else + (unsigned int)FC_HARDCODED_PAGESIZE); +#endif return buf; }