]> git.wh0rd.org Git - fontconfig.git/commitdiff
Patrick Lam <plam@mit.edu>
authorPatrick Lam <plam@MIT.EDU>
Fri, 7 Apr 2006 04:42:32 +0000 (04:42 +0000)
committerPatrick Lam <plam@MIT.EDU>
Fri, 7 Apr 2006 04:42:32 +0000 (04:42 +0000)
Make fontconfig compile under MinGW:
1) remove unneeded #includes;
2) make use of mmap and sysconf conditional;
3) replace rand_r by srand/rand if needed;
4) use chsize instead of ftruncate; and
5) update libtool exports file

ChangeLog
configure.in
fc-cache/fc-cache.c
fc-cat/fc-cat.c
src/fccache.c
src/fcfreetype.c
src/fontconfig.def.in

index 6a5deb1031c1b8a27629043cad3be920b473dc6c..1b1fc469549629fbd83cc2adae50a4dd4a0bd8e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2006-04-07  Dominic Lachowicz  <cinamod@hotmail.com>
+           Patrick Lam  <plam@mit.edu>
+       * configure.in:
+       * fc-cache/fc-cache.c:
+       * fc-cat/fc-cat.c:
+       * src/fccache.c (FcGlobalCacheSave, FcCacheNextOffset, 
+                        FcDirCacheConsume, FcDirCacheProduce, 
+                        FcDirCacheWrite, FcCacheMachineSignature):
+       * src/fcfreetype.c (FcFreeTypeQuery):
+       * src/fontconfig.def.in:
+
+       Make fontconfig compile under MinGW: 
+       1) remove unneeded #includes;
+       2) make use of mmap and sysconf conditional;
+       3) replace rand_r by srand/rand if needed;
+       4) use chsize instead of ftruncate; and
+       5) update libtool exports file
+
 2006-04-07  Patrick Lam  <plam@mit.edu>
        * src/fcdir.c (FcDirScanConfig):
 
index 26fd05b27c710be6f9d489777abd3c6521d5b04e..4ec7abd121986d7d21897a8351331c42e5bf315b 100644 (file)
@@ -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 ftruncate chsize rand_r])
 
 #
 # Checks for FreeType
index ba1ba2bbba7d36b6cac8746f4b5bb4a48d2f6c7c..ce6b567ce92e6b92ce064261640a4899f8713b5d 100644 (file)
 #define HAVE_GETOPT 1
 #endif
 
+#if defined (_WIN32)
+#define STRICT
+#include <windows.h>
+#define sleep(x) Sleep((x) * 1000)
+#undef STRICT
+#endif
+
 #ifndef HAVE_GETOPT
 #define HAVE_GETOPT 0
 #endif
index 24f8a44d5f9e80b8a2ab336dfb6d628da2309f3c..80c381c049d560632220cfd669430d1e5ac7391d 100644 (file)
@@ -27,7 +27,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <libgen.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
index 5aa0df894a3e491554b22a24976d7995d44dd070..248c6d1584569aa32870f3eb8d2db77f64678fe1 100644 (file)
 #include <fcntl.h>
 #include <dirent.h>
 #include <string.h>
-#include <sys/mman.h>
-#include <sys/utsname.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include "fcint.h"
 #include <unistd.h>
+#if defined(HAVE_MMAP) || defined(__CYGWIN__)
+#  include <sys/mman.h>
+#  include <sys/utsname.h>
+#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
@@ -458,8 +462,17 @@ FcGlobalCacheSave (FcGlobalCache    *cache,
        goto bail3;
 
     current_arch_start = lseek(fd, 0, SEEK_CUR);
+#if defined (HAVE_FTRUNCATE)
     if (ftruncate (fd, current_arch_start) == -1)
        goto bail3;
+#else
+#if defined (HAVE_CHSIZE)
+    if (chsize (fd, current_arch_start) == -1)
+       goto bail3;
+#else
+    goto bail3;
+#endif
+#endif
 
     header = malloc (10 + strlen (current_arch_machine_name));
     if (!header)
@@ -602,7 +615,11 @@ FcCacheNextOffset(off_t w)
 {
     static long pagesize = -1;
     if (pagesize == -1)
+#if defined (HAVE_SYSCONF)
        pagesize = sysconf(_SC_PAGESIZE);
+#else
+       pagesize = FC_HARDCODED_PAGESIZE;
+#endif
     if (w % pagesize == 0) 
        return w;
     else
@@ -1160,20 +1177,35 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config)
     }
 
     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;
