Fix build and warnings on win32

This commit is contained in:
Behdad Esfahbod 2013-01-02 17:35:56 -06:00
parent 5c0a4f2726
commit ec8a40d238
10 changed files with 67 additions and 42 deletions

View File

@ -148,6 +148,7 @@ libfontconfig_la_SOURCES = \
fcserialize.c \
fcstat.c \
fcstr.c \
fcwindows.h \
fcxml.c \
ftglue.h \
ftglue.c

View File

@ -3,9 +3,7 @@
*
* Copyright © 2007 Chris Wilson
* Copyright © 2009,2010 Red Hat, Inc.
* Copyright © 2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
* Copyright © 2011,2012,2013 Google, Inc.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
@ -48,8 +46,7 @@
#elif !defined(FC_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "fcwindows.h"
/* mingw32 does not have MemoryBarrier.
* MemoryBarrier may be defined as a macro or a function.
@ -63,7 +60,7 @@ static inline void HBMemoryBarrier (void) {
}
#endif
typedef int fc_atomic_int_t;
typedef LONG fc_atomic_int_t;
#define fc_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V))
#define fc_atomic_ptr_get(P) (HBMemoryBarrier (), (void *) *(P))

View File

@ -77,7 +77,7 @@ FcCacheIsMmapSafe (int fd)
status = use ? MMAP_USE : MMAP_DONT_USE;
else
status = MMAP_CHECK_FS;
fc_atomic_ptr_cmpexch (&static_status, NULL, (void *) status);
(void) fc_atomic_ptr_cmpexch (&static_status, NULL, (void *) status);
}
if (status == MMAP_CHECK_FS)

View File

@ -28,12 +28,6 @@
#include <dirent.h>
#include <sys/types.h>
#if defined (_WIN32) && (defined (PIC) || defined (DLL_EXPORT))
#define STRICT
#include <windows.h>
#undef STRICT
#endif
#if defined (_WIN32) && !defined (R_OK)
#define R_OK 4
#endif
@ -270,7 +264,7 @@ FcConfigDestroy (FcConfig *config)
if (FcRefDec (&config->ref) != 1)
return;
fc_atomic_ptr_cmpexch (&_fcConfig, config, NULL);
(void) fc_atomic_ptr_cmpexch (&_fcConfig, config, NULL);
FcStrSetDestroy (config->configDirs);
FcStrSetDestroy (config->fontDirs);
@ -1737,14 +1731,15 @@ FcConfigSubstitute (FcConfig *config,
#if defined (_WIN32)
# define WIN32_LEAN_AND_MEAN
# define WIN32_EXTRA_LEAN
# include <windows.h>
static FcChar8 fontconfig_path[1000] = ""; /* MT-dontcare */
# if (defined (PIC) || defined (DLL_EXPORT))
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved);
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,

View File

@ -53,12 +53,7 @@
#endif
#ifdef _WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500
# endif
# define WIN32_LEAN_AND_MEAN
# define STRICT
# include <windows.h>
# include "fcwindows.h"
typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT);
typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;

View File

@ -3,7 +3,7 @@
*
* Copyright © 2007 Chris Wilson
* Copyright © 2009,2010 Red Hat, Inc.
* Copyright © 2011,2012 Google, Inc.
* Copyright © 2011,2012,2013 Google, Inc.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
@ -48,8 +48,7 @@
#elif !defined(FC_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "fcwindows.h"
typedef CRITICAL_SECTION fc_mutex_impl_t;
#define FC_MUTEX_IMPL_INIT { NULL, 0, 0, NULL, NULL, 0 }
#define fc_mutex_impl_init(M) InitializeCriticalSection (M)

View File

@ -44,9 +44,6 @@
#endif
#ifdef _WIN32
#include <windows.h>
#ifdef __GNUC__
typedef long long INT64;
#define EPOCH_OFFSET 11644473600ll

View File

@ -29,9 +29,6 @@
#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
/* Objects MT-safe for readonly access. */

44
src/fcwindows.h Normal file
View File

@ -0,0 +1,44 @@
/*
* fontconfig/src/fcwindows.h
*
* Copyright © 2013 Google, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the author(s) not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. The authors make no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Google Author(s): Behdad Esfahbod
*/
#ifndef _FCWINDOWS_H_
#define _FCWINDOWS_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef _WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500
# endif
# define WIN32_LEAN_AND_MEAN
# define WIN32_EXTRA_LEAN
# define STRICT
# include <windows.h>
#endif
#endif /* _FCWINDOWS_H_ */

View File

@ -1419,7 +1419,7 @@ static void
FcParseRange (FcConfigParse *parse)
{
FcVStack *vstack;
FcRange r;
FcRange r = {0, 0};
FcChar32 n;
int count = 1;
@ -1961,7 +1961,7 @@ FcParseDir (FcConfigParse *parse)
#ifdef _WIN32
if (strcmp ((const char *) data, "CUSTOMFONTDIR") == 0)
{
char *p;
FcChar8 *p;
data = buffer;
if (!GetModuleFileName (NULL, (LPCH) buffer, sizeof (buffer) - 20))
{
@ -1976,11 +1976,11 @@ FcParseDir (FcConfigParse *parse)
*/
p = _mbsrchr (data, '\\');
if (p) *p = '\0';
strcat (data, "\\fonts");
strcat ((char *) data, "\\fonts");
}
else if (strcmp ((const char *) data, "APPSHAREFONTDIR") == 0)
{
char *p;
FcChar8 *p;
data = buffer;
if (!GetModuleFileName (NULL, (LPCH) buffer, sizeof (buffer) - 20))
{
@ -1989,7 +1989,7 @@ FcParseDir (FcConfigParse *parse)
}
p = _mbsrchr (data, '\\');
if (p) *p = '\0';
strcat (data, "\\..\\share\\fonts");
strcat ((char *) data, "\\..\\share\\fonts");
}
else if (strcmp ((const char *) data, "WINDOWSFONTDIR") == 0)
{
@ -2002,8 +2002,8 @@ FcParseDir (FcConfigParse *parse)
goto bail;
}
if (data [strlen ((const char *) data) - 1] != '\\')
strcat (data, "\\");
strcat (data, "fonts");
strcat ((char *) data, "\\");
strcat ((char *) data, "fonts");
}
#endif
if (strlen ((char *) data) == 0)
@ -2072,8 +2072,8 @@ FcParseCacheDir (FcConfigParse *parse)
goto bail;
}
if (data [strlen ((const char *) data) - 1] != '\\')
strcat (data, "\\");
strcat (data, "fontconfig\\cache");
strcat ((char *) data, "\\");
strcat ((char *) data, "fontconfig\\cache");
}
else if (strcmp ((const char *) data, "LOCAL_APPDATA_FONTCONFIG_CACHE") == 0)
{