Merge branch 'nmake-improvements' into 'master'

Improve NMake Makefiles (later Visual Studio vesions, ARM64 support, building bundled GLib, etc)

See merge request pkg-config/pkg-config!21
This commit is contained in:
Chun-wei Fan 2023-09-19 08:49:52 +00:00
commit b79fcfc48e
22 changed files with 1989 additions and 125 deletions

View file

@ -6,7 +6,7 @@ endif
# Normally we'd want glib to be part of DIST_SUBDIRS unconditionally,
# but distclean gets broken unless we always run glib's configure
SUBDIRS = $(GLIB_SUBDIR) . check
SUBDIRS = $(GLIB_SUBDIR) . check nmake
DIST_SUBDIRS = $(SUBDIRS)
# Escape paths properly on windows
@ -45,11 +45,7 @@ m4dir = $(datadir)/aclocal
m4_DATA = pkg.m4
dist_doc_DATA = pkg-config-guide.html
dist_man_MANS = pkg-config.1
EXTRA_DIST = \
README.win32 \
detectenv-msvc.mak \
Makefile.vc \
config.h.win32
EXTRA_DIST = README.win32
# gcov test coverage
gcov:

View file

@ -1,96 +0,0 @@
# Note: This does assume an existing GLib installation!
# Visual Studio builds of GLib does not need an existing pkg-config
# installation, so build GLib first before using this.
# Change these if necessary. If building from GLib's included
# Visual Studio projects, this should be able to locate the GLib build
# out-of-the-box if they were not moved. GLib's headers will be found
# in $(GLIB_PREFIX)\include\glib-2.0 and $(GLIB_PREFIX)\lib\glib-2.0\include
# and its import library will be found in $(GLIB_PREFIX)\lib.
GLIB_PREFIX = ..\vs$(VSVER)\$(PLAT)
# The items below this line should not be changed, unless one is maintaining
# the NMake Makefiles.
!include detectenv-msvc.mak
!if "$(VALID_CFGSET)" == "TRUE"
CFLAGS = $(CFLAGS_ADD) /W3 /Zi /FImsvc_recommended_pragmas.h /I. \
/I$(GLIB_PREFIX)\include\glib-2.0 \
/I$(GLIB_PREFIX)\lib\glib-2.0\include
# PKG_CONFIG_SYSTEM_INCLUDE_PATH and PKG_CONFIG_SYSTEM_LIBRARY_PATH only
# work for GCC builds for now, so just set this to nothing for now
pkg_config_CFLAGS = \
$(CFLAGS) \
/DHAVE_CONFIG_H \
/DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"\"" \
/DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"\""
LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(GLIB_PREFIX)\lib /DEBUG
NULL=
!if "$(CFG)" == "debug"
LDFLAGS = $(LDFLAGS_BASE)
!else
LDFLAGS = $(LDFLAGS_BASE) /opt:ref /LTCG
!endif
!include Makefile.sources
# Convert the source (*.c) listing to object (.obj) listing in
# another NMake Makefile module, include it, and clean it up.
!if [echo pkg_config_OBJS = \> objs.mak]
!endif
!if [for %c in ($(pkg_config_SOURCES)) do @if "%~xc" == ".c" echo. ^$(CFG)\^$(PLAT)\pkg-config\%~nc.obj \>> objs.mak]
!endif
!if [echo. ^$(NULL)>> objs.mak]
!endif
!include objs.mak
!if [del /f /q objs.mak]
!endif
pkg_config_LIBS = glib-2.0.lib
{}.c{$(CFG)\$(PLAT)\pkg-config\}.obj::
$(CC) $(pkg_config_CFLAGS) /Fo$(CFG)\$(PLAT)\pkg-config\ /c @<<
$<
<<
all: $(CFG)\$(PLAT)\pkg-config.exe
$(CFG)\$(PLAT)\pkg-config.exe: $(CFG)\$(PLAT)\pkg-config config.h $(pkg_config_OBJS)
link $(LDFLAGS) $(pkg_config_LIBS) -out:$@ @<<
$(pkg_config_OBJS)
<<
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
$(CFG)\$(PLAT)\pkg-config:
@-mkdir $@
config.h: config.h.win32
@-copy $@.win32 $@
clean:
@-del /f /q $(CFG)\$(PLAT)\*.pdb
@-del /f /q $(CFG)\$(PLAT)\*.exe.manifest
@-del /f /q $(CFG)\$(PLAT)\*.exe
@-del /f /q $(CFG)\$(PLAT)\*.ilk
@-del /f /q $(CFG)\$(PLAT)\pkg-config\*.obj
@-rmdir /s /q $(CFG)\$(PLAT)
@-del vc$(VSVER)0.pdb
@-del config.h
!else
all:
@echo You need to specify a valid configuration, via
@echo CFG=release or CFG=debug
!endif

View file

@ -27,20 +27,29 @@ arguments that work with MSVC. This means -Lfoo will be converted to
/libpath:foo, and -lfoo will be converted to foo.lib.
Building pkg-config is now supported on Visual Studio/MSVC as well. To
build it, you will need to have a glib installation. Note that MSVC
builds of glib does not have a build-time dependency on pkg-config,
unlike the normal autotools builds. The headers and libs either need to
be found in your default %INCLUDE% and %LIB% respectively, or they need
to be found in $(GLIB_PREFIX)\include and $(GLIB_PREFIX)\lib respectively;
please see Makefile.vc for adjusting $(GLIB_PREFIX) to suit your needs.
To build pkg-config with MSVC, run in a Visual Studio command prompt:
build it, you can choose to use an existing glib installation, or build
pkg-config with the copy of GLib that is bundled with the pkg-config
sources, by using `HAVE_GLIB=1` in your NMake command line to use an
existing installation of GLib. Building with the bundled GLib will
require an existing installation of gettext-runtime or proxy-libintl.
Note that MSVC builds of glib does not have a build-time dependency on
pkg-config, unlike the normal autotools builds. The headers and libs
either need to be found in your default %INCLUDE% and %LIB% respectively,
or they need to be found in $(GLIB_PREFIX)\include and $(GLIB_PREFIX)\lib
respectively; please see Makefile.vc for adjusting $(GLIB_PREFIX) to suit
your needs. To build pkg-config with MSVC, run in a Visual Studio command
prompt from the "nmake" subdirectory:
"nmake /f Makefile.vc CFG=release" (release builds) -or-
"nmake /f Makefile.vc CFG=debug" (debug builds)
"nmake /f Makefile.vc CFG=release" [HAVE_GLIB=1] (release builds) -or-
"nmake /f Makefile.vc CFG=debug" [HAVE_GLIB=1] (debug builds)
The resulting pkg-config.exe will be found in [release|debug]\[win32|x64];
a 'clean' target is supported to clean up the build. MSVC 2008
through 2015 is supported; older versions may work as well but is not
tested. Note that building with the glib bundled with this source
distribution is not currently supported-the glib DLL and all of its
dependent DLLs are required at runtime.
The resulting pkg-config.exe will be found in
nmake\vsXX\[release|debug]\[win32|x64|arm64], where vsXX stands for the
short Visual Studio version, which is 9 for 2008, 10 for 2010, 14 for 2015
and so on; a 'clean' target is supported to clean up the build. MSVC 2008
through 2022 is supported, for the x86, x86_64 (x64) and aarch64 (ARM64)
architectures; older versions may work as well but is not tested. The
GLIib DLL and all of its dependent DLLs are required at runtime if using
an existing installation, if using the GLib that is bundled with
pkg-config; if using the bundled GLib, the built pkg-config-glib.dll is
required along with the gettext-runtime or proxy-libintl DLL.

View file

@ -258,6 +258,7 @@ Makefile
pkg.m4
check/Makefile
check/config.sh
config.h.win32
nmake/Makefile
nmake/config.h.win32
])
AC_OUTPUT

View file

@ -19,6 +19,7 @@ EXTRA_DIST += \
acglib.m4 \
README.in \
glib.mk \
config.h.win32 \
$(NULL)

957
glib/config.h.win32 Normal file
View file

