diff --git a/Makefile.am b/Makefile.am index 566253316..547dbeca1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -773,6 +773,7 @@ libneighbor_a_SOURCES = \ src/neighbor/NeighborPlugin.hxx libneighbor_a_CPPFLAGS = $(AM_CPPFLAGS) \ + $(UPNP_CFLAGS) \ $(SMBCLIENT_CFLAGS) if ENABLE_SMBCLIENT @@ -822,6 +823,8 @@ libdb_plugins_a_SOURCES = \ src/db/plugins/simple/PrefixedLightSong.hxx \ src/db/plugins/simple/SimpleDatabasePlugin.cxx \ src/db/plugins/simple/SimpleDatabasePlugin.hxx +libdb_plugins_a_CPPFLAGS = $(AM_CPPFLAGS) \ + $(UPNP_CFLAGS) if ENABLE_LIBMPDCLIENT libdb_plugins_a_SOURCES += \ @@ -2422,6 +2425,7 @@ EXTRA_DIST = $(doc_DATA) autogen.sh \ $(man_MANS) $(DOCBOOK_FILES) doc/mpdconf.example doc/doxygen.conf \ $(wildcard $(srcdir)/doc/include/*.xml) \ systemd/system/mpd.socket \ + $(wildcard $(srcdir)/python/build/*.py) \ android/AndroidManifest.xml \ android/build.py \ android/custom_rules.xml \ @@ -2429,5 +2433,6 @@ EXTRA_DIST = $(doc_DATA) autogen.sh \ android/src/Bridge.java \ android/src/Loader.java \ android/src/Main.java \ + win32/build.py \ win32/res/mpd.rc.in win32/res/mpd.ico \ src/haiku/App_MusicPD diff --git a/NEWS b/NEWS index 73033f310..8863ae8ab 100644 --- a/NEWS +++ b/NEWS @@ -16,11 +16,15 @@ ver 0.21 (not yet released) - sndio: new mixer plugin ver 0.20.13 (not yet released) +* output + - osx: set up ring buffer to hold at least 100ms * database - simple: don't purge mount points on update/rescan - simple: fix "mount" bug caused by bad compiler optimization - upnp: work around libupnp 1.6.24 API breakage * queue: fix spuriously misplaced prioritized songs +* include Windows cross-build script in source tarball +* fix Windows build failures ver 0.20.12 (2017/11/25) * database diff --git a/android/build.py b/android/build.py index 3ec3d9ba3..fab6ecb49 100755 --- a/android/build.py +++ b/android/build.py @@ -46,13 +46,14 @@ class AndroidNdkToolchain: self.ndk_arch = 'arm' android_abi = 'armeabi-v7a' - ndk_platform = 'android-14' + ndk_platform = 'android-21' # select the NDK compiler gcc_version = '4.9' ndk_platform_path = os.path.join(ndk_path, 'platforms', ndk_platform) - sysroot = os.path.join(ndk_platform_path, 'arch-' + self.ndk_arch) + sysroot = os.path.join(ndk_path, 'sysroot') + target_root = os.path.join(ndk_platform_path, 'arch-' + self.ndk_arch) install_prefix = os.path.join(arch_path, 'root') @@ -79,8 +80,15 @@ class AndroidNdkToolchain: self.cflags = '-Os -g ' + common_flags self.cxxflags = '-Os -g ' + common_flags - self.cppflags = '--sysroot=' + self.sysroot + ' -isystem ' + os.path.join(install_prefix, 'include') - self.ldflags = '--sysroot=' + self.sysroot + ' ' + common_flags + ' -L' + os.path.join(install_prefix, 'lib') + self.cppflags = '--sysroot=' + sysroot + \ + ' -isystem ' + os.path.join(install_prefix, 'include') + \ + ' -isystem ' + os.path.join(sysroot, 'usr', 'include', arch) + \ + ' -D__ANDROID_API__=21' + self.ldflags = '--sysroot=' + sysroot + \ + ' -L' + os.path.join(install_prefix, 'lib') + \ + ' -L' + os.path.join(target_root, 'usr', 'lib') + \ + ' -B' + os.path.join(target_root, 'usr', 'lib') + \ + ' ' + common_flags self.libs = '' self.is_arm = self.ndk_arch == 'arm' diff --git a/configure.ac b/configure.ac index 335c3de5c..7e43fe7fe 100644 --- a/configure.ac +++ b/configure.ac @@ -492,7 +492,7 @@ if test x$enable_ipv6 = xyes; then AC_EGREP_CPP([AP_maGiC_VALUE], [ #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/python/build/libs.py b/python/build/libs.py index 0dd950dbf..5acabf695 100644 --- a/python/build/libs.py +++ b/python/build/libs.py @@ -69,8 +69,8 @@ liblame = AutotoolsProject( ) ffmpeg = FfmpegProject( - 'http://ffmpeg.org/releases/ffmpeg-3.3.3.tar.xz', - 'd2a9002cdc6b533b59728827186c044ad02ba64841f1b7cd6c21779875453a1e', + 'http://ffmpeg.org/releases/ffmpeg-3.4.1.tar.xz', + '5a77278a63741efa74e26bf197b9bb09ac6381b9757391b922407210f0f991c0', 'lib/libavcodec.a', [ '--disable-shared', '--enable-static', @@ -84,17 +84,26 @@ ffmpeg = FfmpegProject( '--disable-swscale', '--disable-postproc', '--disable-avfilter', + '--disable-lzo', + '--disable-faan', + '--disable-pixelutils', '--disable-network', '--disable-encoders', '--disable-protocols', - '--disable-outdevs', + '--disable-devices', '--disable-filters', + '--disable-v4l2_m2m', + + # clang misinterprets the "B0" in hevc_mvs.c as binary + # literal, which breaks the build; but we don't need that + # video codec anyway + '--disable-decoder=hevc', ], ) curl = AutotoolsProject( - 'http://curl.haxx.se/download/curl-7.55.1.tar.xz', - '3eafca6e84ecb4af5f35795dee84e643d5428287e88c041122bb8dac18676bb7', + 'http://curl.haxx.se/download/curl-7.57.0.tar.xz', + 'f5f6fd3c72b7b8389969f4fb671ed8532fa9b5bb7a5cae7ca89bc1cea45c7878', 'lib/libcurl.a', [ '--disable-shared', '--enable-static', @@ -114,7 +123,7 @@ curl = AutotoolsProject( ) boost = BoostProject( - 'http://downloads.sourceforge.net/project/boost/boost/1.65.0/boost_1_65_0.tar.bz2', - 'ea26712742e2fb079c2a566a31f3266973b76e38222b9f88b387e3c8b2f9902c', + 'http://downloads.sourceforge.net/project/boost/boost/1.65.1/boost_1_65_1.tar.bz2', + '9807a5d16566c57fd74fb522764e0b134a8bbe6b6e8967b83afefd30dcd3be81', 'include/boost/version.hpp', ) diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx index 9429af528..0d0484686 100644 --- a/src/CommandLine.cxx +++ b/src/CommandLine.cxx @@ -67,7 +67,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #define CONFIG_FILE_LOCATION PATH_LITERAL("mpd\\mpd.conf") #define APP_CONFIG_FILE_LOCATION PATH_LITERAL("conf\\mpd.conf") #else @@ -389,7 +389,7 @@ ParseCommandLine(int argc, char **argv, struct options *options) ConfigLoader loader; bool found = -#ifdef WIN32 +#ifdef _WIN32 loader.TryFile(GetUserConfigDir(), CONFIG_FILE_LOCATION) || loader.TryFile(GetSystemConfigDir(), CONFIG_FILE_LOCATION) || loader.TryFile(GetAppBaseDir(), APP_CONFIG_FILE_LOCATION); diff --git a/src/LocateUri.hxx b/src/LocateUri.hxx index 8d1a6d893..aa216f35e 100644 --- a/src/LocateUri.hxx +++ b/src/LocateUri.hxx @@ -24,7 +24,7 @@ #include "Compiler.h" #include "fs/AllocatedPath.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include /* damn you, windows.h! */ #ifdef ABSOLUTE diff --git a/src/LogBackend.cxx b/src/LogBackend.cxx index 433462cf9..767170d2a 100644 --- a/src/LogBackend.cxx +++ b/src/LogBackend.cxx @@ -164,7 +164,7 @@ FileLog(const Domain &domain, const char *message) noexcept domain.GetName(), chomp_length(message), message); -#ifdef WIN32 +#ifdef _WIN32 /* force-flush the log file, because setvbuf() does not seem to have an effect on WIN32 */ fflush(stderr); diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 43dddb847..5660f5576 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -72,7 +72,7 @@ log_init_file(int line) out_fd = open_log_file(); if (out_fd < 0) { -#ifdef WIN32 +#ifdef _WIN32 const std::string out_path_utf8 = out_path.ToUTF8(); throw FormatRuntimeError("failed to open log file \"%s\" (config line %d)", out_path_utf8.c_str(), line); @@ -182,7 +182,7 @@ void setup_log_output() fflush(nullptr); if (out_fd < 0) { -#ifdef WIN32 +#ifdef _WIN32 return; #else out_fd = open("/dev/null", O_WRONLY); diff --git a/src/LogLevel.hxx b/src/LogLevel.hxx index 36aad476d..e91ed84ca 100644 --- a/src/LogLevel.hxx +++ b/src/LogLevel.hxx @@ -20,7 +20,7 @@ #ifndef MPD_LOG_LEVEL_HXX #define MPD_LOG_LEVEL_HXX -#ifdef WIN32 +#ifdef _WIN32 #include /* damn you, windows.h! */ #ifdef ERROR diff --git a/src/Main.cxx b/src/Main.cxx index f80265768..f5bc28467 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -105,7 +105,7 @@ #include #endif -#ifdef WIN32 +#ifdef _WIN32 #include #include #endif @@ -290,7 +290,7 @@ glue_state_file_init() */ static void winsock_init(void) { -#ifdef WIN32 +#ifdef _WIN32 WSADATA sockinfo; int retval = WSAStartup(MAKEWORD(2, 2), &sockinfo); @@ -421,7 +421,7 @@ Instance::OnIdle(unsigned flags) int main(int argc, char *argv[]) { -#ifdef WIN32 +#ifdef _WIN32 return win32_main(argc, argv); #else return mpd_main(argc, argv); @@ -622,7 +622,7 @@ try { for (auto &partition : instance->partitions) partition.pc.LockUpdateAudio(); -#ifdef WIN32 +#ifdef _WIN32 win32_app_started(); #endif @@ -637,7 +637,7 @@ try { /* run the main loop */ instance->event_loop.Run(); -#ifdef WIN32 +#ifdef _WIN32 win32_app_stopping(); #endif @@ -711,7 +711,7 @@ try { daemonize_finish(); #endif -#ifdef WIN32 +#ifdef _WIN32 WSACleanup(); #endif diff --git a/src/Main.hxx b/src/Main.hxx index 6b89eb016..9b41abf9f 100644 --- a/src/Main.hxx +++ b/src/Main.hxx @@ -42,7 +42,7 @@ int mpd_main(int argc, char *argv[]); #endif -#ifdef WIN32 +#ifdef _WIN32 /** * If program is run as windows service performs nessesary initialization diff --git a/src/Stats.cxx b/src/Stats.cxx index 43988bbbc..c80136f85 100644 --- a/src/Stats.cxx +++ b/src/Stats.cxx @@ -32,7 +32,7 @@ #include -#ifndef WIN32 +#ifndef _WIN32 /** * The monotonic time stamp when MPD was started. It is used to * calculate the uptime. @@ -115,7 +115,7 @@ stats_print(Response &r, const Partition &partition) { r.Format("uptime: %u\n" "playtime: %lu\n", -#ifdef WIN32 +#ifdef _WIN32 GetProcessUptimeS(), #else (unsigned)std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time).count(), diff --git a/src/TimePrint.cxx b/src/TimePrint.cxx index f93d965cb..a9e932a43 100644 --- a/src/TimePrint.cxx +++ b/src/TimePrint.cxx @@ -24,7 +24,7 @@ void time_print(Response &r, const char *name, time_t t) { -#ifdef WIN32 +#ifdef _WIN32 const struct tm *tm2 = gmtime(&t); #else struct tm tm; @@ -35,7 +35,7 @@ time_print(Response &r, const char *name, time_t t) char buffer[32]; strftime(buffer, sizeof(buffer), -#ifdef WIN32 +#ifdef _WIN32 "%Y-%m-%dT%H:%M:%SZ", #else "%FT%TZ", diff --git a/src/client/ClientFile.cxx b/src/client/ClientFile.cxx index 03827890d..e38974dee 100644 --- a/src/client/ClientFile.cxx +++ b/src/client/ClientFile.cxx @@ -28,7 +28,7 @@ void Client::AllowFile(Path path_fs) const { -#ifdef WIN32 +#ifdef _WIN32 (void)path_fs; throw ProtocolError(ACK_ERROR_PERMISSION, "Access denied"); diff --git a/src/client/ClientMessage.hxx b/src/client/ClientMessage.hxx index b665cd65e..1da871a60 100644 --- a/src/client/ClientMessage.hxx +++ b/src/client/ClientMessage.hxx @@ -24,7 +24,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 /* fuck WIN32! */ #include #undef GetMessage diff --git a/src/client/ClientNew.cxx b/src/client/ClientNew.cxx index 5cfcf750f..11b5bc76c 100644 --- a/src/client/ClientNew.cxx +++ b/src/client/ClientNew.cxx @@ -29,7 +29,7 @@ #include "Log.hxx" #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/command/CommandResult.hxx b/src/command/CommandResult.hxx index cf6d590f8..30a7e8b6a 100644 --- a/src/command/CommandResult.hxx +++ b/src/command/CommandResult.hxx @@ -20,7 +20,7 @@ #ifndef MPD_COMMAND_RESULT_HXX #define MPD_COMMAND_RESULT_HXX -#ifdef WIN32 +#ifdef _WIN32 #include /* damn you, windows.h! */ #ifdef ERROR diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx index b8623395b..49f769eeb 100644 --- a/src/command/FileCommands.cxx +++ b/src/command/FileCommands.cxx @@ -61,7 +61,7 @@ skip_path(Path name_fs) noexcept return name_fs.HasNewline(); } -#if defined(WIN32) && GCC_CHECK_VERSION(4,6) +#if defined(_WIN32) && GCC_CHECK_VERSION(4,6) /* PRIu64 causes bogus compiler warning */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat" @@ -104,7 +104,7 @@ handle_listfiles_local(Response &r, Path path_fs) return CommandResult::OK; } -#if defined(WIN32) && GCC_CHECK_VERSION(4,6) +#if defined(_WIN32) && GCC_CHECK_VERSION(4,6) #pragma GCC diagnostic pop #endif diff --git a/src/command/StorageCommands.cxx b/src/command/StorageCommands.cxx index d144c0a63..b47c4ab74 100644 --- a/src/command/StorageCommands.cxx +++ b/src/command/StorageCommands.cxx @@ -50,7 +50,7 @@ skip_path(const char *name_utf8) noexcept return strchr(name_utf8, '\n') != nullptr; } -#if defined(WIN32) && GCC_CHECK_VERSION(4,6) +#if defined(_WIN32) && GCC_CHECK_VERSION(4,6) /* PRIu64 causes bogus compiler warning */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat" @@ -94,7 +94,7 @@ handle_listfiles_storage(Response &r, StorageDirectoryReader &reader) } } -#if defined(WIN32) && GCC_CHECK_VERSION(4,6) +#if defined(_WIN32) && GCC_CHECK_VERSION(4,6) #pragma GCC diagnostic pop #endif diff --git a/src/config/ConfigOption.hxx b/src/config/ConfigOption.hxx index b29bf526b..697909593 100644 --- a/src/config/ConfigOption.hxx +++ b/src/config/ConfigOption.hxx @@ -22,7 +22,7 @@ #include "Compiler.h" -#if defined(WIN32) && CLANG_OR_GCC_VERSION(4,7) +#if defined(_WIN32) && CLANG_OR_GCC_VERSION(4,7) /* "INPUT" is declared by winuser.h */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" @@ -93,7 +93,7 @@ enum class ConfigBlockOption { MAX }; -#if defined(WIN32) && CLANG_OR_GCC_VERSION(4,7) +#if defined(_WIN32) && CLANG_OR_GCC_VERSION(4,7) #pragma GCC diagnostic pop #endif diff --git a/src/config/ConfigPath.cxx b/src/config/ConfigPath.cxx index 0f6c37a3d..204b626f6 100644 --- a/src/config/ConfigPath.cxx +++ b/src/config/ConfigPath.cxx @@ -29,7 +29,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include /** @@ -79,7 +79,7 @@ ParsePath(const char *path) { assert(path != nullptr); -#ifndef WIN32 +#ifndef _WIN32 if (path[0] == '~') { ++path; @@ -119,7 +119,7 @@ ParsePath(const char *path) } else { #endif return AllocatedPath::FromUTF8Throw(path); -#ifndef WIN32 +#ifndef _WIN32 } #endif } diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index b2dbb4917..9330735b6 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -116,7 +116,7 @@ SimpleDatabase::Check() const path_utf8 + "\" because the " "parent path is not a directory"); -#ifndef WIN32 +#ifndef _WIN32 /* Check if we can write to the directory */ if (!CheckAccess(dirPath, X_OK | W_OK)) { const int e = errno; @@ -135,7 +135,7 @@ SimpleDatabase::Check() const if (!fi.IsRegular()) throw std::runtime_error("db file \"" + path_utf8 + "\" is not a regular file"); -#ifndef WIN32 +#ifndef _WIN32 /* And check that we can write to it */ if (!CheckAccess(path, R_OK | W_OK)) throw FormatErrno("Can't open db file \"%s\" for reading/writing", diff --git a/src/db/update/UpdateIO.cxx b/src/db/update/UpdateIO.cxx index 9680c06a0..2623b0dc4 100644 --- a/src/db/update/UpdateIO.cxx +++ b/src/db/update/UpdateIO.cxx @@ -91,7 +91,7 @@ bool directory_child_access(Storage &storage, const Directory &directory, const char *name, int mode) noexcept { -#ifdef WIN32 +#ifdef _WIN32 /* CheckAccess() is useless on WIN32 */ (void)storage; (void)directory; diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 1ef37e4d1..8e58f126d 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -55,7 +55,7 @@ UpdateWalk::UpdateWalk(EventLoop &_loop, DatabaseListener &_listener, storage(_storage), editor(_loop, _listener) { -#ifndef WIN32 +#ifndef _WIN32 follow_inside_symlinks = config_get_bool(ConfigOption::FOLLOW_INSIDE_SYMLINKS, DEFAULT_FOLLOW_INSIDE_SYMLINKS); @@ -133,7 +133,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) } } -#ifndef WIN32 +#ifndef _WIN32 static bool update_directory_stat(Storage &storage, Directory &directory) { @@ -156,7 +156,7 @@ static int FindAncestorLoop(Storage &storage, Directory *parent, unsigned inode, unsigned device) { -#ifndef WIN32 +#ifndef _WIN32 if (device == 0 && inode == 0) /* can't detect loops if the Storage does not support these numbers */ @@ -258,7 +258,7 @@ bool UpdateWalk::SkipSymlink(const Directory *directory, const char *utf8_name) const noexcept { -#ifndef WIN32 +#ifndef _WIN32 const auto path_fs = storage.MapChildFS(directory->GetPath(), utf8_name); if (path_fs.IsNull()) diff --git a/src/db/update/Walk.hxx b/src/db/update/Walk.hxx index 7d7a03db5..cdc42f4b8 100644 --- a/src/db/update/Walk.hxx +++ b/src/db/update/Walk.hxx @@ -36,7 +36,7 @@ class UpdateWalk final { friend class UpdateArchiveVisitor; #endif -#ifndef WIN32 +#ifndef _WIN32 static constexpr bool DEFAULT_FOLLOW_INSIDE_SYMLINKS = true; static constexpr bool DEFAULT_FOLLOW_OUTSIDE_SYMLINKS = true; diff --git a/src/decoder/plugins/FlacIOHandle.cxx b/src/decoder/plugins/FlacIOHandle.cxx index 997a42730..bdd433491 100644 --- a/src/decoder/plugins/FlacIOHandle.cxx +++ b/src/decoder/plugins/FlacIOHandle.cxx @@ -46,7 +46,7 @@ FlacIORead(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle) p += nbytes; -#ifndef WIN32 +#ifndef _WIN32 } catch (const std::system_error &e) { errno = e.code().category() == ErrnoCategory() ? e.code().value() diff --git a/src/event/MultiSocketMonitor.cxx b/src/event/MultiSocketMonitor.cxx index 8dfef02f9..0e713cf10 100644 --- a/src/event/MultiSocketMonitor.cxx +++ b/src/event/MultiSocketMonitor.cxx @@ -23,7 +23,7 @@ #include -#ifndef WIN32 +#ifndef _WIN32 #include #endif @@ -51,7 +51,7 @@ MultiSocketMonitor::ClearSocketList() noexcept fds.clear(); } -#ifndef WIN32 +#ifndef _WIN32 void MultiSocketMonitor::ReplaceSocketList(pollfd *pfds, unsigned n) noexcept diff --git a/src/event/MultiSocketMonitor.hxx b/src/event/MultiSocketMonitor.hxx index 971499d36..f030a7f59 100644 --- a/src/event/MultiSocketMonitor.hxx +++ b/src/event/MultiSocketMonitor.hxx @@ -31,7 +31,7 @@ #include -#ifndef WIN32 +#ifndef _WIN32 struct pollfd; #endif @@ -184,7 +184,7 @@ public: } } -#ifndef WIN32 +#ifndef _WIN32 /** * Replace the socket list with the given file descriptors. * The given pollfd array will be modified by this method. diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index b0fbe94d9..ef069b00e 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -44,7 +44,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #else diff --git a/src/event/SignalMonitor.cxx b/src/event/SignalMonitor.cxx index 36c00b450..3c9c8dc57 100644 --- a/src/event/SignalMonitor.cxx +++ b/src/event/SignalMonitor.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "SignalMonitor.hxx" -#ifndef WIN32 +#ifndef _WIN32 #include "SocketMonitor.hxx" #include "util/Manual.hxx" diff --git a/src/event/SignalMonitor.hxx b/src/event/SignalMonitor.hxx index 854a565ec..cdec98945 100644 --- a/src/event/SignalMonitor.hxx +++ b/src/event/SignalMonitor.hxx @@ -24,7 +24,7 @@ class EventLoop; -#ifndef WIN32 +#ifndef _WIN32 #include "util/BindMethod.hxx" diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx index 0d8c326c3..3be187ecf 100644 --- a/src/event/SocketMonitor.cxx +++ b/src/event/SocketMonitor.cxx @@ -23,7 +23,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/fs/AllocatedPath.cxx b/src/fs/AllocatedPath.cxx index fd5e54bf4..0bf2ba4ad 100644 --- a/src/fs/AllocatedPath.cxx +++ b/src/fs/AllocatedPath.cxx @@ -31,7 +31,7 @@ AllocatedPath::~AllocatedPath() {} AllocatedPath AllocatedPath::FromUTF8(const char *path_utf8) noexcept { -#if defined(HAVE_FS_CHARSET) || defined(WIN32) +#if defined(HAVE_FS_CHARSET) || defined(_WIN32) try { return AllocatedPath(::PathFromUTF8(path_utf8)); } catch (const std::runtime_error &) { @@ -45,7 +45,7 @@ AllocatedPath::FromUTF8(const char *path_utf8) noexcept AllocatedPath AllocatedPath::FromUTF8Throw(const char *path_utf8) { -#if defined(HAVE_FS_CHARSET) || defined(WIN32) +#if defined(HAVE_FS_CHARSET) || defined(_WIN32) return AllocatedPath(::PathFromUTF8(path_utf8)); #else return FromFS(path_utf8); diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx index 1b84063fa..a2db26546 100644 --- a/src/fs/Charset.cxx +++ b/src/fs/Charset.cxx @@ -24,7 +24,7 @@ #include "lib/icu/Converter.hxx" #include "util/AllocatedString.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include "lib/icu/Win32.hxx" #include #endif @@ -70,7 +70,7 @@ GetFSCharset() noexcept { #ifdef HAVE_FS_CHARSET return fs_charset.empty() ? "UTF-8" : fs_charset.c_str(); -#elif defined(WIN32) +#elif defined(_WIN32) return "ACP"; #else return "UTF-8"; @@ -100,7 +100,7 @@ PathToUTF8(PathTraitsFS::const_pointer_type path_fs) assert(path_fs != nullptr); #endif -#ifdef WIN32 +#ifdef _WIN32 const auto buffer = WideCharToMultiByte(CP_UTF8, path_fs); return FixSeparators(PathTraitsUTF8::string(buffer.c_str())); #else @@ -116,7 +116,7 @@ PathToUTF8(PathTraitsFS::const_pointer_type path_fs) #endif } -#if defined(HAVE_FS_CHARSET) || defined(WIN32) +#if defined(HAVE_FS_CHARSET) || defined(_WIN32) PathTraitsFS::string PathFromUTF8(PathTraitsUTF8::const_pointer_type path_utf8) @@ -126,7 +126,7 @@ PathFromUTF8(PathTraitsUTF8::const_pointer_type path_utf8) assert(path_utf8 != nullptr); #endif -#ifdef WIN32 +#ifdef _WIN32 const auto buffer = MultiByteToWideChar(CP_UTF8, path_utf8); return PathTraitsFS::string(buffer.c_str()); #else diff --git a/src/fs/Charset.hxx b/src/fs/Charset.hxx index 7f7097b95..de6cc22d0 100644 --- a/src/fs/Charset.hxx +++ b/src/fs/Charset.hxx @@ -24,7 +24,7 @@ #include "Compiler.h" #include "Traits.hxx" -#if (defined(HAVE_ICU) || defined(HAVE_ICONV)) && !defined(WIN32) +#if (defined(HAVE_ICU) || defined(HAVE_ICONV)) && !defined(_WIN32) #define HAVE_FS_CHARSET #endif diff --git a/src/fs/CheckFile.cxx b/src/fs/CheckFile.cxx index da875f1fc..fa4ac0ead 100644 --- a/src/fs/CheckFile.cxx +++ b/src/fs/CheckFile.cxx @@ -41,7 +41,7 @@ try { return; } -#ifndef WIN32 +#ifndef _WIN32 try { const auto x = AllocatedPath::Build(path_fs, PathTraitsFS::CURRENT_DIRECTORY); diff --git a/src/fs/DirectoryReader.cxx b/src/fs/DirectoryReader.cxx index 15e50daf4..acec65051 100644 --- a/src/fs/DirectoryReader.cxx +++ b/src/fs/DirectoryReader.cxx @@ -21,7 +21,7 @@ #include "DirectoryReader.hxx" #include "system/Error.hxx" -#ifdef WIN32 +#ifdef _WIN32 DirectoryReader::DirectoryReader(Path dir) :handle(FindFirstFile(MakeWildcardPath(dir.c_str()), &data)) diff --git a/src/fs/DirectoryReader.hxx b/src/fs/DirectoryReader.hxx index 8795f6d13..9c57fc441 100644 --- a/src/fs/DirectoryReader.hxx +++ b/src/fs/DirectoryReader.hxx @@ -23,7 +23,7 @@ #include "check.h" #include "Path.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include #include diff --git a/src/fs/FileInfo.hxx b/src/fs/FileInfo.hxx index dd8f6be1a..249ce0368 100644 --- a/src/fs/FileInfo.hxx +++ b/src/fs/FileInfo.hxx @@ -24,7 +24,7 @@ #include "Path.hxx" #include "system/Error.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include #else #include @@ -34,7 +34,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 static inline constexpr uint64_t ConstructUint64(DWORD lo, DWORD hi) @@ -63,7 +63,7 @@ class FileInfo { bool follow_symlinks); friend class FileReader; -#ifdef WIN32 +#ifdef _WIN32 WIN32_FILE_ATTRIBUTE_DATA data; #else struct stat st; @@ -74,7 +74,7 @@ public: FileInfo(Path path, bool follow_symlinks=true) { if (!GetFileInfo(path, *this, follow_symlinks)) { -#ifdef WIN32 +#ifdef _WIN32 throw FormatLastError("Failed to access %s", path.ToUTF8().c_str()); #else @@ -85,7 +85,7 @@ public: } bool IsRegular() const { -#ifdef WIN32 +#ifdef _WIN32 return (data.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE)) == 0; #else @@ -94,7 +94,7 @@ public: } bool IsDirectory() const { -#ifdef WIN32 +#ifdef _WIN32 return data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; #else return S_ISDIR(st.st_mode); @@ -102,7 +102,7 @@ public: } uint64_t GetSize() const { -#ifdef WIN32 +#ifdef _WIN32 return ConstructUint64(data.nFileSizeLow, data.nFileSizeHigh); #else return st.st_size; @@ -110,14 +110,14 @@ public: } std::chrono::system_clock::time_point GetModificationTime() const { -#ifdef WIN32 +#ifdef _WIN32 return FileTimeToChrono(data.ftLastWriteTime); #else return std::chrono::system_clock::from_time_t(st.st_mtime); #endif } -#ifndef WIN32 +#ifndef _WIN32 uid_t GetUid() const { return st.st_uid; } @@ -139,7 +139,7 @@ public: inline bool GetFileInfo(Path path, FileInfo &info, bool follow_symlinks=true) { -#ifdef WIN32 +#ifdef _WIN32 (void)follow_symlinks; return GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &info.data); diff --git a/src/fs/FileSystem.cxx b/src/fs/FileSystem.cxx index cf90bf4cb..54543d2c7 100644 --- a/src/fs/FileSystem.cxx +++ b/src/fs/FileSystem.cxx @@ -29,7 +29,7 @@ void RenameFile(Path oldpath, Path newpath) { -#ifdef WIN32 +#ifdef _WIN32 if (!MoveFileEx(oldpath.c_str(), newpath.c_str(), MOVEFILE_REPLACE_EXISTING)) throw MakeLastError("Failed to rename file"); @@ -42,7 +42,7 @@ RenameFile(Path oldpath, Path newpath) AllocatedPath ReadLink(Path path) { -#ifdef WIN32 +#ifdef _WIN32 (void)path; errno = EINVAL; return AllocatedPath::Null(); @@ -63,7 +63,7 @@ ReadLink(Path path) void TruncateFile(Path path) { -#ifdef WIN32 +#ifdef _WIN32 HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, nullptr, TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); @@ -81,7 +81,7 @@ TruncateFile(Path path) void RemoveFile(Path path) { -#ifdef WIN32 +#ifdef _WIN32 if (!DeleteFile(path.c_str())) throw FormatLastError("Failed to delete %s", path.c_str()); #else diff --git a/src/fs/FileSystem.hxx b/src/fs/FileSystem.hxx index 913c3592b..6d7318a43 100644 --- a/src/fs/FileSystem.hxx +++ b/src/fs/FileSystem.hxx @@ -25,7 +25,7 @@ #include "Path.hxx" #include "system/UniqueFileDescriptor.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include #endif @@ -42,7 +42,7 @@ class AllocatedPath; static inline FILE * FOpen(Path file, PathTraitsFS::const_pointer_type mode) { -#ifdef WIN32 +#ifdef _WIN32 return _tfopen(file.c_str(), mode); #else return fopen(file.c_str(), mode); @@ -68,7 +68,7 @@ OpenFile(Path file, int flags, int mode) void RenameFile(Path oldpath, Path newpath); -#ifndef WIN32 +#ifndef _WIN32 /** * Wrapper for stat() that uses #Path names. @@ -104,7 +104,7 @@ RemoveFile(Path path); AllocatedPath ReadLink(Path path); -#ifndef WIN32 +#ifndef _WIN32 static inline bool MakeFifo(Path path, mode_t mode) @@ -129,7 +129,7 @@ CheckAccess(Path path, int mode) static inline bool FileExists(Path path, bool follow_symlinks = true) { -#ifdef WIN32 +#ifdef _WIN32 (void)follow_symlinks; const auto a = GetFileAttributes(path.c_str()); @@ -147,7 +147,7 @@ FileExists(Path path, bool follow_symlinks = true) static inline bool DirectoryExists(Path path, bool follow_symlinks = true) { -#ifdef WIN32 +#ifdef _WIN32 (void)follow_symlinks; const auto a = GetFileAttributes(path.c_str()); @@ -164,7 +164,7 @@ DirectoryExists(Path path, bool follow_symlinks = true) static inline bool PathExists(Path path) { -#ifdef WIN32 +#ifdef _WIN32 return GetFileAttributes(path.c_str()) != INVALID_FILE_ATTRIBUTES; #else return CheckAccess(path, F_OK); diff --git a/src/fs/Glob.hxx b/src/fs/Glob.hxx index 1f8402089..b15972f0d 100644 --- a/src/fs/Glob.hxx +++ b/src/fs/Glob.hxx @@ -26,7 +26,7 @@ #define HAVE_CLASS_GLOB #include #include -#elif defined(WIN32) +#elif defined(_WIN32) #define HAVE_CLASS_GLOB #include #include @@ -40,12 +40,12 @@ * (asterisk and question mark). */ class Glob { -#if defined(HAVE_FNMATCH) || defined(WIN32) +#if defined(HAVE_FNMATCH) || defined(_WIN32) std::string pattern; #endif public: -#if defined(HAVE_FNMATCH) || defined(WIN32) +#if defined(HAVE_FNMATCH) || defined(_WIN32) explicit Glob(const char *_pattern) :pattern(_pattern) {} @@ -57,7 +57,7 @@ public: bool Check(const char *name_fs) const noexcept { #ifdef HAVE_FNMATCH return fnmatch(pattern.c_str(), name_fs, 0) == 0; -#elif defined(WIN32) +#elif defined(_WIN32) return PathMatchSpecA(name_fs, pattern.c_str()); #endif } diff --git a/src/fs/Limits.hxx b/src/fs/Limits.hxx index c9ce51ed2..5a646c63f 100644 --- a/src/fs/Limits.hxx +++ b/src/fs/Limits.hxx @@ -25,7 +25,7 @@ #include #include -#if defined(WIN32) +#if defined(_WIN32) static constexpr size_t MPD_PATH_MAX = 260; #elif defined(MAXPATHLEN) static constexpr size_t MPD_PATH_MAX = MAXPATHLEN; diff --git a/src/fs/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx index 41b5fee7a..a74fc5fcb 100644 --- a/src/fs/StandardDirectory.cxx +++ b/src/fs/StandardDirectory.cxx @@ -20,7 +20,7 @@ #include "config.h" // Use X Desktop guidelines where applicable -#if !defined(__APPLE__) && !defined(WIN32) && !defined(ANDROID) +#if !defined(__APPLE__) && !defined(_WIN32) && !defined(ANDROID) #define USE_XDG #endif @@ -29,7 +29,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #else @@ -53,7 +53,7 @@ #include "Main.hxx" #endif -#if !defined(WIN32) && !defined(ANDROID) +#if !defined(_WIN32) && !defined(ANDROID) class PasswdEntry { #if defined(HAVE_GETPWNAM_R) || defined(HAVE_GETPWUID_R) @@ -113,7 +113,7 @@ SafePathFromFS(PathTraitsFS::const_pointer_type dir) } #endif -#ifdef WIN32 +#ifdef _WIN32 static AllocatedPath GetStandardDir(int folder_id) { std::array dir; @@ -226,7 +226,7 @@ try { AllocatedPath GetUserConfigDir() noexcept { -#if defined(WIN32) +#if defined(_WIN32) return GetStandardDir(CSIDL_LOCAL_APPDATA); #elif defined(USE_XDG) // Check for $XDG_CONFIG_HOME @@ -251,7 +251,7 @@ GetUserConfigDir() noexcept AllocatedPath GetUserMusicDir() noexcept { -#if defined(WIN32) +#if defined(_WIN32) return GetStandardDir(CSIDL_MYMUSIC); #elif defined(USE_XDG) return GetUserDir("XDG_MUSIC_DIR"); @@ -287,7 +287,7 @@ GetUserCacheDir() noexcept #endif } -#ifdef WIN32 +#ifdef _WIN32 AllocatedPath GetSystemConfigDir() noexcept diff --git a/src/fs/StandardDirectory.hxx b/src/fs/StandardDirectory.hxx index 13d324c92..2742c6f50 100644 --- a/src/fs/StandardDirectory.hxx +++ b/src/fs/StandardDirectory.hxx @@ -42,7 +42,7 @@ gcc_pure AllocatedPath GetUserCacheDir() noexcept; -#ifdef WIN32 +#ifdef _WIN32 /** * Obtains system configuration directory. diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx index 9f2bbac02..64698996c 100644 --- a/src/fs/Traits.cxx +++ b/src/fs/Traits.cxx @@ -78,7 +78,7 @@ GetParentPathImpl(typename Traits::const_pointer_type p) return typename Traits::string(Traits::CURRENT_DIRECTORY); if (sep == p) return typename Traits::string(p, p + 1); -#ifdef WIN32 +#ifdef _WIN32 if (Traits::IsDrive(p) && sep == p + 2) return typename Traits::string(p, p + 3); #endif diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 67f74dc57..e41ae1030 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -25,7 +25,7 @@ #include "util/StringPointer.hxx" #include "util/StringAPI.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include "util/CharUtil.hxx" #include #endif @@ -34,7 +34,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #define PATH_LITERAL(s) _T(s) #else #define PATH_LITERAL(s) (s) @@ -44,7 +44,7 @@ * This class describes the nature of a native filesystem path. */ struct PathTraitsFS { -#ifdef WIN32 +#ifdef _WIN32 typedef std::wstring string; #else typedef std::string string; @@ -55,7 +55,7 @@ struct PathTraitsFS { typedef Pointer::pointer_type pointer_type; typedef Pointer::const_pointer_type const_pointer_type; -#ifdef WIN32 +#ifdef _WIN32 static constexpr value_type SEPARATOR = '\\'; #else static constexpr value_type SEPARATOR = '/'; @@ -65,7 +65,7 @@ struct PathTraitsFS { static constexpr bool IsSeparator(value_type ch) noexcept { return -#ifdef WIN32 +#ifdef _WIN32 ch == '/' || #endif ch == SEPARATOR; @@ -78,7 +78,7 @@ struct PathTraitsFS { assert(p != nullptr); #endif -#ifdef WIN32 +#ifdef _WIN32 const_pointer_type pos = p + GetLength(p); while (p != pos && !IsSeparator(*pos)) --pos; @@ -88,7 +88,7 @@ struct PathTraitsFS { #endif } -#ifdef WIN32 +#ifdef _WIN32 gcc_pure gcc_nonnull_all static constexpr bool IsDrive(const_pointer_type p) noexcept { return IsAlphaASCII(p[0]) && p[1] == ':'; @@ -102,7 +102,7 @@ struct PathTraitsFS { assert(p != nullptr); #endif -#ifdef WIN32 +#ifdef _WIN32 if (IsDrive(p) && IsSeparator(p[2])) return true; #endif @@ -188,7 +188,7 @@ struct PathTraitsUTF8 { return strrchr(p, SEPARATOR); } -#ifdef WIN32 +#ifdef _WIN32 gcc_pure gcc_nonnull_all static constexpr bool IsDrive(const_pointer_type p) noexcept { return IsAlphaASCII(p[0]) && p[1] == ':'; @@ -202,7 +202,7 @@ struct PathTraitsUTF8 { assert(p != nullptr); #endif -#ifdef WIN32 +#ifdef _WIN32 if (IsDrive(p) && IsSeparator(p[2])) return true; #endif diff --git a/src/fs/io/FileOutputStream.cxx b/src/fs/io/FileOutputStream.cxx index b72bee643..ddf7208a7 100644 --- a/src/fs/io/FileOutputStream.cxx +++ b/src/fs/io/FileOutputStream.cxx @@ -43,7 +43,7 @@ FileOutputStream::FileOutputStream(Path _path, Mode _mode) } } -#ifdef WIN32 +#ifdef _WIN32 inline void FileOutputStream::OpenCreate(gcc_unused bool visible) @@ -223,7 +223,7 @@ FileOutputStream::Commit() #endif if (!Close()) { -#ifdef WIN32 +#ifdef _WIN32 throw FormatLastError("Failed to commit %s", path.ToUTF8().c_str()); #else diff --git a/src/fs/io/FileOutputStream.hxx b/src/fs/io/FileOutputStream.hxx index 0d195909c..a87036aec 100644 --- a/src/fs/io/FileOutputStream.hxx +++ b/src/fs/io/FileOutputStream.hxx @@ -25,14 +25,14 @@ #include "fs/AllocatedPath.hxx" #include "Compiler.h" -#ifndef WIN32 +#ifndef _WIN32 #include "system/FileDescriptor.hxx" #endif #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #endif @@ -41,7 +41,7 @@ class Path; class FileOutputStream final : public OutputStream { const AllocatedPath path; -#ifdef WIN32 +#ifdef _WIN32 HANDLE handle = INVALID_HANDLE_VALUE; #else FileDescriptor fd = FileDescriptor::Undefined(); @@ -116,7 +116,7 @@ private: bool Close() { assert(IsDefined()); -#ifdef WIN32 +#ifdef _WIN32 CloseHandle(handle); handle = INVALID_HANDLE_VALUE; return true; @@ -125,7 +125,7 @@ private: #endif } -#ifdef WIN32 +#ifdef _WIN32 bool SeekEOF() { return SetFilePointer(handle, 0, nullptr, FILE_END) != 0xffffffff; @@ -133,7 +133,7 @@ private: #endif bool IsDefined() const { -#ifdef WIN32 +#ifdef _WIN32 return handle != INVALID_HANDLE_VALUE; #else return fd.IsDefined(); diff --git a/src/fs/io/FileReader.cxx b/src/fs/io/FileReader.cxx index 72ee8f405..42adab501 100644 --- a/src/fs/io/FileReader.cxx +++ b/src/fs/io/FileReader.cxx @@ -24,7 +24,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 FileReader::FileReader(Path _path) :path(_path), diff --git a/src/fs/io/FileReader.hxx b/src/fs/io/FileReader.hxx index 7dc122217..d4d54564a 100644 --- a/src/fs/io/FileReader.hxx +++ b/src/fs/io/FileReader.hxx @@ -25,11 +25,11 @@ #include "fs/AllocatedPath.hxx" #include "Compiler.h" -#ifndef WIN32 +#ifndef _WIN32 #include "system/FileDescriptor.hxx" #endif -#ifdef WIN32 +#ifdef _WIN32 #include #endif @@ -39,7 +39,7 @@ class FileInfo; class FileReader final : public Reader { AllocatedPath path; -#ifdef WIN32 +#ifdef _WIN32 HANDLE handle; #else FileDescriptor fd; @@ -48,7 +48,7 @@ class FileReader final : public Reader { public: explicit FileReader(Path _path); -#ifdef WIN32 +#ifdef _WIN32 FileReader(FileReader &&other) :path(std::move(other.path)), handle(other.handle) { @@ -70,7 +70,7 @@ public: protected: bool IsDefined() const { -#ifdef WIN32 +#ifdef _WIN32 return handle != INVALID_HANDLE_VALUE; #else return fd.IsDefined(); @@ -78,7 +78,7 @@ protected: } public: -#ifndef WIN32 +#ifndef _WIN32 FileDescriptor GetFD() const { return fd; } @@ -90,7 +90,7 @@ public: gcc_pure uint64_t GetSize() const noexcept { -#ifdef WIN32 +#ifdef _WIN32 LARGE_INTEGER size; return GetFileSizeEx(handle, &size) ? size.QuadPart @@ -102,7 +102,7 @@ public: gcc_pure uint64_t GetPosition() const noexcept { -#ifdef WIN32 +#ifdef _WIN32 LARGE_INTEGER zero; zero.QuadPart = 0; LARGE_INTEGER position; diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index d9b984b37..cdeec5d94 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -230,7 +230,7 @@ CurlInputStream::OnHeaders(unsigned status, if (i != headers.end()) { size_t icy_metaint = ParseUint64(i->second.c_str()); -#ifndef WIN32 +#ifndef _WIN32 /* Windows doesn't know "%z" */ FormatDebug(curl_domain, "icy-metaint=%zu", icy_metaint); #endif @@ -407,7 +407,7 @@ CurlInputStream::SeekInternal(offset_type new_offset) if (offset > 0) { char range[32]; -#ifdef WIN32 +#ifdef _WIN32 // TODO: what can we use on Windows to format 64 bit? sprintf(range, "%lu-", (long)offset); #else diff --git a/src/lib/icu/CaseFold.cxx b/src/lib/icu/CaseFold.cxx index ccdf998d5..d0f086897 100644 --- a/src/lib/icu/CaseFold.cxx +++ b/src/lib/icu/CaseFold.cxx @@ -36,7 +36,7 @@ #include #endif -#ifdef WIN32 +#ifdef _WIN32 #include "Win32.hxx" #include #endif @@ -73,7 +73,7 @@ try { folded.SetSize(folded_length); return UCharToUTF8({folded.begin(), folded.size()}); -#elif defined(WIN32) +#elif defined(_WIN32) const auto u = MultiByteToWideChar(CP_UTF8, src); const int size = LCMapStringEx(LOCALE_NAME_INVARIANT, diff --git a/src/lib/icu/Collate.cxx b/src/lib/icu/Collate.cxx index f16cba597..7772785aa 100644 --- a/src/lib/icu/Collate.cxx +++ b/src/lib/icu/Collate.cxx @@ -32,7 +32,7 @@ #include #endif -#ifdef WIN32 +#ifdef _WIN32 #include "Win32.hxx" #include "util/AllocatedString.hxx" #include @@ -103,7 +103,7 @@ IcuCollate(const char *a, const char *b) noexcept } #endif -#elif defined(WIN32) +#elif defined(_WIN32) AllocatedString wa = nullptr, wb = nullptr; try { diff --git a/src/lib/upnp/Action.hxx b/src/lib/upnp/Action.hxx index 367da528a..03c200bfc 100644 --- a/src/lib/upnp/Action.hxx +++ b/src/lib/upnp/Action.hxx @@ -22,7 +22,7 @@ #include "Compiler.h" -#include +#include static inline constexpr unsigned CountNameValuePairs() noexcept diff --git a/src/lib/upnp/Callback.hxx b/src/lib/upnp/Callback.hxx index 544bd9d41..00fd64577 100644 --- a/src/lib/upnp/Callback.hxx +++ b/src/lib/upnp/Callback.hxx @@ -20,7 +20,7 @@ #ifndef MPD_UPNP_CALLBACK_HXX #define MPD_UPNP_CALLBACK_HXX -#include +#include /** * A class that is supposed to be used for libupnp asynchronous diff --git a/src/lib/upnp/ClientInit.cxx b/src/lib/upnp/ClientInit.cxx index b2f6b3348..2fd891b83 100644 --- a/src/lib/upnp/ClientInit.cxx +++ b/src/lib/upnp/ClientInit.cxx @@ -24,7 +24,7 @@ #include "thread/Mutex.hxx" #include "util/RuntimeError.hxx" -#include +#include #include diff --git a/src/lib/upnp/ClientInit.hxx b/src/lib/upnp/ClientInit.hxx index a36d24f9a..f45901eff 100644 --- a/src/lib/upnp/ClientInit.hxx +++ b/src/lib/upnp/ClientInit.hxx @@ -22,7 +22,7 @@ #include "check.h" -#include +#include void UpnpClientGlobalInit(UpnpClient_Handle &handle); diff --git a/src/lib/upnp/Compat.hxx b/src/lib/upnp/Compat.hxx index c9f1cc47f..b4b5bd01b 100644 --- a/src/lib/upnp/Compat.hxx +++ b/src/lib/upnp/Compat.hxx @@ -20,7 +20,7 @@ #ifndef MPD_UPNP_COMPAT_HXX #define MPD_UPNP_COMPAT_HXX -#include +#include #if UPNP_VERSION < 10800 /* emulate the libupnp 1.8 API with older versions */ diff --git a/src/lib/upnp/ContentDirectoryService.hxx b/src/lib/upnp/ContentDirectoryService.hxx index 973468c34..cefb208c1 100644 --- a/src/lib/upnp/ContentDirectoryService.hxx +++ b/src/lib/upnp/ContentDirectoryService.hxx @@ -22,7 +22,7 @@ #include "Compiler.h" -#include +#include #include #include diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index 27dedac62..039f3a905 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -27,7 +27,7 @@ #include "util/ScopeExit.hxx" #include "util/RuntimeError.hxx" -#include +#include #include #include diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index eb6297a73..623b5d8dc 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -30,7 +30,7 @@ #include "event/DeferEvent.hxx" #include "Compiler.h" -#include +#include #include diff --git a/src/lib/upnp/Init.cxx b/src/lib/upnp/Init.cxx index ca3140599..33484539d 100644 --- a/src/lib/upnp/Init.cxx +++ b/src/lib/upnp/Init.cxx @@ -22,9 +22,9 @@ #include "thread/Mutex.hxx" #include "util/RuntimeError.hxx" -#include -#include -#include +#include +#include +#include #include diff --git a/src/lib/upnp/UniqueIxml.hxx b/src/lib/upnp/UniqueIxml.hxx index ddfc4aa94..59f1ae845 100644 --- a/src/lib/upnp/UniqueIxml.hxx +++ b/src/lib/upnp/UniqueIxml.hxx @@ -20,7 +20,7 @@ #ifndef MPD_UPNP_UNIQUE_XML_HXX #define MPD_UPNP_UNIQUE_XML_HXX -#include +#include #include diff --git a/src/lib/upnp/ixmlwrap.hxx b/src/lib/upnp/ixmlwrap.hxx index 9d9813e13..73a0ce83f 100644 --- a/src/lib/upnp/ixmlwrap.hxx +++ b/src/lib/upnp/ixmlwrap.hxx @@ -17,7 +17,7 @@ #ifndef _IXMLWRAP_H_INCLUDED_ #define _IXMLWRAP_H_INCLUDED_ -#include +#include #include diff --git a/src/net/AllocatedSocketAddress.cxx b/src/net/AllocatedSocketAddress.cxx index bd4725692..f3632ca3c 100644 --- a/src/net/AllocatedSocketAddress.cxx +++ b/src/net/AllocatedSocketAddress.cxx @@ -37,7 +37,7 @@ #endif #ifdef HAVE_TCP -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/net/Resolver.cxx b/src/net/Resolver.cxx index 036f95fb2..160447e03 100644 --- a/src/net/Resolver.cxx +++ b/src/net/Resolver.cxx @@ -23,7 +23,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/net/SocketAddress.cxx b/src/net/SocketAddress.cxx index 615eb6303..8b28832f8 100644 --- a/src/net/SocketAddress.cxx +++ b/src/net/SocketAddress.cxx @@ -33,7 +33,7 @@ #include #ifdef HAVE_TCP -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/net/SocketAddress.hxx b/src/net/SocketAddress.hxx index 1c8c006ba..ac934e431 100644 --- a/src/net/SocketAddress.hxx +++ b/src/net/SocketAddress.hxx @@ -35,7 +35,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include @@ -46,7 +46,7 @@ */ class SocketAddress { public: -#ifdef WIN32 +#ifdef _WIN32 typedef int size_type; #else typedef socklen_t size_type; diff --git a/src/net/SocketDescriptor.cxx b/src/net/SocketDescriptor.cxx index 97f83cdd9..a572da34e 100644 --- a/src/net/SocketDescriptor.cxx +++ b/src/net/SocketDescriptor.cxx @@ -108,7 +108,7 @@ SocketDescriptor::Connect(SocketAddress address) bool SocketDescriptor::Create(int domain, int type, int protocol) { -#ifdef WIN32 +#ifdef _WIN32 static bool initialised = false; if (!initialised) { WSADATA data; diff --git a/src/net/SocketError.cxx b/src/net/SocketError.cxx index 082dec187..9beef4fc9 100644 --- a/src/net/SocketError.cxx +++ b/src/net/SocketError.cxx @@ -23,7 +23,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept { diff --git a/src/net/SocketError.hxx b/src/net/SocketError.hxx index 6e3a7799c..c4caac646 100644 --- a/src/net/SocketError.hxx +++ b/src/net/SocketError.hxx @@ -23,7 +23,7 @@ #include "Compiler.h" #include "system/Error.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include typedef DWORD socket_error_t; #else @@ -35,7 +35,7 @@ gcc_pure static inline socket_error_t GetSocketError() noexcept { -#ifdef WIN32 +#ifdef _WIN32 return WSAGetLastError(); #else return errno; @@ -46,7 +46,7 @@ gcc_const static inline bool IsSocketErrorAgain(socket_error_t code) noexcept { -#ifdef WIN32 +#ifdef _WIN32 return code == WSAEINPROGRESS; #else return code == EAGAIN; @@ -57,7 +57,7 @@ gcc_const static inline bool IsSocketErrorInterruped(socket_error_t code) noexcept { -#ifdef WIN32 +#ifdef _WIN32 return code == WSAEINTR; #else return code == EINTR; @@ -68,7 +68,7 @@ gcc_const static inline bool IsSocketErrorClosed(socket_error_t code) noexcept { -#ifdef WIN32 +#ifdef _WIN32 return code == WSAECONNRESET; #else return code == EPIPE || code == ECONNRESET; @@ -81,7 +81,7 @@ IsSocketErrorClosed(socket_error_t code) noexcept * and this class hosts the buffer. */ class SocketErrorMessage { -#ifdef WIN32 +#ifdef _WIN32 char msg[256]; #else const char *const msg; @@ -99,7 +99,7 @@ gcc_const static inline std::system_error MakeSocketError(socket_error_t code, const char *msg) noexcept { -#ifdef WIN32 +#ifdef _WIN32 return MakeLastError(code, msg); #else return MakeErrno(code, msg); diff --git a/src/net/StaticSocketAddress.cxx b/src/net/StaticSocketAddress.cxx index ceaee9d7c..5ff64d518 100644 --- a/src/net/StaticSocketAddress.cxx +++ b/src/net/StaticSocketAddress.cxx @@ -35,7 +35,7 @@ #include #ifdef HAVE_TCP -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/net/ToString.cxx b/src/net/ToString.cxx index 98f9f9b10..5dfd8abe9 100644 --- a/src/net/ToString.cxx +++ b/src/net/ToString.cxx @@ -34,7 +34,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index e6b039b52..c3d3966e2 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -36,6 +36,8 @@ #include +static constexpr unsigned MPD_OSX_BUFFER_TIME_MS = 100; + struct OSXOutput final : AudioOutput { /* configuration settings */ OSType component_subtype; @@ -686,7 +688,9 @@ OSXOutput::Open(AudioFormat &audio_format) errormsg); } - ring_buffer = new boost::lockfree::spsc_queue(buffer_frame_size); + size_t ring_buffer_size = std::max(buffer_frame_size, + MPD_OSX_BUFFER_TIME_MS * audio_format.GetFrameSize() * audio_format.sample_rate / 1000); + ring_buffer = new boost::lockfree::spsc_queue(ring_buffer_size); status = AudioOutputUnitStart(au); if (status != 0) { @@ -708,7 +712,7 @@ OSXOutput::Delay() const noexcept { return ring_buffer->write_available() ? std::chrono::steady_clock::duration::zero() - : std::chrono::milliseconds(25); + : std::chrono::milliseconds(MPD_OSX_BUFFER_TIME_MS / 4); } int diff --git a/src/pcm/SampleFormat.hxx b/src/pcm/SampleFormat.hxx index febb89ff5..9d956b7f9 100644 --- a/src/pcm/SampleFormat.hxx +++ b/src/pcm/SampleFormat.hxx @@ -24,7 +24,7 @@ #include -#if defined(WIN32) && GCC_CHECK_VERSION(4,6) +#if defined(_WIN32) && GCC_CHECK_VERSION(4,6) /* on WIN32, "FLOAT" is already defined, and this triggers -Wshadow */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" @@ -57,7 +57,7 @@ enum class SampleFormat : uint8_t { DSD, }; -#if defined(WIN32) && GCC_CHECK_VERSION(4,6) +#if defined(_WIN32) && GCC_CHECK_VERSION(4,6) #pragma GCC diagnostic pop #endif diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx index 816286b1b..3f4816f80 100644 --- a/src/storage/plugins/LocalStorage.cxx +++ b/src/storage/plugins/LocalStorage.cxx @@ -86,7 +86,7 @@ Stat(Path path, bool follow) info.size = src.GetSize(); info.mtime = src.GetModificationTime(); -#ifdef WIN32 +#ifdef _WIN32 info.device = info.inode = 0; #else info.device = src.GetDevice(); diff --git a/src/system/Clock.cxx b/src/system/Clock.cxx index 7e15412e5..dc29bdc70 100644 --- a/src/system/Clock.cxx +++ b/src/system/Clock.cxx @@ -19,7 +19,7 @@ #include "Clock.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include gcc_const diff --git a/src/system/Clock.hxx b/src/system/Clock.hxx index 92fbb6a77..222ac4848 100644 --- a/src/system/Clock.hxx +++ b/src/system/Clock.hxx @@ -22,7 +22,7 @@ #include "Compiler.h" -#ifdef WIN32 +#ifdef _WIN32 /** * Returns the uptime of the current process in seconds. diff --git a/src/system/EPollFD.cxx b/src/system/EPollFD.cxx index fd472c2c3..93c957f4d 100644 --- a/src/system/EPollFD.cxx +++ b/src/system/EPollFD.cxx @@ -22,7 +22,7 @@ #include "EPollFD.hxx" #include "Error.hxx" -#ifdef __BIONIC__ +#if defined(__BIONIC__) && __ANDROID_API__ < 21 #include #include diff --git a/src/system/Error.hxx b/src/system/Error.hxx index 5fc697ccb..f65a602b3 100644 --- a/src/system/Error.hxx +++ b/src/system/Error.hxx @@ -47,7 +47,7 @@ FormatSystemError(std::error_code code, const char *fmt, return std::system_error(code, buffer); } -#ifdef WIN32 +#ifdef _WIN32 #include @@ -90,7 +90,7 @@ FormatLastError(const char *fmt, Args&&... args) noexcept std::forward(args)...); } -#endif /* WIN32 */ +#endif /* _WIN32 */ #include #include @@ -106,7 +106,7 @@ FormatLastError(const char *fmt, Args&&... args) noexcept static inline const std::error_category & ErrnoCategory() noexcept { -#ifdef WIN32 +#ifdef _WIN32 /* on Windows, the generic_category() is used for errno values */ return std::generic_category(); @@ -151,7 +151,7 @@ gcc_pure static inline bool IsFileNotFound(const std::system_error &e) noexcept { -#ifdef WIN32 +#ifdef _WIN32 return e.code().category() == std::system_category() && e.code().value() == ERROR_FILE_NOT_FOUND; #else @@ -164,7 +164,7 @@ gcc_pure static inline bool IsPathNotFound(const std::system_error &e) noexcept { -#ifdef WIN32 +#ifdef _WIN32 return e.code().category() == std::system_category() && e.code().value() == ERROR_PATH_NOT_FOUND; #else @@ -177,7 +177,7 @@ gcc_pure static inline bool IsAccessDenied(const std::system_error &e) noexcept { -#ifdef WIN32 +#ifdef _WIN32 return e.code().category() == std::system_category() && e.code().value() == ERROR_ACCESS_DENIED; #else diff --git a/src/system/EventPipe.cxx b/src/system/EventPipe.cxx index e56534e2a..ff642cc63 100644 --- a/src/system/EventPipe.cxx +++ b/src/system/EventPipe.cxx @@ -27,20 +27,20 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include "net/IPv4Address.hxx" #include "net/StaticSocketAddress.hxx" #include "net/UniqueSocketDescriptor.hxx" #include "net/SocketError.hxx" #endif -#ifdef WIN32 +#ifdef _WIN32 static void PoorSocketPair(int fd[2]); #endif EventPipe::EventPipe() { -#ifdef WIN32 +#ifdef _WIN32 PoorSocketPair(fds); #else FileDescriptor r, w; @@ -54,7 +54,7 @@ EventPipe::EventPipe() EventPipe::~EventPipe() { -#ifdef WIN32 +#ifdef _WIN32 closesocket(fds[0]); closesocket(fds[1]); #else @@ -70,7 +70,7 @@ EventPipe::Read() assert(fds[1] >= 0); char buffer[256]; -#ifdef WIN32 +#ifdef _WIN32 return recv(fds[0], buffer, sizeof(buffer), 0) > 0; #else return read(fds[0], buffer, sizeof(buffer)) > 0; @@ -83,14 +83,14 @@ EventPipe::Write() assert(fds[0] >= 0); assert(fds[1] >= 0); -#ifdef WIN32 +#ifdef _WIN32 send(fds[1], "", 1, 0); #else gcc_unused ssize_t nbytes = write(fds[1], "", 1); #endif } -#ifdef WIN32 +#ifdef _WIN32 /* Our poor man's socketpair() implementation * Due to limited protocol/address family support diff --git a/src/system/FatalError.cxx b/src/system/FatalError.cxx index 02ff209a9..9648bbbeb 100644 --- a/src/system/FatalError.cxx +++ b/src/system/FatalError.cxx @@ -28,7 +28,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include @@ -61,7 +61,7 @@ FormatFatalError(const char *fmt, ...) Abort(); } -#ifdef WIN32 +#ifdef _WIN32 void FatalSystemError(const char *msg, DWORD code) @@ -79,7 +79,7 @@ FatalSystemError(const char *msg, DWORD code) void FatalSystemError(const char *msg) { -#ifdef WIN32 +#ifdef _WIN32 FatalSystemError(msg, GetLastError()); #else const char *system_error = strerror(errno); diff --git a/src/system/FatalError.hxx b/src/system/FatalError.hxx index dfef2c168..c692a2c39 100644 --- a/src/system/FatalError.hxx +++ b/src/system/FatalError.hxx @@ -23,7 +23,7 @@ #include "check.h" #include "Compiler.h" -#ifdef WIN32 +#ifdef _WIN32 #include #endif @@ -47,7 +47,7 @@ gcc_noreturn void FatalSystemError(const char *msg); -#ifdef WIN32 +#ifdef _WIN32 gcc_noreturn void diff --git a/src/tag/Format.cxx b/src/tag/Format.cxx index 09b6065a4..d8aa2f3f3 100644 --- a/src/tag/Format.cxx +++ b/src/tag/Format.cxx @@ -87,7 +87,7 @@ TagGetter(const void *object, const char *name) noexcept if (strcmp(name, "iso8601") == 0) { time_t t = time(nullptr); -#ifdef WIN32 +#ifdef _WIN32 const struct tm *tm2 = gmtime(&t); #else struct tm tm; @@ -97,7 +97,7 @@ TagGetter(const void *object, const char *name) noexcept return ""; strftime(ctx.buffer, sizeof(ctx.buffer), -#ifdef WIN32 +#ifdef _WIN32 /* kludge: use underscore instead of colon on Windows because colons are not allowed in file names, and this library is mostly diff --git a/src/thread/Cond.hxx b/src/thread/Cond.hxx index 3ca640ff1..7123635df 100644 --- a/src/thread/Cond.hxx +++ b/src/thread/Cond.hxx @@ -30,7 +30,7 @@ #ifndef THREAD_COND_HXX #define THREAD_COND_HXX -#ifdef WIN32 +#ifdef _WIN32 #include "WindowsCond.hxx" class Cond : public WindowsCond {}; diff --git a/src/thread/Id.hxx b/src/thread/Id.hxx index 217a39e72..17cdfa0d2 100644 --- a/src/thread/Id.hxx +++ b/src/thread/Id.hxx @@ -22,7 +22,7 @@ #include "Compiler.h" -#ifdef WIN32 +#ifdef _WIN32 #include #else #include @@ -34,7 +34,7 @@ * debugging code. */ class ThreadId { -#ifdef WIN32 +#ifdef _WIN32 DWORD id; #else pthread_t id; @@ -46,7 +46,7 @@ public: */ ThreadId() noexcept = default; -#ifdef WIN32 +#ifdef _WIN32 constexpr ThreadId(DWORD _id) noexcept:id(_id) {} #else constexpr ThreadId(pthread_t _id) noexcept:id(_id) {} @@ -54,7 +54,7 @@ public: gcc_const static ThreadId Null() noexcept { -#ifdef WIN32 +#ifdef _WIN32 return 0; #else static ThreadId null; @@ -72,7 +72,7 @@ public: */ gcc_pure static const ThreadId GetCurrent() noexcept { -#ifdef WIN32 +#ifdef _WIN32 return ::GetCurrentThreadId(); #else return pthread_self(); @@ -81,7 +81,7 @@ public: gcc_pure bool operator==(const ThreadId &other) const noexcept { -#ifdef WIN32 +#ifdef _WIN32 return id == other.id; #else return pthread_equal(id, other.id); diff --git a/src/thread/Mutex.hxx b/src/thread/Mutex.hxx index 530ff9697..f1aa03cb2 100644 --- a/src/thread/Mutex.hxx +++ b/src/thread/Mutex.hxx @@ -32,7 +32,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include "CriticalSection.hxx" class Mutex : public CriticalSection {}; diff --git a/src/thread/Thread.cxx b/src/thread/Thread.cxx index 3b6da667d..91b060628 100644 --- a/src/thread/Thread.cxx +++ b/src/thread/Thread.cxx @@ -30,7 +30,7 @@ Thread::Start() { assert(!IsDefined()); -#ifdef WIN32 +#ifdef _WIN32 handle = ::CreateThread(nullptr, 0, ThreadProc, this, 0, &id); if (handle == nullptr) throw MakeLastError("Failed to create thread"); @@ -61,7 +61,7 @@ Thread::Join() noexcept assert(IsDefined()); assert(!IsInside()); -#ifdef WIN32 +#ifdef _WIN32 ::WaitForSingleObject(handle, INFINITE); ::CloseHandle(handle); handle = nullptr; @@ -74,7 +74,7 @@ Thread::Join() noexcept inline void Thread::Run() noexcept { -#ifndef WIN32 +#ifndef _WIN32 #ifndef NDEBUG /* this works around a race condition that causes an assertion failure due to IsInside() spuriously returning false right @@ -91,7 +91,7 @@ Thread::Run() noexcept #endif } -#ifdef WIN32 +#ifdef _WIN32 DWORD WINAPI Thread::ThreadProc(LPVOID ctx) noexcept diff --git a/src/thread/Thread.hxx b/src/thread/Thread.hxx index cbf3310d0..d8bd1cfc7 100644 --- a/src/thread/Thread.hxx +++ b/src/thread/Thread.hxx @@ -24,7 +24,7 @@ #include "util/BindMethod.hxx" #include "Compiler.h" -#ifdef WIN32 +#ifdef _WIN32 #include #else #include @@ -36,7 +36,7 @@ class Thread { typedef BoundMethod Function; const Function f; -#ifdef WIN32 +#ifdef _WIN32 HANDLE handle = nullptr; DWORD id; #else @@ -67,7 +67,7 @@ public: #endif bool IsDefined() const noexcept { -#ifdef WIN32 +#ifdef _WIN32 return handle != nullptr; #else return defined; @@ -79,7 +79,7 @@ public: */ gcc_pure bool IsInside() const noexcept { -#ifdef WIN32 +#ifdef _WIN32 return GetCurrentThreadId() == id; #else #ifdef NDEBUG @@ -96,7 +96,7 @@ public: private: void Run() noexcept; -#ifdef WIN32 +#ifdef _WIN32 static DWORD WINAPI ThreadProc(LPVOID ctx) noexcept; #else static void *ThreadProc(void *ctx) noexcept; diff --git a/src/thread/Util.cxx b/src/thread/Util.cxx index 34c6b5380..b336467bd 100644 --- a/src/thread/Util.cxx +++ b/src/thread/Util.cxx @@ -34,7 +34,7 @@ #include #include #include -#elif defined(WIN32) +#elif defined(_WIN32) #include #endif @@ -71,7 +71,7 @@ SetThreadIdlePriority() noexcept ioprio_set_idle(); -#elif defined(WIN32) +#elif defined(_WIN32) SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); #endif }; diff --git a/src/unix/Daemon.cxx b/src/unix/Daemon.cxx index 14f3891fb..fd4539310 100644 --- a/src/unix/Daemon.cxx +++ b/src/unix/Daemon.cxx @@ -23,7 +23,7 @@ #include "fs/AllocatedPath.hxx" #include "fs/FileSystem.hxx" -#ifndef WIN32 +#ifndef _WIN32 #include "PidFile.hxx" #endif @@ -31,7 +31,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #include @@ -42,7 +42,7 @@ #define WCOREDUMP(v) 0 #endif -#ifndef WIN32 +#ifndef _WIN32 /** the Unix user name which MPD runs as */ static char *user_name; diff --git a/src/unix/Daemon.hxx b/src/unix/Daemon.hxx index f6ea9f6a2..2b12b17f6 100644 --- a/src/unix/Daemon.hxx +++ b/src/unix/Daemon.hxx @@ -22,7 +22,7 @@ class AllocatedPath; -#ifndef WIN32 +#ifndef _WIN32 void daemonize_init(const char *user, const char *group, AllocatedPath &&pidfile); #else @@ -31,7 +31,7 @@ daemonize_init(const char *user, const char *group, AllocatedPath &&pidfile) { (void)user; (void)group; (void)pidfile; } #endif -#ifndef WIN32 +#ifndef _WIN32 void daemonize_finish(); #else @@ -44,7 +44,7 @@ daemonize_finish() * Kill the MPD which is currently running, pid determined from the * pid file. */ -#ifndef WIN32 +#ifndef _WIN32 void daemonize_kill(); #else @@ -59,7 +59,7 @@ daemonize_kill() /** * Close stdin (fd 0) and re-open it as /dev/null. */ -#ifndef WIN32 +#ifndef _WIN32 void daemonize_close_stdin(); #else @@ -70,7 +70,7 @@ daemonize_close_stdin() {} /** * Change to the configured Unix user. */ -#ifndef WIN32 +#ifndef _WIN32 void daemonize_set_user(); #else @@ -79,7 +79,7 @@ daemonize_set_user() { /* nop */ } #endif -#ifndef WIN32 +#ifndef _WIN32 void daemonize_begin(bool detach); #else @@ -88,7 +88,7 @@ daemonize_begin(bool detach) { (void)detach; } #endif -#ifndef WIN32 +#ifndef _WIN32 void daemonize_commit(); #else diff --git a/src/unix/SignalHandlers.cxx b/src/unix/SignalHandlers.cxx index d0908096e..ac2c4e603 100644 --- a/src/unix/SignalHandlers.cxx +++ b/src/unix/SignalHandlers.cxx @@ -21,7 +21,7 @@ #include "SignalHandlers.hxx" #include "event/SignalMonitor.hxx" -#ifndef WIN32 +#ifndef _WIN32 #include "Log.hxx" #include "LogInit.hxx" @@ -61,7 +61,7 @@ SignalHandlersInit(EventLoop &loop) { SignalMonitorInit(loop); -#ifndef WIN32 +#ifndef _WIN32 struct sigaction sa; sa.sa_flags = 0; diff --git a/src/util/FormatString.cxx b/src/util/FormatString.cxx index 57ea57525..f3085d8e7 100644 --- a/src/util/FormatString.cxx +++ b/src/util/FormatString.cxx @@ -23,14 +23,14 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #endif AllocatedString<> FormatStringV(const char *fmt, va_list args) noexcept { -#ifndef WIN32 +#ifndef _WIN32 va_list tmp; va_copy(tmp, args); const int length = vsnprintf(NULL, 0, fmt, tmp); diff --git a/src/util/HugeAllocator.cxx b/src/util/HugeAllocator.cxx index f5d4683be..99afe23f7 100644 --- a/src/util/HugeAllocator.cxx +++ b/src/util/HugeAllocator.cxx @@ -99,7 +99,7 @@ HugeDiscard(void *p, size_t size) noexcept #endif } -#elif defined(WIN32) +#elif defined(_WIN32) WritableBuffer HugeAllocate(size_t size) diff --git a/src/util/HugeAllocator.hxx b/src/util/HugeAllocator.hxx index 0ae1c8581..c1eb50ce3 100644 --- a/src/util/HugeAllocator.hxx +++ b/src/util/HugeAllocator.hxx @@ -78,7 +78,7 @@ HugeForkCow(void *p, size_t size, bool enable) noexcept; void HugeDiscard(void *p, size_t size) noexcept; -#elif defined(WIN32) +#elif defined(_WIN32) #include WritableBuffer diff --git a/src/util/StringAPI.hxx b/src/util/StringAPI.hxx index 5c67d045e..1d6a7dea9 100644 --- a/src/util/StringAPI.hxx +++ b/src/util/StringAPI.hxx @@ -111,7 +111,7 @@ gcc_nonnull_all static inline char * UnsafeCopyStringP(char *dest, const char *src) noexcept { -#if defined(WIN32) || defined(__BIONIC__) +#if defined(_WIN32) || defined(__BIONIC__) /* emulate stpcpy() */ UnsafeCopyString(dest, src); return dest + StringLength(dest); diff --git a/src/util/TimeParser.cxx b/src/util/TimeParser.cxx index 9ce915c7f..5576b5a7d 100644 --- a/src/util/TimeParser.cxx +++ b/src/util/TimeParser.cxx @@ -35,7 +35,7 @@ #include #include -#if !defined(__GLIBC__) && !defined(WIN32) +#if !defined(__GLIBC__) && !defined(_WIN32) /** * Determine the time zone offset in a portable way. @@ -59,7 +59,7 @@ ParseTimePoint(const char *s, const char *format) assert(s != nullptr); assert(format != nullptr); -#ifdef WIN32 +#ifdef _WIN32 /* TODO: emulate strptime()? */ (void)s; (void)format; @@ -80,5 +80,5 @@ ParseTimePoint(const char *s, const char *format) return std::chrono::system_clock::from_time_t(t); -#endif /* !WIN32 */ +#endif /* !_WIN32 */ } diff --git a/src/util/WStringAPI.hxx b/src/util/WStringAPI.hxx index 6ed788927..4d000dab1 100644 --- a/src/util/WStringAPI.hxx +++ b/src/util/WStringAPI.hxx @@ -101,7 +101,7 @@ gcc_nonnull_all static inline wchar_t * UnsafeCopyStringP(wchar_t *dest, const wchar_t *src) noexcept { -#if defined(WIN32) || defined(__BIONIC__) || defined(__OpenBSD__) || \ +#if defined(_WIN32) || defined(__BIONIC__) || defined(__OpenBSD__) || \ defined(__NetBSD__) /* emulate wcpcpy() */ UnsafeCopyString(dest, src); diff --git a/src/win32/Win32Main.cxx b/src/win32/Win32Main.cxx index 700a32178..e26846321 100644 --- a/src/win32/Win32Main.cxx +++ b/src/win32/Win32Main.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "Main.hxx" -#ifdef WIN32 +#ifdef _WIN32 #include "Compiler.h" #include "Instance.hxx" diff --git a/test/ShutdownHandler.cxx b/test/ShutdownHandler.cxx index 6d69408f3..c0153cfde 100644 --- a/test/ShutdownHandler.cxx +++ b/test/ShutdownHandler.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "ShutdownHandler.hxx" -#ifndef WIN32 +#ifndef _WIN32 #include "event/SignalMonitor.hxx" #include "event/Loop.hxx" diff --git a/test/ShutdownHandler.hxx b/test/ShutdownHandler.hxx index 0e1a18a4e..eb2556364 100644 --- a/test/ShutdownHandler.hxx +++ b/test/ShutdownHandler.hxx @@ -28,7 +28,7 @@ public: ~ShutdownHandler(); }; -#ifdef WIN32 +#ifdef _WIN32 ShutdownHandler::ShutdownHandler(EventLoop &loop) {} ShutdownHandler::~ShutdownHandler() {} #endif diff --git a/test/run_resolver.cxx b/test/run_resolver.cxx index b35ed844a..da8ac7292 100644 --- a/test/run_resolver.cxx +++ b/test/run_resolver.cxx @@ -25,7 +25,7 @@ #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #else