Patrick Lam <plam@mit.edu>

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
This commit is contained in:
Patrick Lam 2006-04-07 04:42:32 +00:00
parent 3a342c5a6c
commit d6217cc6bc
7 changed files with 374 additions and 144 deletions

View File

@ -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> 2006-04-07 Patrick Lam <plam@mit.edu>
* src/fcdir.c (FcDirScanConfig): * src/fcdir.c (FcDirScanConfig):

View File

@ -143,7 +143,8 @@ AC_TYPE_PID_T
# Checks for library functions. # Checks for library functions.
AC_FUNC_VPRINTF 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 # Checks for FreeType

View File

@ -38,6 +38,13 @@
#define HAVE_GETOPT 1 #define HAVE_GETOPT 1
#endif #endif
#if defined (_WIN32)
#define STRICT
#include <windows.h>
#define sleep(x) Sleep((x) * 1000)
#undef STRICT
#endif
#ifndef HAVE_GETOPT #ifndef HAVE_GETOPT
#define HAVE_GETOPT 0 #define HAVE_GETOPT 0
#endif #endif

View File

@ -27,7 +27,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <libgen.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>

View File

@ -26,15 +26,19 @@
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <dirent.h>
#include <string.h> #include <string.h>
#include <sys/mman.h>
#include <sys/utsname.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include "fcint.h" #include "fcint.h"
#include <unistd.h> #include <unistd.h>
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
# include <sys/mman.h>
# include <sys/utsname.h>
#endif
#define ENDIAN_TEST 0x12345678 #define ENDIAN_TEST 0x12345678
#define MACHINE_SIGNATURE_SIZE (9 + 5*20 + 1) #define MACHINE_SIGNATURE_SIZE (9 + 5*20 + 1)
/* for when we don't have sysconf: */
#define FC_HARDCODED_PAGESIZE 8192
#ifndef O_BINARY #ifndef O_BINARY
#define O_BINARY 0 #define O_BINARY 0
@ -458,8 +462,17 @@ FcGlobalCacheSave (FcGlobalCache *cache,
goto bail3; goto bail3;
current_arch_start = lseek(fd, 0, SEEK_CUR); current_arch_start = lseek(fd, 0, SEEK_CUR);
#if defined (HAVE_FTRUNCATE)
if (ftruncate (fd, current_arch_start) == -1) if (ftruncate (fd, current_arch_start) == -1)
goto bail3; 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)); header = malloc (10 + strlen (current_arch_machine_name));
if (!header) if (!header)
@ -602,7 +615,11 @@ FcCacheNextOffset(off_t w)
{ {
static long pagesize = -1; static long pagesize = -1;
if (pagesize == -1) if (pagesize == -1)
#if defined (HAVE_SYSCONF)
pagesize = sysconf(_SC_PAGESIZE); pagesize = sysconf(_SC_PAGESIZE);
#else
pagesize = FC_HARDCODED_PAGESIZE;
#endif
if (w % pagesize == 0) if (w % pagesize == 0)
return w; return w;
else else
@ -1160,20 +1177,35 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config)
} }
pos = FcCacheNextOffset (lseek(fd, 0, SEEK_CUR)); pos = FcCacheNextOffset (lseek(fd, 0, SEEK_CUR));
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
current_dir_block = mmap (0, metadata.count, current_dir_block = mmap (0, metadata.count,
PROT_READ, MAP_SHARED, fd, pos); PROT_READ, MAP_SHARED, fd, pos);
lseek (fd, pos+metadata.count, SEEK_SET);
if (current_dir_block == MAP_FAILED) if (current_dir_block == MAP_FAILED)
return FcFalse; 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); FcCacheAddBankDir (metadata.bank, dir);
if (config) if (config)
FcConfigAddFontDir (config, (FcChar8 *)dir); FcConfigAddFontDir (config, (FcChar8 *)dir);
if (!FcFontSetUnserialize (&metadata, set, current_dir_block)) if (!FcFontSetUnserialize (&metadata, set, current_dir_block))
return FcFalse; goto bail;
return FcTrue; return FcTrue;
bail:
#if !(defined(HAVE_MMAP) || defined(__CYGWIN__))
free (current_dir_block);
#endif
return FcFalse;
} }
static void * static void *
@ -1183,12 +1215,24 @@ FcDirCacheProduce (FcFontSet *set, FcCache *metadata)
static unsigned int rand_state = 0; static unsigned int rand_state = 0;
int bank, needed_bytes_no_align; int bank, needed_bytes_no_align;
#if defined (HAVE_RAND_R)
if (!rand_state) if (!rand_state)
rand_state = time(0L); rand_state = time(0L);
bank = rand_r(&rand_state); bank = rand_r(&rand_state);
while (FcCacheHaveBank(bank)) while (FcCacheHaveBank(bank))
bank = rand_r(&rand_state); 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)); memset (metadata, 0, sizeof(FcCache));
FcFontSetNewBank(); FcFontSetNewBank();
@ -1336,8 +1380,17 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
close (fd_orig); close (fd_orig);
current_arch_start = lseek(fd, 0, SEEK_CUR); current_arch_start = lseek(fd, 0, SEEK_CUR);
#if defined (HAVE_FTRUNCATE)
if (ftruncate (fd, current_arch_start) == -1) if (ftruncate (fd, current_arch_start) == -1)
goto bail4; 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 */ /* allocate space for subdir names in this block */
dirs_count = 0; 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 */ /* this actually serves to pad out the cache file, if needed */
#if defined (HAVE_FTRUNCATE)
if (ftruncate (fd, current_arch_start + truncate_to) == -1) if (ftruncate (fd, current_arch_start + truncate_to) == -1)
goto bail5; 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); free (header);
close(fd); close(fd);
@ -1439,7 +1501,11 @@ FcCacheMachineSignature ()
(unsigned int)sizeof (FcCharLeaf), (unsigned int)sizeof (FcCharLeaf),
(unsigned int)sizeof (FcChar32), (unsigned int)sizeof (FcChar32),
(unsigned int)sizeof (FcCache), (unsigned int)sizeof (FcCache),
#if defined (HAVE_SYSCONF)
(unsigned int)sysconf(_SC_PAGESIZE)); (unsigned int)sysconf(_SC_PAGESIZE));
#else
(unsigned int)FC_HARDCODED_PAGESIZE);
#endif
return buf; return buf;
} }