@ -0,0 +1,957 @@
/* config.h.win32.in Merged from two versions generated by configure for gcc and MSVC. */
/* config.h. Generated by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* The normal alignment of `guint32', in bytes. */
#define ALIGNOF_GUINT32 4
/* The normal alignment of `guint64', in bytes. */
#define ALIGNOF_GUINT64 8
/* The normal alignment of `unsigned long', in bytes. */
#define ALIGNOF_UNSIGNED_LONG 4
/* poll doesn't work on devices */
#define BROKEN_POLL 1
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
/* #undef CRAY_STACKSEG_END */
/* Define to 1 if using `alloca.c'. */
/* #undef C_ALLOCA */
/* Whether to disable memory pools */
/* #undef DISABLE_MEM_POOLS */
/* Whether to enable GC friendliness by default */
/* #undef ENABLE_GC_FRIENDLY_DEFAULT */
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* Define the gettext package to be used */
#define GETTEXT_PACKAGE "glib20"
/* Define to the GLIB binary age */
#define GLIB_BINARY_AGE 3802
/* Define to the GLIB interface age */
#define GLIB_INTERFACE_AGE 2
/* Define the location where the catalogs will be installed */
#define GLIB_LOCALE_DIR "NONE/share/locale"
/* Define to the GLIB major version */
#define GLIB_MAJOR_VERSION 2
/* Define to the GLIB micro version */
#define GLIB_MICRO_VERSION 2
/* Define to the GLIB minor version */
#define GLIB_MINOR_VERSION 38
/* Have inline keyword */
#if !defined (_MSC_VER) || (_MSC_VER >= 1900)
#define G_HAVE_INLINE 1
#else /* _MSC_VER */
/* #undef G_HAVE_INLINE */
#endif /* _MSC_VER */
/* Have __inline keyword */
#define G_HAVE___INLINE 1
/* Have __inline__ keyword */
#if !defined(_MSC_VER) && !defined(__DMC__)
#define G_HAVE___INLINE__ 1
#else /* _MSC_VER or __DMC__ */
/* #undef G_HAVE___INLINE__ */
#endif /* _MSC_VER or __DMC__ */
/* A 'va_copy' style function */
#if !defined (_MSC_VER) || (_MSC_VER >= 1900)
#define G_VA_COPY va_copy
#else /* _MSC_VER */
/* #undef G_VA_COPY */
#endif /* _MSC_VER */
/* 'va_lists' cannot be copies as values */
/* #undef G_VA_COPY_AS_ARRAY */
/* Define to 1 if you have `alloca', as a function or macro. */
#define HAVE_ALLOCA 1
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
/* #undef HAVE_ALLOCA_H */
/* Define to 1 if you have the `atexit' function. */
#define HAVE_ATEXIT 1
/* Define to 1 if you have the <attr/xattr.h> header file. */
/* #undef HAVE_ATTR_XATTR_H */
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#define HAVE_BIND_TEXTDOMAIN_CODESET 1
/* Define if you have a version of the snprintf function with semantics as
specified by the ISO C99 standard. */
/* #undef HAVE_C99_SNPRINTF */
/* Define if you have a version of the vsnprintf function with semantics as
specified by the ISO C99 standard. */
/* #undef HAVE_C99_VSNPRINTF */
/* define to 1 if Carbon is available */
/* #undef HAVE_CARBON */
/* Define to 1 if you have the `chown' function. */
/* #undef HAVE_CHOWN */
/* Define to 1 if you have the `clock_gettime' function. */
/* #undef HAVE_CLOCK_GETTIME */
/* define to 1 if Cocoa is available */
/* #undef HAVE_COCOA */
/* Have nl_langinfo (CODESET) */
/* #undef HAVE_CODESET */
/* Define to 1 if you have the <crt_externs.h> header file. */
/* #undef HAVE_CRT_EXTERNS_H */
/* Define if dbus-1 is available */
/* #undef HAVE_DBUS1 */
/* Define to 1 if you have the `dcgettext' function. */
#define HAVE_DCGETTEXT 1
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#ifndef _MSC_VER
#define HAVE_DIRENT_H 1
#else
/* #undef HAVE_DIRENT_H */
#endif
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */
/* define for working do while(0) macros */
#define HAVE_DOWHILE_MACROS 1
/* Define to 1 if using dtrace probes. */
/* #undef HAVE_DTRACE */
/* Define to 1 if you have the `endmntent' function. */
/* #undef HAVE_ENDMNTENT */
/* Define to 1 if you have the `endservent' function. */
/* #undef HAVE_ENDSERVENT */
/* we have the eventfd(2) system call */
/* #undef HAVE_EVENTFD */
/* Define to 1 if you have the `fallocate' function. */
/* #undef HAVE_FALLOCATE */
/* Define if we have FAM */
/* #undef HAVE_FAM */
/* Define to 1 if you have the <fam.h> header file. */
/* #undef HAVE_FAM_H */
/* Define if we have FAMNoExists in fam */
/* #undef HAVE_FAM_NO_EXISTS */
/* Define to 1 if you have the `fchmod' function. */
/* #undef HAVE_FCHMOD */
/* Define to 1 if you have the `fchown' function. */
/* #undef HAVE_FCHOWN */
/* Define to 1 if you have the `fdwalk' function. */
/* #undef HAVE_FDWALK */
/* Define to 1 if you have the <float.h> header file. */
#define HAVE_FLOAT_H 1
/* Define to 1 if you have the <fstab.h> header file. */
/* #undef HAVE_FSTAB_H */
/* Define to 1 if you have the `fsync' function. */
/* #undef HAVE_FSYNC */
/* we have the futex(2) system call */
/* #undef HAVE_FUTEX */
/* Define to 1 if you have the `getcwd' function. */
#define HAVE_GETCWD 1
/* Define to 1 if you have the `getc_unlocked' function. */
/* #undef HAVE_GETC_UNLOCKED */
/* Define to 1 if you have the `getfsstat' function. */
/* #undef HAVE_GETFSSTAT */
/* Define to 1 if you have the `getgrgid' function. */
/* #undef HAVE_GETGRGID */
/* Define to 1 if you have the `getmntent_r' function. */
/* #undef HAVE_GETMNTENT_R */
/* Define to 1 if you have the `getprotobyname_r' function. */
/* #undef HAVE_GETPROTOBYNAME_R */
/* Define to 1 if you have the `getpwuid' function. */
/* #undef HAVE_GETPWUID */
/* Define to 1 if you have the `getresuid' function. */
/* #undef HAVE_GETRESUID */
/* Define if the GNU gettext() function is already present or preinstalled. */
#define HAVE_GETTEXT 1
/* Define to 1 if you have the `getvfsstat' function. */
/* #undef HAVE_GETVFSSTAT */
/* Define to 1 if you have the `gmtime_r' function. */
/* #undef HAVE_GMTIME_R */
/* define to use system printf */
/* #undef HAVE_GOOD_PRINTF */
/* Define to 1 if you have the <grp.h> header file. */
/* #undef HAVE_GRP_H */
/* Define to 1 if you have the `hasmntopt' function. */
/* #undef HAVE_HASMNTOPT */
/* Define to 1 if you have the `if_indextoname' function. */
/* This is available on Windows, but the catch is that this will require */
/* Windows Vista/Server 2008, so disabled for now-please see */
/* http://msdn.microsoft.com/en-us/library/windows/desktop/bb408408%28v=vs.85%29.aspx */
/* #undef HAVE_IF_INDEXTONAME */
/* Define to 1 if you have the `if_nametoindex' function. */
/* This is available on Windows, but the catch is that this will require */
/* Windows Vista/Server 2008, so disabled for now-please see */
/* http://msdn.microsoft.com/en-us/library/windows/desktop/bb408409%28v=vs.85%29.aspx */
/* A workaround for Windows XP is under review in Bug 668071 */
/* #undef HAVE_IF_NAMETOINDEX */
/* Define to 1 if you have the `inotify_init1' function. */
/* #undef HAVE_INOTIFY_INIT1 */
/* define to support printing 64-bit integers with format I64 */
#define HAVE_INT64_AND_I64 1
/* Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>. */
#ifndef _MSC_VER
#define HAVE_INTMAX_T 1
#else /* _MSC_VER */
#if (_MSC_VER >= 1600)
#define HAVE_INTMAX_T 1
#endif
/* #undef HAVE_INTMAX_T */
#endif /* _MSC_VER */
/* Define to 1 if you have the <inttypes.h> header file. */
#if !defined (_MSC_VER) || (_MSC_VER >= 1800)
#define HAVE_INTTYPES_H 1
#else /* _MSC_VER */
/* #undef HAVE_INTTYPES_H */
#endif /* _MSC_VER */
/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, and
declares uintmax_t. */
#if !defined (_MSC_VER) || (_MSC_VER >= 1800)
#define HAVE_INTTYPES_H_WITH_UINTMAX 1
#else /* _MSC_VER */
/* #undef HAVE_INTTYPES_H_WITH_UINTMAX */
#endif /* _MSC_VER */
/* Define if we have struct ip_mreqn */
/* #undef HAVE_IP_MREQN */
/* Define to 1 if you have the `issetugid' function. */
/* #undef HAVE_ISSETUGID */
/* Define to 1 if you have the `kevent' function. */
/* #undef HAVE_KEVENT */
/* Define to 1 if you have the `kqueue' function. */
/* #undef HAVE_KQUEUE */
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
/* #undef HAVE_LANGINFO_CODESET */
/* Have nl_langinfo (_NL_CTYPE_OUTDIGITn_MB) */
/* #undef HAVE_LANGINFO_OUTDIGIT */
/* Have nl_langinfo (PM_STR) */
/* #undef HAVE_LANGINFO_TIME */
/* Define to 1 if you have the `lchmod' function. */
/* #undef HAVE_LCHMOD */
/* Define to 1 if you have the `lchown' function. */
/* #undef HAVE_LCHOWN */
/* Define if your <locale.h> file defines LC_MESSAGES. */
/* #undef HAVE_LC_MESSAGES */
/* Define if you have the __libc_enable_secure variable (GNU libc, eglibc) */
/* #undef HAVE_LIBC_ENABLE_SECURE */
/* Define if libelf is available */
/* #undef HAVE_LIBELF */
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define to 1 if you have the `link' function. */
/* #undef HAVE_LINK */
/* Define to 1 if you have the <linux/magic.h> header file. */
/* #undef HAVE_LINUX_MAGIC_H */
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define to 1 if you have the `localtime_r' function. */
/* #undef HAVE_LOCALTIME_R */
/* Define if you have the 'long double' type. */
#define HAVE_LONG_DOUBLE 1
/* Define if you have the 'long long' type. */
#ifndef _MSC_VER
#define HAVE_LONG_LONG 1
#else /* _MSC_VER */
/* #undef HAVE_LONG_LONG */
#endif /* _MSC_VER */
/* define if system printf can print long long */
#define HAVE_LONG_LONG_FORMAT 1
/* Define to 1 if you have the `lstat' function. */
/* #undef HAVE_LSTAT */
/* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define to 1 if you have the `memalign' function. */
/* #undef HAVE_MEMALIGN */
/* Define to 1 if you have the `memmem' function. */
/* #undef HAVE_MEMMEM */
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mmap' function. */
/* #undef HAVE_MMAP */
/* Define to 1 if you have the <mntent.h> header file. */
/* #undef HAVE_MNTENT_H */
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* We have AF_NETLINK sockets */
/* #undef HAVE_NETLINK */
/* Define to 1 if you have the `newlocale' function. */
/* #undef HAVE_NEWLOCALE */
/* Have non-POSIX function getgrgid_r */
/* #undef HAVE_NONPOSIX_GETGRGID_R */
/* Have non-POSIX function getpwuid_r */
/* #undef HAVE_NONPOSIX_GETPWUID_R */
/* Define to 1 if you have the `on_exit' function. */
/* #undef HAVE_ON_EXIT */
/* Define to 1 if you have the `pipe2' function. */
/* #undef HAVE_PIPE2 */
/* Define to 1 if you have the `poll' function. */
/* #undef HAVE_POLL */
/* Have POSIX function getgrgid_r */
/* #undef HAVE_POSIX_GETGRGID_R */
/* Have POSIX function getpwuid_r */
/* #undef HAVE_POSIX_GETPWUID_R */
/* Define to 1 if you have the `posix_memalign' function. */
/* #undef HAVE_POSIX_MEMALIGN */
/* Define to 1 if you have the `prlimit' function. */
/* #undef HAVE_PRLIMIT */
/* Have function pthread_attr_setstacksize */
/* #undef HAVE_PTHREAD_ATTR_SETSTACKSIZE */
/* Have function pthread_condattr_setclock */
/* #undef HAVE_PTHREAD_CONDATTR_SETCLOCK */
/* Have function pthread_cond_timedwait_monotonic */
/* #undef HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC */
/* Have function pthread_cond_timedwait_monotonic_np */
/* #undef HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC_NP */
/* Define to 1 if the system has the type `ptrdiff_t'. */
#define HAVE_PTRDIFF_T 1
/* Define to 1 if you have the <pwd.h> header file. */
/* #undef HAVE_PWD_H */
/* Define to 1 if you have the `readlink' function. */
/* #undef HAVE_READLINK */
/* Define to 1 if you have the 'res_init' function. */
/* #undef HAVE_RES_INIT */
/* Define to 1 if you have the <sched.h> header file. */
/* #undef HAVE_SCHED_H */
/* Define to 1 if libselinux is available */
/* #undef HAVE_SELINUX */
/* Define to 1 if you have the <selinux/selinux.h> header file. */
/* #undef HAVE_SELINUX_SELINUX_H */
/* Define to 1 if you have the `setenv' function. */
/* #undef HAVE_SETENV */
/* Define to 1 if you have the `setlocale' function. */
#define HAVE_SETLOCALE 1
/* Define to 1 if you have the `setmntent' function. */
/* #undef HAVE_SETMNTENT */
/* Define if you have the 'sig_atomic_t' type. */
#define HAVE_SIG_ATOMIC_T 1
/* Define to 1 if you have the `snprintf' function. */
#if !defined (_MSC_VER) || (_MSC_VER >= 1900)
#define HAVE_SNPRINTF 1
#ifdef __DMC__
#define snprintf _snprintf
#endif
#else /* _MSC_VER */
/* #undef HAVE_SNPRINTF */
#endif /* _MSC_VER */
/* Define to 1 if you have the `splice' function. */
/* #undef HAVE_SPLICE */
/* Define to 1 if you have the `statfs' function. */
/* #undef HAVE_STATFS */
/* Define to 1 if you have the `statvfs' function. */
/* #undef HAVE_STATVFS */
/* Define to 1 if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#ifndef _MSC_VER
#define HAVE_STDINT_H 1
#else /* _MSC_VER */
#if (_MSC_VER >= 1600) /*VS 2010 ships with stdint.h*/
#define HAVE_STDINT_H 1
#else
/* #undef HAVE_STDINT_H */
#endif
#endif /* _MSC_VER */
/* Define if <stdint.h> exists, doesn't clash with <sys/types.h>, and declares
uintmax_t. */
#ifndef _MSC_VER
#define HAVE_STDINT_H_WITH_UINTMAX 1
#else /* _MSC_VER */
#if (_MSC_VER >= 1600)
#define HAVE_STDINT_H_WITH_UINTMAX 1
#else
/* #undef HAVE_STDINT_H_WITH_UINTMAX */
#endif
#endif /* _MSC_VER */
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `stpcpy' function. */
/* #undef HAVE_STPCPY */
/* Define to 1 if you have the `strcasecmp' function. */
#if defined(_MSC_VER)
#define strcasecmp _stricmp
#endif /* _MSC_VER uses _stricmp, which is identical to strcasecmp */
#if !defined(__DMC__)
#define HAVE_STRCASECMP 1
#endif /* _MSC_VER or __gcc__ */
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the <strings.h> header file. */
#if !defined(_MSC_VER) && !defined(__DMC__)
#define HAVE_STRINGS_H 1
#else /* _MSC_VER or __DMC__ */
/* #undef HAVE_STRINGS_H */
#endif /* _MSC_VER or __DMC__ */
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Have functions strlcpy and strlcat */
/* #undef HAVE_STRLCPY */
/* Define to 1 if you have the `strncasecmp' function. */
#if !defined(__DMC__)
#if defined(_MSC_VER)
#define strncasecmp _strnicmp
#endif /* _MSC_VER uses _strnicmp, which is identical to strncasecmp */
#define HAVE_STRNCASECMP 1
#else /* __DMC__ */
/* #undef HAVE_STRNCASECMP */
#endif /* __DMC__ */
/* Define to 1 if you have the `strsignal' function. */
/* #undef HAVE_STRSIGNAL */
/* Define to 1 if you have the `strtod_l' function. */
/* #undef HAVE_STRTOD_L */
/* Define to 1 if you have the `strtoll_l' function. */
/* #undef HAVE_STRTOLL_L */
/* Define to 1 if you have the `strtoull_l' function. */
/* #undef HAVE_STRTOULL_L */
/* Define to 1 if `d_type' is a member of `struct dirent'. */
/* #undef HAVE_STRUCT_DIRENT_D_TYPE */
/* Define to 1 if `f_bavail' is a member of `struct statfs'. */
/* #undef HAVE_STRUCT_STATFS_F_BAVAIL */
/* Define to 1 if `f_fstypename' is a member of `struct statfs'. */
/* #undef HAVE_STRUCT_STATFS_F_FSTYPENAME */
/* Define to 1 if `f_basetype' is a member of `struct statvfs'. */
/* #undef HAVE_STRUCT_STATVFS_F_BASETYPE */
/* Define to 1 if `f_fstypename' is a member of `struct statvfs'. */
/* #undef HAVE_STRUCT_STATVFS_F_FSTYPENAME */
/* Define to 1 if `st_atimensec' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_ATIMENSEC */
/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC */
/* Define to 1 if `st_blksize' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_BLKSIZE */
/* Define to 1 if `st_blocks' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_BLOCKS */
/* Define to 1 if `st_ctimensec' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_CTIMENSEC */
/* Define to 1 if `st_ctim.tv_nsec' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC */
/* Define to 1 if `st_mtimensec' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_MTIMENSEC */
/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */
/* Define to 1 if `tm_gmtoff' is a a member of `struct tm'. */
/* #undef HAVE_STRUCT_TM_TM_GMTOFF */
/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */
/* #undef HAVE_STRUCT_TM___TM_GMTOFF */
/* Define to 1 if you have the `symlink' function. */
/* #undef HAVE_SYMLINK */
/* Define to 1 if you have the `sysctlbyname' function. */
/* #undef HAVE_SYSCTLBYNAME */
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/event.h> header file. */
/* #undef HAVE_SYS_EVENT_H */
/* Define to 1 if you have the <sys/filio.h> header file. */
/* #undef HAVE_SYS_FILIO_H */
/* Define to 1 if you have the <sys/inotify.h> header file. */
/* #undef HAVE_SYS_INOTIFY_H */
/* Define to 1 if you have the <sys/mkdev.h> header file. */
/* #undef HAVE_SYS_MKDEV_H */
/* Define to 1 if you have the <sys/mntctl.h> header file. */
/* #undef HAVE_SYS_MNTCTL_H */
/* Define to 1 if you have the <sys/mnttab.h> header file. */
/* #undef HAVE_SYS_MNTTAB_H */
/* Define to 1 if you have the <sys/mount.h> header file. */
/* #undef HAVE_SYS_MOUNT_H */
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/param.h> header file. */
#if !defined(_MSC_VER) && !defined(__DMC__)
#define HAVE_SYS_PARAM_H 1
#else /* _MSC_VER or __DMC__ */
/* #undef HAVE_SYS_PARAM_H */
#endif /* _MSC_VER or __DMC__ */
/* Define to 1 if you have the <sys/poll.h> header file. */
/* #undef HAVE_SYS_POLL_H */
/* Define to 1 if you have the <sys/prctl.h> header file. */
/* #undef HAVE_SYS_PRCTL_H */
/* Define to 1 if you have the <sys/resource.h> header file. */
/* #undef HAVE_SYS_RESOURCE_H */
/* found fd_set in sys/select.h */
/* #undef HAVE_SYS_SELECT_H */
/* Define to 1 if you have the <sys/statfs.h> header file. */
/* #undef HAVE_SYS_STATFS_H */
/* Define to 1 if you have the <sys/statvfs.h> header file. */
/* #undef HAVE_SYS_STATVFS_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/sysctl.h> header file. */
/* #undef HAVE_SYS_SYSCTL_H */
/* Define to 1 if you have the <sys/times.h> header file. */
/* #undef HAVE_SYS_TIMES_H */
/* Define to 1 if you have the <sys/time.h> header file. */
#ifndef _MSC_VER
#define HAVE_SYS_TIME_H 1
#else /* _MSC_VER */
/* #undef HAVE_SYS_TIME_H */
#endif /* _MSC_VER */
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
/* #undef HAVE_SYS_UIO_H */
/* Define to 1 if you have the <sys/vfstab.h> header file. */
/* #undef HAVE_SYS_VFSTAB_H */
/* Define to 1 if you have the <sys/vfs.h> header file. */
/* #undef HAVE_SYS_VFS_H */
/* Define to 1 if you have the <sys/vmount.h> header file. */
/* #undef HAVE_SYS_VMOUNT_H */
/* Define to 1 if you have the <sys/wait.h> header file. */
/* #undef HAVE_SYS_WAIT_H */
/* Define to 1 if you have the <sys/xattr.h> header file. */
/* #undef HAVE_SYS_XATTR_H */
/* Define to 1 if you have the `timegm' function. */
/* #undef HAVE_TIMEGM */
/* Define to 1 if you have the <unistd.h> header file. */
#ifndef _MSC_VER
#define HAVE_UNISTD_H 1
#else /* _MSC_VER */
/* #undef HAVE_UNISTD_H */
#endif /* _MSC_VER */
/* Define if your printf function family supports positional parameters as
specified by Unix98. */
/* #undef HAVE_UNIX98_PRINTF */
/* Define to 1 if you have the `unsetenv' function. */
/* #undef HAVE_UNSETENV */
/* Define to 1 if you have the `uselocale' function. */
/* #undef HAVE_USELOCALE */
/* Define to 1 if you have the `utimes' function. */
/* #undef HAVE_UTIMES */
/* Define to 1 if you have the `valloc' function. */
/* #undef HAVE_VALLOC */
/* Define to 1 if you have the <values.h> header file. */
#if !defined(_MSC_VER) && !defined(__DMC__)
#define HAVE_VALUES_H 1
#else /* _MSC_VER or __DMC__ */
/* #undef HAVE_VALUES_H */
#endif /* _MSC_VER or __DMC__ */
/* Define to 1 if you have the `vasprintf' function. */
#define HAVE_VASPRINTF 1
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the `vsnprintf' function. */
#ifndef _MSC_VER
#define HAVE_VSNPRINTF 1
#ifdef __DMC__
#define vsnprintf _vsnprintf
#endif
#else /* _MSC_VER */
#if (_MSC_VER >= 1500)
#define HAVE_VSNPRINTF 1
#endif /* VS 2008+ has vsnprintf */
/* #undef HAVE_VSNPRINTF */
#endif /* _MSC_VER */
/* Define if you have the 'wchar_t' type. */
#define HAVE_WCHAR_T 1
/* Define to 1 if you have the `wcslen' function. */
#define HAVE_WCSLEN 1
/* Define if you have the 'wint_t' type. */
#define HAVE_WINT_T 1
/* Have a working bcopy */
/* #undef HAVE_WORKING_BCOPY */
/* Define to 1 if xattr is available */
/* #undef HAVE_XATTR */
/* Define to 1 if xattr API uses XATTR_NOFOLLOW */
/* #undef HAVE_XATTR_NOFOLLOW */
/* Define to 1 if you have the <xlocale.h> header file. */
/* #undef HAVE_XLOCALE_H */
/* Define to 1 if you have the `_NSGetEnviron' function. */
/* #undef HAVE__NSGETENVIRON */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* didn't find fd_set */
#define NO_FD_SET 1
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=glib"
/* Define to the full name of this package. */
#define PACKAGE_NAME "glib"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "glib 2.38.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "glib"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.38.2"
/* define if posix_memalign() can allocate any size */
/* #undef POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS */
/* whether realloc (NULL,) works */
#define REALLOC_0_WORKS 1
/* The size of `char', as computed by sizeof. */
#define SIZEOF_CHAR 1
/* The size of `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* The size of `long long', as computed by sizeof. */
#ifndef _MSC_VER
#define SIZEOF_LONG_LONG 8
#else /* _MSC_VER */
#define SIZEOF_LONG_LONG 0
#endif /* _MSC_VER */
/* The size of `short', as computed by sizeof. */
#define SIZEOF_SHORT 2
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 4
/* The size of `void *', as computed by sizeof. */
#ifdef _MSC_VER
#ifdef _WIN64
#define SIZEOF_VOID_P 8
#else
#define SIZEOF_VOID_P 4
#endif
#else
#define SIZEOF_VOID_P 4
#endif
/* The size of `__int64', as computed by sizeof. */
#define SIZEOF___INT64 8
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */
/* Number of arguments to statfs() */
/* #undef STATFS_ARGS */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Use no threads */
/* #undef THREADS_NONE */
/* Use pthreads */
/* #undef THREADS_POSIX */
/* Use w32 threads */
#define THREADS_WIN32 1
/* Using GNU libiconv */
/* #undef USE_LIBICONV_GNU */
/* Using a native implementation of iconv in a separate library */
#define USE_LIBICONV_NATIVE 1
/* Define to use statfs() */
/* #undef USE_STATFS */
/* Define to use statvfs() */
/* #undef USE_STATVFS */
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
/* # undef _ALL_SOURCE */
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
/* # undef _GNU_SOURCE */
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
/* # undef _POSIX_PTHREAD_SEMANTICS */
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
/* # undef _TANDEM_SOURCE */
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
/* # undef __EXTENSIONS__ */
#endif
/* using the system-supplied PCRE library */
/* This is defined in the *_PCRE MSVC project configs */
/* #undef USE_SYSTEM_PCRE */
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
/* # define _DARWIN_USE_64_BIT_INODE 1 */
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* defines how to decorate public symbols while building */
#define _GLIB_EXTERN __declspec (dllexport) extern
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */
/* Target the Windows XP API */
#define _WIN32_WINNT 0x0501
/* Needed to get declarations for msg_control and msg_controllen on Solaris */
/* #undef _XOPEN_SOURCE */
/* Needed to get declarations for msg_control and msg_controllen on Solaris */
/* #undef _XOPEN_SOURCE_EXTENDED */
/* Needed to get declarations for msg_control and msg_controllen on Solaris */
/* #undef __EXTENSIONS__ */
/* compiler supports atomic operations */
/* #undef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to long or long long if <inttypes.h> and <stdint.h> don't define. */
/* #undef intmax_t */
/* Define to empty if the C compiler doesn't support this keyword. */
/* #undef signed */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */

