Merge pull request #2134 from kleisauke/cleanup-configure

Cleanup configure.ac and #ifdef's
This commit is contained in:
John Cupitt 2021-03-07 11:29:47 +00:00 committed by GitHub
commit ab4dd00fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 161 additions and 282 deletions

View File

@ -141,69 +141,35 @@ AM_CONDITIONAL(ENABLE_DEPRECATED, [test x"$enable_deprecated" = x"yes"])
# this gets pasted into version.h as a #define
AC_SUBST(VIPS_ENABLE_DEPRECATED)
AC_MSG_CHECKING([for native Win32])
case "$host" in
*-*-mingw*)
vips_os_win32=yes
;;
*)
vips_os_win32=no
;;
esac
AC_MSG_RESULT([$vips_os_win32])
if test x"$vips_os_win32" = x"yes"; then
AC_DEFINE(OS_WIN32,1,[native win32])
# makes gcc use win native alignment
VIPS_CFLAGS="-mms-bitfields $VIPS_CFLAGS"
fi
# CImg needs flags changed on win32
AM_CONDITIONAL(OS_WIN32, [test x"$vips_os_win32" = x"yes"])
# Cygwin/mingw need binary open to avoid CR/LF madness
# ... should be a better way to test for this
AC_MSG_CHECKING([for binary open needed])
AC_MSG_CHECKING([for -mms-bitfields support])
case "$host_os" in
cygwin* | mingw*)
vips_binary_open=yes
mingw*)
# makes gcc use win native alignment
# GCC >= 4.7 and Clang >= 11 does this automatically, see:
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1510#note_841637
VIPS_CFLAGS="-mms-bitfields $VIPS_CFLAGS"
AC_MSG_RESULT([yes])
;;
*)
vips_binary_open=no
AC_MSG_RESULT([no])
;;
esac
AC_MSG_RESULT([$vips_binary_open])
if test x"$vips_binary_open" = x"yes"; then
AC_DEFINE(BINARY_OPEN,1,[define to open non-text files in binary mode])
fi
AC_MSG_CHECKING([for Mac OS X])
case "$host" in
*-*-darwin*)
vips_os_darwin=yes
;;
*)
vips_os_darwin=no
;;
esac
AC_MSG_RESULT([$vips_os_darwin])
if test x"$vips_os_darwin" = x"yes"; then
AC_DEFINE(VIPS_OS_DARWIN,1,[native Mac OS X])
fi
# set the default directory for ICC profiles
if test x"$vips_os_darwin" = x"yes"; then
profile_dir="/Library/ColorSync/Profiles"
elif test x"$vips_os_win32" = x"yes"; then
# need double escapes since this will get pasted into a #define in a C
# header ... the C:\Windows is usually overrwritten with the result of
# GetWindowsDirectoryW()
profile_dir="C:\\\\Windows\\\\System32\\\\spool\\\\drivers\\\\color"
else
profile_dir="/usr/share/color/icc"
fi
case "$host_os" in
darwin*)
profile_dir="/Library/ColorSync/Profiles"
;;
mingw*)
# need double escapes since this will get pasted into a #define in a C
# header ... the C:\Windows is usually overwritten with the result of
# GetWindowsDirectoryW()
profile_dir="C:\\\\Windows\\\\System32\\\\spool\\\\drivers\\\\color"
;;
*)
profile_dir="/usr/share/color/icc"
;;
esac
AC_DEFINE_UNQUOTED(VIPS_ICC_DIR,"$profile_dir",[default directory for ICC profiles])
# we want largefile support, if possible
@ -447,8 +413,8 @@ PKG_CHECK_MODULES(DATE_TIME_FORMAT_ISO8601, glib-2.0 >= 2.62,
# thread by default
save_pthread_LIBS="$LIBS"
save_pthread_CFLAGS="$CFLAGS"
LIBS="$LIBS $GTHREAD_LIBS"
CFLAGS="$CFLAGS $GTHREAD_CFLAGS"
LIBS="$LIBS $REQUIRED_LIBS"
CFLAGS="$CFLAGS $REQUIRED_CFLAGS"
AC_CHECK_FUNC(pthread_setattr_default_np,
[AC_DEFINE(HAVE_PTHREAD_DEFAULT_NP,1,[have pthread_setattr_default_np().])
]
@ -456,11 +422,6 @@ AC_CHECK_FUNC(pthread_setattr_default_np,
LIBS="$save_pthread_LIBS"
CFLAGS="$save_pthread_CFLAGS"
if test x"$vips_os_win32" = x"yes"; then
AC_DEFINE(HAVE_G_WIN32_GET_COMMAND_LINE,1,[define if your glib has g_win32_get_command_line().])
have_g_win32_get_command_line=yes
fi
# from 2.48 we have g_uint_checked_mul() etc.
PKG_CHECK_MODULES(HAVE_CHECKED_MUL, glib-2.0 >= 2.48,
[AC_DEFINE(HAVE_CHECKED_MUL,1,[define if your glib has checked multiply.])
@ -1231,13 +1192,13 @@ if test x"$LIB_FUZZING_ENGINE" = x; then
fi
# Gather all up for VIPS_CFLAGS, VIPS_INCLUDES, VIPS_LIBS
VIPS_CFLAGS="$VIPS_CFLAGS $GTHREAD_CFLAGS $GIO_CFLAGS $REQUIRED_CFLAGS $EXPAT_CFLAGS $ZLIB_CFLAGS $PANGOFT2_CFLAGS $GSF_CFLAGS $FFTW_CFLAGS $MAGICK_CFLAGS $JPEG_CFLAGS $SPNG_CFLAGS $PNG_CFLAGS $IMAGEQUANT_CFLAGS $EXIF_CFLAGS $MATIO_CFLAGS $CFITSIO_CFLAGS $LIBWEBP_CFLAGS $LIBWEBPMUX_CFLAGS $GIFLIB_INCLUDES $RSVG_CFLAGS $PDFIUM_CFLAGS $POPPLER_CFLAGS $OPENEXR_CFLAGS $OPENSLIDE_CFLAGS $ORC_CFLAGS $TIFF_CFLAGS $LCMS_CFLAGS $HEIF_CFLAGS" VIPS_CFLAGS="$VIPS_DEBUG_FLAGS $VIPS_CFLAGS"
VIPS_CFLAGS="$VIPS_CFLAGS $GIO_CFLAGS $REQUIRED_CFLAGS $EXPAT_CFLAGS $ZLIB_CFLAGS $PANGOFT2_CFLAGS $GSF_CFLAGS $FFTW_CFLAGS $MAGICK_CFLAGS $JPEG_CFLAGS $SPNG_CFLAGS $PNG_CFLAGS $IMAGEQUANT_CFLAGS $EXIF_CFLAGS $MATIO_CFLAGS $CFITSIO_CFLAGS $LIBWEBP_CFLAGS $GIFLIB_INCLUDES $RSVG_CFLAGS $PDFIUM_CFLAGS $POPPLER_CFLAGS $OPENEXR_CFLAGS $OPENSLIDE_CFLAGS $ORC_CFLAGS $TIFF_CFLAGS $LCMS_CFLAGS $HEIF_CFLAGS" VIPS_CFLAGS="$VIPS_DEBUG_FLAGS $VIPS_CFLAGS"
VIPS_INCLUDES="$ZLIB_INCLUDES $PNG_INCLUDES $TIFF_INCLUDES $JPEG_INCLUDES $NIFTI_INCLUDES"
VIPS_LIBS="$ZLIB_LIBS $HEIF_LIBS $MAGICK_LIBS $SPNG_LIBS $PNG_LIBS $IMAGEQUANT_LIBS $TIFF_LIBS $JPEG_LIBS $GTHREAD_LIBS $GIO_LIBS $REQUIRED_LIBS $EXPAT_LIBS $PANGOFT2_LIBS $GSF_LIBS $FFTW_LIBS $ORC_LIBS $LCMS_LIBS $GIFLIB_LIBS $RSVG_LIBS $NIFTI_LIBS $PDFIUM_LIBS $POPPLER_LIBS $OPENEXR_LIBS $OPENSLIDE_LIBS $CFITSIO_LIBS $LIBWEBP_LIBS $LIBWEBPMUX_LIBS $MATIO_LIBS $EXIF_LIBS -lm"
VIPS_LIBS="$ZLIB_LIBS $HEIF_LIBS $MAGICK_LIBS $SPNG_LIBS $PNG_LIBS $IMAGEQUANT_LIBS $TIFF_LIBS $JPEG_LIBS $GIO_LIBS $REQUIRED_LIBS $EXPAT_LIBS $PANGOFT2_LIBS $GSF_LIBS $FFTW_LIBS $ORC_LIBS $LCMS_LIBS $GIFLIB_LIBS $RSVG_LIBS $NIFTI_LIBS $PDFIUM_LIBS $POPPLER_LIBS $OPENEXR_LIBS $OPENSLIDE_LIBS $CFITSIO_LIBS $LIBWEBP_LIBS $MATIO_LIBS $EXIF_LIBS -lm"
# autoconf hates multi-line AC_SUBST so we have to have another copy of this
# thing
VIPS_CONFIG="native win32: $vips_os_win32, native OS X: $vips_os_darwin, open files in binary mode: $vips_binary_open, enable debug: $enable_debug, enable deprecated library components: $enable_deprecated, enable docs with gtkdoc: $enable_gtk_doc, gobject introspection: $found_introspection, enable radiance support: $with_radiance, enable analyze support: $with_analyze, enable PPM support: $with_ppm, generate C++ docs: $with_doxygen, use fftw3 for FFT: $with_fftw, Magick package: $with_magickpackage, Magick API version: $magick_version, load with libMagick: $enable_magickload, save with libMagick: $enable_magicksave, accelerate loops with orc: $with_orc, ICC profile support with lcms: $with_lcms, file import with niftiio: $with_nifti, file import with libheif: $with_heif, file import with OpenEXR: $with_OpenEXR, file import with OpenSlide: $with_openslide, file import with matio: $with_matio, PDF import with PDFium: $with_pdfium, PDF import with poppler-glib: $with_poppler, SVG import with librsvg-2.0: $with_rsvg, zlib: $with_zlib, file import with cfitsio: $with_cfitsio, file import/export with libwebp: $with_libwebp, text rendering with pangoft2: $with_pangoft2, file import/export with libspng: $with_libspng, file import/export with libpng: $with_png, support 8bpp PNG quantisation: $with_imagequant, file import/export with libtiff: $with_tiff, file import/export with giflib: $with_giflib, file import/export with libjpeg: $with_jpeg, image pyramid export: $with_gsf, use libexif to load/save JPEG metadata: $with_libexif"
VIPS_CONFIG="enable debug: $enable_debug, enable deprecated library components: $enable_deprecated, enable docs with gtkdoc: $enable_gtk_doc, gobject introspection: $found_introspection, enable radiance support: $with_radiance, enable analyze support: $with_analyze, enable PPM support: $with_ppm, generate C++ docs: $with_doxygen, use fftw3 for FFT: $with_fftw, Magick package: $with_magickpackage, Magick API version: $magick_version, load with libMagick: $enable_magickload, save with libMagick: $enable_magicksave, accelerate loops with orc: $with_orc, ICC profile support with lcms: $with_lcms, file import with niftiio: $with_nifti, file import with libheif: $with_heif, file import with OpenEXR: $with_OpenEXR, file import with OpenSlide: $with_openslide, file import with matio: $with_matio, PDF import with PDFium: $with_pdfium, PDF import with poppler-glib: $with_poppler, SVG import with librsvg-2.0: $with_rsvg, zlib: $with_zlib, file import with cfitsio: $with_cfitsio, file import/export with libwebp: $with_libwebp, text rendering with pangoft2: $with_pangoft2, file import/export with libspng: $with_libspng, file import/export with libpng: $with_png, support 8bpp PNG quantisation: $with_imagequant, file import/export with libtiff: $with_tiff, file import/export with giflib: $with_giflib, file import/export with libjpeg: $with_jpeg, image pyramid export: $with_gsf, use libexif to load/save JPEG metadata: $with_libexif"
AC_SUBST(VIPS_LIBDIR)
@ -1301,9 +1262,6 @@ AC_OUTPUT
# also add any new items to VIPS_CONFIG above
AC_MSG_RESULT([dnl
* build options
native win32: $vips_os_win32
native OS X: $vips_os_darwin
open files in binary mode: $vips_binary_open
enable debug: $enable_debug
enable deprecated library components: $enable_deprecated
enable docs with gtkdoc: $enable_gtk_doc
@ -1351,11 +1309,3 @@ image pyramid export: $with_gsf
(requires libgsf-1 1.14.26 or later)
use libexif to load/save JPEG metadata: $with_libexif
])
if test x"$vips_os_win32" = x"yes"; then
if test x"$have_g_win32_get_command_line" != x"yes"; then
AC_MSG_RESULT([dnl
Your glib is too old, vips will not support unicode command-line arguments.
])
fi
fi

View File

@ -104,7 +104,7 @@ vips__tiff_openout( const char *path, gboolean bigtiff )
/* Need the utf-16 version on Windows.
*/
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
GError *error = NULL;
wchar_t *path16;
@ -119,9 +119,9 @@ vips__tiff_openout( const char *path, gboolean bigtiff )
g_free( path16 );
}
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
tif = TIFFOpen( path, mode );
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
if( !tif ) {
vips_error( "tiff",

View File

@ -365,7 +365,6 @@ int vips_object_get_argument_priority( VipsObject *object, const char *name );
VIPS_ARGUMENT_COLLECT_END
*/
#if GLIB_CHECK_VERSION( 2, 24, 0 )
#define VIPS_ARGUMENT_COLLECT_SET( PSPEC, ARG_CLASS, AP ) \
if( (ARG_CLASS->flags & VIPS_ARGUMENT_INPUT) ) { \
GValue value = { 0, }; \
@ -383,25 +382,6 @@ int vips_object_get_argument_priority( VipsObject *object, const char *name );
VIPS_DEBUG_MSG( "VIPS_OBJECT_COLLECT_SET: err\n" ); \
g_free( error ); \
}
#else
#define VIPS_ARGUMENT_COLLECT_SET( PSPEC, ARG_CLASS, AP ) \
if( (ARG_CLASS->flags & VIPS_ARGUMENT_INPUT) ) { \
GValue value = { 0, }; \
gchar *error = NULL; \
\
/* Input args are given inline, eg. ("factor", 12.0) \
* and must be collected. \
*/ \
g_value_init( &value, G_PARAM_SPEC_VALUE_TYPE( PSPEC ) ); \
G_VALUE_COLLECT( &value, AP, 0, &error ); \
\
/* Don't bother with the error message. \
*/ \
if( error ) { \
VIPS_DEBUG_MSG( "VIPS_OBJECT_COLLECT_SET: err\n" ); \
g_free( error ); \
}
#endif
#define VIPS_ARGUMENT_COLLECT_GET( PSPEC, ARG_CLASS, AP ) \
g_value_unset( &value ); \

View File

@ -65,10 +65,10 @@
#include <vips/thread.h>
#include <vips/debug.h>
#ifdef OS_WIN32
#ifdef G_OS_WIN32
#include <windows.h>
#include <lmerr.h>
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
/**
* SECTION: errors
@ -294,7 +294,7 @@ vips_verror_system( int err, const char *domain, const char *fmt, va_list ap )
{
vips_verror( domain, fmt, ap );
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
char *buf;
@ -310,7 +310,7 @@ vips_verror_system( int err, const char *domain, const char *fmt, va_list ap )
LocalFree( buf );
}
}
#else /*OS_WIN32*/
#else /*!G_OS_WIN32*/
{
char *buf;
@ -318,7 +318,7 @@ vips_verror_system( int err, const char *domain, const char *fmt, va_list ap )
vips_error( _( "unix error" ), "%s", buf );
g_free( buf );
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
}
/**

View File

@ -1676,14 +1676,7 @@ vips_image_temp_name( char *name, int size )
{
static int global_serial = 0;
/* Old glibs named this differently.
*/
int serial =
#if GLIB_CHECK_VERSION( 2, 30, 0 )
g_atomic_int_add( &global_serial, 1 );
#else
g_atomic_int_exchange_and_add( &global_serial, 1 );
#endif
int serial = g_atomic_int_add( &global_serial, 1 );
vips_snprintf( name, size, "temp-%d", serial );
}

View File

@ -290,24 +290,6 @@ empty_log_handler( const gchar *log_domain, GLogLevelFlags log_level,
{
}
#if !GLIB_CHECK_VERSION( 2, 31, 0 )
static void
default_log_handler( const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer user_data )
{
if( log_level & (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO) ) {
const char *domains = g_getenv( "G_MESSAGES_DEBUG" );
if( !domains ||
(!g_str_equal( domains, "all" ) &&
!g_strrstr( domains, log_domain )) )
return;
}
g_log_default_handler( log_domain, log_level, message, user_data );
}
#endif /*!GLIB_CHECK_VERSION( 2, 31, 0 )*/
/* Attempt to set a minimum stacksize. This can be important on systems with a
* very low default, like musl.
*/
@ -407,7 +389,7 @@ vips_init( const char *argv0 )
return( 0 );
started = TRUE;
#ifdef OS_WIN32
#ifdef G_OS_WIN32
/* Windows has a limit of 512 files open at once for the fopen() family
* of functions, and 2048 for the _open() family. This raises the limit
* of fopen() to the same level as _open().
@ -415,7 +397,7 @@ vips_init( const char *argv0 )
* It will not go any higher than this, unfortunately.
*/
(void) _setmaxstdio( 2048 );
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
vips__threadpool_init();
vips__buffer_init();
@ -595,18 +577,6 @@ vips_init( const char *argv0 )
g_log_set_handler( G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
empty_log_handler, NULL );
#if !GLIB_CHECK_VERSION( 2, 31, 0 )
/* Older glibs can sometimes show G_LOG_LEVEL_{INFO,DEBUG} messages.
* Block them ourselves. We test the env var inside the handler since
* vips_verbose() can be toggled at runtime.
*
* Again, we should not call g_log_set_handler(), but this is the only
* convenient way to fix this behaviour.
*/
g_log_set_handler( G_LOG_DOMAIN, G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG,
default_log_handler, NULL );
#endif /*!GLIB_CHECK_VERSION( 2, 31, 0 )*/
/* Set a minimum stacksize, if we can.
*/
if( (vips_min_stack_size = g_getenv( "VIPS_MIN_STACK_SIZE" )) )
@ -1057,7 +1027,7 @@ find_file( const char *name )
printf( "vips_guess_prefix: g_getenv( \"PATH\" ) == \"%s\"\n", path );
#endif /*DEBUG*/
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
char *dir;
@ -1068,9 +1038,9 @@ find_file( const char *name )
"%s" G_SEARCHPATH_SEPARATOR_S "%s", dir, path );
g_free( dir );
}
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
vips_strncpy( full_path, path, VIPS_PATH_MAX );
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
if( (prefix = scan_path( full_path, name )) )
return( prefix );
@ -1177,9 +1147,9 @@ vips_guess_prefix( const char *argv0, const char *env_name )
return( prefix );
}
#ifdef OS_WIN32
#ifdef G_OS_WIN32
prefix = vips__windows_prefix();
#else
#else /*!G_OS_WIN32*/
{
char *basename;
@ -1187,7 +1157,7 @@ vips_guess_prefix( const char *argv0, const char *env_name )
prefix = guess_prefix( argv0, basename );
g_free( basename );
}
#endif
#endif /*G_OS_WIN32*/
g_setenv( env_name, prefix, TRUE );

View File

@ -77,18 +77,16 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /*HAVE_UNISTD_H*/
#ifdef OS_WIN32
#ifndef S_ISREG
#define S_ISREG(m) (!!(m & _S_IFREG))
#endif
#endif /*OS_WIN32*/
#include <vips/vips.h>
#ifdef OS_WIN32
#ifdef G_OS_WIN32
#ifndef S_ISREG
#define S_ISREG(m) (!!(m & _S_IFREG))
#endif
#include <windows.h>
#include <io.h>
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
/* Does this fd support mmap. Pipes won't, for example.
*/
@ -99,7 +97,7 @@ vips__mmap_supported( int fd )
size_t length = 4096;
off_t offset = 0;
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
HANDLE hFile = (HANDLE) _get_osfhandle( fd );
@ -128,7 +126,7 @@ vips__mmap_supported( int fd )
CloseHandle( hMMFile );
UnmapViewOfFile( baseaddr );
}
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
{
int prot = PROT_READ;
int flags = MAP_SHARED;
@ -138,7 +136,7 @@ vips__mmap_supported( int fd )
return( FALSE );
munmap( baseaddr, length );
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
return( TRUE );
}
@ -153,7 +151,7 @@ vips__mmap( int fd, int writeable, size_t length, gint64 offset )
length, offset );
#endif /*DEBUG*/
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
HANDLE hFile = (HANDLE) _get_osfhandle( fd );
@ -203,7 +201,7 @@ vips__mmap( int fd, int writeable, size_t length, gint64 offset )
*/
CloseHandle( hMMFile );
}
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
{
int prot;
int flags;
@ -237,7 +235,7 @@ vips__mmap( int fd, int writeable, size_t length, gint64 offset )
return( NULL );
}
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
return( baseaddr );
}
@ -245,19 +243,19 @@ vips__mmap( int fd, int writeable, size_t length, gint64 offset )
int
vips__munmap( const void *start, size_t length )
{
#ifdef OS_WIN32
#ifdef G_OS_WIN32
if( !UnmapViewOfFile( (void *) start ) ) {
vips_error_system( GetLastError(), "vips_mapfile",
"%s", _( "unable to UnmapViewOfFile" ) );
return( -1 );
}
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
if( munmap( (void *) start, length ) < 0 ) {
vips_error_system( errno, "vips_mapfile",
"%s", _( "unable to munmap file" ) );
return( -1 );
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
return( 0 );
}
@ -345,7 +343,7 @@ vips_remapfilerw( VipsImage *image )
printf( "vips_remapfilerw:\n" );
#endif /*DEBUG*/
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
HANDLE hFile = (HANDLE) _get_osfhandle( image->fd );
HANDLE hMMFile;
@ -377,7 +375,7 @@ vips_remapfilerw( VipsImage *image )
*/
CloseHandle( hMMFile );
}
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
{
assert( image->dtype == VIPS_IMAGE_MMAPIN );
@ -390,7 +388,7 @@ vips_remapfilerw( VipsImage *image )
return( -1 );
}
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
image->dtype = VIPS_IMAGE_MMAPINRW;