View File

@ -47,7 +47,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <libgen.h>
#include "fcint.h" #include "fcint.h"
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
@ -1281,7 +1280,7 @@ FcFreeTypeQuery (const FcChar8 *file,
} }
file2 = FcStrCopy (file); file2 = FcStrCopy (file);
if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)file2))) if (!FcPatternAddString (pat, FC_FILE, FcStrBasename(file2)))
{ {
FcStrFree (file2); FcStrFree (file2);
goto bail1; goto bail1;

View File

@ -1,163 +1,303 @@
EXPORTS EXPORTS
FcDirCacheValid
FcDirCacheHasCurrentArch
FcDirCacheUnlink
FcBlanksCreate
FcBlanksDestroy
FcBlanksAdd
FcBlanksIsMember
FcConfigHome
FcConfigEnableHome
FcConfigFilename
FcConfigCreate
FcConfigDestroy
FcConfigSetCurrent
FcConfigGetCurrent
FcConfigUptoDate
FcConfigBuildFonts
FcConfigGetFontDirs
FcConfigNormalizeFontDir
FcConfigGetConfigDirs
FcConfigGetConfigFiles
FcConfigGetCache
FcConfigGetBlanks
FcConfigGetRescanInverval
FcConfigSetRescanInverval
FcConfigGetFonts
FcConfigAppFontAddFile
FcConfigAppFontAddDir
FcConfigAppFontClear
FcConfigSubstituteWithPat
FcConfigSubstitute
FcCharSetCreate
FcCharSetDestroy
FcCharSetAddChar
FcCharSetCopy
FcCharSetEqual
FcCharSetIntersect
FcCharSetUnion
FcCharSetSubtract
FcCharSetHasChar
FcCharSetCount
FcCharSetIntersectCount
FcCharSetSubtractCount
FcCharSetIsSubset
FcCharSetFirstPage
FcCharSetNextPage
FcValuePrint
FcPatternPrint
FcFontSetPrint
FcDebugVal
FcFontSetUnserialize
FcDefaultSubstitute
FcFileScan
FcDirScan
FcDirSave
FcFreeTypeQuery
FcFontSetCreate
FcFontSetDestroy
FcFontSetAdd
FcInitLoadConfig
FcInitLoadConfigAndFonts
FcInit
FcFini
FcGetVersion
FcInitReinitialize
FcInitBringUptoDate
FcLangSetCreate
FcLangSetDestroy
FcLangSetCopy
FcLangSetAdd
FcLangSetHasLang
FcLangSetCompare
FcLangSetContains
FcLangSetEqual
FcLangSetHash
FcObjectSetCreate
FcObjectSetAdd
FcObjectSetDestroy
FcObjectSetVaBuild
FcObjectSetBuild
FcFontSetList
FcFontList
FcAtomicCreate FcAtomicCreate
FcAtomicDeleteNew
FcAtomicDestroy
FcAtomicLock FcAtomicLock
FcAtomicNewFile FcAtomicNewFile
FcAtomicOrigFile FcAtomicOrigFile
FcAtomicReplaceOrig FcAtomicReplaceOrig
FcAtomicDeleteNew
FcAtomicUnlock FcAtomicUnlock
FcBlanksAdd FcAtomicDestroy
FcBlanksCreate FcFontSetMatch
FcBlanksDestroy
FcBlanksIsMember
FcCharSetAddChar
FcCharSetCopy
FcCharSetCount
FcCharSetCreate
FcCharSetDestroy
FcCharSetEqual
FcCharSetFirstPage
FcCharSetHasChar
FcCharSetIntersect
FcCharSetIntersectCount
FcCharSetIsSubset
FcCharSetNextPage
FcCharSetSubtract
FcCharSetSubtractCount
FcCharSetUnion
FcConfigAppFontAddDir
FcConfigAppFontAddFile
FcConfigAppFontClear
FcConfigBuildFonts
FcConfigCreate
FcConfigDestroy
FcConfigEnableHome
FcConfigFilename
FcConfigGetBlanks
FcConfigGetCache
FcConfigGetConfigDirs
FcConfigGetConfigFiles
FcConfigGetCurrent
FcConfigGetFontDirs
FcConfigGetFonts
FcConfigGetRescanInverval
FcConfigParseAndLoad
FcConfigSetCurrent
FcConfigSetRescanInverval
FcConfigSubstitute
FcConfigSubstituteWithPat
FcConfigUptoDate
FcDefaultSubstitute
FcDirCacheValid
FcDirSave
FcDirScan
FcFileScan
FcFini
FcFontList
FcFontMatch FcFontMatch
FcFontRenderPrepare FcFontRenderPrepare
FcFontSetAdd
FcFontSetCreate
FcFontSetDestroy
FcFontSetList
FcFontSetMatch
FcFontSetPrint
FcFontSetSort FcFontSetSort
FcFontSetSortDestroy
FcFontSort FcFontSort
FcFreeTypeCharIndex FcFontSetSortDestroy
FcFreeTypeCharSet
FcFreeTypeQuery
FcGetVersion
FcInit
FcInitBringUptoDate
FcInitLoadConfig
FcInitLoadConfigAndFonts
FcInitReinitialize
FcLangSetAdd
FcLangSetCompare
FcLangSetCopy
FcLangSetCreate
FcLangSetDestroy
FcLangSetEqual
FcLangSetHasLang
FcLangSetHash
FcMatrixCopy FcMatrixCopy
FcMatrixEqual FcMatrixEqual
FcMatrixMultiply FcMatrixMultiply
FcMatrixRotate FcMatrixRotate
FcMatrixScale FcMatrixScale
FcMatrixShear FcMatrixShear
FcNameConstant
FcNameGetConstant
FcNameGetObjectType
FcNameParse
FcNameRegisterConstants
FcNameRegisterObjectTypes FcNameRegisterObjectTypes
FcNameUnparse
FcNameUnregisterConstants
FcNameUnregisterObjectTypes FcNameUnregisterObjectTypes
FcObjectSetAdd FcNameGetObjectType
FcObjectSetBuild FcNameRegisterConstants
FcObjectSetCreate FcNameUnregisterConstants
FcObjectSetDestroy FcNameGetConstant
FcObjectSetVaBuild FcNameConstant
FcPatternAdd FcNameParse
FcPatternAddBool FcNameUnparse
FcPatternAddCharSet FcNameUnparseEscaped
FcPatternAddDouble
FcPatternAddFTFace
FcPatternAddInteger
FcPatternAddLangSet
FcPatternAddMatrix
FcPatternAddString
FcPatternAddWeak
FcPatternBuild
FcPatternCreate FcPatternCreate
FcPatternDel
FcPatternDestroy
FcPatternDuplicate FcPatternDuplicate
FcPatternEqual
FcPatternEqualSubset
FcPatternGet
FcPatternGetBool
FcPatternGetCharSet
FcPatternGetDouble
FcPatternGetFTFace
FcPatternGetInteger
FcPatternGetLangSet
FcPatternGetMatrix
FcPatternGetString
FcPatternHash
FcPatternPrint
FcPatternReference FcPatternReference
FcPatternVaBuild
FcStrBasename
FcStrCmp
FcStrCmp
FcStrCmpIgnoreCase
FcStrCopy
FcStrCopyFilename
FcStrDirname
FcStrListCreate
FcStrListDone
FcStrListNext
FcStrSetAdd
FcStrSetAddFilename
FcStrSetCreate
FcStrSetDel
FcStrSetDestroy
FcStrSetEqual
FcStrSetMember
FcUcs4ToUtf8
FcUtf16Len
FcUtf16ToUcs4
FcUtf8Len
FcUtf8ToUcs4
FcValueDestroy FcValueDestroy
FcValueEqual FcValueEqual
FcValuePrint
FcValueSave FcValueSave
FcPatternDestroy
FcPatternEqual
FcPatternEqualSubset
FcPatternHash
FcPatternAdd
FcPatternAddWeak
FcPatternGet
FcPatternDel
FcPatternRemove
FcPatternAddInteger
FcPatternAddDouble
FcPatternAddString
FcPatternAddMatrix
FcPatternAddCharSet
FcPatternAddBool
FcPatternAddLangSet
FcPatternGetInteger
FcPatternGetDouble
FcPatternGetString
FcPatternGetMatrix
FcPatternGetCharSet
FcPatternGetBool
FcPatternGetLangSet
FcPatternVaBuild
FcPatternBuild
FcStrCopy
FcStrCopyFilename
FcStrDowncase
FcStrCmpIgnoreCase
FcStrCmp
FcStrStrIgnoreCase
FcStrStr
FcUtf8ToUcs4
FcUtf8Len
FcUcs4ToUtf8
FcUtf16ToUcs4
FcUtf16Len
FcStrDirname
FcStrBasename
FcStrSetCreate
FcStrSetMember
FcStrSetEqual
FcStrSetAdd
FcStrSetAddFilename
FcStrSetDel
FcStrSetDestroy
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 LIBRARY libfontconfig-@LT_CURRENT_MINUS_AGE@.dll
VERSION @LT_CURRENT@.@LT_REVISION@ VERSION @LT_CURRENT@.@LT_REVISION@