View file

@ -53,6 +53,7 @@ EXTRA_DIST += \
win_iconv.c \
docs.c \
gconstructor.h \
glibconfig.h.win32 \
$(MIRRORING_TAB_SOURCE)
# These may be in the builddir too

View file

@ -43,8 +43,8 @@
#include "glibintl.h"
#if defined (_MSC_VER) && !defined (HAVE_DIRENT_H)
#include "../build/win32/dirent/dirent.h"
#include "../build/win32/dirent/wdirent.c"
#include "../../nmake/dirent/dirent.h"
#include "../../nmake/dirent/wdirent.c"
#endif
#include "glib-private.h" /* g_dir_open_with_errno, g_dir_new_from_dirp */

View file

@ -0,0 +1,266 @@
/* glibconfig.h.win32.in. Originally merged from two versions of
* glibconfig.h, generated by the GLib configure script, for gcc and
* MSVC.
*/
/* glibconfig.h
*
* This is a generated file. Please modify 'glibconfig.h.win32.in'
*/
#ifndef __G_LIBCONFIG_H__
#define __G_LIBCONFIG_H__
#include <glib/gmacros.h>
#include <limits.h>
#include <float.h>
G_BEGIN_DECLS
#define G_MINFLOAT FLT_MIN
#define G_MAXFLOAT FLT_MAX
#define G_MINDOUBLE DBL_MIN
#define G_MAXDOUBLE DBL_MAX
#define G_MINSHORT SHRT_MIN
#define G_MAXSHORT SHRT_MAX
#define G_MAXUSHORT USHRT_MAX
#define G_MININT INT_MIN
#define G_MAXINT INT_MAX
#define G_MAXUINT UINT_MAX
#define G_MINLONG LONG_MIN
#define G_MAXLONG LONG_MAX
#define G_MAXULONG ULONG_MAX
typedef signed char gint8;
typedef unsigned char guint8;
typedef signed short gint16;
typedef unsigned short guint16;
#define G_GINT16_MODIFIER "h"
#define G_GINT16_FORMAT "hi"
#define G_GUINT16_FORMAT "hu"
typedef signed int gint32;
typedef unsigned int guint32;
#define G_GINT32_MODIFIER ""
#define G_GINT32_FORMAT "i"
#define G_GUINT32_FORMAT "u"
#define G_HAVE_GINT64 1 /* deprecated, always true */
#ifndef _MSC_VER
G_GNUC_EXTENSION typedef signed long long gint64;
G_GNUC_EXTENSION typedef unsigned long long guint64;
#else /* _MSC_VER */
typedef signed __int64 gint64;
typedef unsigned __int64 guint64;
#endif /* _MSC_VER */
#ifndef _MSC_VER
#define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL))
#else /* _MSC_VER */
#define G_GINT64_CONSTANT(val) (val##i64)
#endif /* _MSC_VER */
#ifndef _MSC_VER
#define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##ULL))
#else /* _MSC_VER */
#define G_GUINT64_CONSTANT(val) (val##Ui64)
#endif /* _MSC_VER */
#define G_GINT64_MODIFIER "I64"
#define G_GINT64_FORMAT "I64i"
#define G_GUINT64_FORMAT "I64u"
#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64)
#define GLIB_SIZEOF_VOID_P 8
#define GLIB_SIZEOF_LONG 4
#define GLIB_SIZEOF_SIZE_T 8
typedef signed long long gssize;
typedef unsigned long long gsize;
#define G_GSIZE_MODIFIER "I64"
#define G_GSSIZE_FORMAT "I64d"
#define G_GSIZE_FORMAT "I64u"
#define G_MAXSIZE G_MAXUINT64
#define G_MINSSIZE G_MININT64
#define G_MAXSSIZE G_MAXINT64
#else
#define GLIB_SIZEOF_VOID_P 4
#define GLIB_SIZEOF_LONG 4
#define GLIB_SIZEOF_SIZE_T 4
typedef signed int gssize;
typedef unsigned int gsize;
#define G_GSIZE_MODIFIER ""
#define G_GSSIZE_FORMAT "i"
#define G_GSIZE_FORMAT "u"
#define G_MAXSIZE G_MAXUINT
#define G_MINSSIZE G_MININT
#define G_MAXSSIZE G_MAXINT
#endif
typedef gint64 goffset;
#define G_MINOFFSET G_MININT64
#define G_MAXOFFSET G_MAXINT64
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
#ifndef _WIN64
#define GPOINTER_TO_INT(p) ((gint) (p))
#define GPOINTER_TO_UINT(p) ((guint) (p))
#define GINT_TO_POINTER(i) ((gpointer) (i))
#define GUINT_TO_POINTER(u) ((gpointer) (u))
typedef signed int gintptr;
typedef unsigned int guintptr;
#define G_GINTPTR_MODIFIER ""
#define G_GINTPTR_FORMAT "i"
#define G_GUINTPTR_FORMAT "u"
#else
#define GPOINTER_TO_INT(p) ((gint) (gint64) (p))
#define GPOINTER_TO_UINT(p) ((guint) (guint64) (p))
#define GINT_TO_POINTER(i) ((gpointer) (gint64) (i))
#define GUINT_TO_POINTER(u) ((gpointer) (guint64) (u))
#ifndef _MSC_VER
typedef signed long long gintptr;
typedef unsigned long long guintptr;
#else
typedef signed __int64 gintptr;
typedef unsigned __int64 guintptr;
#endif
#define G_GINTPTR_MODIFIER "I64"
#define G_GINTPTR_FORMAT "I64i"
#define G_GUINTPTR_FORMAT "I64u"
#endif
#ifdef NeXT /* @#%@! NeXTStep */
# define g_ATEXIT(proc) (!atexit (proc))
#else
# define g_ATEXIT(proc) (atexit (proc))
#endif
#define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
#define GLIB_MAJOR_VERSION 2
#define GLIB_MINOR_VERSION 38
#define GLIB_MICRO_VERSION 2
#define G_OS_WIN32
#define G_PLATFORM_WIN32
#ifndef _MSC_VER
#define G_VA_COPY va_copy
#endif /* not _MSC_VER */
#ifdef __cplusplus
#define G_HAVE_INLINE 1
#else /* !__cplusplus */
#ifndef _MSC_VER
#define G_HAVE_INLINE 1
#endif /* _MSC_VER */
#define G_HAVE___INLINE 1
#if !defined(_MSC_VER) && !defined(__DMC__)
#define G_HAVE___INLINE__ 1
#endif /* !_MSC_VER and !__DMC__ */
#endif /* !__cplusplus */
#define G_CAN_INLINE 1
#ifndef _MSC_VER
#define G_HAVE_ISO_VARARGS 1
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
* is passed ISO vararg support is turned off, and there is no work
* around to turn it on, so we unconditionally turn it off.
*/
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
# undef G_HAVE_ISO_VARARGS
#endif
#define G_HAVE_GNUC_VARARGS 1
#else /* _MSC_VER */
/* varargs macros available since msvc8 (vs2005) */
# if _MSC_VER >= 1400
# define G_HAVE_ISO_VARARGS 1
# endif
#endif /* not _MSC_VER */
#define G_HAVE_GROWING_STACK 0
#define G_GNUC_INTERNAL
#define G_THREADS_ENABLED
#define G_THREADS_IMPL_WIN32
#define G_ATOMIC_LOCK_FREE
#define GINT16_TO_LE(val) ((gint16) (val))
#define GUINT16_TO_LE(val) ((guint16) (val))
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
#define GINT32_TO_LE(val) ((gint32) (val))
#define GUINT32_TO_LE(val) ((guint32) (val))
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
#define GINT64_TO_LE(val) ((gint64) (val))
#define GUINT64_TO_LE(val) ((guint64) (val))
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
#define GLONG_TO_LE(val) ((glong) GINT32_TO_LE (val))
#define GULONG_TO_LE(val) ((gulong) GUINT32_TO_LE (val))
#define GLONG_TO_BE(val) ((glong) GINT32_TO_BE (val))
#define GULONG_TO_BE(val) ((gulong) GUINT32_TO_BE (val))
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
#define GSIZE_TO_LE(val) ((gsize) GUINT32_TO_LE (val))
#define GSSIZE_TO_LE(val) ((gssize) GINT32_TO_LE (val))
#define GSIZE_TO_BE(val) ((gsize) GUINT32_TO_BE (val))
#define GSSIZE_TO_BE(val) ((gssize) GINT32_TO_BE (val))
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#define GLIB_SYSDEF_POLLIN =1
#define GLIB_SYSDEF_POLLOUT =4
#define GLIB_SYSDEF_POLLPRI =2
#define GLIB_SYSDEF_POLLHUP =16
#define GLIB_SYSDEF_POLLERR =8
#define GLIB_SYSDEF_POLLNVAL =32
#define G_MODULE_SUFFIX "dll"
/* A GPid is an abstraction for a process "handle". It is *not* an
* abstraction for a process identifier in general. GPid is used in
* GLib only for descendant processes spawned with the g_spawn*
* functions. On POSIX there is no "process handle" concept as such,
* but on Windows a GPid is a handle to a process, a kind of pointer,
* not a process identifier.
*/
typedef void * GPid;
#define GLIB_SYSDEF_AF_UNIX 1
#define GLIB_SYSDEF_AF_INET 2
#define GLIB_SYSDEF_AF_INET6 23
#define GLIB_SYSDEF_MSG_OOB 1
#define GLIB_SYSDEF_MSG_PEEK 2
#define GLIB_SYSDEF_MSG_DONTROUTE 4
G_END_DECLS
#endif /* GLIBCONFIG_H */