View File

@ -65,23 +65,24 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef OS_WIN32
#include <io.h>
#endif /*OS_WIN32*/
#include <vips/vips.h>
#include <vips/internal.h>
#include <vips/debug.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif /*G_OS_WIN32*/
/* Try to make an O_BINARY ... sometimes need the leading '_'.
*/
#ifdef BINARY_OPEN
#ifdef G_PLATFORM_WIN32
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#endif /*_O_BINARY*/
#endif /*!O_BINARY*/
#endif /*BINARY_OPEN*/
#endif /*G_PLATFORM_WIN32*/
/* If we have O_BINARY, add it to a mode flags set.
*/
@ -307,12 +308,12 @@ vips_source_build( VipsObject *object )
connection->descriptor = dup( connection->descriptor );
connection->close_descriptor = connection->descriptor;
#ifdef OS_WIN32
#ifdef G_OS_WIN32
/* Windows will create eg. stdin and stdout in text mode.
* We always read in binary mode.
*/
_setmode( connection->descriptor, _O_BINARY );
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
}
if( vips_object_argument_isset( object, "blob" ) ) {

View File

@ -55,23 +55,24 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef OS_WIN32
#include <io.h>
#endif /*OS_WIN32*/
#include <vips/vips.h>
#include <vips/internal.h>
#include <vips/debug.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif /*G_OS_WIN32*/
/* Try to make an O_BINARY ... sometimes need the leading '_'.
*/
#ifdef BINARY_OPEN
#ifdef G_PLATFORM_WIN32
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#endif /*_O_BINARY*/
#endif /*!O_BINARY*/
#endif /*BINARY_OPEN*/
#endif /*G_PLATFORM_WIN32*/
/* If we have O_BINARY, add it to a mode flags set.
*/
@ -143,12 +144,12 @@ vips_target_build( VipsObject *object )
connection->descriptor = dup( connection->descriptor );
connection->close_descriptor = connection->descriptor;
#ifdef OS_WIN32
#ifdef G_OS_WIN32
/* Windows will create eg. stdin and stdout in text mode.
* We always write in binary mode.
*/
_setmode( connection->descriptor, _O_BINARY );
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
}
else if( target->memory )
target->memory_buffer = g_byte_array_new();

