From f510564d9d3591dba683224f1ca73f9c8dc65521 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 13 Oct 2021 11:28:04 +0200 Subject: [PATCH] more [[gnu::...]] attributes --- src/IdleFlags.hxx | 6 +-- src/Instance.hxx | 3 +- src/Mapper.hxx | 9 ++-- src/MixRampInfo.hxx | 8 ++- src/MusicBuffer.hxx | 2 +- src/MusicChunk.hxx | 2 +- src/MusicPipe.hxx | 11 ++-- src/ReplayGainInfo.hxx | 3 +- src/ReplayGainMode.cxx | 1 + src/ReplayGainMode.hxx | 4 +- src/SingleMode.cxx | 1 + src/SingleMode.hxx | 4 +- src/SongLoader.hxx | 7 ++- src/StateFile.hxx | 3 +- src/client/Client.hxx | 15 +++--- src/client/Message.hxx | 4 +- src/command/NeighborCommands.hxx | 3 +- src/command/PlaylistCommands.hxx | 3 +- src/config/Block.hxx | 12 ++--- src/config/Data.hxx | 8 +-- src/config/Option.hxx | 4 +- src/config/Param.hxx | 2 +- src/db/DatabaseLock.hxx | 3 +- src/db/Interface.hxx | 3 +- src/db/LightDirectory.hxx | 7 +-- src/db/PlaylistInfo.hxx | 4 +- src/db/PlaylistVector.hxx | 3 +- src/db/Registry.hxx | 4 +- src/db/Selection.hxx | 7 ++- src/db/plugins/simple/Directory.hxx | 25 +++++---- .../plugins/simple/SimpleDatabasePlugin.hxx | 9 ++-- src/db/plugins/simple/Song.hxx | 9 ++-- src/db/plugins/upnp/Directory.cxx | 6 +-- src/db/plugins/upnp/Directory.hxx | 3 +- src/db/plugins/upnp/Object.hxx | 5 +- src/db/update/ExcludeList.hxx | 3 +- src/db/update/Queue.hxx | 5 -- src/db/update/Service.hxx | 2 - src/db/update/UpdateIO.hxx | 8 ++- src/db/update/Walk.hxx | 3 +- src/decoder/Bridge.hxx | 2 +- src/decoder/Client.hxx | 7 ++- src/decoder/Control.hxx | 12 ++--- src/decoder/DecoderBuffer.hxx | 3 +- src/decoder/DecoderList.hxx | 6 +-- src/decoder/DecoderPlugin.hxx | 8 ++- src/decoder/plugins/DsdLib.hxx | 5 +- src/filter/Registry.hxx | 4 +- src/fs/AllocatedPath.hxx | 49 +++++++++-------- src/fs/Charset.hxx | 3 +- src/fs/Glob.hxx | 4 +- src/fs/Path.hxx | 17 +++--- src/fs/StandardDirectory.hxx | 2 +- src/fs/Traits.hxx | 54 +++++++++---------- src/fs/io/AutoGunzipReader.cxx | 2 +- src/fs/io/BufferedReader.hxx | 3 +- src/fs/io/FileOutputStream.hxx | 3 +- src/fs/io/FileReader.hxx | 5 +- src/fs/io/Reader.hxx | 4 +- src/input/AsyncInputStream.hxx | 2 +- src/input/Error.hxx | 4 +- src/input/IcyInputStream.hxx | 3 +- src/input/InputPlugin.hxx | 5 +- src/input/InputStream.hxx | 35 ++++++------ src/input/Registry.hxx | 4 +- src/input/cache/Manager.hxx | 9 ++-- src/input/plugins/FfmpegInputPlugin.cxx | 2 +- src/input/plugins/QobuzClient.hxx | 2 +- src/input/plugins/QobuzInputPlugin.cxx | 2 +- src/java/File.hxx | 6 +-- src/java/Global.hxx | 7 ++- src/lib/alsa/Format.hxx | 7 ++- src/lib/alsa/Version.cxx | 2 +- src/lib/alsa/Version.hxx | 4 +- src/lib/cdio/Paranoia.hxx | 5 +- src/lib/crypto/MD5.hxx | 5 +- src/lib/curl/Easy.hxx | 5 +- src/lib/curl/Global.cxx | 5 +- src/lib/curl/Request.cxx | 2 +- src/lib/curl/Version.hxx | 4 +- src/lib/dbus/Error.hxx | 4 +- src/lib/expat/ExpatParser.hxx | 10 ++-- src/lib/ffmpeg/Buffer.hxx | 4 +- src/lib/ffmpeg/IOContext.hxx | 5 +- src/lib/ffmpeg/Time.hxx | 11 ++-- src/lib/gcrypt/Hash.hxx | 3 +- src/lib/gcrypt/MD5.hxx | 3 +- src/lib/icu/Collate.cxx | 2 +- src/lib/icu/Collate.hxx | 4 +- src/lib/icu/Compare.hxx | 7 ++- src/lib/icu/Converter.hxx | 3 -- src/lib/icu/Win32.hxx | 6 +-- src/lib/nfs/Base.hxx | 4 +- src/lib/nfs/Cancellable.hxx | 14 +++-- src/lib/nfs/Connection.hxx | 7 ++- src/lib/nfs/Glue.hxx | 6 +-- src/lib/nfs/Manager.hxx | 9 ++-- src/lib/pcre/RegexPointer.hxx | 2 +- src/lib/upnp/ContentDirectoryService.hxx | 3 +- src/lib/xiph/FlacMetadataChain.hxx | 6 +-- src/ls.hxx | 4 +- src/mixer/Volume.hxx | 6 +-- src/neighbor/Glue.hxx | 3 +- src/neighbor/Registry.hxx | 4 +- src/net/ToString.hxx | 4 +- src/output/Control.hxx | 13 +++-- src/pcm/Buffer.hxx | 5 +- src/pcm/ChannelsConverter.hxx | 2 +- src/pcm/Export.hxx | 14 ++--- src/pcm/FormatConverter.hxx | 2 +- src/pcm/PcmFormat.hxx | 8 +-- src/pcm/Volume.hxx | 2 +- src/player/Control.hxx | 4 +- src/player/CrossFade.hxx | 3 +- src/player/Outputs.hxx | 3 +- src/playlist/PlaylistRegistry.hxx | 7 ++- src/song/AndSongFilter.hxx | 3 +- src/song/DetachedSong.hxx | 26 +++++---- src/song/Filter.hxx | 13 ++--- src/song/ISongFilter.hxx | 4 +- src/song/LightSong.hxx | 5 +- src/song/StringFilter.hxx | 5 +- src/storage/CompositeStorage.hxx | 17 +++--- src/storage/Configured.hxx | 4 +- src/storage/StorageInterface.hxx | 10 ++-- src/system/Clock.hxx | 4 +- src/tag/Id3Load.cxx | 2 +- src/thread/Id.hxx | 8 ++- src/thread/Thread.hxx | 3 +- src/unix/PidFile.hxx | 2 +- src/util/BitReverse.hxx | 4 +- src/util/HexFormat.hxx | 3 +- src/util/UriExtract.cxx | 6 +-- src/util/UriExtract.hxx | 14 +++-- src/util/UriUtil.hxx | 8 ++- 135 files changed, 361 insertions(+), 514 deletions(-) diff --git a/src/IdleFlags.hxx b/src/IdleFlags.hxx index b58fd02d1..2d413c838 100644 --- a/src/IdleFlags.hxx +++ b/src/IdleFlags.hxx @@ -25,8 +25,6 @@ #ifndef MPD_IDLE_FLAGS_HXX #define MPD_IDLE_FLAGS_HXX -#include "util/Compiler.h" - /** song database has been updated*/ static constexpr unsigned IDLE_DATABASE = 0x1; @@ -73,7 +71,7 @@ static constexpr unsigned IDLE_PARTITION = 0x2000; /** * Get idle names */ -gcc_const +[[gnu::const]] const char*const* idle_get_names() noexcept; @@ -81,7 +79,7 @@ idle_get_names() noexcept; * Parse an idle name and return its mask. Returns 0 if the given * name is unknown. */ -gcc_nonnull_all gcc_pure +[[gnu::nonnull]] [[gnu::pure]] unsigned idle_parse_name(const char *name) noexcept; diff --git a/src/Instance.hxx b/src/Instance.hxx index 189aabab4..68abe4cde 100644 --- a/src/Instance.hxx +++ b/src/Instance.hxx @@ -24,7 +24,6 @@ #include "event/Loop.hxx" #include "event/Thread.hxx" #include "event/MaskMonitor.hxx" -#include "util/Compiler.h" #ifdef ENABLE_SYSTEMD_DAEMON #include "lib/systemd/Watchdog.hxx" @@ -168,7 +167,7 @@ struct Instance final * Find a #Partition with the given name. Returns nullptr if * no such partition was found. */ - gcc_pure + [[gnu::pure]] Partition *FindPartition(const char *name) noexcept; void DeletePartition(Partition &partition) noexcept; diff --git a/src/Mapper.hxx b/src/Mapper.hxx index 6a2b033d5..19268dd94 100644 --- a/src/Mapper.hxx +++ b/src/Mapper.hxx @@ -24,7 +24,6 @@ #ifndef MPD_MAPPER_HXX #define MPD_MAPPER_HXX -#include "util/Compiler.h" #include "config.h" #include @@ -44,7 +43,7 @@ mapper_init(AllocatedPath &&playlist_dir); * is basically done by converting the URI to the file system charset * and prepending the music directory. */ -gcc_pure +[[gnu::pure]] AllocatedPath map_uri_fs(const char *uri) noexcept; @@ -56,7 +55,7 @@ map_uri_fs(const char *uri) noexcept; * @return the relative path in UTF-8, or an empty string if mapping * failed */ -gcc_pure +[[gnu::pure]] std::string map_fs_to_utf8(Path path_fs) noexcept; @@ -65,7 +64,7 @@ map_fs_to_utf8(Path path_fs) noexcept; /** * Returns the playlist directory. */ -gcc_const +[[gnu::const]] const AllocatedPath & map_spl_path() noexcept; @@ -75,7 +74,7 @@ map_spl_path() noexcept; * * @return the path in file system encoding, or nullptr if mapping failed */ -gcc_pure +[[gnu::pure]] AllocatedPath map_spl_utf8_to_fs(const char *name) noexcept; diff --git a/src/MixRampInfo.hxx b/src/MixRampInfo.hxx index 393991520..ebe094e1c 100644 --- a/src/MixRampInfo.hxx +++ b/src/MixRampInfo.hxx @@ -20,8 +20,6 @@ #ifndef MPD_MIX_RAMP_INFO_HXX #define MPD_MIX_RAMP_INFO_HXX -#include "util/Compiler.h" - #include class MixRampInfo { @@ -35,17 +33,17 @@ public: end.clear(); } - gcc_pure + [[gnu::pure]] bool IsDefined() const noexcept { return !start.empty() || !end.empty(); } - gcc_pure + [[gnu::pure]] const char *GetStart() const noexcept { return start.empty() ? nullptr : start.c_str(); } - gcc_pure + [[gnu::pure]] const char *GetEnd() const noexcept { return end.empty() ? nullptr : end.c_str(); } diff --git a/src/MusicBuffer.hxx b/src/MusicBuffer.hxx index 84120b2db..9d8ee2c0a 100644 --- a/src/MusicBuffer.hxx +++ b/src/MusicBuffer.hxx @@ -63,7 +63,7 @@ public: * is the same value which was passed to the constructor * music_buffer_new(). */ - gcc_pure + [[gnu::pure]] unsigned GetSize() const noexcept { return buffer.GetCapacity(); } diff --git a/src/MusicChunk.hxx b/src/MusicChunk.hxx index 4efadd50d..21720fd6f 100644 --- a/src/MusicChunk.hxx +++ b/src/MusicChunk.hxx @@ -105,7 +105,7 @@ struct MusicChunkInfo { * Checks if the audio format if the chunk is equal to the * specified audio_format. */ - gcc_pure + [[gnu::pure]] bool CheckFormat(AudioFormat audio_format) const noexcept; #endif }; diff --git a/src/MusicPipe.hxx b/src/MusicPipe.hxx index 8c9e0da23..68527391b 100644 --- a/src/MusicPipe.hxx +++ b/src/MusicPipe.hxx @@ -22,7 +22,6 @@ #include "MusicChunkPtr.hxx" #include "thread/Mutex.hxx" -#include "util/Compiler.h" #ifndef NDEBUG #include "pcm/AudioFormat.hxx" @@ -59,7 +58,7 @@ public: * Checks if the audio format if the chunk is equal to the specified * audio_format. */ - gcc_pure + [[gnu::pure]] bool CheckFormat(AudioFormat other) const noexcept { return !audio_format.IsDefined() || audio_format == other; @@ -68,7 +67,7 @@ public: /** * Checks if the specified chunk is enqueued in the music pipe. */ - gcc_pure + [[gnu::pure]] bool Contains(const MusicChunk *chunk) const noexcept; #endif @@ -76,7 +75,7 @@ public: * Returns the first #MusicChunk from the pipe. Returns * nullptr if the pipe is empty. */ - gcc_pure + [[gnu::pure]] const MusicChunk *Peek() const noexcept { const std::lock_guard protect(mutex); return head.get(); @@ -100,13 +99,13 @@ public: /** * Returns the number of chunks currently in this pipe. */ - gcc_pure + [[gnu::pure]] unsigned GetSize() const noexcept { const std::lock_guard protect(mutex); return size; } - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { return GetSize() == 0; } diff --git a/src/ReplayGainInfo.hxx b/src/ReplayGainInfo.hxx index 2febd3861..4ce685605 100644 --- a/src/ReplayGainInfo.hxx +++ b/src/ReplayGainInfo.hxx @@ -20,7 +20,6 @@ #ifndef MPD_REPLAY_GAIN_INFO_HXX #define MPD_REPLAY_GAIN_INFO_HXX -#include "util/Compiler.h" #include "ReplayGainMode.hxx" struct ReplayGainConfig; @@ -42,7 +41,7 @@ struct ReplayGainTuple { return {-200.0f, 0.0f}; } - gcc_pure + [[gnu::pure]] float CalculateScale(const ReplayGainConfig &config) const noexcept; }; diff --git a/src/ReplayGainMode.cxx b/src/ReplayGainMode.cxx index 0d8bf918d..6460e4540 100644 --- a/src/ReplayGainMode.cxx +++ b/src/ReplayGainMode.cxx @@ -18,6 +18,7 @@ */ #include "ReplayGainMode.hxx" +#include "util/Compiler.h" #include #include diff --git a/src/ReplayGainMode.hxx b/src/ReplayGainMode.hxx index 0557e8160..ff53b2592 100644 --- a/src/ReplayGainMode.hxx +++ b/src/ReplayGainMode.hxx @@ -20,8 +20,6 @@ #ifndef MPD_REPLAY_GAIN_MODE_HXX #define MPD_REPLAY_GAIN_MODE_HXX -#include "util/Compiler.h" - #include enum class ReplayGainMode : uint8_t { @@ -34,7 +32,7 @@ enum class ReplayGainMode : uint8_t { /** * Return the string representation of a #ReplayGainMode. */ -gcc_pure +[[gnu::pure]] const char * ToString(ReplayGainMode mode) noexcept; diff --git a/src/SingleMode.cxx b/src/SingleMode.cxx index 56a6faebe..0e27e8f0b 100644 --- a/src/SingleMode.cxx +++ b/src/SingleMode.cxx @@ -18,6 +18,7 @@ */ #include "SingleMode.hxx" +#include "util/Compiler.h" #include #include diff --git a/src/SingleMode.hxx b/src/SingleMode.hxx index 47e0c8c39..91a9a2619 100644 --- a/src/SingleMode.hxx +++ b/src/SingleMode.hxx @@ -20,8 +20,6 @@ #ifndef MPD_SINGLE_MODE_HXX #define MPD_SINGLE_MODE_HXX -#include "util/Compiler.h" - #include enum class SingleMode : uint8_t { @@ -33,7 +31,7 @@ enum class SingleMode : uint8_t { /** * Return the string representation of a #SingleMode. */ -gcc_pure +[[gnu::pure]] const char * SingleToString(SingleMode mode) noexcept; diff --git a/src/SongLoader.hxx b/src/SongLoader.hxx index 0cdc4636e..2af382926 100644 --- a/src/SongLoader.hxx +++ b/src/SongLoader.hxx @@ -20,7 +20,6 @@ #ifndef MPD_SONG_LOADER_HXX #define MPD_SONG_LOADER_HXX -#include "util/Compiler.h" #include "config.h" #include @@ -72,14 +71,14 @@ public: /** * Throws #std::runtime_error on error. */ - gcc_nonnull_all + [[gnu::nonnull]] DetachedSong LoadSong(const char *uri_utf8) const; private: - gcc_nonnull_all + [[gnu::nonnull]] DetachedSong LoadFromDatabase(const char *uri) const; - gcc_nonnull_all + [[gnu::nonnull]] DetachedSong LoadFile(const char *path_utf8, Path path_fs) const; }; diff --git a/src/StateFile.hxx b/src/StateFile.hxx index e94737dc1..7c1aed4b4 100644 --- a/src/StateFile.hxx +++ b/src/StateFile.hxx @@ -22,7 +22,6 @@ #include "StateFileConfig.hxx" #include "event/FarTimerEvent.hxx" -#include "util/Compiler.h" #include "config.h" #include @@ -76,7 +75,7 @@ private: * Check if MPD's state was modified since the last * RememberVersions() call. */ - gcc_pure + [[gnu::pure]] bool IsModified() const noexcept; /* callback for #timer_event */ diff --git a/src/client/Client.hxx b/src/client/Client.hxx index 516830669..c182eb6b5 100644 --- a/src/client/Client.hxx +++ b/src/client/Client.hxx @@ -27,7 +27,6 @@ #include "tag/Mask.hxx" #include "event/FullyBufferedSocket.hxx" #include "event/CoarseTimerEvent.hxx" -#include "util/Compiler.h" #include #include @@ -138,7 +137,7 @@ public: using FullyBufferedSocket::GetEventLoop; using FullyBufferedSocket::GetOutputMaxSize; - gcc_pure + [[gnu::pure]] bool IsExpired() const noexcept { return !FullyBufferedSocket::IsDefined(); } @@ -211,7 +210,7 @@ public: FULL, }; - gcc_pure + [[gnu::pure]] bool IsSubscribed(const char *channel_name) const noexcept { return subscriptions.find(channel_name) != subscriptions.end(); } @@ -252,19 +251,19 @@ public: void SetPartition(Partition &new_partition) noexcept; - gcc_pure + [[gnu::pure]] Instance &GetInstance() const noexcept; - gcc_pure + [[gnu::pure]] playlist &GetPlaylist() const noexcept; - gcc_pure + [[gnu::pure]] PlayerControl &GetPlayerControl() const noexcept; /** * Wrapper for Instance::GetDatabase(). */ - gcc_pure + [[gnu::pure]] const Database *GetDatabase() const noexcept; /** @@ -272,7 +271,7 @@ public: */ const Database &GetDatabaseOrThrow() const; - gcc_pure + [[gnu::pure]] const Storage *GetStorage() const noexcept; private: diff --git a/src/client/Message.hxx b/src/client/Message.hxx index 0c2f0ad41..ac2d58aba 100644 --- a/src/client/Message.hxx +++ b/src/client/Message.hxx @@ -20,8 +20,6 @@ #ifndef MPD_CLIENT_MESSAGE_HXX #define MPD_CLIENT_MESSAGE_HXX -#include "util/Compiler.h" - #include #ifdef _WIN32 @@ -51,7 +49,7 @@ public: } }; -gcc_pure +[[gnu::pure]] bool client_message_valid_channel_name(const char *name) noexcept; diff --git a/src/command/NeighborCommands.hxx b/src/command/NeighborCommands.hxx index ac5966182..94674cd9a 100644 --- a/src/command/NeighborCommands.hxx +++ b/src/command/NeighborCommands.hxx @@ -21,14 +21,13 @@ #define MPD_NEIGHBOR_COMMANDS_HXX #include "CommandResult.hxx" -#include "util/Compiler.h" struct Instance; class Client; class Request; class Response; -gcc_pure +[[gnu::pure]] bool neighbor_commands_available(const Instance &instance) noexcept; diff --git a/src/command/PlaylistCommands.hxx b/src/command/PlaylistCommands.hxx index 09c53cc94..32e9c5fcb 100644 --- a/src/command/PlaylistCommands.hxx +++ b/src/command/PlaylistCommands.hxx @@ -21,13 +21,12 @@ #define MPD_PLAYLIST_COMMANDS_HXX #include "CommandResult.hxx" -#include "util/Compiler.h" class Client; class Request; class Response; -gcc_const +[[gnu::const]] bool playlist_commands_available() noexcept; diff --git a/src/config/Block.hxx b/src/config/Block.hxx index c2f645ef5..82fce9761 100644 --- a/src/config/Block.hxx +++ b/src/config/Block.hxx @@ -20,8 +20,6 @@ #ifndef MPD_CONFIG_BLOCK_HXX #define MPD_CONFIG_BLOCK_HXX -#include "util/Compiler.h" - #include #include @@ -39,7 +37,7 @@ struct BlockParam { mutable bool used = false; template - gcc_nonnull_all + [[gnu::nonnull]] BlockParam(N &&_name, V &&_value, int _line=-1) noexcept :name(std::forward(_name)), value(std::forward(_value)), line(_line) {} @@ -99,7 +97,7 @@ struct ConfigBlock { return line < 0; } - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { return block_params.empty(); } @@ -109,17 +107,17 @@ struct ConfigBlock { } template - gcc_nonnull_all + [[gnu::nonnull]] void AddBlockParam(N &&_name, V &&_value, int _line=-1) noexcept { block_params.emplace_back(std::forward(_name), std::forward(_value), _line); } - gcc_nonnull_all gcc_pure + [[gnu::nonnull]] [[gnu::pure]] const BlockParam *GetBlockParam(const char *_name) const noexcept; - gcc_pure + [[gnu::pure]] const char *GetBlockValue(const char *name, const char *default_value=nullptr) const noexcept; diff --git a/src/config/Data.hxx b/src/config/Data.hxx index 7ce016885..73068f2c7 100644 --- a/src/config/Data.hxx +++ b/src/config/Data.hxx @@ -46,7 +46,7 @@ struct ConfigData { void AddParam(ConfigOption option, ConfigParam &¶m) noexcept; - gcc_pure + [[gnu::pure]] const ConfigParam *GetParam(ConfigOption option) const noexcept { const auto &list = GetParamList(option); return list.empty() ? nullptr : &list.front(); @@ -60,7 +60,7 @@ struct ConfigData { : f(nullptr); } - gcc_pure + [[gnu::pure]] const char *GetString(ConfigOption option, const char *default_value=nullptr) const noexcept; @@ -100,7 +100,7 @@ struct ConfigData { ConfigBlock &AddBlock(ConfigBlockOption option, ConfigBlock &&block) noexcept; - gcc_pure + [[gnu::pure]] const ConfigBlock *GetBlock(ConfigBlockOption option) const noexcept { const auto &list = GetBlockList(option); return list.empty() ? nullptr : &list.front(); @@ -115,7 +115,7 @@ struct ConfigData { * @param key the attribute name * @param value the expected attribute value */ - gcc_pure + [[gnu::pure]] const ConfigBlock *FindBlock(ConfigBlockOption option, const char *key, const char *value) const; diff --git a/src/config/Option.hxx b/src/config/Option.hxx index 568d46a45..e05c48fd1 100644 --- a/src/config/Option.hxx +++ b/src/config/Option.hxx @@ -102,14 +102,14 @@ enum class ConfigBlockOption { /** * @return #ConfigOption::MAX if not found */ -gcc_pure +[[gnu::pure]] enum ConfigOption ParseConfigOptionName(const char *name) noexcept; /** * @return #ConfigOption::MAX if not found */ -gcc_pure +[[gnu::pure]] enum ConfigBlockOption ParseConfigBlockOptionName(const char *name) noexcept; diff --git a/src/config/Param.hxx b/src/config/Param.hxx index dfd54ed58..9d0e48f2d 100644 --- a/src/config/Param.hxx +++ b/src/config/Param.hxx @@ -35,7 +35,7 @@ struct ConfigParam { :line(_line) {} template - gcc_nonnull_all + [[gnu::nonnull]] explicit ConfigParam(V &&_value, int _line=-1) noexcept :value(std::forward(_value)), line(_line) {} diff --git a/src/db/DatabaseLock.hxx b/src/db/DatabaseLock.hxx index 19466fb29..ce0ec2579 100644 --- a/src/db/DatabaseLock.hxx +++ b/src/db/DatabaseLock.hxx @@ -27,7 +27,6 @@ #define MPD_DB_LOCK_HXX #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include @@ -42,7 +41,7 @@ extern ThreadId db_mutex_holder; /** * Does the current thread hold the database lock? */ -gcc_pure +[[gnu::pure]] static inline bool holding_db_lock() noexcept { diff --git a/src/db/Interface.hxx b/src/db/Interface.hxx index 76f25c66c..c414611aa 100644 --- a/src/db/Interface.hxx +++ b/src/db/Interface.hxx @@ -22,7 +22,6 @@ #include "Visitor.hxx" #include "tag/Type.h" -#include "util/Compiler.h" #include #include @@ -136,7 +135,7 @@ public: * Returns the time stamp of the last database update. * Returns a negative value if that is not not known/available. */ - gcc_pure + [[gnu::pure]] virtual std::chrono::system_clock::time_point GetUpdateStamp() const noexcept = 0; }; diff --git a/src/db/LightDirectory.hxx b/src/db/LightDirectory.hxx index 1dec50143..962fd856b 100644 --- a/src/db/LightDirectory.hxx +++ b/src/db/LightDirectory.hxx @@ -20,12 +20,9 @@ #ifndef MPD_LIGHT_DIRECTORY_HXX #define MPD_LIGHT_DIRECTORY_HXX -#include "util/Compiler.h" - +#include #include -#include - struct Tag; /** @@ -53,7 +50,7 @@ struct LightDirectory { return *uri == 0; } - gcc_pure + [[gnu::pure]] const char *GetPath() const noexcept { return uri; } diff --git a/src/db/PlaylistInfo.hxx b/src/db/PlaylistInfo.hxx index ca3f136a6..e5e655a4f 100644 --- a/src/db/PlaylistInfo.hxx +++ b/src/db/PlaylistInfo.hxx @@ -20,8 +20,6 @@ #ifndef MPD_PLAYLIST_INFO_HXX #define MPD_PLAYLIST_INFO_HXX -#include "util/Compiler.h" - #include #include #include @@ -49,7 +47,7 @@ struct PlaylistInfo { constexpr CompareName(std::string_view _name) noexcept :name(_name) {} - gcc_pure + [[gnu::pure]] bool operator()(const PlaylistInfo &pi) const noexcept { return pi.name == name; } diff --git a/src/db/PlaylistVector.hxx b/src/db/PlaylistVector.hxx index 5136c17e6..cf51749b2 100644 --- a/src/db/PlaylistVector.hxx +++ b/src/db/PlaylistVector.hxx @@ -21,7 +21,6 @@ #define MPD_PLAYLIST_VECTOR_HXX #include "db/PlaylistInfo.hxx" -#include "util/Compiler.h" #include #include @@ -31,7 +30,7 @@ protected: /** * Caller must lock the #db_mutex. */ - gcc_pure + [[gnu::pure]] iterator find(std::string_view name) noexcept; public: diff --git a/src/db/Registry.hxx b/src/db/Registry.hxx index a136693e0..8c4648478 100644 --- a/src/db/Registry.hxx +++ b/src/db/Registry.hxx @@ -20,8 +20,6 @@ #ifndef MPD_DATABASE_REGISTRY_HXX #define MPD_DATABASE_REGISTRY_HXX -#include "util/Compiler.h" - struct DatabasePlugin; /** @@ -30,7 +28,7 @@ struct DatabasePlugin; */ extern const DatabasePlugin *const database_plugins[]; -gcc_pure +[[gnu::pure]] const DatabasePlugin * GetDatabasePluginByName(const char *name) noexcept; diff --git a/src/db/Selection.hxx b/src/db/Selection.hxx index 20938e141..a54210dac 100644 --- a/src/db/Selection.hxx +++ b/src/db/Selection.hxx @@ -22,7 +22,6 @@ #include "protocol/RangeArg.hxx" #include "tag/Type.h" -#include "util/Compiler.h" #include @@ -60,16 +59,16 @@ struct DatabaseSelection { DatabaseSelection(const char *_uri, bool _recursive, const SongFilter *_filter=nullptr) noexcept; - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept; /** * Does this selection contain constraints other than "base"? */ - gcc_pure + [[gnu::pure]] bool HasOtherThanBase() const noexcept; - gcc_pure + [[gnu::pure]] bool Match(const LightSong &song) const noexcept; }; diff --git a/src/db/plugins/simple/Directory.hxx b/src/db/plugins/simple/Directory.hxx index 87e8351e7..50728fb45 100644 --- a/src/db/plugins/simple/Directory.hxx +++ b/src/db/plugins/simple/Directory.hxx @@ -21,7 +21,6 @@ #define MPD_DIRECTORY_HXX #include "Ptr.hxx" -#include "util/Compiler.h" #include "db/Visitor.hxx" #include "db/PlaylistVector.hxx" #include "db/Ptr.hxx" @@ -113,7 +112,7 @@ public: /** * Create a new root #Directory object. */ - gcc_malloc gcc_returns_nonnull + [[gnu::malloc]] [[gnu::returns_nonnull]] static Directory *NewRoot() noexcept { return new Directory(std::string(), nullptr); } @@ -141,7 +140,7 @@ public: * (e.g. #DEVICE_PLAYLIST) and whether the underlying plugin * is available. */ - gcc_pure + [[gnu::pure]] bool IsPluginAvailable() const noexcept; /** @@ -164,10 +163,10 @@ public: /** * Caller must lock the #db_mutex. */ - gcc_pure + [[gnu::pure]] const Directory *FindChild(std::string_view name) const noexcept; - gcc_pure + [[gnu::pure]] Directory *FindChild(std::string_view name) noexcept { const Directory *cthis = this; return const_cast(cthis->FindChild(name)); @@ -211,20 +210,20 @@ public: * * @param uri the relative URI */ - gcc_pure + [[gnu::pure]] LookupResult LookupDirectory(std::string_view uri) noexcept; [[gnu::pure]] bool TargetExists(std::string_view target) const noexcept; - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { return children.empty() && songs.empty() && playlists.empty(); } - gcc_pure + [[gnu::pure]] const char *GetPath() const noexcept { return path.c_str(); } @@ -232,13 +231,13 @@ public: /** * Returns the base name of the directory. */ - gcc_pure + [[gnu::pure]] const char *GetName() const noexcept; /** * Is this the root directory of the music database? */ - gcc_pure + [[gnu::pure]] bool IsRoot() const noexcept { return parent == nullptr; } @@ -266,10 +265,10 @@ public: * * Caller must lock the #db_mutex. */ - gcc_pure + [[gnu::pure]] const Song *FindSong(std::string_view name_utf8) const noexcept; - gcc_pure + [[gnu::pure]] Song *FindSong(std::string_view name_utf8) noexcept { const Directory *cthis = this; return const_cast(cthis->FindSong(name_utf8)); @@ -307,7 +306,7 @@ public: const VisitDirectory& visit_directory, const VisitSong& visit_song, const VisitPlaylist& visit_playlist) const; - gcc_pure + [[gnu::pure]] LightDirectory Export() const noexcept; }; diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx index 4fe68014e..9a8bd42f9 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx @@ -25,7 +25,6 @@ #include "db/Ptr.hxx" #include "fs/AllocatedPath.hxx" #include "util/Manual.hxx" -#include "util/Compiler.h" #include "config.h" #include @@ -78,7 +77,7 @@ public: DatabaseListener &listener, const ConfigBlock &block); - gcc_pure + [[gnu::pure]] Directory &GetRoot() noexcept { assert(root != NULL); @@ -98,7 +97,7 @@ public: * @param db the #Database to be mounted; must be "open"; on * success, this object gains ownership of the given #Database */ - gcc_nonnull_all + [[gnu::nonnull]] void Mount(const char *uri, DatabasePtr db); /** @@ -106,10 +105,10 @@ public: * * @return false if the mounted database needs to be updated */ - gcc_nonnull_all + [[gnu::nonnull]] bool Mount(const char *local_uri, const char *storage_uri); - gcc_nonnull_all + [[gnu::nonnull]] bool Unmount(const char *uri) noexcept; /* virtual methods from class Database */ diff --git a/src/db/plugins/simple/Song.hxx b/src/db/plugins/simple/Song.hxx index eb425dc5c..795a066d0 100644 --- a/src/db/plugins/simple/Song.hxx +++ b/src/db/plugins/simple/Song.hxx @@ -24,7 +24,6 @@ #include "Chrono.hxx" #include "tag/Tag.hxx" #include "pcm/AudioFormat.hxx" -#include "util/Compiler.h" #include "config.h" #include @@ -108,14 +107,14 @@ struct Song { Song(DetachedSong &&other, Directory &_parent) noexcept; - gcc_pure + [[gnu::pure]] const char *GetFilenameSuffix() const noexcept; /** * Checks whether the decoder plugin for this song is * available. */ - gcc_pure + [[gnu::pure]] bool IsPluginAvailable() const noexcept; /** @@ -149,10 +148,10 @@ struct Song { * Returns the URI of the song in UTF-8 encoding, including its * location within the music directory. */ - gcc_pure + [[gnu::pure]] std::string GetURI() const noexcept; - gcc_pure + [[gnu::pure]] ExportedSong Export() const noexcept; }; diff --git a/src/db/plugins/upnp/Directory.cxx b/src/db/plugins/upnp/Directory.cxx index 59dfba0e6..19c96a385 100644 --- a/src/db/plugins/upnp/Directory.cxx +++ b/src/db/plugins/upnp/Directory.cxx @@ -33,7 +33,7 @@ /* this destructor exists here just so it won't get inlined */ UPnPDirContent::~UPnPDirContent() = default; -gcc_pure +[[gnu::pure]] static UPnPDirObject::ItemClass ParseItemClass(StringView name) noexcept { @@ -45,7 +45,7 @@ ParseItemClass(StringView name) noexcept return UPnPDirObject::ItemClass::UNKNOWN; } -gcc_pure +[[gnu::pure]] static SignedSongTime ParseDuration(const char *duration) noexcept { @@ -73,7 +73,7 @@ ParseDuration(const char *duration) noexcept * elements. There is a very slight risk of collision in doing * this. Twonky returns directory names (titles) like 'Artist/Album'. */ -gcc_pure +[[gnu::pure]] static std::string && TitleToPathSegment(std::string &&s) noexcept { diff --git a/src/db/plugins/upnp/Directory.hxx b/src/db/plugins/upnp/Directory.hxx index af500099a..297b62a88 100644 --- a/src/db/plugins/upnp/Directory.hxx +++ b/src/db/plugins/upnp/Directory.hxx @@ -21,7 +21,6 @@ #define MPD_UPNP_DIRECTORY_HXX #include "Object.hxx" -#include "util/Compiler.h" #include #include @@ -39,7 +38,7 @@ public: ~UPnPDirContent(); - gcc_pure + [[gnu::pure]] UPnPDirObject *FindObject(std::string_view name) noexcept { for (auto &o : objects) if (o.name == name) diff --git a/src/db/plugins/upnp/Object.hxx b/src/db/plugins/upnp/Object.hxx index e2bd908a7..49942fa0f 100644 --- a/src/db/plugins/upnp/Object.hxx +++ b/src/db/plugins/upnp/Object.hxx @@ -21,7 +21,6 @@ #define MPD_UPNP_OBJECT_HXX #include "tag/Tag.hxx" -#include "util/Compiler.h" #include @@ -89,12 +88,12 @@ public: tag.Clear(); } - gcc_pure + [[gnu::pure]] bool IsRoot() const noexcept { return type == Type::CONTAINER && id == "0"; } - gcc_pure + [[gnu::pure]] bool Check() const noexcept { return !id.empty() && /* root nodes don't need a parent id and a diff --git a/src/db/update/ExcludeList.hxx b/src/db/update/ExcludeList.hxx index 102c1cfba..10c5840bf 100644 --- a/src/db/update/ExcludeList.hxx +++ b/src/db/update/ExcludeList.hxx @@ -25,7 +25,6 @@ #ifndef MPD_EXCLUDE_H #define MPD_EXCLUDE_H -#include "util/Compiler.h" #include "fs/Glob.hxx" #include "input/Ptr.hxx" #include "config.h" @@ -50,7 +49,7 @@ public: ExcludeList(const ExcludeList &_parent) noexcept :parent(&_parent) {} - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { #ifdef HAVE_CLASS_GLOB return ((parent == nullptr) || parent->IsEmpty()) && patterns.empty(); diff --git a/src/db/update/Queue.hxx b/src/db/update/Queue.hxx index 3b4e8aa46..d9a543977 100644 --- a/src/db/update/Queue.hxx +++ b/src/db/update/Queue.hxx @@ -20,8 +20,6 @@ #ifndef MPD_UPDATE_QUEUE_HXX #define MPD_UPDATE_QUEUE_HXX -#include "util/Compiler.h" - #include #include #include @@ -61,7 +59,6 @@ class UpdateQueue { std::list update_queue; public: - gcc_nonnull_all bool Push(SimpleDatabase &db, Storage &storage, std::string_view path, bool discard, unsigned id) noexcept; @@ -71,10 +68,8 @@ public: update_queue.clear(); } - gcc_nonnull_all void Erase(SimpleDatabase &db) noexcept; - gcc_nonnull_all void Erase(Storage &storage) noexcept; }; diff --git a/src/db/update/Service.hxx b/src/db/update/Service.hxx index 0d372ce5f..80964a3b8 100644 --- a/src/db/update/Service.hxx +++ b/src/db/update/Service.hxx @@ -24,7 +24,6 @@ #include "Queue.hxx" #include "event/InjectEvent.hxx" #include "thread/Thread.hxx" -#include "util/Compiler.h" #include #include @@ -90,7 +89,6 @@ public: * the whole music directory is updated * @return the job id */ - gcc_nonnull_all unsigned Enqueue(std::string_view path, bool discard); /** diff --git a/src/db/update/UpdateIO.hxx b/src/db/update/UpdateIO.hxx index 7846d5189..9f01165be 100644 --- a/src/db/update/UpdateIO.hxx +++ b/src/db/update/UpdateIO.hxx @@ -20,8 +20,6 @@ #ifndef MPD_UPDATE_IO_HXX #define MPD_UPDATE_IO_HXX -#include "util/Compiler.h" - #include struct Directory; @@ -43,11 +41,11 @@ GetInfo(Storage &storage, const char *uri_utf8, StorageFileInfo &info) noexcept; bool GetInfo(StorageDirectoryReader &reader, StorageFileInfo &info) noexcept; -gcc_pure +[[gnu::pure]] bool DirectoryExists(Storage &storage, const Directory &directory) noexcept; -gcc_pure +[[gnu::pure]] bool directory_child_is_regular(Storage &storage, const Directory &directory, std::string_view name_utf8) noexcept; @@ -55,7 +53,7 @@ directory_child_is_regular(Storage &storage, const Directory &directory, /** * Checks if the given permissions on the mapped file are given. */ -gcc_pure +[[gnu::pure]] bool directory_child_access(Storage &storage, const Directory &directory, std::string_view name, int mode) noexcept; diff --git a/src/db/update/Walk.hxx b/src/db/update/Walk.hxx index b2417fab4..c777751f1 100644 --- a/src/db/update/Walk.hxx +++ b/src/db/update/Walk.hxx @@ -22,7 +22,6 @@ #include "Config.hxx" #include "Editor.hxx" -#include "util/Compiler.h" #include "config.h" #include @@ -76,7 +75,7 @@ public: bool Walk(Directory &root, const char *path, bool discard) noexcept; private: - gcc_pure + [[gnu::pure]] bool SkipSymlink(const Directory *directory, std::string_view utf8_name) const noexcept; diff --git a/src/decoder/Bridge.hxx b/src/decoder/Bridge.hxx index daaae0149..6dbf71c9a 100644 --- a/src/decoder/Bridge.hxx +++ b/src/decoder/Bridge.hxx @@ -132,7 +132,7 @@ public: * * Caller must lock the #DecoderControl object. */ - gcc_pure + [[gnu::pure]] bool CheckCancelRead() const noexcept; /** diff --git a/src/decoder/Client.hxx b/src/decoder/Client.hxx index a2e081a5b..8f670885d 100644 --- a/src/decoder/Client.hxx +++ b/src/decoder/Client.hxx @@ -23,7 +23,6 @@ #include "Command.hxx" #include "Chrono.hxx" #include "input/Ptr.hxx" -#include "util/Compiler.h" #include @@ -57,7 +56,7 @@ public: * @return the current command, or DecoderCommand::NONE if there is no * command pending */ - gcc_pure + [[gnu::pure]] virtual DecoderCommand GetCommand() noexcept = 0; /** @@ -72,7 +71,7 @@ public: * * @return the destination position for the seek */ - gcc_pure + [[gnu::pure]] virtual SongTime GetSeekTime() noexcept = 0; /** @@ -80,7 +79,7 @@ public: * * @return the destination position for the seek in frames */ - gcc_pure + [[gnu::pure]] virtual uint64_t GetSeekFrame() noexcept = 0; /** diff --git a/src/decoder/Control.hxx b/src/decoder/Control.hxx index 8312da918..0a02f2066 100644 --- a/src/decoder/Control.hxx +++ b/src/decoder/Control.hxx @@ -229,7 +229,7 @@ public: state == DecoderState::ERROR; } - gcc_pure + [[gnu::pure]] bool LockIsIdle() const noexcept { const std::lock_guard protect(mutex); return IsIdle(); @@ -239,7 +239,7 @@ public: return state == DecoderState::START; } - gcc_pure + [[gnu::pure]] bool LockIsStarting() const noexcept { const std::lock_guard protect(mutex); return IsStarting(); @@ -251,7 +251,7 @@ public: return state == DecoderState::ERROR; } - gcc_pure + [[gnu::pure]] bool LockHasFailed() const noexcept { const std::lock_guard protect(mutex); return HasFailed(); @@ -307,15 +307,15 @@ public: * * Caller must lock the object. */ - gcc_pure + [[gnu::pure]] bool IsCurrentSong(const DetachedSong &_song) const noexcept; - gcc_pure + [[gnu::pure]] bool IsUnseekableCurrentSong(const DetachedSong &_song) const noexcept { return !seekable && IsCurrentSong(_song); } - gcc_pure + [[gnu::pure]] bool IsSeekableCurrentSong(const DetachedSong &_song) const noexcept { return seekable && IsCurrentSong(_song); } diff --git a/src/decoder/DecoderBuffer.hxx b/src/decoder/DecoderBuffer.hxx index 4e89d817b..7b72d8a00 100644 --- a/src/decoder/DecoderBuffer.hxx +++ b/src/decoder/DecoderBuffer.hxx @@ -20,7 +20,6 @@ #ifndef MPD_DECODER_BUFFER_HXX #define MPD_DECODER_BUFFER_HXX -#include "util/Compiler.h" #include "util/DynamicFifoBuffer.hxx" #include "util/ConstBuffer.hxx" @@ -74,7 +73,7 @@ public: /** * How many bytes are stored in the buffer? */ - gcc_pure + [[gnu::pure]] size_t GetAvailable() const noexcept { return buffer.GetAvailable(); } diff --git a/src/decoder/DecoderList.hxx b/src/decoder/DecoderList.hxx index a166124c4..845969be2 100644 --- a/src/decoder/DecoderList.hxx +++ b/src/decoder/DecoderList.hxx @@ -20,8 +20,6 @@ #ifndef MPD_DECODER_LIST_HXX #define MPD_DECODER_LIST_HXX -#include "util/Compiler.h" - #include struct ConfigData; @@ -32,7 +30,7 @@ extern bool decoder_plugins_enabled[]; /* interface for using plugins */ -gcc_pure +[[gnu::pure]] const struct DecoderPlugin * decoder_plugin_from_name(const char *name) noexcept; @@ -98,7 +96,7 @@ decoder_plugins_for_each_enabled(F f) * Is there at least once #DecoderPlugin that supports the specified * file name suffix? */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] bool decoder_plugins_supports_suffix(std::string_view suffix) noexcept; diff --git a/src/decoder/DecoderPlugin.hxx b/src/decoder/DecoderPlugin.hxx index d4887477c..64f139b51 100644 --- a/src/decoder/DecoderPlugin.hxx +++ b/src/decoder/DecoderPlugin.hxx @@ -20,8 +20,6 @@ #ifndef MPD_DECODER_PLUGIN_HXX #define MPD_DECODER_PLUGIN_HXX -#include "util/Compiler.h" - #include // IWYU pragma: export #include #include @@ -246,19 +244,19 @@ struct DecoderPlugin { return container_scan(path, tnum); } - gcc_pure + [[gnu::pure]] bool SupportsUri(const char *uri) const noexcept; /** * Does the plugin announce the specified file name suffix? */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] bool SupportsSuffix(std::string_view suffix) const noexcept; /** * Does the plugin announce the specified MIME type? */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] bool SupportsMimeType(std::string_view mime_type) const noexcept; bool SupportsContainerSuffix(std::string_view suffix) const noexcept { diff --git a/src/decoder/plugins/DsdLib.hxx b/src/decoder/plugins/DsdLib.hxx index b2c5c4189..960cad19a 100644 --- a/src/decoder/plugins/DsdLib.hxx +++ b/src/decoder/plugins/DsdLib.hxx @@ -22,7 +22,6 @@ #include "util/ByteOrder.hxx" #include "input/Offset.hxx" -#include "util/Compiler.h" #include @@ -33,7 +32,7 @@ class InputStream; struct DsdId { char value[4]; - gcc_pure + [[gnu::pure]] bool Equals(const char *s) const noexcept; }; @@ -70,7 +69,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is, /** * Check if the sample frequency is a valid DSD frequency. **/ -gcc_const +[[gnu::const]] bool dsdlib_valid_freq(uint32_t samplefreq) noexcept; diff --git a/src/filter/Registry.hxx b/src/filter/Registry.hxx index b1051f906..06ed3bf25 100644 --- a/src/filter/Registry.hxx +++ b/src/filter/Registry.hxx @@ -26,11 +26,9 @@ #ifndef MPD_FILTER_REGISTRY_HXX #define MPD_FILTER_REGISTRY_HXX -#include "util/Compiler.h" - struct FilterPlugin; -gcc_pure +[[gnu::pure]] const FilterPlugin * filter_plugin_by_name(const char *name) noexcept; diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx index e5b8e5eac..374abddf3 100644 --- a/src/fs/AllocatedPath.hxx +++ b/src/fs/AllocatedPath.hxx @@ -20,7 +20,6 @@ #ifndef MPD_FS_ALLOCATED_PATH_HXX #define MPD_FS_ALLOCATED_PATH_HXX -#include "util/Compiler.h" #include "Traits.hxx" #include "Path.hxx" @@ -81,7 +80,7 @@ public: ~AllocatedPath() noexcept; - gcc_pure + [[gnu::pure]] operator Path() const noexcept { return Path::FromFS(c_str()); } @@ -89,40 +88,40 @@ public: /** * Join two path components with the path separator. */ - gcc_pure + [[gnu::pure]] static AllocatedPath Build(string_view a, string_view b) noexcept { return AllocatedPath(Traits::Build(a, b)); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] static AllocatedPath Build(Path a, string_view b) noexcept { return Build(a.c_str(), b); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] static AllocatedPath Build(Path a, Path b) noexcept { return Build(a, b.c_str()); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] static AllocatedPath Build(string_view a, const AllocatedPath &b) noexcept { return Build(a, b.value); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] static AllocatedPath Build(const AllocatedPath &a, string_view b) noexcept { return Build(a.value, b); } - gcc_pure + [[gnu::pure]] static AllocatedPath Build(const AllocatedPath &a, const AllocatedPath &b) noexcept { return Build(a.value, b.value); } - gcc_pure + [[gnu::pure]] static AllocatedPath Apply(Path base, Path path) noexcept { return Traits::Apply(base.c_str(), path.c_str()); } @@ -131,17 +130,17 @@ public: * Convert a C string that is already in the filesystem * character set to a #Path instance. */ - gcc_pure + [[gnu::pure]] static AllocatedPath FromFS(const_pointer fs) noexcept { return AllocatedPath(fs); } - gcc_pure + [[gnu::pure]] static AllocatedPath FromFS(string_view fs) noexcept { return AllocatedPath(fs); } - gcc_pure + [[gnu::pure]] static AllocatedPath FromFS(const_pointer _begin, const_pointer _end) noexcept { return AllocatedPath(_begin, _end); @@ -151,13 +150,13 @@ public: * Convert a C++ string that is already in the filesystem * character set to a #Path instance. */ - gcc_pure + [[gnu::pure]] static AllocatedPath FromFS(string &&fs) noexcept { return AllocatedPath(std::move(fs)); } #ifdef ANDROID - gcc_pure + [[gnu::pure]] static AllocatedPath FromUTF8(std::string &&utf8) noexcept { /* on Android, the filesystem charset is hard-coded to UTF-8 */ @@ -173,7 +172,7 @@ public: * Convert a UTF-8 C string to an #AllocatedPath instance. * Returns return a "nulled" instance on error. */ - gcc_pure + [[gnu::pure]] static AllocatedPath FromUTF8(std::string_view path_utf8) noexcept; static AllocatedPath FromUTF8(const char *path_utf8) noexcept { @@ -199,12 +198,12 @@ public: return *this; } - gcc_pure + [[gnu::pure]] bool operator==(const AllocatedPath &other) const noexcept { return value == other.value; } - gcc_pure + [[gnu::pure]] bool operator!=(const AllocatedPath &other) const noexcept { return value != other.value; } @@ -238,7 +237,7 @@ public: * @return the length of this string in number of "value_type" * elements (which may not be the number of characters). */ - gcc_pure + [[gnu::pure]] size_t length() const noexcept { return value.length(); } @@ -248,7 +247,7 @@ public: * pointer is invalidated whenever the value of life of this * instance ends. */ - gcc_pure + [[gnu::pure]] const_pointer c_str() const noexcept { return value.c_str(); } @@ -257,7 +256,7 @@ public: * Returns a pointer to the raw value, not necessarily * null-terminated. */ - gcc_pure + [[gnu::pure]] const_pointer data() const noexcept { return value.data(); } @@ -267,7 +266,7 @@ public: * Returns empty string on error or if this instance is "nulled" * (#IsNull returns true). */ - gcc_pure + [[gnu::pure]] std::string ToUTF8() const noexcept { return ((Path)*this).ToUTF8(); } @@ -280,7 +279,7 @@ public: * Gets directory name of this path. * Returns a "nulled" instance on error. */ - gcc_pure + [[gnu::pure]] AllocatedPath GetDirectoryName() const noexcept { return ((Path)*this).GetDirectoryName(); } @@ -291,12 +290,12 @@ public: * empty string if the given path equals this object or * nullptr on mismatch. */ - gcc_pure + [[gnu::pure]] const_pointer Relative(Path other_fs) const noexcept { return Traits::Relative(c_str(), other_fs.c_str()); } - gcc_pure + [[gnu::pure]] const_pointer GetSuffix() const noexcept { return ((Path)*this).GetSuffix(); } @@ -306,7 +305,7 @@ public: */ void ChopSeparators() noexcept; - gcc_pure + [[gnu::pure]] bool IsAbsolute() const noexcept { return Traits::IsAbsolute(c_str()); } diff --git a/src/fs/Charset.hxx b/src/fs/Charset.hxx index 8b858dea8..d4f3370f1 100644 --- a/src/fs/Charset.hxx +++ b/src/fs/Charset.hxx @@ -20,13 +20,12 @@ #ifndef MPD_FS_CHARSET_HXX #define MPD_FS_CHARSET_HXX -#include "util/Compiler.h" #include "Traits.hxx" /** * Gets file system character set name. */ -gcc_const +[[gnu::const]] const char * GetFSCharset() noexcept; diff --git a/src/fs/Glob.hxx b/src/fs/Glob.hxx index 65e3a9e1f..a897abd69 100644 --- a/src/fs/Glob.hxx +++ b/src/fs/Glob.hxx @@ -30,8 +30,6 @@ #endif #ifdef HAVE_CLASS_GLOB -#include "util/Compiler.h" - #include /** @@ -48,7 +46,7 @@ public: Glob(Glob &&other) noexcept = default; Glob &operator=(Glob &&other) noexcept = default; - gcc_pure + [[gnu::pure]] bool Check(const char *name_fs) const noexcept; }; diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx index 04ae21fea..2e5ef14b6 100644 --- a/src/fs/Path.hxx +++ b/src/fs/Path.hxx @@ -20,7 +20,6 @@ #ifndef MPD_FS_PATH_HXX #define MPD_FS_PATH_HXX -#include "util/Compiler.h" #include "Traits.hxx" #include @@ -88,7 +87,7 @@ public: * @return the length of this string in number of "value_type" * elements (which may not be the number of characters). */ - gcc_pure + [[gnu::pure]] size_t length() const noexcept { assert(!IsNull()); @@ -117,7 +116,7 @@ public: * usually rejected by MPD because its protocol cannot * transfer newline characters). */ - gcc_pure + [[gnu::pure]] bool HasNewline() const noexcept { return Traits::Find(c_str(), '\n') != nullptr; } @@ -127,7 +126,7 @@ public: * Returns empty string on error or if this instance is "nulled" * (#IsNull returns true). */ - gcc_pure + [[gnu::pure]] std::string ToUTF8() const noexcept; /** @@ -139,7 +138,7 @@ public: * Determine the "base" file name. * The return value points inside this object. */ - gcc_pure + [[gnu::pure]] Path GetBase() const noexcept { return FromFS(Traits::GetBase(c_str())); } @@ -148,7 +147,7 @@ public: * Gets directory name of this path. * Returns a "nulled" instance on error. */ - gcc_pure + [[gnu::pure]] AllocatedPath GetDirectoryName() const noexcept; /** @@ -157,17 +156,17 @@ public: * empty string if the given path equals this object or * nullptr on mismatch. */ - gcc_pure + [[gnu::pure]] const_pointer Relative(Path other_fs) const noexcept { return Traits::Relative(c_str(), other_fs.c_str()); } - gcc_pure + [[gnu::pure]] bool IsAbsolute() const noexcept { return Traits::IsAbsolute(c_str()); } - gcc_pure + [[gnu::pure]] const_pointer GetSuffix() const noexcept; }; diff --git a/src/fs/StandardDirectory.hxx b/src/fs/StandardDirectory.hxx index e674fd926..a94f1629d 100644 --- a/src/fs/StandardDirectory.hxx +++ b/src/fs/StandardDirectory.hxx @@ -37,7 +37,7 @@ GetUserMusicDir() noexcept; /** * Obtains cache directory for the current user. */ -gcc_pure +[[gnu::pure]] AllocatedPath GetUserCacheDir() noexcept; diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index f88cf33ac..1830758fb 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -71,7 +71,7 @@ struct PathTraitsFS { ch == SEPARATOR; } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer FindLastSeparator(const_pointer p) noexcept { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ @@ -100,7 +100,7 @@ struct PathTraitsFS { #endif } - gcc_pure + [[gnu::pure]] static const_pointer GetFilenameSuffix(const_pointer filename) noexcept { const_pointer dot = StringFindLast(filename, '.'); return dot != nullptr && dot > filename && dot[1] != 0 @@ -108,13 +108,13 @@ struct PathTraitsFS { : nullptr; } - gcc_pure + [[gnu::pure]] static const_pointer GetPathSuffix(const_pointer path) noexcept { return GetFilenameSuffix(GetBase(path)); } #ifdef _WIN32 - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static constexpr bool IsDrive(const_pointer p) noexcept { return IsAlphaASCII(p[0]) && p[1] == ':'; } @@ -124,7 +124,7 @@ struct PathTraitsFS { } #endif - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static bool IsAbsolute(const_pointer p) noexcept { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ @@ -138,18 +138,18 @@ struct PathTraitsFS { return IsSeparator(*p); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static bool IsSpecialFilename(const_pointer name) noexcept { return (name[0] == '.' && name[1] == 0) || (name[0] == '.' && name[1] == '.' && name[2] == 0); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static size_t GetLength(const_pointer p) noexcept { return StringLength(p); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer Find(const_pointer p, value_type ch) noexcept { return StringFind(p, ch); } @@ -158,7 +158,7 @@ struct PathTraitsFS { * Determine the "base" file name of the given native path. * The return value points inside the given string. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer GetBase(const_pointer p) noexcept; /** @@ -166,7 +166,7 @@ struct PathTraitsFS { * As a special case, returns the string "." if there is no * separator in the given input string. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static string_view GetParent(const_pointer p) noexcept; [[gnu::pure]] @@ -178,10 +178,10 @@ struct PathTraitsFS { * empty string if the given path equals this object or * nullptr on mismatch. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer Relative(string_view base, const_pointer other) noexcept; - gcc_pure + [[gnu::pure]] static string_view Relative(string_view base, string_view other) noexcept; /** @@ -190,14 +190,14 @@ struct PathTraitsFS { * remaining component is returned unchanged. * If both components are empty strings, empty string is returned. */ - gcc_pure + [[gnu::pure]] static string Build(string_view a, string_view b) noexcept; /** * Interpret the given path as being relative to the given * base, and return the concatenated path. */ - gcc_pure + [[gnu::pure]] static string Apply(const_pointer base, const_pointer path) noexcept; }; @@ -221,7 +221,7 @@ struct PathTraitsUTF8 { return ch == SEPARATOR; } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer FindLastSeparator(const_pointer p) noexcept { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ @@ -236,7 +236,7 @@ struct PathTraitsUTF8 { return StringFindLast(p.data(), SEPARATOR, p.size()); } - gcc_pure + [[gnu::pure]] static const_pointer GetFilenameSuffix(const_pointer filename) noexcept { const_pointer dot = StringFindLast(filename, '.'); return dot != nullptr && dot > filename && dot[1] != 0 @@ -244,13 +244,13 @@ struct PathTraitsUTF8 { : nullptr; } - gcc_pure + [[gnu::pure]] static const_pointer GetPathSuffix(const_pointer path) noexcept { return GetFilenameSuffix(GetBase(path)); } #ifdef _WIN32 - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static constexpr bool IsDrive(const_pointer p) noexcept { return IsAlphaASCII(p[0]) && p[1] == ':'; } @@ -260,7 +260,7 @@ struct PathTraitsUTF8 { } #endif - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static bool IsAbsolute(const_pointer p) noexcept { #if !CLANG_CHECK_VERSION(3,6) /* disabled on clang due to -Wtautological-pointer-compare */ @@ -281,18 +281,18 @@ struct PathTraitsUTF8 { [[gnu::pure]] [[gnu::nonnull]] static bool IsAbsoluteOrHasScheme(const_pointer p) noexcept; - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static bool IsSpecialFilename(const_pointer name) noexcept { return (name[0] == '.' && name[1] == 0) || (name[0] == '.' && name[1] == '.' && name[2] == 0); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static size_t GetLength(const_pointer p) noexcept { return StringLength(p); } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer Find(const_pointer p, value_type ch) noexcept { return StringFind(p, ch); } @@ -301,7 +301,7 @@ struct PathTraitsUTF8 { * Determine the "base" file name of the given UTF-8 path. * The return value points inside the given string. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer GetBase(const_pointer p) noexcept; /** @@ -309,7 +309,7 @@ struct PathTraitsUTF8 { * As a special case, returns the string "." if there is no * separator in the given input string. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static string_view GetParent(const_pointer p) noexcept; [[gnu::pure]] @@ -321,10 +321,10 @@ struct PathTraitsUTF8 { * empty string if the given path equals this object or * nullptr on mismatch. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static const_pointer Relative(string_view base, const_pointer other) noexcept; - gcc_pure + [[gnu::pure]] static string_view Relative(string_view base, string_view other) noexcept; /** @@ -333,7 +333,7 @@ struct PathTraitsUTF8 { * remaining component is returned unchanged. * If both components are empty strings, empty string is returned. */ - gcc_pure + [[gnu::pure]] static string Build(string_view a, string_view b) noexcept; }; diff --git a/src/fs/io/AutoGunzipReader.cxx b/src/fs/io/AutoGunzipReader.cxx index f2222f482..4c4a4b780 100644 --- a/src/fs/io/AutoGunzipReader.cxx +++ b/src/fs/io/AutoGunzipReader.cxx @@ -25,7 +25,7 @@ AutoGunzipReader::AutoGunzipReader(Reader &_next) noexcept AutoGunzipReader::~AutoGunzipReader() noexcept = default; -gcc_pure +[[gnu::pure]] static bool IsGzip(const uint8_t data[4]) noexcept { diff --git a/src/fs/io/BufferedReader.hxx b/src/fs/io/BufferedReader.hxx index 536d8f482..bfad2b602 100644 --- a/src/fs/io/BufferedReader.hxx +++ b/src/fs/io/BufferedReader.hxx @@ -30,7 +30,6 @@ #ifndef BUFFERED_READER_HXX #define BUFFERED_READER_HXX -#include "util/Compiler.h" #include "util/DynamicFifoBuffer.hxx" #include @@ -64,7 +63,7 @@ public: bool Fill(bool need_more); - gcc_pure + [[gnu::pure]] WritableBuffer Read() const noexcept { return buffer.Read().ToVoid(); } diff --git a/src/fs/io/FileOutputStream.hxx b/src/fs/io/FileOutputStream.hxx index 10c614831..04d8837de 100644 --- a/src/fs/io/FileOutputStream.hxx +++ b/src/fs/io/FileOutputStream.hxx @@ -32,7 +32,6 @@ #include "OutputStream.hxx" #include "fs/AllocatedPath.hxx" -#include "util/Compiler.h" #ifndef _WIN32 #include "io/FileDescriptor.hxx" @@ -133,7 +132,7 @@ public: return path; } - gcc_pure + [[gnu::pure]] uint64_t Tell() const noexcept; /* virtual methods from class OutputStream */ diff --git a/src/fs/io/FileReader.hxx b/src/fs/io/FileReader.hxx index 5be332b72..6f1a34923 100644 --- a/src/fs/io/FileReader.hxx +++ b/src/fs/io/FileReader.hxx @@ -32,7 +32,6 @@ #include "Reader.hxx" #include "fs/AllocatedPath.hxx" -#include "util/Compiler.h" #ifdef _WIN32 #include @@ -94,7 +93,7 @@ public: FileInfo GetFileInfo() const; - gcc_pure + [[gnu::pure]] uint64_t GetSize() const noexcept { #ifdef _WIN32 LARGE_INTEGER size; @@ -106,7 +105,7 @@ public: #endif } - gcc_pure + [[gnu::pure]] uint64_t GetPosition() const noexcept { #ifdef _WIN32 LARGE_INTEGER zero; diff --git a/src/fs/io/Reader.hxx b/src/fs/io/Reader.hxx index b75f73cc3..44fec1fad 100644 --- a/src/fs/io/Reader.hxx +++ b/src/fs/io/Reader.hxx @@ -30,8 +30,6 @@ #ifndef READER_HXX #define READER_HXX -#include "util/Compiler.h" - #include /** @@ -52,7 +50,7 @@ public: * @return the number of bytes read into the given buffer or 0 * on end-of-stream */ - gcc_nonnull_all + [[gnu::nonnull]] virtual size_t Read(void *data, size_t size) = 0; }; diff --git a/src/input/AsyncInputStream.hxx b/src/input/AsyncInputStream.hxx index 353530871..3563c162f 100644 --- a/src/input/AsyncInputStream.hxx +++ b/src/input/AsyncInputStream.hxx @@ -123,7 +123,7 @@ protected: /** * Determine how many bytes can be added to the buffer. */ - gcc_pure + [[gnu::pure]] size_t GetBufferSpace() const noexcept { return buffer.GetSpace(); } diff --git a/src/input/Error.hxx b/src/input/Error.hxx index 01425340e..59f13d1e3 100644 --- a/src/input/Error.hxx +++ b/src/input/Error.hxx @@ -20,8 +20,6 @@ #ifndef INPUT_ERROR_HXX #define INPUT_ERROR_HXX -#include "util/Compiler.h" - #include /** @@ -29,7 +27,7 @@ * exist? This function attempts to recognize exceptions thrown by * various input plugins. */ -gcc_pure +[[gnu::pure]] bool IsFileNotFound(std::exception_ptr e) noexcept; diff --git a/src/input/IcyInputStream.hxx b/src/input/IcyInputStream.hxx index a89bf984a..37857e828 100644 --- a/src/input/IcyInputStream.hxx +++ b/src/input/IcyInputStream.hxx @@ -21,7 +21,6 @@ #define MPD_ICY_INPUT_STREAM_HXX #include "ProxyInputStream.hxx" -#include "util/Compiler.h" #include @@ -63,7 +62,7 @@ public: IcyInputStream(const IcyInputStream &) = delete; IcyInputStream &operator=(const IcyInputStream &) = delete; - gcc_pure + [[gnu::pure]] bool IsEnabled() const noexcept; /* virtual methods from InputStream */ diff --git a/src/input/InputPlugin.hxx b/src/input/InputPlugin.hxx index 3cc4b8f5c..c36f6bb03 100644 --- a/src/input/InputPlugin.hxx +++ b/src/input/InputPlugin.hxx @@ -22,7 +22,6 @@ #include "Ptr.hxx" #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include #include @@ -83,7 +82,7 @@ struct InputPlugin { std::unique_ptr (*scan_tags)(const char *uri, RemoteTagHandler &handler) = nullptr; - gcc_pure + [[gnu::pure]] bool SupportsUri(const char *uri) const noexcept; template @@ -103,7 +102,7 @@ struct InputPlugin { } }; -gcc_pure +[[gnu::pure]] bool protocol_is_whitelisted(const char *proto) noexcept; diff --git a/src/input/InputStream.hxx b/src/input/InputStream.hxx index e8a13dfc1..63c0e908f 100644 --- a/src/input/InputStream.hxx +++ b/src/input/InputStream.hxx @@ -23,7 +23,6 @@ #include "Offset.hxx" #include "Ptr.hxx" #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include #include @@ -123,14 +122,12 @@ public: * notifications * @return an #InputStream object on success */ - gcc_nonnull(1) static InputStreamPtr Open(const char *uri, Mutex &mutex); /** * Just like Open(), but waits for the stream to become ready. * It is a wrapper for Open(), WaitReady() and Check(). */ - gcc_nonnull(1) static InputStreamPtr OpenReady(const char *uri, Mutex &mutex); /** @@ -184,14 +181,14 @@ public: return ready; } - gcc_pure + [[gnu::pure]] bool HasMimeType() const noexcept { assert(ready); return !mime.empty(); } - gcc_pure + [[gnu::pure]] const char *GetMimeType() const noexcept { assert(ready); @@ -202,7 +199,7 @@ public: mime.clear(); } - gcc_nonnull_all + [[gnu::nonnull]] void SetMimeType(const char *_mime) noexcept { assert(!ready); @@ -215,14 +212,14 @@ public: mime = std::move(_mime); } - gcc_pure + [[gnu::pure]] bool KnownSize() const noexcept { assert(ready); return size != UNKNOWN_SIZE; } - gcc_pure + [[gnu::pure]] offset_type GetSize() const noexcept { assert(ready); assert(KnownSize()); @@ -236,14 +233,14 @@ public: offset += delta; } - gcc_pure + [[gnu::pure]] offset_type GetOffset() const noexcept { assert(ready); return offset; } - gcc_pure + [[gnu::pure]] offset_type GetRest() const noexcept { assert(ready); assert(KnownSize()); @@ -251,7 +248,7 @@ public: return size - offset; } - gcc_pure + [[gnu::pure]] bool IsSeekable() const noexcept { assert(ready); @@ -261,7 +258,7 @@ public: /** * Determines whether seeking is cheap. This is true for local files. */ - gcc_pure + [[gnu::pure]] bool CheapSeeking() const noexcept; /** @@ -313,14 +310,14 @@ public: * * The caller must lock the mutex. */ - gcc_pure + [[gnu::pure]] virtual bool IsEOF() const noexcept = 0; /** * Wrapper for IsEOF() which locks and unlocks the mutex; the * caller must not be holding it already. */ - gcc_pure + [[gnu::pure]] bool LockIsEOF() const noexcept; /** @@ -346,7 +343,7 @@ public: * * The caller must lock the mutex. */ - gcc_pure + [[gnu::pure]] virtual bool IsAvailable() const noexcept; /** @@ -363,7 +360,7 @@ public: * @param size the maximum number of bytes to read * @return the number of bytes read */ - gcc_nonnull_all + [[gnu::nonnull]] virtual size_t Read(std::unique_lock &lock, void *ptr, size_t size) = 0; @@ -373,7 +370,7 @@ public: * * Throws std::runtime_error on error. */ - gcc_nonnull_all + [[gnu::nonnull]] size_t LockRead(void *ptr, size_t size); /** @@ -387,7 +384,7 @@ public: * @param size the number of bytes to read * @return true if the whole data was read, false otherwise. */ - gcc_nonnull_all + [[gnu::nonnull]] void ReadFull(std::unique_lock &lock, void *ptr, size_t size); /** @@ -396,7 +393,7 @@ public: * * Throws std::runtime_error on error. */ - gcc_nonnull_all + [[gnu::nonnull]] void LockReadFull(void *ptr, size_t size); protected: diff --git a/src/input/Registry.hxx b/src/input/Registry.hxx index b8643bcb7..e7dbc907f 100644 --- a/src/input/Registry.hxx +++ b/src/input/Registry.hxx @@ -20,8 +20,6 @@ #ifndef MPD_INPUT_REGISTRY_HXX #define MPD_INPUT_REGISTRY_HXX -#include "util/Compiler.h" - /** * NULL terminated list of all input plugins which were enabled at * compile time. @@ -40,7 +38,7 @@ extern bool input_plugins_enabled[]; input_plugins_for_each(plugin) \ if (input_plugins_enabled[input_plugin_iterator - input_plugins]) -gcc_pure +[[gnu::pure]] bool HasRemoteTagScanner(const char *uri) noexcept; diff --git a/src/input/cache/Manager.hxx b/src/input/cache/Manager.hxx index 81492a97a..0360c9bbf 100644 --- a/src/input/cache/Manager.hxx +++ b/src/input/cache/Manager.hxx @@ -21,7 +21,6 @@ #define MPD_INPUT_CACHE_MANAGER_HXX #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include #include @@ -43,15 +42,15 @@ class InputCacheManager { size_t total_size = 0; struct ItemCompare { - gcc_pure + [[gnu::pure]] bool operator()(const InputCacheItem &a, const char *b) const noexcept; - gcc_pure + [[gnu::pure]] bool operator()(const char *a, const InputCacheItem &b) const noexcept; - gcc_pure + [[gnu::pure]] bool operator()(const InputCacheItem &a, const InputCacheItem &b) const noexcept; }; @@ -74,7 +73,7 @@ public: void Flush() noexcept; - gcc_pure + [[gnu::pure]] bool Contains(const char *uri) noexcept; /** diff --git a/src/input/plugins/FfmpegInputPlugin.cxx b/src/input/plugins/FfmpegInputPlugin.cxx index 319f24e96..27907ba1b 100644 --- a/src/input/plugins/FfmpegInputPlugin.cxx +++ b/src/input/plugins/FfmpegInputPlugin.cxx @@ -55,7 +55,7 @@ public: offset_type offset) override; }; -gcc_const +[[gnu::const]] static inline bool input_ffmpeg_supported() noexcept { diff --git a/src/input/plugins/QobuzClient.hxx b/src/input/plugins/QobuzClient.hxx index 54cfddfe1..501a293b1 100644 --- a/src/input/plugins/QobuzClient.hxx +++ b/src/input/plugins/QobuzClient.hxx @@ -77,7 +77,7 @@ public: return format_id; } - gcc_pure + [[gnu::pure]] CurlGlobal &GetCurl() noexcept; void AddLoginHandler(QobuzSessionHandler &h) noexcept; diff --git a/src/input/plugins/QobuzInputPlugin.cxx b/src/input/plugins/QobuzInputPlugin.cxx index d3f43adc3..fe902c90b 100644 --- a/src/input/plugins/QobuzInputPlugin.cxx +++ b/src/input/plugins/QobuzInputPlugin.cxx @@ -166,7 +166,7 @@ FinishQobuzInput() noexcept delete qobuz_client; } -gcc_pure +[[gnu::pure]] static const char * ExtractQobuzTrackId(const char *uri) { diff --git a/src/java/File.hxx b/src/java/File.hxx index b49cd30b8..8c20dc7f6 100644 --- a/src/java/File.hxx +++ b/src/java/File.hxx @@ -48,10 +48,10 @@ class File : public LocalObject { public: using LocalObject::LocalObject; - gcc_nonnull_all + [[gnu::nonnull]] static void Initialise(JNIEnv *env) noexcept; - gcc_nonnull_all + [[gnu::nonnull]] static jstring GetAbsolutePath(JNIEnv *env, jobject file) noexcept { return (jstring)env->CallObjectMethod(file, getAbsolutePath_method); @@ -69,7 +69,7 @@ public: * Invoke File.getAbsolutePath() and release the * specified File reference. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static AllocatedPath ToAbsolutePath(JNIEnv *env, jobject file) noexcept; }; diff --git a/src/java/Global.hxx b/src/java/Global.hxx index f56c504df..2d46b427b 100644 --- a/src/java/Global.hxx +++ b/src/java/Global.hxx @@ -30,8 +30,6 @@ #ifndef JAVA_GLOBAL_HXX #define JAVA_GLOBAL_HXX -#include "util/Compiler.h" - #include namespace Java { @@ -47,8 +45,9 @@ DetachCurrentThread() noexcept jvm->DetachCurrentThread(); } -static inline gcc_pure -JNIEnv *GetEnv() noexcept +[[gnu::pure]] +static inline JNIEnv * +GetEnv() noexcept { JNIEnv *env; jvm->AttachCurrentThread(&env, nullptr); diff --git a/src/lib/alsa/Format.hxx b/src/lib/alsa/Format.hxx index c1eef48c1..898698494 100644 --- a/src/lib/alsa/Format.hxx +++ b/src/lib/alsa/Format.hxx @@ -43,7 +43,7 @@ * enum. Returns SND_PCM_FORMAT_UNKNOWN if there is no according ALSA * PCM format. */ -gcc_const +[[gnu::const]] inline snd_pcm_format_t ToAlsaPcmFormat(SampleFormat sample_format) noexcept { @@ -82,7 +82,7 @@ ToAlsaPcmFormat(SampleFormat sample_format) noexcept * Determine the byte-swapped PCM format. Returns * SND_PCM_FORMAT_UNKNOWN if the format cannot be byte-swapped. */ -gcc_const +[[gnu::const]] inline snd_pcm_format_t ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt) noexcept { @@ -123,8 +123,7 @@ ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt) noexcept * Check if there is a "packed" version of the give PCM format. * Returns SND_PCM_FORMAT_UNKNOWN if not. */ -gcc_const -inline snd_pcm_format_t +constexpr snd_pcm_format_t PackAlsaPcmFormat(snd_pcm_format_t fmt) noexcept { switch (fmt) { diff --git a/src/lib/alsa/Version.cxx b/src/lib/alsa/Version.cxx index 0655dd4e6..896ffe95b 100644 --- a/src/lib/alsa/Version.cxx +++ b/src/lib/alsa/Version.cxx @@ -23,7 +23,7 @@ #include -gcc_pure +[[gnu::pure]] static uint_least32_t ParseAlsaVersion(const char *p) noexcept { diff --git a/src/lib/alsa/Version.hxx b/src/lib/alsa/Version.hxx index e8a99b917..839e534cf 100644 --- a/src/lib/alsa/Version.hxx +++ b/src/lib/alsa/Version.hxx @@ -20,8 +20,6 @@ #ifndef MPD_ALSA_VERSION_HXX #define MPD_ALSA_VERSION_HXX -#include "util/Compiler.h" - #include static constexpr uint_least32_t @@ -35,7 +33,7 @@ MakeAlsaVersion(uint_least32_t major, uint_least32_t minor, * Wrapper for snd_asoundlib_version() which translates the resulting * string to an integer constructed with MakeAlsaVersion(). */ -gcc_const +[[gnu::const]] uint_least32_t GetRuntimeAlsaVersion() noexcept; diff --git a/src/lib/cdio/Paranoia.hxx b/src/lib/cdio/Paranoia.hxx index 330f3800b..1fe7057b9 100644 --- a/src/lib/cdio/Paranoia.hxx +++ b/src/lib/cdio/Paranoia.hxx @@ -31,7 +31,6 @@ #define CDIO_PARANOIA_HXX #include "util/ConstBuffer.hxx" -#include "util/Compiler.h" #include #include @@ -88,7 +87,7 @@ public: return std::pair(first, last); } - gcc_pure + [[gnu::pure]] bool IsAudioTrack(track_t i) const noexcept { return cdio_cddap_track_audiop(drv, i); } @@ -101,7 +100,7 @@ public: return std::pair(first, last); } - gcc_pure + [[gnu::pure]] unsigned GetTrackCount() const noexcept { return cdio_cddap_tracks(drv); } diff --git a/src/lib/crypto/MD5.hxx b/src/lib/crypto/MD5.hxx index f85cca911..1116effd8 100644 --- a/src/lib/crypto/MD5.hxx +++ b/src/lib/crypto/MD5.hxx @@ -31,7 +31,6 @@ #define MD5_HXX #include "util/StringBuffer.hxx" -#include "util/Compiler.h" #include #include @@ -41,11 +40,11 @@ template struct ConstBuffer; void GlobalInitMD5() noexcept; -gcc_pure +[[gnu::pure]] std::array MD5(ConstBuffer input) noexcept; -gcc_pure +[[gnu::pure]] StringBuffer<33> MD5Hex(ConstBuffer input) noexcept; diff --git a/src/lib/curl/Easy.hxx b/src/lib/curl/Easy.hxx index b36274b66..8a434b719 100644 --- a/src/lib/curl/Easy.hxx +++ b/src/lib/curl/Easy.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 Max Kellermann + * Copyright 2016-2021 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,7 +31,6 @@ #define CURL_EASY_HXX #include "String.hxx" -#include "util/Compiler.h" #include @@ -199,7 +198,7 @@ public: /** * Returns the response body's size, or -1 if that is unknown. */ - gcc_pure + [[gnu::pure]] int64_t GetContentLength() const noexcept { double value; return GetInfo(CURLINFO_CONTENT_LENGTH_DOWNLOAD, &value) diff --git a/src/lib/curl/Global.cxx b/src/lib/curl/Global.cxx index 94c4def59..9a19e179e 100644 --- a/src/lib/curl/Global.cxx +++ b/src/lib/curl/Global.cxx @@ -31,6 +31,7 @@ #include "Request.hxx" #include "event/Loop.hxx" #include "event/SocketEvent.hxx" +#include "util/Compiler.h" #include @@ -84,7 +85,7 @@ private: (flags & SocketEvent::ERROR ? CURL_CSELECT_ERR : 0); } - gcc_const + [[gnu::const]] static unsigned CurlPollToFlags(int action) noexcept { switch (action) { case CURL_POLL_NONE: @@ -172,7 +173,7 @@ CurlGlobal::Remove(CurlRequest &r) noexcept /** * Find a request by its CURL "easy" handle. */ -gcc_pure +[[gnu::pure]] static CurlRequest * ToRequest(CURL *easy) noexcept { diff --git a/src/lib/curl/Request.cxx b/src/lib/curl/Request.cxx index d174fdb80..de97f1555 100644 --- a/src/lib/curl/Request.cxx +++ b/src/lib/curl/Request.cxx @@ -172,7 +172,7 @@ CurlRequest::Done(CURLcode result) noexcept } } -gcc_pure +[[gnu::pure]] static bool IsResponseBoundaryHeader(StringView s) noexcept { diff --git a/src/lib/curl/Version.hxx b/src/lib/curl/Version.hxx index a79eeec95..351cd6996 100644 --- a/src/lib/curl/Version.hxx +++ b/src/lib/curl/Version.hxx @@ -30,9 +30,7 @@ #ifndef CURL_VERSION_HXX #define CURL_VERSION_HXX -#include "util/Compiler.h" - -gcc_const +[[gnu::const]] bool IsCurlOlderThan(unsigned version_num) noexcept; diff --git a/src/lib/dbus/Error.hxx b/src/lib/dbus/Error.hxx index 6a5e84f04..f8c90ca1f 100644 --- a/src/lib/dbus/Error.hxx +++ b/src/lib/dbus/Error.hxx @@ -33,8 +33,6 @@ #ifndef ODBUS_ERROR_HXX #define ODBUS_ERROR_HXX -#include "util/Compiler.h" - #include namespace ODBus { @@ -54,7 +52,7 @@ public: Error(const Error &) = delete; Error &operator=(const Error &) = delete; - gcc_pure + [[gnu::pure]] operator bool() const noexcept { return dbus_error_is_set(&error); } diff --git a/src/lib/expat/ExpatParser.hxx b/src/lib/expat/ExpatParser.hxx index 4b5221e89..dcfc137eb 100644 --- a/src/lib/expat/ExpatParser.hxx +++ b/src/lib/expat/ExpatParser.hxx @@ -20,8 +20,6 @@ #ifndef MPD_EXPAT_HXX #define MPD_EXPAT_HXX -#include "util/Compiler.h" - #include #include @@ -80,11 +78,11 @@ public: void Parse(InputStream &is); - gcc_pure + [[gnu::pure]] static const char *GetAttribute(const XML_Char **atts, const char *name) noexcept; - gcc_pure + [[gnu::pure]] static const char *GetAttributeCase(const XML_Char **atts, const char *name) noexcept; }; @@ -117,13 +115,13 @@ public: parser.CompleteParse(); } - gcc_pure + [[gnu::pure]] static const char *GetAttribute(const XML_Char **atts, const char *name) noexcept { return ExpatParser::GetAttribute(atts, name); } - gcc_pure + [[gnu::pure]] static const char *GetAttributeCase(const XML_Char **atts, const char *name) noexcept { return ExpatParser::GetAttributeCase(atts, name); diff --git a/src/lib/ffmpeg/Buffer.hxx b/src/lib/ffmpeg/Buffer.hxx index 6a066aee2..a3514a50a 100644 --- a/src/lib/ffmpeg/Buffer.hxx +++ b/src/lib/ffmpeg/Buffer.hxx @@ -20,8 +20,6 @@ #ifndef MPD_FFMPEG_BUFFER_HXX #define MPD_FFMPEG_BUFFER_HXX -#include "util/Compiler.h" - extern "C" { #include } @@ -42,7 +40,7 @@ public: FfmpegBuffer(const FfmpegBuffer &) = delete; FfmpegBuffer &operator=(const FfmpegBuffer &) = delete; - gcc_malloc + [[gnu::malloc]] void *Get(size_t min_size) noexcept { av_fast_malloc(&data, &size, min_size); return data; diff --git a/src/lib/ffmpeg/IOContext.hxx b/src/lib/ffmpeg/IOContext.hxx index de0e8f1e9..36b8a5470 100644 --- a/src/lib/ffmpeg/IOContext.hxx +++ b/src/lib/ffmpeg/IOContext.hxx @@ -20,7 +20,6 @@ #ifndef MPD_FFMPEG_IO_CONTEXT_HXX #define MPD_FFMPEG_IO_CONTEXT_HXX -#include "util/Compiler.h" #include "Error.hxx" extern "C" { @@ -65,12 +64,12 @@ public: return io_context; } - gcc_pure + [[gnu::pure]] auto GetSize() const noexcept { return avio_size(io_context); } - gcc_pure + [[gnu::pure]] bool IsEOF() const noexcept { return avio_feof(io_context) != 0; } diff --git a/src/lib/ffmpeg/Time.hxx b/src/lib/ffmpeg/Time.hxx index f632d2f22..5d4e85e2b 100644 --- a/src/lib/ffmpeg/Time.hxx +++ b/src/lib/ffmpeg/Time.hxx @@ -21,7 +21,6 @@ #define MPD_FFMPEG_TIME_HXX #include "Chrono.hxx" -#include "util/Compiler.h" extern "C" { #include @@ -41,7 +40,7 @@ static constexpr AVRational AV_TIME_BASE_Q{1, AV_TIME_BASE}; /** * Convert a FFmpeg time stamp to a floating point value (in seconds). */ -gcc_const +[[gnu::const]] static inline FloatDuration FfmpegTimeToDouble(int64_t t, const AVRational time_base) noexcept { @@ -64,7 +63,7 @@ RatioToAVRational() /** * Convert a FFmpeg time stamp to a #SongTime. */ -gcc_const +[[gnu::const]] static inline SongTime FromFfmpegTime(int64_t t, const AVRational time_base) noexcept { @@ -77,7 +76,7 @@ FromFfmpegTime(int64_t t, const AVRational time_base) noexcept /** * Convert a FFmpeg time stamp to a #SignedSongTime. */ -gcc_const +[[gnu::const]] static inline SignedSongTime FromFfmpegTimeChecked(int64_t t, const AVRational time_base) noexcept { @@ -89,7 +88,7 @@ FromFfmpegTimeChecked(int64_t t, const AVRational time_base) noexcept /** * Convert a #SongTime to a FFmpeg time stamp with the given base. */ -gcc_const +[[gnu::const]] static inline int64_t ToFfmpegTime(SongTime t, const AVRational time_base) noexcept { @@ -104,7 +103,7 @@ ToFfmpegTime(SongTime t, const AVRational time_base) noexcept constexpr int64_t FfmpegTimestampFallback(int64_t t, int64_t fallback) { - return gcc_likely(t != int64_t(AV_NOPTS_VALUE)) + return t != int64_t(AV_NOPTS_VALUE) ? t : fallback; } diff --git a/src/lib/gcrypt/Hash.hxx b/src/lib/gcrypt/Hash.hxx index f602910a8..fa704dc89 100644 --- a/src/lib/gcrypt/Hash.hxx +++ b/src/lib/gcrypt/Hash.hxx @@ -31,7 +31,6 @@ #define GCRYPT_HASH_HXX #include "util/ConstBuffer.hxx" -#include "util/Compiler.h" #include @@ -40,7 +39,7 @@ namespace Gcrypt { template -gcc_pure +[[gnu::pure]] auto Hash(ConstBuffer input) noexcept { diff --git a/src/lib/gcrypt/MD5.hxx b/src/lib/gcrypt/MD5.hxx index 7e2d81176..d5670f380 100644 --- a/src/lib/gcrypt/MD5.hxx +++ b/src/lib/gcrypt/MD5.hxx @@ -31,7 +31,6 @@ #define GCRYPT_MD5_HXX #include "util/StringBuffer.hxx" -#include "util/Compiler.h" #include #include @@ -40,7 +39,7 @@ template struct ConstBuffer; namespace Gcrypt { -gcc_pure +[[gnu::pure]] std::array MD5(ConstBuffer input) noexcept; diff --git a/src/lib/icu/Collate.cxx b/src/lib/icu/Collate.cxx index 54d226895..1e95a3dca 100644 --- a/src/lib/icu/Collate.cxx +++ b/src/lib/icu/Collate.cxx @@ -76,7 +76,7 @@ IcuCollateFinish() noexcept #endif -gcc_pure +[[gnu::pure]] int IcuCollate(std::string_view a, std::string_view b) noexcept { diff --git a/src/lib/icu/Collate.hxx b/src/lib/icu/Collate.hxx index 8da130532..717bf818f 100644 --- a/src/lib/icu/Collate.hxx +++ b/src/lib/icu/Collate.hxx @@ -20,8 +20,6 @@ #ifndef MPD_ICU_COLLATE_HXX #define MPD_ICU_COLLATE_HXX -#include "util/Compiler.h" - #include /** @@ -33,7 +31,7 @@ IcuCollateInit(); void IcuCollateFinish() noexcept; -gcc_pure +[[gnu::pure]] int IcuCollate(std::string_view a, std::string_view b) noexcept; diff --git a/src/lib/icu/Compare.hxx b/src/lib/icu/Compare.hxx index 88e2e0711..c0b849cab 100644 --- a/src/lib/icu/Compare.hxx +++ b/src/lib/icu/Compare.hxx @@ -20,7 +20,6 @@ #ifndef MPD_ICU_COMPARE_HXX #define MPD_ICU_COMPARE_HXX -#include "util/Compiler.h" #include "util/AllocatedString.hxx" #include @@ -63,15 +62,15 @@ public: IcuCompare(IcuCompare &&) = default; IcuCompare &operator=(IcuCompare &&) = default; - gcc_pure + [[gnu::pure]] operator bool() const noexcept { return needle != nullptr; } - gcc_pure + [[gnu::pure]] bool operator==(const char *haystack) const noexcept; - gcc_pure + [[gnu::pure]] bool IsIn(const char *haystack) const noexcept; }; diff --git a/src/lib/icu/Converter.hxx b/src/lib/icu/Converter.hxx index fc7d6ae40..28533973d 100644 --- a/src/lib/icu/Converter.hxx +++ b/src/lib/icu/Converter.hxx @@ -20,7 +20,6 @@ #ifndef MPD_ICU_CONVERTER_HXX #define MPD_ICU_CONVERTER_HXX -#include "util/Compiler.h" #include "config.h" #ifdef HAVE_ICU @@ -84,7 +83,6 @@ public: * * Throws std::runtime_error on error. */ - gcc_nonnull_all AllocatedString ToUTF8(std::string_view s) const; /** @@ -92,7 +90,6 @@ public: * * Throws std::runtime_error on error. */ - gcc_nonnull_all AllocatedString FromUTF8(std::string_view s) const; }; diff --git a/src/lib/icu/Win32.hxx b/src/lib/icu/Win32.hxx index 287495010..c40c193fd 100644 --- a/src/lib/icu/Win32.hxx +++ b/src/lib/icu/Win32.hxx @@ -20,8 +20,6 @@ #ifndef MPD_ICU_WIN32_HXX #define MPD_ICU_WIN32_HXX -#include "util/Compiler.h" - #include class AllocatedString; @@ -30,14 +28,14 @@ template class BasicAllocatedString; /** * Throws std::system_error on error. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] AllocatedString WideCharToMultiByte(unsigned code_page, std::wstring_view src); /** * Throws std::system_error on error. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] BasicAllocatedString MultiByteToWideChar(unsigned code_page, std::string_view src); diff --git a/src/lib/nfs/Base.hxx b/src/lib/nfs/Base.hxx index 7bb2eb3da..7fbdd22f2 100644 --- a/src/lib/nfs/Base.hxx +++ b/src/lib/nfs/Base.hxx @@ -20,8 +20,6 @@ #ifndef MPD_NFS_BASE_HXX #define MPD_NFS_BASE_HXX -#include "util/Compiler.h" - /** * Set the "base" NFS server and export name. This will be the * default export that will be mounted if a file within this export is @@ -38,7 +36,7 @@ nfs_set_base(const char *server, const char *export_name) noexcept; * "path" after the export_name is returned; otherwise, nullptr is * returned. */ -gcc_pure +[[gnu::pure]] const char * nfs_check_base(const char *server, const char *path) noexcept; diff --git a/src/lib/nfs/Cancellable.hxx b/src/lib/nfs/Cancellable.hxx index 77d133203..7cab9e929 100644 --- a/src/lib/nfs/Cancellable.hxx +++ b/src/lib/nfs/Cancellable.hxx @@ -20,8 +20,6 @@ #ifndef MPD_NFS_CANCELLABLE_HXX #define MPD_NFS_CANCELLABLE_HXX -#include "util/Compiler.h" - #include #include @@ -89,35 +87,35 @@ private: } }; - gcc_pure + [[gnu::pure]] iterator Find(reference p) noexcept { return std::find_if(list.begin(), list.end(), MatchPointer(p)); } - gcc_pure + [[gnu::pure]] const_iterator Find(const_reference p) const noexcept { return std::find_if(list.begin(), list.end(), MatchPointer(p)); } - gcc_pure + [[gnu::pure]] iterator Find(CT &c) noexcept { return list.iterator_to(c); } - gcc_pure + [[gnu::pure]] const_iterator Find(const CT &c) const noexcept { return list.iterator_to(c); } public: #ifndef NDEBUG - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { return std::all_of(list.begin(), list.end(), [](const auto &c) { return c.IsCancelled(); }); } #endif - gcc_pure + [[gnu::pure]] bool Contains(const_reference p) const noexcept { return Find(p) != list.end(); } diff --git a/src/lib/nfs/Connection.hxx b/src/lib/nfs/Connection.hxx index bf3834541..49987e2c3 100644 --- a/src/lib/nfs/Connection.hxx +++ b/src/lib/nfs/Connection.hxx @@ -24,7 +24,6 @@ #include "event/SocketEvent.hxx" #include "event/CoarseTimerEvent.hxx" #include "event/DeferEvent.hxx" -#include "util/Compiler.h" #include #include @@ -139,7 +138,7 @@ class NfsConnection { bool mount_finished; public: - gcc_nonnull_all + [[gnu::nonnull]] NfsConnection(EventLoop &_loop, const char *_server, const char *_export_name) noexcept :socket_event(_loop, BIND_THIS_METHOD(OnSocketReady)), @@ -157,12 +156,12 @@ public: return socket_event.GetEventLoop(); } - gcc_pure + [[gnu::pure]] const char *GetServer() const noexcept { return server.c_str(); } - gcc_pure + [[gnu::pure]] const char *GetExportName() const noexcept { return export_name.c_str(); } diff --git a/src/lib/nfs/Glue.hxx b/src/lib/nfs/Glue.hxx index 027b36ef5..93c8e80c1 100644 --- a/src/lib/nfs/Glue.hxx +++ b/src/lib/nfs/Glue.hxx @@ -20,8 +20,6 @@ #ifndef MPD_NFS_GLUE_HXX #define MPD_NFS_GLUE_HXX -#include "util/Compiler.h" - class EventLoop; class NfsConnection; @@ -34,11 +32,11 @@ nfs_finish() noexcept; /** * Return the EventLoop that was passed to nfs_init(). */ -gcc_const +[[gnu::const]] EventLoop & nfs_get_event_loop() noexcept; -gcc_pure +[[gnu::pure]] NfsConnection & nfs_get_connection(const char *server, const char *export_name) noexcept; diff --git a/src/lib/nfs/Manager.hxx b/src/lib/nfs/Manager.hxx index 7c3bf57d7..b41ae1773 100644 --- a/src/lib/nfs/Manager.hxx +++ b/src/lib/nfs/Manager.hxx @@ -21,7 +21,6 @@ #define MPD_NFS_MANAGER_HXX #include "Connection.hxx" -#include "util/Compiler.h" #include "event/IdleEvent.hxx" #include @@ -56,15 +55,15 @@ class NfsManager final { }; struct Compare { - gcc_pure + [[gnu::pure]] bool operator()(const LookupKey a, const ManagedConnection &b) const noexcept; - gcc_pure + [[gnu::pure]] bool operator()(const ManagedConnection &a, const LookupKey b) const noexcept; - gcc_pure + [[gnu::pure]] bool operator()(const ManagedConnection &a, const ManagedConnection &b) const noexcept; }; @@ -102,7 +101,7 @@ public: return idle_event.GetEventLoop(); } - gcc_pure + [[gnu::pure]] NfsConnection &GetConnection(const char *server, const char *export_name) noexcept; diff --git a/src/lib/pcre/RegexPointer.hxx b/src/lib/pcre/RegexPointer.hxx index cb7e730ba..00912b26e 100644 --- a/src/lib/pcre/RegexPointer.hxx +++ b/src/lib/pcre/RegexPointer.hxx @@ -59,7 +59,7 @@ public: return re != nullptr; } - gcc_pure + [[gnu::pure]] bool Match(StringView s) const noexcept { /* we don't need the data written to ovector, but PCRE can omit internal allocations if we pass a buffer to diff --git a/src/lib/upnp/ContentDirectoryService.hxx b/src/lib/upnp/ContentDirectoryService.hxx index af3ceaf9f..1c058cbb6 100644 --- a/src/lib/upnp/ContentDirectoryService.hxx +++ b/src/lib/upnp/ContentDirectoryService.hxx @@ -21,7 +21,6 @@ #define _UPNPDIR_HXX_INCLUDED_ #include "Compat.hxx" -#include "util/Compiler.h" #include #include @@ -112,7 +111,7 @@ public: */ std::forward_list getSearchCapabilities(UpnpClient_Handle handle) const; - gcc_pure + [[gnu::pure]] std::string GetURI() const noexcept { return "upnp://" + m_deviceId + "/" + m_serviceType; } diff --git a/src/lib/xiph/FlacMetadataChain.hxx b/src/lib/xiph/FlacMetadataChain.hxx index 5d972e5de..a02c7d937 100644 --- a/src/lib/xiph/FlacMetadataChain.hxx +++ b/src/lib/xiph/FlacMetadataChain.hxx @@ -20,8 +20,6 @@ #ifndef MPD_FLAC_METADATA_CHAIN_HXX #define MPD_FLAC_METADATA_CHAIN_HXX -#include "util/Compiler.h" - #include class InputStream; @@ -67,12 +65,12 @@ public: bool ReadOgg(InputStream &is) noexcept; - gcc_pure + [[gnu::pure]] FLAC__Metadata_ChainStatus GetStatus() const noexcept { return ::FLAC__metadata_chain_status(chain); } - gcc_pure + [[gnu::pure]] const char *GetStatusString() const noexcept { return FLAC__Metadata_ChainStatusString[GetStatus()]; } diff --git a/src/ls.hxx b/src/ls.hxx index 75203ab4d..f6be20671 100644 --- a/src/ls.hxx +++ b/src/ls.hxx @@ -20,8 +20,6 @@ #ifndef MPD_LS_HXX #define MPD_LS_HXX -#include "util/Compiler.h" - #include class Response; @@ -31,7 +29,7 @@ class Response; * It is not allowed to pass an URI without a scheme, check with * uri_has_scheme() first. */ -gcc_pure +[[gnu::pure]] bool uri_supported_scheme(const char *url) noexcept; diff --git a/src/mixer/Volume.hxx b/src/mixer/Volume.hxx index 706f60e22..ae38ce6f0 100644 --- a/src/mixer/Volume.hxx +++ b/src/mixer/Volume.hxx @@ -20,15 +20,13 @@ #ifndef MPD_VOLUME_HXX #define MPD_VOLUME_HXX -#include "util/Compiler.h" - class MultipleOutputs; class BufferedOutputStream; void InvalidateHardwareVolume() noexcept; -gcc_pure +[[gnu::pure]] int volume_level_get(const MultipleOutputs &outputs) noexcept; @@ -47,7 +45,7 @@ save_sw_volume_state(BufferedOutputStream &os); * determine whether the state has changed and the state file should * be saved. */ -gcc_pure +[[gnu::pure]] unsigned sw_volume_state_get_hash() noexcept; diff --git a/src/neighbor/Glue.hxx b/src/neighbor/Glue.hxx index e8a2c5c21..a511c9afe 100644 --- a/src/neighbor/Glue.hxx +++ b/src/neighbor/Glue.hxx @@ -20,7 +20,6 @@ #ifndef MPD_NEIGHBOR_ALL_HXX #define MPD_NEIGHBOR_ALL_HXX -#include "util/Compiler.h" #include "thread/Mutex.hxx" #include @@ -74,7 +73,7 @@ public: * Get the combined list of all neighbors from all active * plugins. */ - gcc_pure + [[gnu::pure]] List GetList() const noexcept; }; diff --git a/src/neighbor/Registry.hxx b/src/neighbor/Registry.hxx index 4d7239124..e04f7187b 100644 --- a/src/neighbor/Registry.hxx +++ b/src/neighbor/Registry.hxx @@ -20,8 +20,6 @@ #ifndef MPD_NEIGHBOR_REGISTRY_HXX #define MPD_NEIGHBOR_REGISTRY_HXX -#include "util/Compiler.h" - struct NeighborPlugin; /** @@ -30,7 +28,7 @@ struct NeighborPlugin; */ extern const NeighborPlugin *const neighbor_plugins[]; -gcc_pure +[[gnu::pure]] const NeighborPlugin * GetNeighborPluginByName(const char *name) noexcept; diff --git a/src/net/ToString.hxx b/src/net/ToString.hxx index ff9261cd8..78ed421c3 100644 --- a/src/net/ToString.hxx +++ b/src/net/ToString.hxx @@ -30,8 +30,6 @@ #ifndef NET_TO_STRING_HXX #define NET_TO_STRING_HXX -#include "util/Compiler.h" - #include class SocketAddress; @@ -40,7 +38,7 @@ class SocketAddress; * Converts the specified socket address into a string in the form * "IP:PORT". */ -gcc_pure +[[gnu::pure]] std::string ToString(SocketAddress address) noexcept; diff --git a/src/output/Control.hxx b/src/output/Control.hxx index 734b29e67..01009b7ae 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -26,7 +26,6 @@ #include "thread/Mutex.hxx" #include "thread/Cond.hxx" #include "system/PeriodClock.hxx" -#include "util/Compiler.h" #include #include @@ -266,20 +265,20 @@ public: */ void Configure(const ConfigBlock &block); - gcc_pure + [[gnu::pure]] const char *GetName() const noexcept; - gcc_pure + [[gnu::pure]] const char *GetPluginName() const noexcept; - gcc_pure + [[gnu::pure]] const char *GetLogName() const noexcept; AudioOutputClient &GetClient() noexcept { return client; } - gcc_pure + [[gnu::pure]] Mixer *GetMixer() const noexcept; bool IsDummy() const noexcept { @@ -451,10 +450,10 @@ public: * * Caller must lock the mutex. */ - gcc_pure + [[gnu::pure]] bool IsChunkConsumed(const MusicChunk &chunk) const noexcept; - gcc_pure + [[gnu::pure]] bool LockIsChunkConsumed(const MusicChunk &chunk) const noexcept; /** diff --git a/src/pcm/Buffer.hxx b/src/pcm/Buffer.hxx index c6f8714ae..37bff2214 100644 --- a/src/pcm/Buffer.hxx +++ b/src/pcm/Buffer.hxx @@ -21,7 +21,6 @@ #define PCM_BUFFER_HXX #include "util/ReusableArray.hxx" -#include "util/Compiler.h" #include @@ -47,11 +46,11 @@ public: * to signal "error". An empty destination buffer is not * always an error. */ - gcc_malloc gcc_returns_nonnull + [[gnu::malloc]] [[gnu::returns_nonnull]] void *Get(size_t size) noexcept; template - gcc_malloc gcc_returns_nonnull + [[gnu::malloc]] [[gnu::returns_nonnull]] T *GetT(size_t n) noexcept { return (T *)Get(n * sizeof(T)); } diff --git a/src/pcm/ChannelsConverter.hxx b/src/pcm/ChannelsConverter.hxx index be49a6b08..74ea75157 100644 --- a/src/pcm/ChannelsConverter.hxx +++ b/src/pcm/ChannelsConverter.hxx @@ -73,7 +73,7 @@ public: * @param src the input buffer * @return the destination buffer */ - gcc_pure + [[gnu::pure]] ConstBuffer Convert(ConstBuffer src) noexcept; }; diff --git a/src/pcm/Export.hxx b/src/pcm/Export.hxx index 105e0154e..518196946 100644 --- a/src/pcm/Export.hxx +++ b/src/pcm/Export.hxx @@ -159,13 +159,13 @@ public: * DSD_U32, four input bytes (= 4 * 8 bits) are combined to * one output word (32 bits), dividing the sample rate by 4. */ - gcc_pure + [[gnu::pure]] unsigned CalcOutputSampleRate(unsigned input_sample_rate) const noexcept; /** * The inverse of CalcOutputSampleRate(). */ - gcc_pure + [[gnu::pure]] unsigned CalcInputSampleRate(unsigned output_sample_rate) const noexcept; }; @@ -198,7 +198,7 @@ public: /** * Calculate the size of one input frame. */ - gcc_pure + [[gnu::pure]] size_t GetInputFrameSize() const noexcept { return channels * sample_format_size(src_sample_format); } @@ -206,19 +206,19 @@ public: /** * Calculate the size of one output frame. */ - gcc_pure + [[gnu::pure]] size_t GetOutputFrameSize() const noexcept; /** * @return the size of one input block in bytes */ - gcc_pure + [[gnu::pure]] size_t GetInputBlockSize() const noexcept; /** * @return the size of one output block in bytes */ - gcc_pure + [[gnu::pure]] size_t GetOutputBlockSize() const noexcept; /** @@ -243,7 +243,7 @@ public: * destination buffer to the according number of bytes from the * pcm_export() source buffer. */ - gcc_pure + [[gnu::pure]] size_t CalcInputSize(size_t dest_size) const noexcept; }; diff --git a/src/pcm/FormatConverter.hxx b/src/pcm/FormatConverter.hxx index ef1061d78..84c0e7de7 100644 --- a/src/pcm/FormatConverter.hxx +++ b/src/pcm/FormatConverter.hxx @@ -72,7 +72,7 @@ public: * @param src the input buffer * @return the destination buffer */ - gcc_pure + [[gnu::pure]] ConstBuffer Convert(ConstBuffer src) noexcept; }; diff --git a/src/pcm/PcmFormat.hxx b/src/pcm/PcmFormat.hxx index 109dd6de5..41d67ebae 100644 --- a/src/pcm/PcmFormat.hxx +++ b/src/pcm/PcmFormat.hxx @@ -37,7 +37,7 @@ class PcmDither; * @param src the source PCM buffer * @return the destination buffer */ -gcc_pure +[[gnu::pure]] ConstBuffer pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither, SampleFormat src_format, ConstBuffer src) noexcept; @@ -49,7 +49,7 @@ pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither, * @param src the source PCM buffer * @return the destination buffer */ -gcc_pure +[[gnu::pure]] ConstBuffer pcm_convert_to_24(PcmBuffer &buffer, SampleFormat src_format, ConstBuffer src) noexcept; @@ -61,7 +61,7 @@ pcm_convert_to_24(PcmBuffer &buffer, * @param src the source PCM buffer * @return the destination buffer */ -gcc_pure +[[gnu::pure]] ConstBuffer pcm_convert_to_32(PcmBuffer &buffer, SampleFormat src_format, ConstBuffer src) noexcept; @@ -73,7 +73,7 @@ pcm_convert_to_32(PcmBuffer &buffer, * @param src the source PCM buffer * @return the destination buffer */ -gcc_pure +[[gnu::pure]] ConstBuffer pcm_convert_to_float(PcmBuffer &buffer, SampleFormat src_format, ConstBuffer src) noexcept; diff --git a/src/pcm/Volume.hxx b/src/pcm/Volume.hxx index 3bc5b5be4..af1964ec3 100644 --- a/src/pcm/Volume.hxx +++ b/src/pcm/Volume.hxx @@ -120,7 +120,7 @@ public: /** * Apply the volume level. */ - gcc_pure + [[gnu::pure]] ConstBuffer Apply(ConstBuffer src) noexcept; }; diff --git a/src/player/Control.hxx b/src/player/Control.hxx index e2d7de63e..9c79d88a7 100644 --- a/src/player/Control.hxx +++ b/src/player/Control.hxx @@ -326,7 +326,7 @@ public: */ std::unique_ptr LockReadTaggedSong() noexcept; - gcc_pure + [[gnu::pure]] PlayerStatus LockGetStatus() noexcept; PlayerState GetState() const noexcept { @@ -338,7 +338,7 @@ public: bool has_next_song; }; - gcc_pure + [[gnu::pure]] SyncInfo LockGetSyncInfo() const noexcept { const std::lock_guard protect(mutex); return {state, next_song != nullptr}; diff --git a/src/player/CrossFade.hxx b/src/player/CrossFade.hxx index 171aed06f..b4a45bf77 100644 --- a/src/player/CrossFade.hxx +++ b/src/player/CrossFade.hxx @@ -21,7 +21,6 @@ #define MPD_CROSSFADE_HXX #include "Chrono.hxx" -#include "util/Compiler.h" struct AudioFormat; class SignedSongTime; @@ -61,7 +60,7 @@ struct CrossFadeSettings { * @return the number of chunks for crossfading, or 0 if cross fading * should be disabled for this song change */ - gcc_pure + [[gnu::pure]] unsigned Calculate(SignedSongTime total_time, float replay_gain_db, float replay_gain_prev_db, const char *mixramp_start, diff --git a/src/player/Outputs.hxx b/src/player/Outputs.hxx index d800f97d2..7217a5541 100644 --- a/src/player/Outputs.hxx +++ b/src/player/Outputs.hxx @@ -22,7 +22,6 @@ #include "MusicChunkPtr.hxx" #include "Chrono.hxx" -#include "util/Compiler.h" struct AudioFormat; struct MusicChunk; @@ -107,7 +106,7 @@ public: * chunk. A negative value is returned when no chunk has been * finished yet. */ - gcc_pure + [[gnu::pure]] virtual SignedSongTime GetElapsedTime() const noexcept = 0; }; diff --git a/src/playlist/PlaylistRegistry.hxx b/src/playlist/PlaylistRegistry.hxx index f017200ef..d9e208454 100644 --- a/src/playlist/PlaylistRegistry.hxx +++ b/src/playlist/PlaylistRegistry.hxx @@ -22,7 +22,6 @@ #include "input/Ptr.hxx" #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include @@ -65,7 +64,7 @@ public: * Shall this playlists supported by this plugin be represented as * directories in the database? */ -gcc_const +[[gnu::const]] bool GetPlaylistPluginAsFolder(const PlaylistPlugin &plugin) noexcept; @@ -88,7 +87,7 @@ playlist_list_open_stream_suffix(InputStreamPtr &&is, std::string_view suffix); std::unique_ptr playlist_list_open_stream(InputStreamPtr &&is, const char *uri); -gcc_pure +[[gnu::pure]] const PlaylistPlugin * FindPlaylistPluginBySuffix(std::string_view suffix) noexcept; @@ -96,7 +95,7 @@ FindPlaylistPluginBySuffix(std::string_view suffix) noexcept; * Determines if there is a playlist plugin which can handle the * specified file name suffix. */ -gcc_pure +[[gnu::pure]] inline bool playlist_suffix_supported(std::string_view suffix) noexcept { diff --git a/src/song/AndSongFilter.hxx b/src/song/AndSongFilter.hxx index 901db99b9..126aa6131 100644 --- a/src/song/AndSongFilter.hxx +++ b/src/song/AndSongFilter.hxx @@ -21,7 +21,6 @@ #define MPD_AND_SONG_FILTER_HXX #include "ISongFilter.hxx" -#include "util/Compiler.h" #include @@ -44,7 +43,7 @@ public: items.emplace_back(std::forward(_item)); } - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { return items.empty(); } diff --git a/src/song/DetachedSong.hxx b/src/song/DetachedSong.hxx index 255f0c7f7..0cdebd7c9 100644 --- a/src/song/DetachedSong.hxx +++ b/src/song/DetachedSong.hxx @@ -23,7 +23,6 @@ #include "tag/Tag.hxx" #include "pcm/AudioFormat.hxx" #include "Chrono.hxx" -#include "util/Compiler.h" #include #include @@ -108,7 +107,6 @@ public: */ explicit DetachedSong(const LightSong &other) noexcept; - gcc_noinline ~DetachedSong() noexcept = default; /* these are declared because the user-defined destructor @@ -117,10 +115,10 @@ public: DetachedSong(DetachedSong &&) = default; DetachedSong &operator=(DetachedSong &&) = default; - gcc_pure + [[gnu::pure]] explicit operator LightSong() const noexcept; - gcc_pure + [[gnu::pure]] const char *GetURI() const noexcept { return uri.c_str(); } @@ -134,7 +132,7 @@ public: * Does this object have a "real" URI different from the * displayed URI? */ - gcc_pure + [[gnu::pure]] bool HasRealURI() const noexcept { return !real_uri.empty(); } @@ -143,7 +141,7 @@ public: * Returns "real" URI (#real_uri) and falls back to just * GetURI(). */ - gcc_pure + [[gnu::pure]] const char *GetRealURI() const noexcept { return (HasRealURI() ? real_uri : uri).c_str(); } @@ -157,35 +155,35 @@ public: * Returns true if both objects refer to the same physical * song. */ - gcc_pure + [[gnu::pure]] bool IsSame(const DetachedSong &other) const noexcept { return uri == other.uri && start_time == other.start_time && end_time == other.end_time; } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] bool IsURI(const char *other_uri) const noexcept { return uri == other_uri; } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] bool IsRealURI(const char *other_uri) const noexcept { return (HasRealURI() ? real_uri : uri) == other_uri; } - gcc_pure + [[gnu::pure]] bool IsRemote() const noexcept; - gcc_pure + [[gnu::pure]] bool IsFile() const noexcept { return !IsRemote(); } - gcc_pure + [[gnu::pure]] bool IsAbsoluteFile() const noexcept; - gcc_pure + [[gnu::pure]] bool IsInDatabase() const noexcept; const Tag &GetTag() const noexcept { @@ -240,7 +238,7 @@ public: end_time = _value; } - gcc_pure + [[gnu::pure]] SignedSongTime GetDuration() const noexcept; const AudioFormat &GetAudioFormat() const noexcept { diff --git a/src/song/Filter.hxx b/src/song/Filter.hxx index abec2ae5e..68e441cfa 100644 --- a/src/song/Filter.hxx +++ b/src/song/Filter.hxx @@ -21,7 +21,6 @@ #define MPD_SONG_FILTER_HXX #include "AndSongFilter.hxx" -#include "util/Compiler.h" #include #include @@ -42,7 +41,6 @@ class SongFilter { public: SongFilter() = default; - gcc_nonnull(3) SongFilter(TagType tag, const char *value, bool fold_case=false); ~SongFilter(); @@ -59,7 +57,6 @@ public: private: static ISongFilterPtr ParseExpression(const char *&s, bool fold_case=false); - gcc_nonnull(2,3) void Parse(const char *tag, const char *value, bool fold_case=false); public: @@ -70,14 +67,14 @@ public: void Optimize() noexcept; - gcc_pure + [[gnu::pure]] bool Match(const LightSong &song) const noexcept; const auto &GetItems() const noexcept { return and_filter.GetItems(); } - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { return and_filter.IsEmpty(); } @@ -85,20 +82,20 @@ public: /** * Is there at least one item with "fold case" enabled? */ - gcc_pure + [[gnu::pure]] bool HasFoldCase() const noexcept; /** * Does this filter contain constraints other than "base"? */ - gcc_pure + [[gnu::pure]] bool HasOtherThanBase() const noexcept; /** * Returns the "base" specification (if there is one) or * nullptr. */ - gcc_pure + [[gnu::pure]] const char *GetBase() const noexcept; /** diff --git a/src/song/ISongFilter.hxx b/src/song/ISongFilter.hxx index f22526416..3e602ec60 100644 --- a/src/song/ISongFilter.hxx +++ b/src/song/ISongFilter.hxx @@ -20,8 +20,6 @@ #ifndef MPD_I_SONG_FILTER_HXX #define MPD_I_SONG_FILTER_HXX -#include "util/Compiler.h" - #include #include @@ -41,7 +39,7 @@ public: */ virtual std::string ToExpression() const noexcept = 0; - gcc_pure + [[gnu::pure]] virtual bool Match(const LightSong &song) const noexcept = 0; }; diff --git a/src/song/LightSong.hxx b/src/song/LightSong.hxx index 06f0a41f9..3d004d855 100644 --- a/src/song/LightSong.hxx +++ b/src/song/LightSong.hxx @@ -22,7 +22,6 @@ #include "Chrono.hxx" #include "pcm/AudioFormat.hxx" -#include "util/Compiler.h" #include #include @@ -101,7 +100,7 @@ struct LightSong { start_time(src.start_time), end_time(src.end_time), audio_format(src.audio_format) {} - gcc_pure + [[gnu::pure]] std::string GetURI() const noexcept { if (directory == nullptr) return std::string(uri); @@ -112,7 +111,7 @@ struct LightSong { return result; } - gcc_pure + [[gnu::pure]] SignedSongTime GetDuration() const noexcept; }; diff --git a/src/song/StringFilter.hxx b/src/song/StringFilter.hxx index e9cc17017..62cec0283 100644 --- a/src/song/StringFilter.hxx +++ b/src/song/StringFilter.hxx @@ -21,7 +21,6 @@ #define MPD_STRING_FILTER_HXX #include "lib/icu/Compare.hxx" -#include "util/Compiler.h" #include "config.h" #ifdef HAVE_PCRE @@ -102,13 +101,13 @@ public: : (negated ? "!=" : "==")); } - gcc_pure + [[gnu::pure]] bool Match(const char *s) const noexcept; /** * Like Match(), but ignore the "negated" flag. */ - gcc_pure + [[gnu::pure]] bool MatchWithoutNegation(const char *s) const noexcept; }; diff --git a/src/storage/CompositeStorage.hxx b/src/storage/CompositeStorage.hxx index e4c986dc2..13364ddf3 100644 --- a/src/storage/CompositeStorage.hxx +++ b/src/storage/CompositeStorage.hxx @@ -22,7 +22,6 @@ #include "StorageInterface.hxx" #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include #include @@ -51,12 +50,12 @@ class CompositeStorage final : public Storage { std::map> children; - gcc_pure + [[gnu::pure]] bool IsEmpty() const noexcept { return storage == nullptr && children.empty(); } - gcc_pure + [[gnu::pure]] const Directory *Find(std::string_view uri) const noexcept; Directory &Make(std::string_view uri); @@ -64,7 +63,7 @@ class CompositeStorage final : public Storage { bool Unmount() noexcept; bool Unmount(std::string_view uri) noexcept; - gcc_pure + [[gnu::pure]] bool MapToRelativeUTF8(std::string &buffer, std::string_view uri) const noexcept; }; @@ -97,14 +96,14 @@ public: * allowed to unmount the given mount point while the return * value is being used. */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] Storage *GetMount(std::string_view uri) noexcept; /** * Is the given URI a mount point, i.e. is something already * mounted on this path? */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] bool IsMountPoint(const char *uri) noexcept { return GetMount(uri) != nullptr; } @@ -124,7 +123,7 @@ public: /** * Is a storage with the given URI already mounted? */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] bool IsMounted(const char *storage_uri) const noexcept { const std::lock_guard protect(mutex); return IsMounted(root, storage_uri); @@ -164,7 +163,7 @@ private: } } - gcc_pure gcc_nonnull_all + [[gnu::pure]] [[gnu::nonnull]] static bool IsMounted(const Directory &directory, const char *storage_uri) noexcept { if (directory.storage) { @@ -188,7 +187,7 @@ private: * remaining unused part of the URI (may be empty if all of * the URI was used). */ - gcc_pure + [[gnu::pure]] FindResult FindStorage(std::string_view uri) const noexcept; const char *MapToRelativeUTF8(const Directory &directory, diff --git a/src/storage/Configured.hxx b/src/storage/Configured.hxx index 4905c9d88..b7bd6fc3f 100644 --- a/src/storage/Configured.hxx +++ b/src/storage/Configured.hxx @@ -20,8 +20,6 @@ #ifndef MPD_STORAGE_CONFIG_HXX #define MPD_STORAGE_CONFIG_HXX -#include "util/Compiler.h" - #include struct ConfigData; @@ -40,7 +38,7 @@ CreateConfiguredStorage(const ConfigData &config, EventLoop &event_loop); /** * Returns true if there is configuration for a #Storage instance. */ -gcc_const +[[gnu::const]] bool IsStorageConfigured(const ConfigData &config) noexcept; diff --git a/src/storage/StorageInterface.hxx b/src/storage/StorageInterface.hxx index 6532c6d83..1d8846fcd 100644 --- a/src/storage/StorageInterface.hxx +++ b/src/storage/StorageInterface.hxx @@ -20,8 +20,6 @@ #ifndef MPD_STORAGE_INTERFACE_HXX #define MPD_STORAGE_INTERFACE_HXX -#include "util/Compiler.h" - #include #include #include @@ -62,7 +60,7 @@ public: /** * Map the given relative URI to an absolute URI. */ - gcc_pure + [[gnu::pure]] virtual std::string MapUTF8(std::string_view uri_utf8) const noexcept = 0; /** @@ -70,10 +68,10 @@ public: * nullptr on error or if this storage does not * support local files. */ - gcc_pure + [[gnu::pure]] virtual AllocatedPath MapFS(std::string_view uri_utf8) const noexcept; - gcc_pure + [[gnu::pure]] AllocatedPath MapChildFS(std::string_view uri_utf8, std::string_view child_utf8) const noexcept; @@ -82,7 +80,7 @@ public: * then it returns a relative URI (pointing inside the given * string); if not, returns nullptr. */ - gcc_pure + [[gnu::pure]] virtual std::string_view MapToRelativeUTF8(std::string_view uri_utf8) const noexcept = 0; }; diff --git a/src/system/Clock.hxx b/src/system/Clock.hxx index 733a9f3b4..ff533b499 100644 --- a/src/system/Clock.hxx +++ b/src/system/Clock.hxx @@ -22,14 +22,12 @@ #ifdef _WIN32 -#include "util/Compiler.h" - #include /** * Returns the uptime of the current process in seconds. */ -gcc_pure +[[gnu::pure]] std::chrono::seconds GetProcessUptimeS(); diff --git a/src/tag/Id3Load.cxx b/src/tag/Id3Load.cxx index 85af733fd..69a4381f0 100644 --- a/src/tag/Id3Load.cxx +++ b/src/tag/Id3Load.cxx @@ -28,7 +28,7 @@ static constexpr size_t ID3V1_SIZE = 128; -gcc_pure +[[gnu::pure]] static inline bool tag_is_id3v1(struct id3_tag *tag) noexcept { diff --git a/src/thread/Id.hxx b/src/thread/Id.hxx index 04471a54a..cfee3ac31 100644 --- a/src/thread/Id.hxx +++ b/src/thread/Id.hxx @@ -30,8 +30,6 @@ #ifndef THREAD_ID_HXX #define THREAD_ID_HXX -#include "util/Compiler.h" - #ifdef _WIN32 #include #else @@ -70,7 +68,7 @@ public: #endif } - gcc_pure + [[gnu::pure]] bool IsNull() const noexcept { return *this == Null(); } @@ -78,7 +76,7 @@ public: /** * Return the current thread's id . */ - gcc_pure + [[gnu::pure]] static const ThreadId GetCurrent() noexcept { #ifdef _WIN32 return ::GetCurrentThreadId(); @@ -87,7 +85,7 @@ public: #endif } - gcc_pure + [[gnu::pure]] bool operator==(const ThreadId &other) const noexcept { /* note: not using pthread_equal() because that function "is undefined if either thread ID is not diff --git a/src/thread/Thread.hxx b/src/thread/Thread.hxx index 071f9d7bd..59a0e8ea5 100644 --- a/src/thread/Thread.hxx +++ b/src/thread/Thread.hxx @@ -21,7 +21,6 @@ #define MPD_THREAD_HXX #include "util/BindMethod.hxx" -#include "util/Compiler.h" #include @@ -78,7 +77,7 @@ public: /** * Check if this thread is the current thread. */ - gcc_pure + [[gnu::pure]] bool IsInside() const noexcept { #ifdef _WIN32 return GetCurrentThreadId() == id; diff --git a/src/unix/PidFile.hxx b/src/unix/PidFile.hxx index f267514fe..a471eae0c 100644 --- a/src/unix/PidFile.hxx +++ b/src/unix/PidFile.hxx @@ -87,7 +87,7 @@ public: } }; -gcc_pure +[[gnu::pure]] static inline pid_t ReadPidFile(Path path) noexcept { diff --git a/src/util/BitReverse.hxx b/src/util/BitReverse.hxx index 566cf47f1..b211e946a 100644 --- a/src/util/BitReverse.hxx +++ b/src/util/BitReverse.hxx @@ -20,8 +20,6 @@ #ifndef MPD_BIT_REVERSE_HXX #define MPD_BIT_REVERSE_HXX -#include "Compiler.h" - #include /** @@ -43,7 +41,7 @@ struct BitReverseTable { extern const BitReverseTable bit_reverse_table; -gcc_const +[[gnu::const]] static inline uint8_t bit_reverse(uint8_t x) noexcept { diff --git a/src/util/HexFormat.hxx b/src/util/HexFormat.hxx index 0940862da..93f5127bd 100644 --- a/src/util/HexFormat.hxx +++ b/src/util/HexFormat.hxx @@ -32,7 +32,6 @@ #include "ConstBuffer.hxx" #include "StringBuffer.hxx" -#include "Compiler.h" #include #include @@ -53,7 +52,7 @@ HexFormat(char *dest, ConstBuffer src) noexcept; * required size. */ template -gcc_pure +[[gnu::pure]] auto HexFormatBuffer(const uint8_t *src) noexcept { diff --git a/src/util/UriExtract.cxx b/src/util/UriExtract.cxx index 5859b4b0e..34717201b 100644 --- a/src/util/UriExtract.cxx +++ b/src/util/UriExtract.cxx @@ -46,7 +46,7 @@ IsValidSchemeChar(char ch) ch == '+' || ch == '.' || ch == '-'; } -gcc_pure +[[gnu::pure]] static bool IsValidScheme(std::string_view p) noexcept { @@ -64,7 +64,7 @@ IsValidScheme(std::string_view p) noexcept * Return the URI part after the scheme specification (and after the * double slash). */ -gcc_pure +[[gnu::pure]] static std::string_view uri_after_scheme(std::string_view uri) noexcept { @@ -120,7 +120,7 @@ uri_get_path(std::string_view uri) noexcept return uri; } -gcc_pure +[[gnu::pure]] static StringView UriWithoutQueryString(StringView uri) noexcept { diff --git a/src/util/UriExtract.hxx b/src/util/UriExtract.hxx index 8c5555cd7..69cd7496c 100644 --- a/src/util/UriExtract.hxx +++ b/src/util/UriExtract.hxx @@ -30,26 +30,24 @@ #ifndef URI_EXTRACT_HXX #define URI_EXTRACT_HXX -#include "Compiler.h" - #include /** * Checks whether the specified URI has a scheme in the form * "scheme://". */ -gcc_pure +[[gnu::pure]] bool uri_has_scheme(std::string_view uri) noexcept; /** * Returns the scheme name of the specified URI, or an empty string. */ -gcc_pure +[[gnu::pure]] std::string_view uri_get_scheme(std::string_view uri) noexcept; -gcc_pure +[[gnu::pure]] bool uri_is_relative_path(const char *uri) noexcept; @@ -57,11 +55,11 @@ uri_is_relative_path(const char *uri) noexcept; * Returns the URI path (including the query string) or nullptr if the * given URI has no path. */ -gcc_pure +[[gnu::pure]] std::string_view uri_get_path(std::string_view uri) noexcept; -gcc_pure +[[gnu::pure]] std::string_view uri_get_suffix(std::string_view uri) noexcept; @@ -71,7 +69,7 @@ uri_get_suffix(std::string_view uri) noexcept; * nullptr; if there is a '#' but no fragment text, it returns an * empty StringView. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] const char * uri_get_fragment(const char *uri) noexcept; diff --git a/src/util/UriUtil.hxx b/src/util/UriUtil.hxx index eb08e1a51..835be0a09 100644 --- a/src/util/UriUtil.hxx +++ b/src/util/UriUtil.hxx @@ -30,8 +30,6 @@ #ifndef URI_UTIL_HXX #define URI_UTIL_HXX -#include "Compiler.h" - #include /** @@ -42,7 +40,7 @@ * - no double slashes * - no path component begins with a dot */ -gcc_pure +[[gnu::pure]] bool uri_safe_local(const char *uri) noexcept; @@ -52,7 +50,7 @@ uri_safe_local(const char *uri) noexcept; * an empty string if nothing needs to be removed, or if the URI is * not recognized. */ -gcc_pure +[[gnu::pure]] std::string uri_remove_auth(const char *uri) noexcept; @@ -60,7 +58,7 @@ uri_remove_auth(const char *uri) noexcept; * Remove dot segments in the URI. For example, uri_squash_dot_segments * ("foo/bar/.././")=="foo/". */ -gcc_pure +[[gnu::pure]] std::string uri_squash_dot_segments(const char *uri) noexcept;