+
+    /* could also use CreateMappedViewOfFile under MinGW... */
+    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 *
@@ -1183,12 +1215,24 @@ FcDirCacheProduce (FcFontSet *set, FcCache *metadata)
     static unsigned int rand_state = 0;
     int bank, needed_bytes_no_align;
 
+#if defined (HAVE_RAND_R)
     if (!rand_state) 
        rand_state = time(0L);
     bank = rand_r(&rand_state);
 
     while (FcCacheHaveBank(bank))
        bank = rand_r(&rand_state);
+#else
+    if (!rand_state)
+    {
+        rand_state = 1;
+        srand (time (0L));
+    }
+    bank = rand();
+
+    while (FcCacheHaveBank(bank))
+        bank = rand();
+#endif
 
     memset (metadata, 0, sizeof(FcCache));
     FcFontSetNewBank();
@@ -1336,8 +1380,17 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
         close (fd_orig);
 
     current_arch_start = lseek(fd, 0, SEEK_CUR);
+#if defined (HAVE_FTRUNCATE)
     if (ftruncate (fd, current_arch_start) == -1)
        goto bail4;
+#else
+#if defined (HAVE_CHSIZE)
+    if (chsize (fd, current_arch_start) == -1)
+       goto bail4;
+#else
+    goto bail4;
+#endif
+#endif
 
     /* allocate space for subdir names in this block */
     dirs_count = 0;
@@ -1377,8 +1430,17 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
     }
 
     /* this actually serves to pad out the cache file, if needed */
+#if defined (HAVE_FTRUNCATE)
     if (ftruncate (fd, current_arch_start + truncate_to) == -1)
        goto bail5;
+#else
+#if defined (HAVE_CHSIZE)
+    if (chsize (fd, current_arch_start + truncate_to) == -1)
+       goto bail5;
+#else
+    goto bail5;
+#endif
+#endif
 
     free (header);
     close(fd);
@@ -1439,7 +1501,11 @@ FcCacheMachineSignature ()
             (unsigned int)sizeof (FcCharLeaf),
             (unsigned int)sizeof (FcChar32),
             (unsigned int)sizeof (FcCache),
+#if defined (HAVE_SYSCONF)
             (unsigned int)sysconf(_SC_PAGESIZE));
+#else
+            (unsigned int)FC_HARDCODED_PAGESIZE);
+#endif
 
     return buf;
 }
index 6bdd733dba104ead798a6106a9bd937ef1358520..2689b9f2c63fb196c09db30dc2f2716951116738 100644 (file)
@@ -47,7 +47,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <libgen.h>
 #include "fcint.h"
 #include <ft2build.h>
 #include FT_FREETYPE_H
@@ -1281,7 +1280,7 @@ FcFreeTypeQuery (const FcChar8    *file,
     }
 
     file2 = FcStrCopy (file);