View File

@ -75,9 +75,9 @@
#include <vips/thread.h>
#include <vips/debug.h>
#ifdef OS_WIN32
#ifdef G_OS_WIN32
#include <windows.h>
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
/**
* SECTION: threadpool
@ -338,7 +338,7 @@ get_num_processors( void )
#endif /*G_OS_UNIX*/
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
/* Count the CPUs currently available to this process.
*/
@ -365,7 +365,7 @@ get_num_processors( void )
nproc = af_count;
}
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
return( nproc );
#endif /*!GLIB_CHECK_VERSION( 2, 48, 1 )*/

View File

@ -53,27 +53,27 @@
#endif /*HAVE_IO_H*/
#include <fcntl.h>
#ifdef OS_WIN32
#include <windows.h>
#endif /*OS_WIN32*/
#include <vips/vips.h>
#include <vips/debug.h>
#include <vips/internal.h>
#ifdef G_OS_WIN32
#include <windows.h>
#endif /*G_OS_WIN32*/
/* Temp buffer for snprintf() layer on old systems.
*/
#define MAX_BUF (100000)
/* Try to make an O_BINARY ... sometimes need the leading '_'.
*/
#ifdef BINARY_OPEN
#ifdef G_PLATFORM_WIN32
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#endif /*_O_BINARY*/
#endif /*!O_BINARY*/
#endif /*BINARY_OPEN*/
#endif /*G_PLATFORM_WIN32*/
/* If we have O_BINARY, add it to a mode flags set.
*/
@ -562,15 +562,15 @@ vips_filename_suffix_match( const char *path, const char *suffixes[] )
gint64
vips_file_length( int fd )
{
#ifdef OS_WIN32
#ifdef G_OS_WIN32
struct _stati64 st;
if( _fstati64( fd, &st ) == -1 ) {
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
struct stat st;
if( fstat( fd, &st ) == -1 ) {
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
vips_error_system( errno, "vips_file_length",
"%s", _( "unable to get file stats" ) );
return( -1 );
@ -600,7 +600,7 @@ vips__write( int fd, const void *buf, size_t count )
return( 0 );
}
#ifdef OS_WIN32
#ifdef G_OS_WIN32
/* Set the create date on a file. On Windows, the create date may be copied
* over from an existing file of the same name, unless you reset it.
*
@ -619,7 +619,7 @@ vips__set_create_time( int fd )
SystemTimeToFileTime( &st, &ft );
SetFileTime( handle, &ft, &ft, &ft );
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
/* open() with a utf8 filename, setting errno.
*/
@ -638,10 +638,10 @@ vips__open( const char *filename, int flags, int mode )
fd = g_open( filename, flags, mode );
#ifdef OS_WIN32
#ifdef G_OS_WIN32
if( mode & O_CREAT )
vips__set_create_time( fd );
#endif
#endif /*G_OS_WIN32*/
return( fd );
}
@ -661,10 +661,10 @@ vips__fopen( const char *filename, const char *mode )
fp = g_fopen( filename, mode );
#ifdef OS_WIN32
#ifdef G_OS_WIN32
if( mode[0] == 'w' )
vips__set_create_time( _fileno( fp ) );
#endif
#endif /*G_OS_WIN32*/
return( fp );
}
@ -698,14 +698,14 @@ vips__file_open_read( const char *filename, const char *fallback_dir,
char *mode;
FILE *fp;
#ifdef BINARY_OPEN
#ifdef G_PLATFORM_WIN32
if( text_mode )
mode = "r";
else
mode = "rb";
#else /*BINARY_OPEN*/
#else /*!G_PLATFORM_WIN32*/
mode = "r";
#endif /*BINARY_OPEN*/
#endif /*G_PLATFORM_WIN32*/
if( (fp = vips__fopen( filename, mode )) )
return( fp );
@ -734,14 +734,14 @@ vips__file_open_write( const char *filename, gboolean text_mode )
char *mode;
FILE *fp;
#ifdef BINARY_OPEN
#ifdef G_PLATFORM_WIN32
if( text_mode )
mode = "w";
else
mode = "wb";
#else /*BINARY_OPEN*/
#else /*!G_PLATFORM_WIN32*/
mode = "w";
#endif /*BINARY_OPEN*/
#endif /*G_PLATFORM_WIN32*/
if( !(fp = vips__fopen( filename, mode )) ) {
vips_error_system( errno, "vips__file_open_write",
@ -1089,15 +1089,15 @@ vips__seek_no_error( int fd, gint64 pos, int whence )
{
gint64 new_pos;
#ifdef OS_WIN32
#ifdef G_OS_WIN32
new_pos = _lseeki64( fd, pos, whence );
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
/* On error, eg. opening a directory and seeking to the end, lseek()
* on linux seems to return 9223372036854775807 ((1 << 63) - 1)
* rather than (off_t) -1 for reasons I don't understand.
*/
new_pos = lseek( fd, pos, whence );
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
return( new_pos );
}
@ -1128,7 +1128,7 @@ vips__seek( int fd, gint64 pos, int whence )
int
vips__ftruncate( int fd, gint64 pos )
{
#ifdef OS_WIN32
#ifdef G_OS_WIN32
{
HANDLE hFile = (HANDLE) _get_osfhandle( fd );
@ -1140,13 +1140,13 @@ vips__ftruncate( int fd, gint64 pos )
return( -1 );
}
}
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
if( ftruncate( fd, pos ) ) {
vips_error_system( errno, "vips__ftruncate",
"%s", _( "unable to truncate" ) );
return( -1 );
}
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
return( 0 );
}
@ -1620,7 +1620,7 @@ vips__temp_dir( void )
const char *tmpd;
if( !(tmpd = g_getenv( "TMPDIR" )) ) {
#ifdef OS_WIN32
#ifdef G_OS_WIN32
static gboolean done = FALSE;
static char buf[256];
@ -1629,9 +1629,9 @@ vips__temp_dir( void )
strcpy( buf, "C:\\temp" );
}
tmpd = buf;
#else /*!OS_WIN32*/
#else /*!G_OS_WIN32*/
tmpd = "/tmp";
#endif /*!OS_WIN32*/
#endif /*!G_OS_WIN32*/
}
return( tmpd );
@ -1651,14 +1651,7 @@ vips__temp_name( const char *format )
char file2[FILENAME_MAX];
char *name;
/* Old glibs named this differently.
*/
int serial =
#if GLIB_CHECK_VERSION( 2, 30, 0 )
g_atomic_int_add( &global_serial, 1 );
#else
g_atomic_int_exchange_and_add( &global_serial, 1 );
#endif
int serial = g_atomic_int_add( &global_serial, 1 );
vips_snprintf( file, FILENAME_MAX, "vips-%d-%u",
serial, g_random_int() );
@ -1961,7 +1954,7 @@ vips__random_add( guint32 seed, int value )
static void *
vips_icc_dir_once( void *null )
{
#ifdef OS_WIN32
#ifdef G_OS_WIN32
/* From glib get_windows_directory_root()
*/
wchar_t wwindowsdir[MAX_PATH];
@ -1983,7 +1976,7 @@ vips_icc_dir_once( void *null )
return( (void *) full_path );
}
}
#endif
#endif /*G_OS_WIN32*/
return( (void *) VIPS_ICC_DIR );
}
@ -1997,7 +1990,7 @@ vips__icc_dir( void )
vips_icc_dir_once, NULL ) );
}
#ifdef OS_WIN32
#ifdef G_OS_WIN32
static HMODULE vips__dll = NULL;
#ifdef DLL_EXPORT
BOOL WINAPI
@ -2009,19 +2002,19 @@ DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
return( TRUE );
}
#endif
#endif
#endif /*G_OS_WIN32*/
static void *
vips__windows_prefix_once( void *null )
{
char *prefix;
#ifdef OS_WIN32
#ifdef G_OS_WIN32
prefix = g_win32_get_package_installation_directory_of_module(
vips__dll );
#else
#else /*!G_OS_WIN32*/
prefix = (char *) g_getenv( "VIPSHOME" );
#endif
#endif /*G_OS_WIN32*/
return( (void *) prefix );
}