View file

@ -260,7 +260,7 @@
* fields through their offsets.
*/
#if defined(__GNUC__) && __GNUC__ >= 4
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined (_MSC_VER)
# define G_STRUCT_OFFSET(struct_type, member) \
((glong) offsetof (struct_type, member))
#else

View file

@ -337,12 +337,12 @@ static CRITICAL_SECTION g_private_lock;
static DWORD
g_private_get_impl (GPrivate *key)
{
DWORD impl = (DWORD) key->p;
DWORD impl = (DWORD) GPOINTER_TO_UINT(key->p);
if G_UNLIKELY (impl == 0)
{
EnterCriticalSection (&g_private_lock);
impl = (DWORD) key->p;
impl = (UINT_PTR) key->p;
if (impl == 0)
{
GPrivateDestructor *destructor;

2
nmake/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
config.h.win32
vs*/

10
nmake/Makefile.am Normal file
View file

@ -0,0 +1,10 @@
EXTRA_DIST = \
build-rules-msvc.mak \
create-lists-msvc.mak \
detectenv-msvc.mak \
Makefile.vc \
dirent/dirent.h \
dirent/dirent.c \
dirent/wdirent.c \
dirent/README \
config.h.win32

99
nmake/Makefile.vc Normal file
View file

@ -0,0 +1,99 @@
# Note: This does assume an existing GLib installation!
# Visual Studio builds of GLib does not need an existing pkg-config
# installation, so build GLib first before using this.
# Set these if necessary. If building from GLib's included
# Visual Studio projects, this should be able to locate the GLib build
# out-of-the-box if they were not moved. GLib's headers will be found
# in $(INCLUDEDIR)\glib-2.0 and $(LIBDIR)\glib-2.0\include
# and its import library will be found in $(LIBDIR).
!ifndef GLIB_PREFIX
GLIB_PREFIX = ..\vs$(VSVER)\$(PLAT)
!endif
!ifndef INCLUDEDIR
INCLUDEDIR = $(GLIB_PREFIX)\include
!endif
!ifndef LIBDIR
LIBDIR = $(GLIB_PREFIX)\lib
!endif
# The items below this line should not be changed, unless one is maintaining
# the NMake Makefiles.
!include detectenv-msvc.mak
!if "$(VALID_CFGSET)" == "TRUE"
INCLUDES_GLIB = \
/I..\glib\glib /I..\glib \
/I.\vs$(VSVER)\$(CFG)\$(PLAT)\glib\glib /I.\vs$(VSVER)\$(CFG)\$(PLAT)\glib \
/I.\dirent
INCLUDES_PKGCONFIG = /I. /I.\vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config
CFLAGS = $(CFLAGS_ADD) /W3 /Zi
!ifdef HAVE_GLIB
CFLAGS = $(CFLAGS) /FImsvc_recommended_pragmas.h
INCLUDES_PKGCONFIG = \
$(INCLUDES_PKGCONFIG) \
/I$(INCLUDEDIR)\glib-2.0 \
/I$(LIBDIR)\glib-2.0\include
!else
CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_WARNIGS /D_CRT_NONSTDC_NO_WARNINGS /wd4244
INCLUDES_PKGCONFIG = $(INCLUDES_PKGCONFIG) $(INCLUDES_GLIB)
!endif
# PKG_CONFIG_SYSTEM_INCLUDE_PATH and PKG_CONFIG_SYSTEM_LIBRARY_PATH only
# work for GCC builds for now, so just set this to nothing for now
pkg_config_CFLAGS = \
$(CFLAGS) \
/DHAVE_CONFIG_H \
/DPKG_CONFIG_SYSTEM_INCLUDE_PATH="\"\"" \
/DPKG_CONFIG_SYSTEM_LIBRARY_PATH="\"\""
glib_CFLAGS = \
$(CFLAGS) \
/DHAVE_CONFIG_H \
/DG_LOG_DOMAIN=\"GLib\" \
/DGLIB_COMPILATION \
/DGLIB_DISABLE_DEPRECATIONS \
/DDLL_EXPORT \
/DPCRE_STATIC
LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(LIBDIR) /DEBUG
NULL=
!if "$(CFG)" == "debug"
LDFLAGS = $(LDFLAGS_BASE)
ARFLAGS = $(LDFLAGS)
!else
LDFLAGS = $(LDFLAGS_BASE) /opt:ref /LTCG
ARFLAGS = $(LDFLAGS_BASE) /LTCG
!endif
!include ..\Makefile.sources
!include create-lists-msvc.mak
pkg_config_build_deps =
!ifdef HAVE_GLIB
pkg_config_LIBS = glib-2.0.lib
!else
pkg_config_build_deps = vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config-glib.lib
pkg_config_LIBS = $(pkg_config_build_deps)
glib_dep_libs = intl.lib winmm.lib ws2_32.lib ole32.lib advapi32.lib shell32.lib user32.lib
!endif
all: vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config.exe
!include build-rules-msvc.mak
!else
all:
@echo You need to specify a valid configuration, via
@echo CFG=release or CFG=debug
!endif

View file

@ -0,0 +1,80 @@
# rules for building objects, libraries and executables
BASE_OBJDIR = vs$(VSVER)\$(CFG)\$(PLAT)
$(BASE_OBJDIR)\pkg-config\config.h: config.h.win32
$(BASE_OBJDIR)\glib\config.h: ..\glib\config.h.win32
$(BASE_OBJDIR)\glib\glib\glibconfig.h: ..\glib\glib\glibconfig.h.win32
$(BASE_OBJDIR)\pkg-config\config.h \
$(BASE_OBJDIR)\glib\config.h \
$(BASE_OBJDIR)\glib\glib\glibconfig.h:
@echo Copying $** to $@
@if not exist $(@D)\ md $(@D)
@-copy $** $@
!include objs-targets-vs$(VSVER)-$(PLAT)-$(CFG).mak
!if [del /f/q objs-targets-vs$(VSVER)-$(PLAT)-$(CFG).mak]
!endif
{..\}.c{$(BASE_OBJDIR)\pkg-config\}.obj::
$(CC) $(pkg_config_CFLAGS) $(INCLUDES_PKGCONFIG) /Fo$(BASE_OBJDIR)\pkg-config\ /Fd$(BASE_OBJDIR)\pkg-config\ /c @<<
$<
<<
{..\glib\glib\}.c{$(BASE_OBJDIR)\glib\}.obj::
$(CC) $(glib_CFLAGS) $(INCLUDES_GLIB) /Fo$(BASE_OBJDIR)\glib\ /Fd$(BASE_OBJDIR)\glib\ /c @<<
$<
<<
{..\glib\glib\deprecated\}.c{$(BASE_OBJDIR)\glib\}.obj::
$(CC) $(glib_CFLAGS) $(INCLUDES_GLIB) /Fo$(BASE_OBJDIR)\glib\ /Fd$(BASE_OBJDIR)\glib\ /c @<<
$<
<<
{..\glib\glib\gnulib\}.c{$(BASE_OBJDIR)\glib\}.obj::
$(CC) $(glib_CFLAGS) $(INCLUDES_GLIB) /Fo$(BASE_OBJDIR)\glib\ /Fd$(BASE_OBJDIR)\glib\ /c @<<
$<
<<
{..\glib\glib\libcharset\}.c{$(BASE_OBJDIR)\glib\}.obj::
$(CC) /DLIBDIR=\"blah\" $(glib_CFLAGS) $(INCLUDES_GLIB) /Fo$(BASE_OBJDIR)\glib\ /Fd$(BASE_OBJDIR)\glib\ /c @<<
$<
<<
{.\dirent\}.c{$(BASE_OBJDIR)\glib\}.obj::
$(CC) $(CFLAGS) /Fo$(BASE_OBJDIR)\glib\ /Fd$(BASE_OBJDIR)\glib\ /c @<<
$<
<<
$(BASE_OBJDIR)\pkg-config-glib.lib: $(glib_OBJS)
link $(LDFLAGS) /DLL /out:$(@R).dll $(glib_dep_libs) @<<
$**
<<
$(BASE_OBJDIR)\pkg-config.exe: $(pkg_config_OBJS) $(pkg_config_build_deps)
link $(LDFLAGS) $(pkg_config_LIBS) -out:$@ @<<
$(pkg_config_OBJS)
<<
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
clean:
@-del /f /q $(BASE_OBJDIR)\*.exe.manifest
@-del /f /q $(BASE_OBJDIR)\*.exe
@-del /f /q $(BASE_OBJDIR)\*.dll.manifest
@-del /f /q $(BASE_OBJDIR)\*.dll
@-del /f /q $(BASE_OBJDIR)\*.exp
@-del /f /q $(BASE_OBJDIR)\*.pdb
@-del /f /q $(BASE_OBJDIR)\pkg-config-glib.lib
@-del /f /q $(BASE_OBJDIR)\*.ilk
@-del /f /q $(BASE_OBJDIR)\pkg-config\*.obj
@-del /f /q $(BASE_OBJDIR)\pkg-config\vc$(PDBVER).pdb
@-del /f /q $(BASE_OBJDIR)\pkg-config\config.h
@-del /f /q $(BASE_OBJDIR)\glib\*.obj
@-del /f /q $(BASE_OBJDIR)\glib\vc$(PDBVER).pdb
@-del /f /q $(BASE_OBJDIR)\glib\glib\glibconfig.h
@-del /f /q $(BASE_OBJDIR)\glib\config.h
@-rd $(BASE_OBJDIR)\pkg-config
@-rd $(BASE_OBJDIR)\glib\glib
@-rd $(BASE_OBJDIR)\glib

View file

@ -0,0 +1,49 @@
# Convert the source (*.c) listing to object (.obj) listing in
# another NMake Makefile module, include it, and clean it up.
!if [echo pkg_config_OBJS = \> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [for %c in ($(pkg_config_SOURCES)) do @if "%~xc" == ".c" echo. vs^$(VSVER)\^$(CFG)\^$(PLAT)\pkg-config\%~nc.obj \>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [echo. ^$(NULL)>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [echo glib_OBJS = \>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\g*.c) do @if not "%~nxc" == "gspawn.c" if not "%~nxc" == "gthread-posix.c" if not "%~nxc" == "giounix.c" if not "%~nxc" == "glib-unix.c" echo. vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj \>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\deprecated\*.c) do @echo. vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj \>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\gnulib\*.c) do @echo. vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj \>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\libcharset\*.c) do @echo. vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj \>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [echo. ^$(NULL)>> objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!include objs_vs$(VSVER)_$(PLAT)_$(CFG).mak
!if [del /f /q objs_vs$(VSVER)_$(PLAT)_$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\g*.c) do @if not "%~nxc" == "gspawn.c" if not "%~nxc" == "glib-unix.c" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj: %c vs$(VSVER)\$(CFG)\$(PLAT)\glib\config.h vs$(VSVER)\$(CFG)\$(PLAT)\glib\glib\glibconfig.h>> objs-targets-vs$(VSVER)-$(PLAT)-$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\deprecated\g*.c) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj: %c vs$(VSVER)\$(CFG)\$(PLAT)\glib\config.h vs$(VSVER)\$(CFG)\$(PLAT)\glib\glib\glibconfig.h>> objs-targets-vs$(VSVER)-$(PLAT)-$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\gnulib\*.c) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj: %c vs$(VSVER)\$(CFG)\$(PLAT)\glib\config.h vs$(VSVER)\$(CFG)\$(PLAT)\glib\glib\glibconfig.h>> objs-targets-vs$(VSVER)-$(PLAT)-$(CFG).mak]
!endif
!if [for %c in (..\glib\glib\libcharset\*.c) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\glib\%~nc.obj: %c vs$(VSVER)\$(CFG)\$(PLAT)\glib\config.h vs$(VSVER)\$(CFG)\$(PLAT)\glib\glib\glibconfig.h>> objs-targets-vs$(VSVER)-$(PLAT)-$(CFG).mak]
!endif
!if [for %c in ($(pkg_config_SOURCES)) do @if "%~xc" == ".c" echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\pkg-config\%~nc.obj: ..\%c vs$(VSVER)\$(CFG)\$(PLAT)\pkg-config\config.h>> objs-targets-vs$(VSVER)-$(PLAT)-$(CFG).mak]
!endif

View file

@ -16,6 +16,8 @@ _HASH=^#
&& ![echo PLAT=Win32 >> vercl.x] \
&& ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
&& ![echo PLAT=x64 >> vercl.x] \
&& ![echo $(_HASH)elif defined(_M_ARM64) >> vercl.x] \
&& ![echo PLAT=arm64 >> vercl.x] \
&& ![echo $(_HASH)endif >> vercl.x] \
&& ![cl -nologo -TC -P vercl.x $(ERRNUL)]
!include vercl.i
@ -35,8 +37,14 @@ VSVER = 10
VSVER = 11
!elseif $(VCVERSION) > 1799 && $(VCVERSION) < 1900
VSVER = 12
!elseif $(VCVERSION) > 1899 && $(VCVERSION) < 2000
!elseif $(VCVERSION) > 1899 && $(VCVERSION) < 1910
VSVER = 14
!elseif $(VCVERSION) > 1909 && $(VCVERSION) < 1920
VSVER = 15
!elseif $(VCVERSION) > 1919 && $(VCVERSION) < 1930
VSVER = 16
!elseif $(VCVERSION) > 1929 && $(VCVERSION) < 2000
VSVER = 17
!else
VSVER = 0
!endif
@ -44,11 +52,17 @@ VSVER = 0
!if "$(VSVER)" == "0"
MSG = ^
This NMake Makefile set supports Visual Studio^
9 (2008) through 14 (2015). Your Visual Studio^
9 (2008) through 17 (2022). Your Visual Studio^
version is not supported.
!error $(MSG)
!endif
!if $(VSVER) < 15
PDBVER = $(VSVER)0
!else
PDBVER = 140
!endif
VALID_CFGSET = FALSE
!if "$(CFG)" == "release" || "$(CFG)" == "debug"
VALID_CFGSET = TRUE
@ -62,6 +76,8 @@ CFLAGS_ADD = /MDd /Od
!if "$(PLAT)" == "x64"
LDFLAGS_ARCH = /machine:x64
!elseif "$(PLAT)" == "arm64"
LDFLAGS_ARCH = /machine:arm64
!else
LDFLAGS_ARCH = /machine:x86
!endif

2
nmake/dirent/README Normal file
View file

@ -0,0 +1,2 @@
This is dirent from mingw-runtime-3.3, separated for MSVC user's
benefit.

341
nmake/dirent/dirent.c Normal file
View file

@ -0,0 +1,341 @@
/*
* dirent.c
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Derived from DIRLIB.C by Matt J. Weinstein
* This note appears in the DIRLIB.H
* DIRLIB.H by M. J. Weinstein Released to public domain 1-Jan-89
*
* Updated by Jeremy Bettis <jeremy@hksys.com>
* Significantly revised and rewinddir, seekdir and telldir added by Colin
* Peters <colin@fu.is.saga-u.ac.jp>
*
*/
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <io.h>
#include <direct.h>
#include "dirent.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h> /* for GetFileAttributes */
#include <tchar.h>
#ifdef _UNICODE
#define _tdirent _wdirent
#define _TDIR _WDIR
#define _topendir _wopendir
#define _tclosedir _wclosedir
#define _treaddir _wreaddir
#define _trewinddir _wrewinddir
#define _ttelldir _wtelldir
#define _tseekdir _wseekdir
#else
#define _tdirent dirent
#define _TDIR DIR
#define _topendir opendir
#define _tclosedir closedir
#define _treaddir readdir
#define _trewinddir rewinddir
#define _ttelldir telldir
#define _tseekdir seekdir
#endif
#define SUFFIX _T("*")
#define SLASH _T("\\")
/*
* opendir
*
* Returns a pointer to a DIR structure appropriately filled in to begin
* searching a directory.
*/
_TDIR *
_topendir (const _TCHAR *szPath)
{
_TDIR *nd;
unsigned int rc;
_TCHAR szFullPath[MAX_PATH];
errno = 0;
if (!szPath)
{
errno = EFAULT;
return (_TDIR *) 0;
}
if (szPath[0] == _T('\0'))
{
errno = ENOTDIR;
return (_TDIR *) 0;
}
/* Attempt to determine if the given path really is a directory. */
rc = GetFileAttributes (szPath);
if (rc == (unsigned int)-1)
{
/* call GetLastError for more error info */
errno = ENOENT;
return (_TDIR *) 0;
}
if (!(rc & FILE_ATTRIBUTE_DIRECTORY))
{
/* Error, entry exists but not a directory. */
errno = ENOTDIR;
return (_TDIR *) 0;
}
/* Make an absolute pathname. */
_tfullpath (szFullPath, szPath, MAX_PATH);
/* Allocate enough space to store DIR structure and the complete
* directory path given. */
nd = (_TDIR *) malloc (sizeof (_TDIR) + (_tcslen(szFullPath) + _tcslen (SLASH) +
_tcslen(SUFFIX) + 1) * sizeof(_TCHAR));
if (!nd)
{
/* Error, out of memory. */
errno = ENOMEM;
return (_TDIR *) 0;
}
/* Create the search expression. */
_tcscpy (nd->dd_name, szFullPath);
/* Add on a slash if the path does not end with one. */
if (nd->dd_name[0] != _T('\0') &&
nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('/') &&
nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('\\'))
{
_tcscat (nd->dd_name, SLASH);
}
/* Add on the search pattern */
_tcscat (nd->dd_name, SUFFIX);
/* Initialize handle to -1 so that a premature closedir doesn't try
* to call _findclose on it. */
nd->dd_handle = -1;
/* Initialize the status. */
nd->dd_stat = 0;
/* Initialize the dirent structure. ino and reclen are invalid under
* Win32, and name simply points at the appropriate part of the
* findfirst_t structure. */
nd->dd_dir.d_ino = 0;
nd->dd_dir.d_reclen = 0;
nd->dd_dir.d_namlen = 0;
memset (nd->dd_dir.d_name, 0, FILENAME_MAX);
return nd;
}
/*
* readdir
*
* Return a pointer to a dirent structure filled with the information on the
* next entry in the directory.
*/
struct _tdirent *
_treaddir (_TDIR * dirp)
{
errno = 0;
/* Check for valid DIR struct. */
if (!dirp)
{
errno = EFAULT;
return (struct _tdirent *) 0;
}
if (dirp->dd_stat < 0)
{
/* We have already returned all files in the directory
* (or the structure has an invalid dd_stat). */
return (struct _tdirent *) 0;
}
else if (dirp->dd_stat == 0)
{
/* We haven't started the search yet. */
/* Start the search */
dirp->dd_handle = _tfindfirst (dirp->dd_name, &(dirp->dd_dta));
if (dirp->dd_handle == -1)
{
/* Whoops! Seems there are no files in that
* directory. */
dirp->dd_stat = -1;
}
else
{
dirp->dd_stat = 1;
}
}
else
{
/* Get the next search entry. */
if (_tfindnext (dirp->dd_handle, &(dirp->dd_dta)))
{
/* We are off the end or otherwise error.
_findnext sets errno to ENOENT if no more file
Undo this. */
DWORD winerr = GetLastError();
if (winerr == ERROR_NO_MORE_FILES)
errno = 0;
_findclose (dirp->dd_handle);
dirp->dd_handle = -1;
dirp->dd_stat = -1;
}
else
{
/* Update the status to indicate the correct
* number. */
dirp->dd_stat++;
}
}
if (dirp->dd_stat > 0)
{
/* Successfully got an entry. Everything about the file is
* already appropriately filled in except the length of the
* file name. */
dirp->dd_dir.d_namlen = _tcslen (dirp->dd_dta.name);
_tcscpy (dirp->dd_dir.d_name, dirp->dd_dta.name);
return &dirp->dd_dir;
}
return (struct _tdirent *) 0;
}
/*
* closedir
*
* Frees up resources allocated by opendir.
*/
int
_tclosedir (_TDIR * dirp)
{
int rc;
errno = 0;
rc = 0;
if (!dirp)
{
errno = EFAULT;
return -1;
}
if (dirp->dd_handle != -1)
{
rc = _findclose (dirp->dd_handle);
}
/* Delete the dir structure. */
free (dirp);
return rc;
}
/*
* rewinddir
*
* Return to the beginning of the directory "stream". We simply call findclose
* and then reset things like an opendir.
*/
void
_trewinddir (_TDIR * dirp)
{
errno = 0;
if (!dirp)
{
errno = EFAULT;
return;
}
if (dirp->dd_handle != -1)
{
_findclose (dirp->dd_handle);
}
dirp->dd_handle = -1;
dirp->dd_stat = 0;
}
/*
* telldir
*
* Returns the "position" in the "directory stream" which can be used with
* seekdir to go back to an old entry. We simply return the value in stat.
*/
long
_ttelldir (_TDIR * dirp)
{
errno = 0;
if (!dirp)
{
errno = EFAULT;
return -1;
}
return dirp->dd_stat;
}
/*
* seekdir
*
* Seek to an entry previously returned by telldir. We rewind the directory
* and call readdir repeatedly until either dd_stat is the position number
* or -1 (off the end). This is not perfect, in that the directory may
* have changed while we weren't looking. But that is probably the case with
* any such system.
*/
void
_tseekdir (_TDIR * dirp, long lPos)
{
errno = 0;
if (!dirp)
{
errno = EFAULT;
return;
}
if (lPos < -1)
{
/* Seeking to an invalid position. */
errno = EINVAL;
return;
}
else if (lPos == -1)
{
/* Seek past end. */
if (dirp->dd_handle != -1)
{
_findclose (dirp->dd_handle);
}
dirp->dd_handle = -1;
dirp->dd_stat = -1;
}
else
{
/* Rewind and read forward to the appropriate index. */
_trewinddir (dirp);
while ((dirp->dd_stat < lPos) && _treaddir (dirp))
;
}
}

127
nmake/dirent/dirent.h Normal file
View file

@ -0,0 +1,127 @@
/*
* DIRENT.H (formerly DIRLIB.H)
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
*/
#ifndef _DIRENT_H_
#define _DIRENT_H_
#include <stdio.h>
#include <io.h>
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
struct dirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
char d_name[FILENAME_MAX]; /* File name. */
};
#ifdef _WIN64
#define INTPTR __int64
#else
#define INTPTR long
#endif
/*
* This is an internal data structure. Good programmers will not use it
* except as an argument to one of the functions below.
* dd_stat field is now int (was short in older versions).
*/
typedef struct
{
/* disk transfer area for this dir */
struct _finddata_t dd_dta;
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
* a time) */
struct dirent dd_dir;
/* _findnext handle */
INTPTR dd_handle;
/*
* Status of search:
* 0 = not started yet (next entry to read is first entry)
* -1 = off the end
* positive = 0 based index of next entry
*/
int dd_stat;
/* given path for dir with search pattern (struct is extended) */
char dd_name[1];
} DIR;
DIR* __cdecl opendir (const char*);
struct dirent* __cdecl readdir (DIR*);
int __cdecl closedir (DIR*);
void __cdecl rewinddir (DIR*);
long __cdecl telldir (DIR*);
void __cdecl seekdir (DIR*, long);
/* wide char versions */
struct _wdirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
wchar_t d_name[FILENAME_MAX]; /* File name. */
};
/*
* This is an internal data structure. Good programmers will not use it
* except as an argument to one of the functions below.
*/
typedef struct
{
/* disk transfer area for this dir */
struct _wfinddata_t dd_dta;
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
* a time) */
struct _wdirent dd_dir;
/* _findnext handle */
INTPTR dd_handle;
/*
* Status of search:
* 0 = not started yet (next entry to read is first entry)
* -1 = off the end
* positive = 0 based index of next entry
*/
int dd_stat;
/* given path for dir with search pattern (struct is extended) */
wchar_t dd_name[1];
} _WDIR;
_WDIR* __cdecl _wopendir (const wchar_t*);
struct _wdirent* __cdecl _wreaddir (_WDIR*);
int __cdecl _wclosedir (_WDIR*);
void __cdecl _wrewinddir (_WDIR*);
long __cdecl _wtelldir (_WDIR*);
void __cdecl _wseekdir (_WDIR*, long);
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not _DIRENT_H_ */

3
nmake/dirent/wdirent.c Normal file
View file

@ -0,0 +1,3 @@
#define _UNICODE 1
#define UNICODE 1
#include "dirent.c"