-    if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)file2)))
+    if (!FcPatternAddString (pat, FC_FILE, FcStrBasename(file2)))
     {
        FcStrFree (file2);
        goto bail1;
index 83dac955936ca247ec1cb7cf5dc270b11431579e..0bccef54db280aeb1b41b3b264e8a36c5a804fdc 100755 (executable)
 EXPORTS
-       FcAtomicCreate
-       FcAtomicDeleteNew
-       FcAtomicDestroy
-       FcAtomicLock
-       FcAtomicNewFile
-       FcAtomicOrigFile
-       FcAtomicReplaceOrig
-       FcAtomicUnlock
-       FcBlanksAdd
+       FcDirCacheValid
+       FcDirCacheHasCurrentArch
+       FcDirCacheUnlink
        FcBlanksCreate
        FcBlanksDestroy
+       FcBlanksAdd
        FcBlanksIsMember
-       FcCharSetAddChar
-       FcCharSetCopy
-       FcCharSetCount
-       FcCharSetCreate
-       FcCharSetDestroy
-       FcCharSetEqual
-       FcCharSetFirstPage
-       FcCharSetHasChar
-       FcCharSetIntersect
-       FcCharSetIntersectCount
-       FcCharSetIsSubset
-       FcCharSetNextPage
-       FcCharSetSubtract
-       FcCharSetSubtractCount
-       FcCharSetUnion
-       FcConfigAppFontAddDir
-       FcConfigAppFontAddFile
-       FcConfigAppFontClear
-       FcConfigBuildFonts
-       FcConfigCreate
-       FcConfigDestroy
+       FcConfigHome
        FcConfigEnableHome
        FcConfigFilename
-       FcConfigGetBlanks
-       FcConfigGetCache
-       FcConfigGetConfigDirs
-       FcConfigGetConfigFiles
+       FcConfigCreate
+       FcConfigDestroy
+       FcConfigSetCurrent
        FcConfigGetCurrent
+       FcConfigUptoDate
+       FcConfigBuildFonts
        FcConfigGetFontDirs
-       FcConfigGetFonts
+       FcConfigNormalizeFontDir
+       FcConfigGetConfigDirs
+       FcConfigGetConfigFiles
+       FcConfigGetCache
+       FcConfigGetBlanks
        FcConfigGetRescanInverval
-       FcConfigParseAndLoad
-       FcConfigSetCurrent
        FcConfigSetRescanInverval
-       FcConfigSubstitute
+       FcConfigGetFonts
+       FcConfigAppFontAddFile
+       FcConfigAppFontAddDir
+       FcConfigAppFontClear
        FcConfigSubstituteWithPat
-       FcConfigUptoDate
+       FcConfigSubstitute
+       FcCharSetCreate
+       FcCharSetDestroy
+       FcCharSetAddChar
+       FcCharSetCopy
+       FcCharSetEqual
+       FcCharSetIntersect
+       FcCharSetUnion
+       FcCharSetSubtract
+       FcCharSetHasChar
+       FcCharSetCount
+       FcCharSetIntersectCount
+       FcCharSetSubtractCount
+       FcCharSetIsSubset
+       FcCharSetFirstPage
+       FcCharSetNextPage
+       FcValuePrint
+       FcPatternPrint
+       FcFontSetPrint
+       FcDebugVal
+       FcFontSetUnserialize
        FcDefaultSubstitute
-       FcDirCacheValid
-       FcDirSave
-       FcDirScan
        FcFileScan
-       FcFini
-       FcFontList
-       FcFontMatch
-       FcFontRenderPrepare
-       FcFontSetAdd
+       FcDirScan
+       FcDirSave
+       FcFreeTypeQuery
        FcFontSetCreate
        FcFontSetDestroy
-       FcFontSetList
-       FcFontSetMatch
-       FcFontSetPrint
-       FcFontSetSort
-       FcFontSetSortDestroy
-       FcFontSort
-       FcFreeTypeCharIndex
-       FcFreeTypeCharSet
-       FcFreeTypeQuery
-       FcGetVersion
-       FcInit
-       FcInitBringUptoDate
+       FcFontSetAdd
        FcInitLoadConfig
        FcInitLoadConfigAndFonts
+       FcInit
+       FcFini
+       FcGetVersion
        FcInitReinitialize
-       FcLangSetAdd
-       FcLangSetCompare
-       FcLangSetCopy
+       FcInitBringUptoDate
        FcLangSetCreate
        FcLangSetDestroy
-       FcLangSetEqual
+       FcLangSetCopy
+       FcLangSetAdd
        FcLangSetHasLang
+       FcLangSetCompare
+       FcLangSetContains
+       FcLangSetEqual
        FcLangSetHash
+       FcObjectSetCreate
+       FcObjectSetAdd
+       FcObjectSetDestroy
+       FcObjectSetVaBuild
+       FcObjectSetBuild
+       FcFontSetList
+       FcFontList
+       FcAtomicCreate
+       FcAtomicLock
+       FcAtomicNewFile
+       FcAtomicOrigFile
+       FcAtomicReplaceOrig
+       FcAtomicDeleteNew
+       FcAtomicUnlock
+       FcAtomicDestroy
+       FcFontSetMatch
+       FcFontMatch
+       FcFontRenderPrepare
+       FcFontSetSort
+       FcFontSort
+       FcFontSetSortDestroy
        FcMatrixCopy
        FcMatrixEqual
        FcMatrixMultiply
        FcMatrixRotate
        FcMatrixScale
        FcMatrixShear
-       FcNameConstant
-       FcNameGetConstant
+       FcNameRegisterObjectTypes
+       FcNameUnregisterObjectTypes
        FcNameGetObjectType
-       FcNameParse
        FcNameRegisterConstants
-       FcNameRegisterObjectTypes
-       FcNameUnparse
        FcNameUnregisterConstants
-       FcNameUnregisterObjectTypes
-       FcObjectSetAdd
-       FcObjectSetBuild
-       FcObjectSetCreate
-       FcObjectSetDestroy
-       FcObjectSetVaBuild
-       FcPatternAdd
-       FcPatternAddBool
-       FcPatternAddCharSet
-       FcPatternAddDouble
-       FcPatternAddFTFace
-       FcPatternAddInteger
-       FcPatternAddLangSet
-       FcPatternAddMatrix
-       FcPatternAddString
-       FcPatternAddWeak
-       FcPatternBuild
+       FcNameGetConstant
+       FcNameConstant
+       FcNameParse
+       FcNameUnparse
+       FcNameUnparseEscaped
        FcPatternCreate
-       FcPatternDel
-       FcPatternDestroy
        FcPatternDuplicate
+       FcPatternReference
+       FcValueDestroy
+       FcValueEqual
+       FcValueSave
+       FcPatternDestroy
        FcPatternEqual
        FcPatternEqualSubset
+       FcPatternHash
+       FcPatternAdd
+       FcPatternAddWeak
        FcPatternGet
-       FcPatternGetBool
-       FcPatternGetCharSet
-       FcPatternGetDouble
-       FcPatternGetFTFace
+       FcPatternDel
+       FcPatternRemove
+       FcPatternAddInteger
+       FcPatternAddDouble
+       FcPatternAddString
+       FcPatternAddMatrix
+       FcPatternAddCharSet
+       FcPatternAddBool
+       FcPatternAddLangSet
        FcPatternGetInteger
-       FcPatternGetLangSet
-       FcPatternGetMatrix
+       FcPatternGetDouble
        FcPatternGetString
-       FcPatternHash
-       FcPatternPrint
-       FcPatternReference
+       FcPatternGetMatrix
+       FcPatternGetCharSet
+       FcPatternGetBool
+       FcPatternGetLangSet
        FcPatternVaBuild
-       FcStrBasename
-       FcStrCmp
-       FcStrCmp
-       FcStrCmpIgnoreCase
+       FcPatternBuild
        FcStrCopy
        FcStrCopyFilename
+       FcStrDowncase
+       FcStrCmpIgnoreCase
+       FcStrCmp
+       FcStrStrIgnoreCase
+       FcStrStr
+       FcUtf8ToUcs4
+       FcUtf8Len
+       FcUcs4ToUtf8
+       FcUtf16ToUcs4
+       FcUtf16Len
        FcStrDirname
-       FcStrListCreate
-       FcStrListDone
-       FcStrListNext
+       FcStrBasename
+       FcStrSetCreate
+       FcStrSetMember
+       FcStrSetEqual
        FcStrSetAdd
        FcStrSetAddFilename
-       FcStrSetCreate
        FcStrSetDel
        FcStrSetDestroy
-       FcStrSetEqual
-       FcStrSetMember
-       FcUcs4ToUtf8
-       FcUtf16Len
-       FcUtf16ToUcs4
-       FcUtf8Len
-       FcUtf8ToUcs4
-       FcValueDestroy
-       FcValueEqual
-       FcValuePrint
-       FcValueSave
+       FcStrListCreate
+       FcStrListNext
+       FcStrListDone
+       FcConfigParseAndLoad
+       FcFreeTypeCharIndex
+       FcFreeTypeCharSetAndSpacing
+       FcFreeTypeCharSet
+       FcPatternGetFTFace
+       FcPatternAddFTFace
+       FcGlobalCacheCreate
+       FcGlobalCacheDestroy
+       FcGlobalCacheReadDir
+       FcGlobalCacheLoad
+       FcGlobalCacheUpdate
+       FcGlobalCacheSave
+       FcCacheRead
+       FcDirCacheWrite
+       FcDirCacheRead
+       FcCacheBankToIndexMTF
+       FcCacheFindBankDir
+       FcConfigAddConfigDir
+       FcConfigAddFontDir
+       FcConfigAddDir
+       FcConfigAddConfigFile
+       FcConfigSetCache
+       FcConfigAddBlank
+       FcConfigAddEdit
+       FcConfigSetFonts
+       FcConfigCompareValue
+       FcConfigGlobAdd
+       FcConfigAcceptFilename
+       FcConfigPatternsAdd
+       FcConfigAcceptFont
+       FcConfigModifiedTime
+       FcLangCharSetPopulate
+       FcCharSetFreeze
+       FcCharSetThawAll
+       FcNameUnparseCharSet
+       FcNameParseCharSet
+       FcCharSetFindLeafCreate
+       FcCharSetNewBank
+       FcCharSetNeededBytes
+       FcCharSetNeededBytesAlign
+       FcCharSetDistributeBytes
+       FcCharSetUnserialize
+       FcValueListPrint
+       FcLangSetPrint
+       FcOpPrint
+       FcTestPrint
+       FcExprPrint
+       FcEditPrint
+       FcSubstPrint
+       FcInitDebug
+       FcGetDefaultLang
+       FcFileIsDir
+       FcFileScanConfig
+       FcDirScanConfig
+       FcFreeTypeIsExclusiveLang
+       FcFreeTypeUcs4ToPrivate
+       FcFreeTypePrivateToUcs4
+       FcFreeTypeGetPrivateMap
+       FcFontSetNewBank
+       FcFontSetNeededBytes
+       FcFontSetNeededBytesAlign
+       FcFontSetDistributeBytes
+       FcFontSetSerialize
+       FcConfigSaveField
+       FcTestDestroy
+       FcExprCreateInteger
+       FcExprCreateDouble
+       FcExprCreateString
+       FcExprCreateMatrix
+       FcExprCreateBool
+       FcExprCreateNil
+       FcExprCreateField
+       FcExprCreateConst
+       FcExprCreateOp
+       FcExprDestroy
+       FcEditDestroy
+       FcMemReport
+       FcMemAlloc
+       FcMemFree
+       FcFreeTypeLangSet
+       FcLangCompare
+       FcCharSetForLang
+       FcLangSetPromote
+       FcNameParseLangSet
+       FcNameUnparseLangSet
+       FcLangSetNewBank
+       FcLangSetNeededBytes
+       FcLangSetNeededBytesAlign
+       FcLangSetDistributeBytes
+       FcLangSetSerialize
+       FcLangSetUnserialize
+       FcListPatternMatchAny
+       FcNameBool
+       FcObjectDistributeBytes
+       FcObjectToPtr
+       FcObjectNeededBytes
+       FcObjectNeededBytesAlign
+       FcObjectUnserialize
+       FcObjectSerialize
+       FcObjectPtrU
+       FcObjectStaticNameFini
+       FcValueCanonicalize
+       FcValueListDestroy
+       FcPatternFindElt
+       FcPatternInsertElt
+       FcPatternAddWithBinding
+       FcPatternFreeze
+       FcPatternFini
+       FcPatternAppend
+       FcPatternAddFullFname
+       FcPatternTransferFullFname
+       FcStrStaticName
+       FcStringHash
+       FcPatternNewBank
+       FcPatternNeededBytes
+       FcPatternNeededBytesAlign
+       FcPatternDistributeBytes
+       FcPatternSerialize
+       FcPatternUnserialize
+       FcMatrixFree
+       FcStrPlus
+       FcStrFree
+       FcStrBufInit
+       FcStrBufDestroy
+       FcStrBufDone
+       FcStrBufChar
+       FcStrBufString
+       FcStrBufData
+       FcStrCmpIgnoreBlanksAndCase
+       FcStrContainsIgnoreBlanksAndCase
+       FcStrContainsIgnoreCase
+       FcStrUsesHome
+       FcStrLastSlash
+       FcStrHashIgnoreCase
 LIBRARY libfontconfig-@LT_CURRENT_MINUS_AGE@.dll
 VERSION @LT_CURRENT@.@LT_REVISION@