View File

@ -115,13 +115,13 @@
/* Try to make an O_BINARY ... sometimes need the leading '_'.
*/
#ifdef BINARY_OPEN
#ifdef G_PLATFORM_WIN32
#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY _O_BINARY
#endif /*_O_BINARY*/
#endif /*!O_BINARY*/
#endif /*BINARY_OPEN*/
#endif /*G_PLATFORM_WIN32*/
/* If we have O_BINARY, add it to a mode flags set.
*/

View File

@ -58,9 +58,9 @@
#include <vips/internal.h>
#include <vips/thread.h>
#ifdef OS_WIN32
#ifdef G_OS_WIN32
#include <windows.h>
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
/* Sanity checking ... write to this during read tests to make sure we don't
* get optimized out.
@ -189,15 +189,15 @@ vips_getpagesize( void )
static int pagesize = 0;
if( !pagesize ) {
#ifdef OS_WIN32
#ifdef G_OS_WIN32
SYSTEM_INFO si;
GetSystemInfo( &si );
pagesize = si.dwAllocationGranularity;
#else /*OS_WIN32*/
#else /*!G_OS_WIN32*/
pagesize = getpagesize();
#endif /*OS_WIN32*/
#endif /*G_OS_WIN32*/
#ifdef DEBUG_TOTAL
printf( "vips_getpagesize: 0x%x\n", pagesize );

