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>
* src/fcdir.c (FcDirScanConfig):

View 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

View File

@ -38,6 +38,13 @@
#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

View 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>

View File

@ -26,15 +26,19 @@
#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;
}

View 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;

View File

@ -1,163 +1,303 @@
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
FcAtomicDeleteNew
FcAtomicDestroy
FcAtomicLock
FcAtomicNewFile
FcAtomicOrigFile
FcAtomicReplaceOrig
FcAtomicDeleteNew
FcAtomicUnlock
FcBlanksAdd
FcBlanksCreate
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
FcAtomicDestroy
FcFontSetMatch
FcFontMatch
FcFontRenderPrepare
FcFontSetAdd
FcFontSetCreate
FcFontSetDestroy
FcFontSetList
FcFontSetMatch
FcFontSetPrint
FcFontSetSort
FcFontSetSortDestroy
FcFontSort
FcFreeTypeCharIndex
FcFreeTypeCharSet
FcFreeTypeQuery
FcGetVersion
FcInit
FcInitBringUptoDate
FcInitLoadConfig
FcInitLoadConfigAndFonts
FcInitReinitialize
FcLangSetAdd
FcLangSetCompare
FcLangSetCopy
FcLangSetCreate
FcLangSetDestroy
FcLangSetEqual
FcLangSetHasLang
FcLangSetHash
FcFontSetSortDestroy
FcMatrixCopy
FcMatrixEqual
FcMatrixMultiply
FcMatrixRotate
FcMatrixScale
FcMatrixShear
FcNameConstant
FcNameGetConstant
FcNameGetObjectType
FcNameParse
FcNameRegisterConstants
FcNameRegisterObjectTypes
FcNameUnparse
FcNameUnregisterConstants
FcNameUnregisterObjectTypes
FcObjectSetAdd
FcObjectSetBuild
FcObjectSetCreate
FcObjectSetDestroy
FcObjectSetVaBuild
FcPatternAdd
FcPatternAddBool
FcPatternAddCharSet
FcPatternAddDouble
FcPatternAddFTFace
FcPatternAddInteger
FcPatternAddLangSet
FcPatternAddMatrix
FcPatternAddString
FcPatternAddWeak
FcPatternBuild
FcNameGetObjectType
FcNameRegisterConstants
FcNameUnregisterConstants
FcNameGetConstant
FcNameConstant
FcNameParse
FcNameUnparse
FcNameUnparseEscaped
FcPatternCreate
FcPatternDel
FcPatternDestroy
FcPatternDuplicate
FcPatternEqual
FcPatternEqualSubset
FcPatternGet
FcPatternGetBool
FcPatternGetCharSet
FcPatternGetDouble
FcPatternGetFTFace
FcPatternGetInteger
FcPatternGetLangSet
FcPatternGetMatrix
FcPatternGetString
FcPatternHash
FcPatternPrint
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
FcValueEqual
FcValuePrint
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
VERSION @LT_CURRENT@.@LT_REVISION@