aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fccache.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-05-29 08:45:04 +0200
committermarha <marha@users.sourceforge.net>2012-05-29 08:45:04 +0200
commitce592e25d6303a8f4a8aa0e2918e0f72a35bf175 (patch)
tree845b108f004259a6e4f72ade3dd5e0521ab3952b /fontconfig/src/fccache.c
parenteef864d36de97903007f04fad9fa43afe297745b (diff)
downloadvcxsrv-ce592e25d6303a8f4a8aa0e2918e0f72a35bf175.tar.gz
vcxsrv-ce592e25d6303a8f4a8aa0e2918e0f72a35bf175.tar.bz2
vcxsrv-ce592e25d6303a8f4a8aa0e2918e0f72a35bf175.zip
fontconfig libX11 mesa pixman xserver git update 29 May 2012
Diffstat (limited to 'fontconfig/src/fccache.c')
-rw-r--r--fontconfig/src/fccache.c152
1 files changed, 8 insertions, 144 deletions
diff --git a/fontconfig/src/fccache.c b/fontconfig/src/fccache.c
index 882dd3eb5..9e582b911 100644
--- a/fontconfig/src/fccache.c
+++ b/fontconfig/src/fccache.c
@@ -37,21 +37,6 @@
# include <unistd.h>
# include <sys/mman.h>
#endif
-#ifdef HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_STATFS_H
-#include <sys/statfs.h>
-#endif
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
#ifndef O_BINARY
#define O_BINARY 0
@@ -71,98 +56,9 @@ static void MD5Transform(FcChar32 buf[4], FcChar32 in[16]);
#define CACHEBASE_LEN (1 + 32 + 1 + sizeof (FC_ARCHITECTURE) + sizeof (FC_CACHE_SUFFIX))
-#ifdef _WIN32
-
-#include <windows.h>
-
-#ifdef __GNUC__
-typedef long long INT64;
-#define EPOCH_OFFSET 11644473600ll
-#else
-#define EPOCH_OFFSET 11644473600i64
-typedef __int64 INT64;
-#endif
-
-/* Workaround for problems in the stat() in the Microsoft C library:
- *
- * 1) stat() uses FindFirstFile() to get the file
- * attributes. Unfortunately this API doesn't return correct values
- * for modification time of a directory until some time after a file
- * or subdirectory has been added to the directory. (This causes
- * run-test.sh to fail, for instance.) GetFileAttributesEx() is
- * better, it returns the updated timestamp right away.
- *
- * 2) stat() does some strange things related to backward
- * compatibility with the local time timestamps on FAT volumes and
- * daylight saving time. This causes problems after the switches
- * to/from daylight saving time. See
- * http://bugzilla.gnome.org/show_bug.cgi?id=154968 , especially
- * comment #30, and http://www.codeproject.com/datetime/dstbugs.asp .
- * We don't need any of that, FAT and Win9x are as good as dead. So
- * just use the UTC timestamps from NTFS, converted to the Unix epoch.
- */
-
-int
-FcStat (const FcChar8 *file, struct stat *statb)
-{
- WIN32_FILE_ATTRIBUTE_DATA wfad;
- char full_path_name[MAX_PATH];
- char *basename;
- DWORD rc;
-
- if (!GetFileAttributesEx (file, GetFileExInfoStandard, &wfad))
- return -1;
-
- statb->st_dev = 0;
-
- /* Calculate a pseudo inode number as a hash of the full path name.
- * Call GetLongPathName() to get the spelling of the path name as it
- * is on disk.
- */
- rc = GetFullPathName (file, sizeof (full_path_name), full_path_name, &basename);
- if (rc == 0 || rc > sizeof (full_path_name))
- return -1;
-
- rc = GetLongPathName (full_path_name, full_path_name, sizeof (full_path_name));
- statb->st_ino = FcStringHash (full_path_name);
-
- statb->st_mode = _S_IREAD | _S_IWRITE;
- statb->st_mode |= (statb->st_mode >> 3) | (statb->st_mode >> 6);
-
- if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- statb->st_mode |= _S_IFDIR;
- else
- statb->st_mode |= _S_IFREG;
-
- statb->st_nlink = 1;
- statb->st_uid = statb->st_gid = 0;
- statb->st_rdev = 0;
-
- if (wfad.nFileSizeHigh > 0)
- return -1;
- statb->st_size = wfad.nFileSizeLow;
-
- statb->st_atime = (*(INT64 *)&wfad.ftLastAccessTime)/10000000 - EPOCH_OFFSET;
- statb->st_mtime = (*(INT64 *)&wfad.ftLastWriteTime)/10000000 - EPOCH_OFFSET;
- statb->st_ctime = statb->st_mtime;
-
- return 0;
-}
-
-#else
-
-int
-FcStat (const FcChar8 *file, struct stat *statb)
-{
- return stat ((char *) file, statb);
-}
-
-#endif
-
static FcBool
FcCacheIsMmapSafe (int fd)
{
- FcBool retval = FcTrue;
static FcBool is_initialized = FcFalse;
static FcBool is_env_available = FcFalse;
static FcBool use_mmap = FcFalse;
@@ -181,40 +77,8 @@ FcCacheIsMmapSafe (int fd)
}
if (is_env_available)
return use_mmap;
-#if defined(HAVE_FSTATVFS) && (defined(HAVE_STRUCT_STATVFS_F_BASETYPE) || defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME))
- struct statvfs buf;
-
- if (fstatvfs (fd, &buf) == 0)
- {
- const char *p;
-#if defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
- p = buf.f_basetype;
-#elif defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)
- p = buf.f_fstypename;
-#endif
-
- if (strcmp (p, "nfs") == 0)
- retval = FcFalse;
- }
-#elif defined(HAVE_FSTATFS) && (defined(HAVE_STRUCT_STATFS_F_FLAGS) || defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(__linux__))
- struct statfs buf;
-
- if (fstatfs (fd, &buf) == 0)
- {
-# if defined(HAVE_STRUCT_STATFS_F_FLAGS) && defined(MNT_LOCAL)
- if (!(buf.f_flags & MNT_LOCAL))
-# elif defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
- if (strcmp (buf.f_fstypename, "nfs") == 0)
-# elif defined(__linux__)
- if (buf.f_type == 0x6969) /* nfs */
-# else
-# error "BUG: No way to figure out with fstatfs()"
-# endif
- retval = FcFalse;
- }
-#endif
- return retval;
+ return FcIsFsMmapSafe (fd);
}
static const char bin2hex[] = { '0', '1', '2', '3',
@@ -317,7 +181,7 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
struct stat file_stat, dir_stat;
FcBool ret = FcFalse;
- if (FcStat (dir, &dir_stat) < 0)
+ if (FcStatChecksum (dir, &dir_stat) < 0)
return FcFalse;
FcDirCacheBasename (dir, cache_base);
@@ -644,14 +508,14 @@ FcCacheTimeValid (FcCache *cache, struct stat *dir_stat)
if (!dir_stat)
{
- if (FcStat (FcCacheDir (cache), &dir_static) < 0)
+ if (FcStatChecksum (FcCacheDir (cache), &dir_static) < 0)
return FcFalse;
dir_stat = &dir_static;
}
if (FcDebug () & FC_DBG_CACHE)
- printf ("FcCacheTimeValid dir \"%s\" cache time %d dir time %d\n",
- FcCacheDir (cache), cache->mtime, (int) dir_stat->st_mtime);
- return cache->mtime == (int) dir_stat->st_mtime;
+ printf ("FcCacheTimeValid dir \"%s\" cache checksum %d dir checksum %d\n",
+ FcCacheDir (cache), cache->checksum, (int) dir_stat->st_mtime);
+ return cache->checksum == (int) dir_stat->st_mtime;
}
/*
@@ -815,7 +679,7 @@ FcDirCacheValidateHelper (int fd, struct stat *fd_stat, struct stat *dir_stat, v
ret = FcFalse;
else if (fd_stat->st_size != c.size)
ret = FcFalse;
- else if (c.mtime != (int) dir_stat->st_mtime)
+ else if (c.checksum != (int) dir_stat->st_mtime)
ret = FcFalse;
return ret;
}
@@ -890,7 +754,7 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcSt
cache->magic = FC_CACHE_MAGIC_ALLOC;
cache->version = FC_CACHE_CONTENT_VERSION;
cache->size = serialize->size;
- cache->mtime = (int) dir_stat->st_mtime;
+ cache->checksum = (int) dir_stat->st_mtime;
/*
* Serialize directory name