View File

@ -1123,16 +1123,9 @@ vips__add_mosaic_name( VipsImage *image )
{
static int global_serial = 0;
/* Old glibs named this differently.
*
* TODO(kleisauke): Could we call vips_image_temp_name instead?
/* TODO(kleisauke): Could we call vips_image_temp_name instead?
*/
int serial =
#if GLIB_CHECK_VERSION( 2, 30, 0 )
g_atomic_int_add( &global_serial, 1 );
#else
g_atomic_int_exchange_and_add( &global_serial, 1 );
#endif
int serial = g_atomic_int_add( &global_serial, 1 );
char name[256];

View File

@ -101,9 +101,9 @@
#include <vips/vips7compat.h>
#endif
#ifdef OS_WIN32
#ifdef G_OS_WIN32
#define strcasecmp(a,b) _stricmp(a,b)
#endif
#endif /*G_OS_WIN32*/
static char *main_option_plugin = NULL;
static gboolean main_option_version;
@ -458,11 +458,11 @@ parse_options( GOptionContext *context, int *argc, char **argv )
"OPER", _( "execute vips operation OPER" ) );
g_option_context_set_summary( context, vips_buf_all( &buf ) );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
#else /*!G_OS_WIN32*/
if( !g_option_context_parse( context, argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
@ -531,9 +531,9 @@ main( int argc, char **argv )
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
#ifdef DEBUG_FATAL
/* Set masks for debugging ... stop on any problem.
@ -582,11 +582,11 @@ main( int argc, char **argv )
*/
g_option_context_set_help_enabled( context, FALSE );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
#else /*!G_OS_WIN32*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
@ -753,9 +753,9 @@ main( int argc, char **argv )
g_option_context_free( context );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
vips_shutdown();

View File

@ -141,9 +141,9 @@ main( int argc, char **argv )
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
context = g_option_context_new(
_( "vipsedit - edit vips file header" ) );
@ -153,11 +153,11 @@ main( int argc, char **argv )
g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE );
g_option_context_set_main_group( context, main_group );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
#else /*!G_OS_WIN32*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
{
vips_g_error( &error );
@ -272,9 +272,9 @@ main( int argc, char **argv )
g_option_context_free( context );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
vips_shutdown();

View File

@ -180,9 +180,9 @@ main( int argc, char *argv[] )
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
context = g_option_context_new( _( "- print image header" ) );
main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL );
@ -191,11 +191,11 @@ main( int argc, char *argv[] )
g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE );
g_option_context_set_main_group( context, main_group );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
#else /*!G_OS_WIN32*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
@ -247,9 +247,9 @@ main( int argc, char *argv[] )
/* We don't free this on error exit, sadly.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
vips_shutdown();

View File

@ -500,9 +500,9 @@ main( int argc, char **argv )
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
argv = g_win32_get_command_line();
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
context = g_option_context_new( _( "- thumbnail generator" ) );
@ -512,11 +512,11 @@ main( int argc, char **argv )
g_option_group_set_translation_domain( main_group, GETTEXT_PACKAGE );
g_option_context_set_main_group( context, main_group );
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
if( !g_option_context_parse_strv( context, &argv, &error ) )
#else /*!HAVE_G_WIN32_GET_COMMAND_LINE*/
#else /*!G_OS_WIN32*/
if( !g_option_context_parse( context, &argc, &argv, &error ) )
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
{
if( error ) {
fprintf( stderr, "%s\n", error->message );
@ -563,9 +563,9 @@ main( int argc, char **argv )
/* We don't free this on error exit, sadly.
*/
#ifdef HAVE_G_WIN32_GET_COMMAND_LINE
#ifdef G_OS_WIN32
g_strfreev( argv );
#endif /*HAVE_G_WIN32_GET_COMMAND_LINE*/
#endif /*G_OS_WIN32*/
vips_shutdown();