From 42f6a0441c1057d55c9e09d80d8daa0c0e5efa24 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Mar 2023 15:57:36 +0100 Subject: [PATCH] use [[gnu::...]] attributes --- src/TagStream.cxx | 2 +- src/command/AllCommands.cxx | 4 ++-- src/command/FileCommands.cxx | 8 ++++---- src/command/FingerprintCommands.cxx | 6 +++--- src/command/OutputCommands.cxx | 2 +- src/command/PartitionCommands.cxx | 4 ++-- src/command/StorageCommands.cxx | 2 +- src/config/Data.cxx | 2 +- src/config/Param.hxx | 2 -- src/config/Templates.cxx | 2 +- src/db/Count.hxx | 3 --- src/db/DatabasePlaylist.hxx | 3 --- src/db/DatabasePrint.cxx | 2 +- src/db/Helpers.cxx | 2 +- src/db/plugins/ProxyDatabasePlugin.cxx | 15 +++++++-------- src/db/plugins/simple/Directory.cxx | 2 +- src/db/plugins/simple/DirectorySave.cxx | 4 ++-- src/db/plugins/simple/SimpleDatabasePlugin.cxx | 2 +- src/db/plugins/simple/Song.cxx | 4 ++-- src/db/plugins/simple/SongSort.cxx | 2 +- src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 2 +- src/db/update/InotifyUpdate.cxx | 9 ++++----- src/db/update/SpecialDirectory.cxx | 6 +++--- src/db/update/Walk.cxx | 4 ++-- src/decoder/Thread.cxx | 8 ++++---- src/decoder/plugins/AudiofileDecoderPlugin.cxx | 4 ++-- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 12 ++++++------ src/decoder/plugins/GmeDecoderPlugin.cxx | 2 +- src/decoder/plugins/MadDecoderPlugin.cxx | 8 ++++---- src/decoder/plugins/OpusDecoderPlugin.cxx | 14 +++++++------- src/decoder/plugins/OpusTags.cxx | 2 +- src/decoder/plugins/SidplayDecoderPlugin.cxx | 6 +++--- src/decoder/plugins/SndfileDecoderPlugin.cxx | 2 +- src/event/BufferedSocket.cxx | 5 ++--- src/event/FullyBufferedSocket.cxx | 5 ++--- src/filter/plugins/HdcdFilterPlugin.cxx | 2 +- src/filter/plugins/NullFilterPlugin.cxx | 1 - src/fs/LookupFile.cxx | 2 +- src/input/InputStream.cxx | 2 +- src/io/BufferedOutputStream.cxx | 4 ++-- src/lib/dbus/UDisks2.cxx | 9 ++++----- src/lib/nfs/FileReader.hxx | 1 - src/lib/sqlite/Util.hxx | 1 - src/lib/upnp/Action.hxx | 2 -- src/lib/xiph/FlacIOHandle.cxx | 1 - src/lib/xiph/FlacMetadataIterator.hxx | 4 +--- src/lib/xiph/FlacStreamMetadata.cxx | 2 +- src/mixer/All.cxx | 2 +- src/mixer/plugins/AlsaMixerPlugin.cxx | 2 +- src/mixer/plugins/SoftwareMixerPlugin.cxx | 2 +- src/output/Filtered.hxx | 6 +++--- src/output/Interface.cxx | 1 - src/output/OutputPlugin.hxx | 4 +--- src/output/SharedPipeConsumer.hxx | 4 +--- src/output/plugins/AlsaOutputPlugin.cxx | 8 ++++---- src/output/plugins/JackOutputPlugin.cxx | 2 +- src/output/plugins/OSXOutputPlugin.cxx | 2 +- src/output/plugins/OpenALOutputPlugin.cxx | 8 ++++---- src/output/plugins/OssOutputPlugin.cxx | 6 ++---- src/output/plugins/RecorderOutputPlugin.cxx | 2 +- src/output/plugins/WinmmOutputPlugin.hxx | 4 +--- src/output/plugins/httpd/HttpdClient.cxx | 2 +- src/output/plugins/httpd/HttpdClient.hxx | 3 +-- src/output/plugins/httpd/HttpdInternal.hxx | 7 +++---- src/pcm/Clamp.hxx | 6 ++---- src/pcm/Mix.hxx | 1 - src/pcm/Pack.cxx | 8 +++----- src/pcm/Resampler.hxx | 2 -- src/pcm/SoxrResampler.cxx | 5 ++--- src/player/CrossFade.cxx | 2 +- src/player/Thread.cxx | 4 ++-- src/playlist/PlaylistPlugin.hxx | 7 +++---- src/playlist/PlaylistStream.hxx | 4 +--- src/playlist/cue/CueParser.hxx | 3 +-- src/queue/IdTable.hxx | 2 -- src/queue/Playlist.hxx | 6 +++--- src/queue/Queue.hxx | 13 ++++++------- src/song/Escape.hxx | 4 +--- src/song/Filter.cxx | 2 +- src/storage/Registry.hxx | 8 +++----- src/storage/plugins/CurlStorage.cxx | 8 ++++---- src/storage/plugins/LocalStorage.hxx | 3 --- src/storage/plugins/NfsStorage.cxx | 2 +- src/storage/plugins/SmbclientStorage.cxx | 2 +- src/tag/Handler.hxx | 1 - src/tag/Id3Scan.cxx | 4 ++-- src/tag/ReplayGainParser.cxx | 4 ++-- src/util/Clamp.hxx | 15 ++++++++------- src/util/ReusableArray.hxx | 4 +--- src/util/Serial.cxx | 3 +-- src/util/StringUtil.hxx | 4 +--- src/util/TruncateString.cxx | 1 + src/util/TruncateString.hxx | 4 +--- src/util/UTF8.cxx | 4 ++-- src/win32/Win32Main.cxx | 1 - src/zeroconf/Bonjour.cxx | 1 - src/zeroconf/Glue.cxx | 1 - test/DumpDecoderClient.cxx | 1 - test/MakeTag.hxx | 1 - test/fs/TestLookupFile.cxx | 1 - test/util/test_byte_reverse.cxx | 1 - 101 files changed, 167 insertions(+), 234 deletions(-) diff --git a/src/TagStream.cxx b/src/TagStream.cxx index 2ee02d299..9f797f215 100644 --- a/src/TagStream.cxx +++ b/src/TagStream.cxx @@ -17,7 +17,7 @@ /** * Does the #DecoderPlugin support either the suffix or the MIME type? */ -gcc_pure +[[gnu::pure]] static bool CheckDecoderPlugin(const DecoderPlugin &plugin, std::string_view suffix, std::string_view mime) noexcept diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index a41bb46eb..da0ebd2b7 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -204,7 +204,7 @@ static constexpr struct command commands[] = { static constexpr unsigned num_commands = std::size(commands); -gcc_pure +[[gnu::pure]] static bool command_available([[maybe_unused]] const Partition &partition, [[maybe_unused]] const struct command *cmd) noexcept @@ -290,7 +290,7 @@ command_init() noexcept #endif } -gcc_pure +[[gnu::pure]] static const struct command * command_lookup(const char *name) noexcept { diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx index 3489c141e..e98104af7 100644 --- a/src/command/FileCommands.cxx +++ b/src/command/FileCommands.cxx @@ -34,14 +34,14 @@ #include #include -gcc_pure +[[gnu::pure]] static bool SkipNameFS(PathTraitsFS::const_pointer name_fs) noexcept { return PathTraitsFS::IsSpecialFilename(name_fs); } -gcc_pure +[[gnu::pure]] static bool skip_path(Path name_fs) noexcept { @@ -87,7 +87,7 @@ handle_listfiles_local(Response &r, Path path_fs) #pragma GCC diagnostic pop #endif -gcc_pure +[[gnu::pure]] static bool IsValidName(const std::string_view s) noexcept { @@ -99,7 +99,7 @@ IsValidName(const std::string_view s) noexcept }); } -gcc_pure +[[gnu::pure]] static bool IsValidValue(const std::string_view s) noexcept { diff --git a/src/command/FingerprintCommands.cxx b/src/command/FingerprintCommands.cxx index 14546a458..294b619c4 100644 --- a/src/command/FingerprintCommands.cxx +++ b/src/command/FingerprintCommands.cxx @@ -101,7 +101,7 @@ GetChromaprintCommand::DecodeStream(InputStream &input_stream, plugin.StreamDecode(*this, input_stream); } -gcc_pure +[[gnu::pure]] static bool decoder_check_plugin_mime(const DecoderPlugin &plugin, const InputStream &is) noexcept @@ -113,7 +113,7 @@ decoder_check_plugin_mime(const DecoderPlugin &plugin, plugin.SupportsMimeType(GetMimeTypeBase(mime_type)); } -gcc_pure +[[gnu::pure]] static bool decoder_check_plugin_suffix(const DecoderPlugin &plugin, std::string_view suffix) noexcept @@ -123,7 +123,7 @@ decoder_check_plugin_suffix(const DecoderPlugin &plugin, return !suffix.empty() && plugin.SupportsSuffix(suffix); } -gcc_pure +[[gnu::pure]] static bool decoder_check_plugin(const DecoderPlugin &plugin, const InputStream &is, std::string_view suffix) noexcept diff --git a/src/command/OutputCommands.cxx b/src/command/OutputCommands.cxx index 4f7d99486..43d5beeda 100644 --- a/src/command/OutputCommands.cxx +++ b/src/command/OutputCommands.cxx @@ -71,7 +71,7 @@ IsValidAttributeNameChar(char ch) noexcept return IsAlphaNumericASCII(ch) || ch == '_'; } -gcc_pure +[[gnu::pure]] static bool IsValidAttributeName(const char *s) noexcept { diff --git a/src/command/PartitionCommands.cxx b/src/command/PartitionCommands.cxx index 4fc96eeb4..79825dd7a 100644 --- a/src/command/PartitionCommands.cxx +++ b/src/command/PartitionCommands.cxx @@ -44,7 +44,7 @@ IsValidPartitionChar(char ch) return IsAlphaNumericASCII(ch) || ch == '-' || ch == '_'; } -gcc_pure +[[gnu::pure]] static bool IsValidPartitionName(const char *name) noexcept { @@ -56,7 +56,7 @@ IsValidPartitionName(const char *name) noexcept return true; } -gcc_pure +[[gnu::pure]] static bool HasPartitionNamed(Instance &instance, const char *name) noexcept { diff --git a/src/command/StorageCommands.cxx b/src/command/StorageCommands.cxx index 1035a7ee6..644268794 100644 --- a/src/command/StorageCommands.cxx +++ b/src/command/StorageCommands.cxx @@ -22,7 +22,7 @@ #include -gcc_pure +[[gnu::pure]] static bool skip_path(const char *name_utf8) noexcept { diff --git a/src/config/Data.cxx b/src/config/Data.cxx index b5dc22af1..d8da9d2ed 100644 --- a/src/config/Data.cxx +++ b/src/config/Data.cxx @@ -20,7 +20,7 @@ ConfigData::Clear() } template -gcc_pure +[[gnu::pure]] static auto FindLast(const std::forward_list &list) { diff --git a/src/config/Param.hxx b/src/config/Param.hxx index 510029075..8ac98df34 100644 --- a/src/config/Param.hxx +++ b/src/config/Param.hxx @@ -4,8 +4,6 @@ #ifndef MPD_CONFIG_PARAM_HXX #define MPD_CONFIG_PARAM_HXX -#include "util/Compiler.h" - #include class AllocatedPath; diff --git a/src/config/Templates.cxx b/src/config/Templates.cxx index 06469fc79..f712efb0f 100644 --- a/src/config/Templates.cxx +++ b/src/config/Templates.cxx @@ -89,7 +89,7 @@ static constexpr unsigned n_config_block_templates = static_assert(n_config_block_templates == unsigned(ConfigBlockOption::MAX), "Wrong number of config_block_templates"); -gcc_pure +[[gnu::pure]] static inline unsigned ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count, const char *name) noexcept diff --git a/src/db/Count.hxx b/src/db/Count.hxx index c32a6a6f6..13728a057 100644 --- a/src/db/Count.hxx +++ b/src/db/Count.hxx @@ -4,8 +4,6 @@ #ifndef MPD_DB_COUNT_HXX #define MPD_DB_COUNT_HXX -#include "util/Compiler.h" - #include enum TagType : uint8_t; @@ -13,7 +11,6 @@ struct Partition; class Response; class SongFilter; -gcc_nonnull(3) void PrintSongCount(Response &r, const Partition &partition, const char *name, const SongFilter *filter, diff --git a/src/db/DatabasePlaylist.hxx b/src/db/DatabasePlaylist.hxx index 89ad72333..e818b2cae 100644 --- a/src/db/DatabasePlaylist.hxx +++ b/src/db/DatabasePlaylist.hxx @@ -4,14 +4,11 @@ #ifndef MPD_DATABASE_PLAYLIST_HXX #define MPD_DATABASE_PLAYLIST_HXX -#include "util/Compiler.h" - class Database; class Storage; struct DatabaseSelection; class PlaylistFileEditor; -gcc_nonnull(3) void search_add_to_playlist(const Database &db, const Storage *storage, const char *playlist_path_utf8, diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx index d6f3d1c69..7e31bf1da 100644 --- a/src/db/DatabasePrint.cxx +++ b/src/db/DatabasePrint.cxx @@ -21,7 +21,7 @@ #include -gcc_pure +[[gnu::pure]] static const char * ApplyBaseFlag(const char *uri, bool base) noexcept { diff --git a/src/db/Helpers.cxx b/src/db/Helpers.cxx index a358a258e..37914cbdb 100644 --- a/src/db/Helpers.cxx +++ b/src/db/Helpers.cxx @@ -12,7 +12,7 @@ #include struct StringLess { - gcc_pure + [[gnu::pure]] bool operator()(const char *a, const char *b) const noexcept { return strcmp(a, b) < 0; } diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 7b35e22d8..5b97184ac 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -16,7 +16,6 @@ #include "song/UriSongFilter.hxx" #include "song/BaseSongFilter.hxx" #include "song/TagSongFilter.hxx" -#include "util/Compiler.h" #include "config/Block.hxx" #include "tag/Builder.hxx" #include "tag/Tag.hxx" @@ -265,7 +264,7 @@ ProxySong::ProxySong(const mpd_song *song) tag_builder.Commit(tag2); } -gcc_const +[[gnu::const]] static enum mpd_tag_type Convert(TagType tag_type) noexcept { @@ -694,7 +693,7 @@ Visit(struct mpd_connection *connection, visit_directory, visit_song, visit_playlist); } -gcc_pure +[[gnu::pure]] static bool Match(const SongFilter *filter, const LightSong &song) noexcept { @@ -864,7 +863,7 @@ try { throw; } -gcc_pure +[[gnu::pure]] static bool IsFilterSupported(const ISongFilter &f) noexcept { @@ -890,7 +889,7 @@ IsFilterSupported(const ISongFilter &f) noexcept return false; } -gcc_pure +[[gnu::pure]] static bool IsFilterFullySupported(const SongFilter &filter, const struct mpd_connection *connection) noexcept @@ -908,7 +907,7 @@ IsFilterFullySupported(const SongFilter &filter, [](const auto &item) { return IsFilterSupported(*item); }); } -gcc_pure +[[gnu::pure]] static bool IsFilterFullySupported(const SongFilter *filter, const struct mpd_connection *connection) noexcept @@ -917,7 +916,7 @@ IsFilterFullySupported(const SongFilter *filter, IsFilterFullySupported(*filter, connection); } -gcc_pure +[[gnu::pure]] static bool IsSortSupported(TagType tag_type, const struct mpd_connection *connection) noexcept @@ -939,7 +938,7 @@ IsSortSupported(TagType tag_type, return Convert(tag_type) != MPD_TAG_COUNT; } -gcc_pure +[[gnu::pure]] static DatabaseSelection CheckSelection(DatabaseSelection selection, struct mpd_connection *connection) noexcept diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index cd48d3ca5..e0b3bbcd5 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -193,7 +193,7 @@ Directory::FindSong(std::string_view name_utf8) const noexcept return nullptr; } -gcc_pure +[[gnu::pure]] static bool directory_cmp(const Directory &a, const Directory &b) noexcept { diff --git a/src/db/plugins/simple/DirectorySave.cxx b/src/db/plugins/simple/DirectorySave.cxx index 889447fdd..99730d13e 100644 --- a/src/db/plugins/simple/DirectorySave.cxx +++ b/src/db/plugins/simple/DirectorySave.cxx @@ -25,7 +25,7 @@ #define DIRECTORY_BEGIN "begin: " #define DIRECTORY_END "end: " -gcc_const +[[gnu::const]] static const char * DeviceToTypeString(unsigned device) noexcept { @@ -44,7 +44,7 @@ DeviceToTypeString(unsigned device) noexcept } } -gcc_pure +[[gnu::pure]] static unsigned ParseTypeString(const char *type) noexcept { diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index dc9fbc0bf..55f406d91 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -248,7 +248,7 @@ SimpleDatabase::ReturnSong([[maybe_unused]] const LightSong *song) const noexcep } } -gcc_const +[[gnu::const]] static DatabaseSelection CheckSelection(DatabaseSelection selection) noexcept { diff --git a/src/db/plugins/simple/Song.cxx b/src/db/plugins/simple/Song.cxx index f0555175b..f7b742407 100644 --- a/src/db/plugins/simple/Song.cxx +++ b/src/db/plugins/simple/Song.cxx @@ -47,7 +47,7 @@ Song::GetURI() const noexcept /** * Path name traversal of a #Directory. */ -gcc_pure +[[gnu::pure]] static const Directory * FindTargetDirectory(const Directory &base, std::string_view path) noexcept { @@ -69,7 +69,7 @@ FindTargetDirectory(const Directory &base, std::string_view path) noexcept /** * Path name traversal of a #Song. */ -gcc_pure +[[gnu::pure]] static const Song * FindTargetSong(const Directory &_directory, std::string_view target) noexcept { diff --git a/src/db/plugins/simple/SongSort.cxx b/src/db/plugins/simple/SongSort.cxx index 0f72ecbdc..d5f03a3ae 100644 --- a/src/db/plugins/simple/SongSort.cxx +++ b/src/db/plugins/simple/SongSort.cxx @@ -60,7 +60,7 @@ compare_tag_item(const Tag &a, const Tag &b, TagType type) noexcept } /* Only used for sorting/searchin a songvec, not general purpose compares */ -gcc_pure +[[gnu::pure]] static bool song_cmp(const Song &a, const Song &b) noexcept { diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index b004cf62a..4ba4971ff 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -563,7 +563,7 @@ UpnpDatabase::VisitServer(const ContentDirectoryService &server, } } -gcc_const +[[gnu::const]] static DatabaseSelection CheckSelection(DatabaseSelection selection) noexcept { diff --git a/src/db/update/InotifyUpdate.cxx b/src/db/update/InotifyUpdate.cxx index e97c6c4a3..28d8ca2e2 100644 --- a/src/db/update/InotifyUpdate.cxx +++ b/src/db/update/InotifyUpdate.cxx @@ -14,7 +14,6 @@ #include "fs/FileInfo.hxx" #include "fs/Traits.hxx" #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include "Log.hxx" #include @@ -61,10 +60,10 @@ struct WatchDirectory { void LoadExcludeList(Path directory_path) noexcept; - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] unsigned GetDepth() const noexcept; - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] AllocatedPath GetUriFS() const noexcept; }; @@ -137,7 +136,7 @@ WatchDirectory::GetUriFS() const noexcept } /* we don't look at "." / ".." nor files with newlines in their name */ -gcc_pure +[[gnu::pure]] static bool SkipFilename(Path name) noexcept { @@ -210,7 +209,7 @@ try { LogError(std::current_exception()); } -gcc_pure +[[gnu::pure]] unsigned WatchDirectory::GetDepth() const noexcept { diff --git a/src/db/update/SpecialDirectory.cxx b/src/db/update/SpecialDirectory.cxx index 3887d30d5..bcd2f2999 100644 --- a/src/db/update/SpecialDirectory.cxx +++ b/src/db/update/SpecialDirectory.cxx @@ -7,7 +7,7 @@ #include "playlist/PlaylistRegistry.hxx" #include "fs/Traits.hxx" -gcc_pure +[[gnu::pure]] static bool HaveArchivePluginForFilename(const char *filename) noexcept { @@ -21,7 +21,7 @@ HaveArchivePluginForFilename(const char *filename) noexcept #endif } -gcc_pure +[[gnu::pure]] static bool HaveContainerPluginForFilename(const char *filename) noexcept { @@ -31,7 +31,7 @@ HaveContainerPluginForFilename(const char *filename) noexcept decoder_plugins_supports_suffix(suffix); } -gcc_pure +[[gnu::pure]] static bool HavePlaylistPluginForFilename(const char *filename) noexcept { diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 3b6d17d95..88420db06 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -215,14 +215,14 @@ try { } /* we don't look at files with newlines in their name */ -gcc_pure +[[gnu::pure]] static bool skip_path(const char *name_utf8) noexcept { return std::strchr(name_utf8, '\n') != nullptr; } -gcc_pure +[[gnu::pure]] bool UpdateWalk::SkipSymlink(const Directory *directory, std::string_view utf8_name) const noexcept diff --git a/src/decoder/Thread.cxx b/src/decoder/Thread.cxx index 3d150c4c1..2ab2f7ee7 100644 --- a/src/decoder/Thread.cxx +++ b/src/decoder/Thread.cxx @@ -148,7 +148,7 @@ decoder_file_decode(const DecoderPlugin &plugin, return bridge.dc.state != DecoderState::START; } -gcc_pure +[[gnu::pure]] static bool decoder_check_plugin_mime(const DecoderPlugin &plugin, const InputStream &is) noexcept @@ -160,7 +160,7 @@ decoder_check_plugin_mime(const DecoderPlugin &plugin, plugin.SupportsMimeType(GetMimeTypeBase(mime_type)); } -gcc_pure +[[gnu::pure]] static bool decoder_check_plugin_suffix(const DecoderPlugin &plugin, std::string_view suffix) noexcept @@ -170,7 +170,7 @@ decoder_check_plugin_suffix(const DecoderPlugin &plugin, return !suffix.empty() && plugin.SupportsSuffix(suffix); } -gcc_pure +[[gnu::pure]] static bool decoder_check_plugin(const DecoderPlugin &plugin, const InputStream &is, std::string_view suffix) noexcept @@ -449,7 +449,7 @@ try { * are only kept as a cache to be displayed by the client; they shall * not be sent to the output. */ -gcc_pure +[[gnu::pure]] static bool SongHasVolatileTags(const DetachedSong &song) noexcept { diff --git a/src/decoder/plugins/AudiofileDecoderPlugin.cxx b/src/decoder/plugins/AudiofileDecoderPlugin.cxx index 6856f4a0c..8b6f253f2 100644 --- a/src/decoder/plugins/AudiofileDecoderPlugin.cxx +++ b/src/decoder/plugins/AudiofileDecoderPlugin.cxx @@ -48,7 +48,7 @@ struct AudioFileInputStream { } }; -gcc_pure +[[gnu::pure]] static SongTime audiofile_get_duration(AFfilehandle fh) noexcept { @@ -124,7 +124,7 @@ setup_virtual_fops(AudioFileInputStream &afis) noexcept return vf; } -gcc_const +[[gnu::const]] static SampleFormat audiofile_bits_to_sample_format(int bits) noexcept { diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 8efc7dce5..989f0a0ba 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -88,14 +88,14 @@ ffmpeg_finish() noexcept av_dict_free(&avformat_options); } -gcc_pure +[[gnu::pure]] static bool IsAudio(const AVStream &stream) noexcept { return stream.codecpar->codec_type == AVMEDIA_TYPE_AUDIO; } -gcc_pure +[[gnu::pure]] static int ffmpeg_find_audio_stream(const AVFormatContext &format_context) noexcept { @@ -106,7 +106,7 @@ ffmpeg_find_audio_stream(const AVFormatContext &format_context) noexcept return -1; } -gcc_pure +[[gnu::pure]] static bool IsPicture(const AVStream &stream) noexcept { @@ -165,7 +165,7 @@ start_time_fallback(const AVStream &stream) * Convert AVPacket::pts to a stream-relative time stamp (still in * AVStream::time_base units). Returns a negative value on error. */ -gcc_pure +[[gnu::pure]] static int64_t StreamRelativePts(const AVPacket &packet, const AVStream &stream) noexcept { @@ -181,7 +181,7 @@ StreamRelativePts(const AVPacket &packet, const AVStream &stream) noexcept * Convert a non-negative stream-relative time stamp in * AVStream::time_base units to a PCM frame number. */ -gcc_pure +[[gnu::pure]] static uint64_t PtsToPcmFrame(uint64_t pts, const AVStream &stream, const AVCodecContext &codec_context) noexcept @@ -323,7 +323,7 @@ ffmpeg_send_packet(DecoderClient &client, InputStream *is, return cmd; } -gcc_const +[[gnu::const]] static SampleFormat ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept { diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index b4a503c30..87fa6952b 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -61,7 +61,7 @@ gme_plugin_init([[maybe_unused]] const ConfigBlock &block) return true; } -gcc_pure +[[gnu::pure]] static unsigned ParseSubtuneName(const char *base) noexcept { diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 4f4e1ed09..4ed21a27f 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -50,7 +50,7 @@ static constexpr unsigned DECODERDELAY = 529; static constexpr Domain mad_domain("mad"); -gcc_const +[[gnu::const]] static SongTime ToSongTime(mad_timer_t t) noexcept { @@ -135,10 +135,10 @@ private: void ParseId3(size_t tagsize, Tag *tag) noexcept; MadDecoderAction DecodeNextFrame(bool skip, Tag *tag) noexcept; - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] offset_type ThisFrameOffset() const noexcept; - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] offset_type RestIncludingThisFrame() const noexcept; /** @@ -157,7 +157,7 @@ private: times = new mad_timer_t[max_frames]; } - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] size_t TimeToFrame(SongTime t) const noexcept; /** diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx index 7155d30c6..190abbf8c 100644 --- a/src/decoder/plugins/OpusDecoderPlugin.cxx +++ b/src/decoder/plugins/OpusDecoderPlugin.cxx @@ -33,15 +33,15 @@ constexpr opus_int32 opus_sample_rate = 48000; */ constexpr unsigned opus_output_buffer_frames = opus_sample_rate / 4; -gcc_pure -bool +[[gnu::pure]] +static bool IsOpusHead(const ogg_packet &packet) noexcept { return packet.bytes >= 8 && memcmp(packet.packet, "OpusHead", 8) == 0; } -gcc_pure -bool +[[gnu::pure]] +static bool IsOpusTags(const ogg_packet &packet) noexcept { return packet.bytes >= 8 && memcmp(packet.packet, "OpusTags", 8) == 0; @@ -50,7 +50,7 @@ IsOpusTags(const ogg_packet &packet) noexcept /** * Convert an EBU R128 value to ReplayGain. */ -constexpr float +static constexpr float EbuR128ToReplayGain(float ebu_r128) noexcept { /* add 5dB to compensate for the different reference levels @@ -58,7 +58,7 @@ EbuR128ToReplayGain(float ebu_r128) noexcept return ebu_r128 + 5; } -bool +static bool mpd_opus_init([[maybe_unused]] const ConfigBlock &block) { LogDebug(opus_domain, opus_get_version_string()); @@ -300,7 +300,7 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet) packet.bytes, output_buffer, opus_output_buffer_frames, 0); - if (gcc_unlikely(nframes <= 0)) { + if (nframes <= 0) [[unlikely]] { if (nframes < 0) throw FmtRuntimeError("libopus error: {}", opus_strerror(nframes)); diff --git a/src/decoder/plugins/OpusTags.cxx b/src/decoder/plugins/OpusTags.cxx index 964423846..84e4e85ec 100644 --- a/src/decoder/plugins/OpusTags.cxx +++ b/src/decoder/plugins/OpusTags.cxx @@ -17,7 +17,7 @@ using std::string_view_literals::operator""sv; -gcc_pure +[[gnu::pure]] static TagType ParseOpusTagName(std::string_view name) noexcept { diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index 9fa1e4274..f889d4768 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -149,7 +149,7 @@ struct SidplayContainerPath { unsigned track; }; -gcc_pure +[[gnu::pure]] static unsigned ParseSubtuneName(const char *base) noexcept { @@ -458,7 +458,7 @@ Windows1252ToUTF8(const char *s) noexcept return t; } -gcc_pure +[[gnu::pure]] static AllocatedString GetInfoString(const SidTuneInfo &info, unsigned i) noexcept { @@ -475,7 +475,7 @@ GetInfoString(const SidTuneInfo &info, unsigned i) noexcept return Windows1252ToUTF8(s); } -gcc_pure +[[gnu::pure]] static AllocatedString GetDateString(const SidTuneInfo &info) noexcept { diff --git a/src/decoder/plugins/SndfileDecoderPlugin.cxx b/src/decoder/plugins/SndfileDecoderPlugin.cxx index 2933fa06f..94c2e964e 100644 --- a/src/decoder/plugins/SndfileDecoderPlugin.cxx +++ b/src/decoder/plugins/SndfileDecoderPlugin.cxx @@ -128,7 +128,7 @@ sndfile_duration(const SF_INFO &info) return SongTime::FromScale(info.frames, info.samplerate); } -gcc_pure +[[gnu::pure]] static SampleFormat sndfile_sample_format(const SF_INFO &info) noexcept { diff --git a/src/event/BufferedSocket.cxx b/src/event/BufferedSocket.cxx index 8598a1280..052c984b1 100644 --- a/src/event/BufferedSocket.cxx +++ b/src/event/BufferedSocket.cxx @@ -3,7 +3,6 @@ #include "BufferedSocket.hxx" #include "net/SocketError.hxx" -#include "util/Compiler.h" #include @@ -11,7 +10,7 @@ BufferedSocket::ssize_t BufferedSocket::DirectRead(void *data, size_t length) noexcept { const auto nbytes = GetSocket().Read((char *)data, length); - if (gcc_likely(nbytes > 0)) + if (nbytes > 0) [[likely]] return nbytes; if (nbytes == 0) { @@ -86,7 +85,7 @@ BufferedSocket::OnSocketReady(unsigned flags) noexcept { assert(IsDefined()); - if (gcc_unlikely(flags & (SocketEvent::ERROR|SocketEvent::HANGUP))) { + if (flags & (SocketEvent::ERROR|SocketEvent::HANGUP)) [[unlikely]] { OnSocketClosed(); return; } diff --git a/src/event/FullyBufferedSocket.cxx b/src/event/FullyBufferedSocket.cxx index 6cb60d7d6..ca9db4dc0 100644 --- a/src/event/FullyBufferedSocket.cxx +++ b/src/event/FullyBufferedSocket.cxx @@ -3,7 +3,6 @@ #include "FullyBufferedSocket.hxx" #include "net/SocketError.hxx" -#include "util/Compiler.h" #include @@ -13,7 +12,7 @@ FullyBufferedSocket::ssize_t FullyBufferedSocket::DirectWrite(const void *data, size_t length) noexcept { const auto nbytes = GetSocket().Write((const char *)data, length); - if (gcc_unlikely(nbytes < 0)) { + if (nbytes < 0) [[unlikely]] { const auto code = GetSocketError(); if (IsSocketErrorSendWouldBlock(code)) return 0; @@ -43,7 +42,7 @@ FullyBufferedSocket::Flush() noexcept } auto nbytes = DirectWrite(data.data(), data.size()); - if (gcc_unlikely(nbytes <= 0)) + if (nbytes <= 0) [[unlikely]] return nbytes == 0; output.Consume(nbytes); diff --git a/src/filter/plugins/HdcdFilterPlugin.cxx b/src/filter/plugins/HdcdFilterPlugin.cxx index 6d9281411..08f316687 100644 --- a/src/filter/plugins/HdcdFilterPlugin.cxx +++ b/src/filter/plugins/HdcdFilterPlugin.cxx @@ -12,7 +12,7 @@ static constexpr const char *hdcd_graph = "hdcd"; -gcc_pure +[[gnu::pure]] static bool MaybeHdcd(const AudioFormat &audio_format) noexcept { diff --git a/src/filter/plugins/NullFilterPlugin.cxx b/src/filter/plugins/NullFilterPlugin.cxx index 1fbb8858c..eaa14d7df 100644 --- a/src/filter/plugins/NullFilterPlugin.cxx +++ b/src/filter/plugins/NullFilterPlugin.cxx @@ -12,7 +12,6 @@ #include "filter/FilterPlugin.hxx" #include "filter/NullFilter.hxx" #include "filter/Prepared.hxx" -#include "util/Compiler.h" class PreparedNullFilter final : public PreparedFilter { public: diff --git a/src/fs/LookupFile.cxx b/src/fs/LookupFile.cxx index f5e1c9a44..ad0a0b0f9 100644 --- a/src/fs/LookupFile.cxx +++ b/src/fs/LookupFile.cxx @@ -5,7 +5,7 @@ #include "FileInfo.hxx" #include "system/Error.hxx" -gcc_pure +[[gnu::pure]] static PathTraitsFS::pointer FindSlash(PathTraitsFS::pointer p, size_t i) noexcept { diff --git a/src/input/InputStream.cxx b/src/input/InputStream.cxx index ded509ff2..ded17ce27 100644 --- a/src/input/InputStream.cxx +++ b/src/input/InputStream.cxx @@ -36,7 +36,7 @@ InputStream::SetReady() noexcept * seeking in a HTTP file requires opening a new connection with a new * HTTP request. */ -gcc_pure +[[gnu::pure]] static bool ExpensiveSeeking(const char *uri) noexcept { diff --git a/src/io/BufferedOutputStream.cxx b/src/io/BufferedOutputStream.cxx index 9973ea267..90ee0ba6e 100644 --- a/src/io/BufferedOutputStream.cxx +++ b/src/io/BufferedOutputStream.cxx @@ -67,7 +67,7 @@ BufferedOutputStream::Format(const char *fmt, ...) std::size_t size = vsnprintf((char *)r.data(), r.size(), fmt, ap); va_end(ap); - if (gcc_unlikely(size >= r.size())) { + if (size >= r.size()) [[unlikely]] { /* buffer was not large enough; flush it and try again */ @@ -75,7 +75,7 @@ BufferedOutputStream::Format(const char *fmt, ...) r = buffer.Write(); - if (gcc_unlikely(size >= r.size())) { + if (size >= r.size()) [[unlikely]] { /* still not enough space: grow the buffer and try again */ ++size; diff --git a/src/lib/dbus/UDisks2.cxx b/src/lib/dbus/UDisks2.cxx index 3657699e8..2e375f6df 100644 --- a/src/lib/dbus/UDisks2.cxx +++ b/src/lib/dbus/UDisks2.cxx @@ -7,7 +7,6 @@ #include "ObjectManager.hxx" #include "util/SpanCast.hxx" #include "util/StringAPI.hxx" -#include "util/Compiler.h" #include #include @@ -15,7 +14,7 @@ namespace UDisks2 { template -gcc_pure +[[gnu::pure]] static const char * CheckString(I &&i) noexcept { @@ -26,7 +25,7 @@ CheckString(I &&i) noexcept } template -gcc_pure +[[gnu::pure]] static std::string_view CheckRecursedByteArrayToString(I &&i) noexcept { @@ -38,7 +37,7 @@ CheckRecursedByteArrayToString(I &&i) noexcept } template -gcc_pure +[[gnu::pure]] static std::string_view CheckByteArrayToString(I &&i) noexcept { @@ -49,7 +48,7 @@ CheckByteArrayToString(I &&i) noexcept } template -gcc_pure +[[gnu::pure]] static std::string_view CheckByteArrayArrayFrontToString(I &&i) noexcept { diff --git a/src/lib/nfs/FileReader.hxx b/src/lib/nfs/FileReader.hxx index 64ceccf4f..786e87e67 100644 --- a/src/lib/nfs/FileReader.hxx +++ b/src/lib/nfs/FileReader.hxx @@ -7,7 +7,6 @@ #include "Lease.hxx" #include "Callback.hxx" #include "event/InjectEvent.hxx" -#include "util/Compiler.h" #include #include diff --git a/src/lib/sqlite/Util.hxx b/src/lib/sqlite/Util.hxx index da734510b..22979bd20 100644 --- a/src/lib/sqlite/Util.hxx +++ b/src/lib/sqlite/Util.hxx @@ -4,7 +4,6 @@ #ifndef MPD_SQLITE_UTIL_HXX #define MPD_SQLITE_UTIL_HXX -#include "util/Compiler.h" #include "Error.hxx" #include diff --git a/src/lib/upnp/Action.hxx b/src/lib/upnp/Action.hxx index 4f31819e8..c7bd2f5a3 100644 --- a/src/lib/upnp/Action.hxx +++ b/src/lib/upnp/Action.hxx @@ -4,8 +4,6 @@ #ifndef MPD_UPNP_ACTION_HXX #define MPD_UPNP_ACTION_HXX -#include "util/Compiler.h" - #include static constexpr unsigned diff --git a/src/lib/xiph/FlacIOHandle.cxx b/src/lib/xiph/FlacIOHandle.cxx index 83287d62b..2bac4f730 100644 --- a/src/lib/xiph/FlacIOHandle.cxx +++ b/src/lib/xiph/FlacIOHandle.cxx @@ -3,7 +3,6 @@ #include "FlacIOHandle.hxx" #include "Log.hxx" -#include "util/Compiler.h" #include "system/Error.hxx" #include diff --git a/src/lib/xiph/FlacMetadataIterator.hxx b/src/lib/xiph/FlacMetadataIterator.hxx index c331d605b..212820452 100644 --- a/src/lib/xiph/FlacMetadataIterator.hxx +++ b/src/lib/xiph/FlacMetadataIterator.hxx @@ -4,8 +4,6 @@ #ifndef MPD_FLAC_METADATA_ITERATOR_HXX #define MPD_FLAC_METADATA_ITERATOR_HXX -#include "util/Compiler.h" - #include class FlacMetadataIterator { @@ -31,7 +29,7 @@ public: return ::FLAC__metadata_iterator_next(iterator); } - gcc_pure + [[gnu::pure]] FLAC__StreamMetadata *GetBlock() noexcept { return ::FLAC__metadata_iterator_get_block(iterator); } diff --git a/src/lib/xiph/FlacStreamMetadata.cxx b/src/lib/xiph/FlacStreamMetadata.cxx index 4d4925386..70d4c57cd 100644 --- a/src/lib/xiph/FlacStreamMetadata.cxx +++ b/src/lib/xiph/FlacStreamMetadata.cxx @@ -59,7 +59,7 @@ flac_scan_comments(const FLAC__StreamMetadata_VorbisComment *comment, ScanVorbisComment(ToStringView(comment->comments[i]), handler); } -gcc_pure +[[gnu::pure]] static inline SongTime flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info) noexcept { diff --git a/src/mixer/All.cxx b/src/mixer/All.cxx index 91a12d008..04c29d326 100644 --- a/src/mixer/All.cxx +++ b/src/mixer/All.cxx @@ -16,7 +16,7 @@ static constexpr Domain mixer_domain("mixer"); -gcc_pure +[[gnu::pure]] static int output_mixer_get_volume(const AudioOutputControl &ao) noexcept { diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index 420332087..43ba6c2f7 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -228,7 +228,7 @@ AlsaMixer::~AlsaMixer() snd_config_update_free_global(); } -gcc_pure +[[gnu::pure]] static snd_mixer_elem_t * alsa_mixer_lookup_elem(snd_mixer_t *handle, const char *name, unsigned idx) noexcept diff --git a/src/mixer/plugins/SoftwareMixerPlugin.cxx b/src/mixer/plugins/SoftwareMixerPlugin.cxx index f2e211e19..6fb48ffff 100644 --- a/src/mixer/plugins/SoftwareMixerPlugin.cxx +++ b/src/mixer/plugins/SoftwareMixerPlugin.cxx @@ -48,7 +48,7 @@ software_mixer_init([[maybe_unused]] EventLoop &event_loop, return new SoftwareMixer(listener); } -gcc_const +[[gnu::const]] static unsigned PercentVolumeToSoftwareVolume(unsigned volume) noexcept { diff --git a/src/output/Filtered.hxx b/src/output/Filtered.hxx index 611a8095e..37e08f4f5 100644 --- a/src/output/Filtered.hxx +++ b/src/output/Filtered.hxx @@ -146,13 +146,13 @@ public: /** * Does the plugin support enabling/disabling a device? */ - gcc_pure + [[gnu::pure]] bool SupportsEnableDisable() const noexcept; /** * Does the plugin support pausing a device? */ - gcc_pure + [[gnu::pure]] bool SupportsPause() const noexcept; std::map GetAttributes() const noexcept; @@ -204,7 +204,7 @@ public: void Interrupt() noexcept; - gcc_pure + [[gnu::pure]] std::chrono::steady_clock::duration Delay() noexcept; void SendTag(const Tag &tag); diff --git a/src/output/Interface.cxx b/src/output/Interface.cxx index 439079f69..5f8236fc8 100644 --- a/src/output/Interface.cxx +++ b/src/output/Interface.cxx @@ -2,7 +2,6 @@ // Copyright The Music Player Daemon Project #include "Interface.hxx" -#include "util/Compiler.h" #include diff --git a/src/output/OutputPlugin.hxx b/src/output/OutputPlugin.hxx index 707dff795..027d4636f 100644 --- a/src/output/OutputPlugin.hxx +++ b/src/output/OutputPlugin.hxx @@ -4,8 +4,6 @@ #ifndef MPD_OUTPUT_PLUGIN_HXX #define MPD_OUTPUT_PLUGIN_HXX -#include "util/Compiler.h" - struct ConfigBlock; class AudioOutput; struct MixerPlugin; @@ -54,7 +52,7 @@ ao_plugin_test_default_device(const AudioOutputPlugin *plugin) : false; } -gcc_malloc gcc_returns_nonnull +[[gnu::malloc]] [[gnu::returns_nonnull]] AudioOutput * ao_plugin_init(EventLoop &event_loop, const AudioOutputPlugin &plugin, diff --git a/src/output/SharedPipeConsumer.hxx b/src/output/SharedPipeConsumer.hxx index 5b3d54620..7b2b56ec7 100644 --- a/src/output/SharedPipeConsumer.hxx +++ b/src/output/SharedPipeConsumer.hxx @@ -4,8 +4,6 @@ #ifndef SHARED_PIPE_CONSUMER_HXX #define SHARED_PIPE_CONSUMER_HXX -#include "util/Compiler.h" - #include struct MusicChunk; @@ -67,7 +65,7 @@ public: consumed = true; } - gcc_pure + [[gnu::pure]] bool IsConsumed(const MusicChunk &_chunk) const noexcept; void ClearTail([[maybe_unused]] const MusicChunk &_chunk) noexcept { diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 8ded77f78..f510d41fc 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -246,7 +246,7 @@ public: using MultiSocketMonitor::GetEventLoop; - gcc_pure + [[gnu::pure]] const char *GetDevice() const noexcept { return device.empty() ? default_device : device.c_str(); } @@ -292,13 +292,13 @@ private: #endif ); - gcc_pure + [[gnu::pure]] bool LockIsActive() const noexcept { const std::scoped_lock lock(mutex); return active; } - gcc_pure + [[gnu::pure]] bool LockIsActiveAndNotWaiting() const noexcept { const std::scoped_lock lock(mutex); return active && !waiting; @@ -654,7 +654,7 @@ MaybeDmix(snd_pcm_type_t type) return type == SND_PCM_TYPE_DMIX || type == SND_PCM_TYPE_PLUG; } -gcc_pure +[[gnu::pure]] static bool MaybeDmix(snd_pcm_t *pcm) noexcept { diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index d65d9698e..f9904f742 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -124,7 +124,7 @@ private: * Determine the number of frames guaranteed to be available * on all channels. */ - gcc_pure + [[gnu::pure]] jack_nframes_t GetAvailable() const noexcept; void Process(jack_nframes_t nframes); diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 97209c18f..45fcdf8a9 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -525,7 +525,7 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept } } -gcc_pure +[[gnu::pure]] static bool IsAudioDeviceName(AudioDeviceID id, const char *expected_name) noexcept { diff --git a/src/output/plugins/OpenALOutputPlugin.cxx b/src/output/plugins/OpenALOutputPlugin.cxx index da88b9c80..735533a19 100644 --- a/src/output/plugins/OpenALOutputPlugin.cxx +++ b/src/output/plugins/OpenALOutputPlugin.cxx @@ -43,7 +43,7 @@ private: void Open(AudioFormat &audio_format) override; void Close() noexcept override; - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] std::chrono::steady_clock::duration Delay() const noexcept override { return filled < NUM_BUFFERS || HasProcessed() ? std::chrono::steady_clock::duration::zero() @@ -57,19 +57,19 @@ private: void Cancel() noexcept override; - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] ALint GetSourceI(ALenum param) const noexcept { ALint value; alGetSourcei(source, param, &value); return value; } - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] bool HasProcessed() const noexcept { return GetSourceI(AL_BUFFERS_PROCESSED) > 0; } - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] bool IsPlaying() const noexcept { return GetSourceI(AL_SOURCE_STATE) == AL_PLAYING; } diff --git a/src/output/plugins/OssOutputPlugin.cxx b/src/output/plugins/OssOutputPlugin.cxx index 79b52e12e..40cb9a054 100644 --- a/src/output/plugins/OssOutputPlugin.cxx +++ b/src/output/plugins/OssOutputPlugin.cxx @@ -372,8 +372,7 @@ oss_setup_sample_rate(FileDescriptor fd, AudioFormat &audio_format, * Convert a MPD sample format to its OSS counterpart. Returns * AFMT_QUERY if there is no direct counterpart. */ -gcc_const -static int +static constexpr int sample_format_to_oss(SampleFormat format) noexcept { switch (format) { @@ -411,8 +410,7 @@ sample_format_to_oss(SampleFormat format) noexcept * Convert an OSS sample format to its MPD counterpart. Returns * SampleFormat::UNDEFINED if there is no direct counterpart. */ -gcc_const -static SampleFormat +static constexpr SampleFormat sample_format_from_oss(int format) noexcept { switch (format) { diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx index b84df2983..300956f7f 100644 --- a/src/output/plugins/RecorderOutputPlugin.cxx +++ b/src/output/plugins/RecorderOutputPlugin.cxx @@ -72,7 +72,7 @@ private: std::size_t Play(std::span src) override; - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] bool HasDynamicPath() const noexcept { return !format_path.empty(); } diff --git a/src/output/plugins/WinmmOutputPlugin.hxx b/src/output/plugins/WinmmOutputPlugin.hxx index 72d63ae5c..adc4b3702 100644 --- a/src/output/plugins/WinmmOutputPlugin.hxx +++ b/src/output/plugins/WinmmOutputPlugin.hxx @@ -8,8 +8,6 @@ #ifdef ENABLE_WINMM_OUTPUT -#include "util/Compiler.h" - #include #include @@ -17,7 +15,7 @@ class WinmmOutput; extern const struct AudioOutputPlugin winmm_output_plugin; -gcc_pure +[[gnu::pure]] HWAVEOUT winmm_output_get_handle(WinmmOutput &output); diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx index d3d24b6b2..76f6b74ca 100644 --- a/src/output/plugins/httpd/HttpdClient.cxx +++ b/src/output/plugins/httpd/HttpdClient.cxx @@ -153,7 +153,7 @@ HttpdClient::SendResponse() noexcept } ssize_t nbytes = GetSocket().Write(response, strlen(response)); - if (gcc_unlikely(nbytes < 0)) { + if (nbytes < 0) [[unlikely]] { const SocketErrorMessage msg; FmtWarning(httpd_output_domain, "failed to write to client: {}", diff --git a/src/output/plugins/httpd/HttpdClient.hxx b/src/output/plugins/httpd/HttpdClient.hxx index cecc9e08f..d0eb294f6 100644 --- a/src/output/plugins/httpd/HttpdClient.hxx +++ b/src/output/plugins/httpd/HttpdClient.hxx @@ -6,7 +6,6 @@ #include "Page.hxx" #include "event/BufferedSocket.hxx" -#include "util/Compiler.h" #include "util/IntrusiveList.hxx" #include @@ -156,7 +155,7 @@ public: */ bool SendResponse() noexcept; - gcc_pure + [[gnu::pure]] ssize_t GetBytesTillMetaData() const noexcept; ssize_t TryWritePage(const Page &page, size_t position) noexcept; diff --git a/src/output/plugins/httpd/HttpdInternal.hxx b/src/output/plugins/httpd/HttpdInternal.hxx index 5c23282d1..67eefe079 100644 --- a/src/output/plugins/httpd/HttpdInternal.hxx +++ b/src/output/plugins/httpd/HttpdInternal.hxx @@ -17,7 +17,6 @@ #include "event/ServerSocket.hxx" #include "event/InjectEvent.hxx" #include "util/Cast.hxx" -#include "util/Compiler.h" #include "util/IntrusiveList.hxx" #include @@ -173,7 +172,7 @@ public: * * Caller must lock the mutex. */ - gcc_pure + [[gnu::pure]] bool HasClients() const noexcept { return !clients.empty(); } @@ -181,7 +180,7 @@ public: /** * Check whether there is at least one client. */ - gcc_pure + [[gnu::pure]] bool LockHasClients() const noexcept { const std::scoped_lock protect(mutex); return HasClients(); @@ -205,7 +204,7 @@ public: */ void SendHeader(HttpdClient &client) const noexcept; - gcc_pure + [[gnu::pure]] std::chrono::steady_clock::duration Delay() const noexcept override; /** diff --git a/src/pcm/Clamp.hxx b/src/pcm/Clamp.hxx index 523c7658a..a0a958f7a 100644 --- a/src/pcm/Clamp.hxx +++ b/src/pcm/Clamp.hxx @@ -4,8 +4,6 @@ #ifndef MPD_PCM_UTILS_H #define MPD_PCM_UTILS_H -#include "util/Compiler.h" - #include #include @@ -26,10 +24,10 @@ PcmClamp(typename Traits::long_type x) noexcept static_assert(Traits::MIN >= limits::min(), "out of range"); static_assert(Traits::MAX <= limits::max(), "out of range"); - if (gcc_unlikely(x < Traits::MIN)) + if (x < Traits::MIN) [[unlikely]] return T(Traits::MIN); - if (gcc_unlikely(x > Traits::MAX)) + if (x > Traits::MAX) [[unlikely]] return T(Traits::MAX); return T(x); diff --git a/src/pcm/Mix.hxx b/src/pcm/Mix.hxx index 11e1c3d04..711c3974d 100644 --- a/src/pcm/Mix.hxx +++ b/src/pcm/Mix.hxx @@ -5,7 +5,6 @@ #define MPD_PCM_MIX_HXX #include "SampleFormat.hxx" -#include "util/Compiler.h" #include diff --git a/src/pcm/Pack.cxx b/src/pcm/Pack.cxx index c9c61cc17..61c0cbe9f 100644 --- a/src/pcm/Pack.cxx +++ b/src/pcm/Pack.cxx @@ -43,8 +43,7 @@ ConstructS24(uint8_t low, uint8_t mid, uint8_t high) noexcept /** * Read a packed signed little-endian 24 bit integer. */ -gcc_pure -static int32_t +static constexpr int32_t ReadS24LE(const uint8_t *src) noexcept { return ConstructS24(src[0], src[1], src[2]); @@ -53,8 +52,7 @@ ReadS24LE(const uint8_t *src) noexcept /** * Read a packed signed big-endian 24 bit integer. */ -gcc_pure -static int32_t +static constexpr int32_t ReadS24BE(const uint8_t *src) noexcept { return ConstructS24(src[2], src[1], src[0]); @@ -63,7 +61,7 @@ ReadS24BE(const uint8_t *src) noexcept /** * Read a packed signed native-endian 24 bit integer. */ -gcc_pure +[[gnu::pure]] static int32_t ReadS24(const uint8_t *src) noexcept { diff --git a/src/pcm/Resampler.hxx b/src/pcm/Resampler.hxx index 0361f10eb..4956b672f 100644 --- a/src/pcm/Resampler.hxx +++ b/src/pcm/Resampler.hxx @@ -4,8 +4,6 @@ #ifndef MPD_PCM_RESAMPLER_HXX #define MPD_PCM_RESAMPLER_HXX -#include "util/Compiler.h" - #include #include diff --git a/src/pcm/SoxrResampler.cxx b/src/pcm/SoxrResampler.cxx index a74c18a53..dea6d4fe3 100644 --- a/src/pcm/SoxrResampler.cxx +++ b/src/pcm/SoxrResampler.cxx @@ -48,8 +48,7 @@ static constexpr struct { { SOXR_INVALID_RECIPE, nullptr } }; -gcc_const -static const char * +static constexpr const char * soxr_quality_name(unsigned long recipe) noexcept { for (const auto *i = soxr_quality_table;; ++i) { @@ -60,7 +59,7 @@ soxr_quality_name(unsigned long recipe) noexcept } } -gcc_pure +[[gnu::pure]] static unsigned long soxr_parse_quality(const char *quality) noexcept { diff --git a/src/player/CrossFade.cxx b/src/player/CrossFade.cxx index 48f2ec066..dcffee513 100644 --- a/src/player/CrossFade.cxx +++ b/src/player/CrossFade.cxx @@ -22,7 +22,7 @@ CrossFadeSettings::CanCrossFadeSong(SignedSongTime total_time) const noexcept duration < std::chrono::duration_cast(total_time); } -gcc_pure +[[gnu::pure]] static FloatDuration mixramp_interpolate(const char *ramp_list, float required_db) noexcept { diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index a8e2fdf13..7588ad779 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -237,7 +237,7 @@ private: * Note: this function does not check if the decoder is already * finished. */ - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] bool IsDecoderAtCurrentSong() const noexcept { assert(pipe != nullptr); @@ -249,7 +249,7 @@ private: * decoding it, or has finished doing it), and the player hasn't * switched to that song yet. */ - [[nodiscard]] gcc_pure + [[nodiscard]] [[gnu::pure]] bool IsDecoderAtNextSong() const noexcept { return dc.pipe != nullptr && !IsDecoderAtCurrentSong(); } diff --git a/src/playlist/PlaylistPlugin.hxx b/src/playlist/PlaylistPlugin.hxx index e9026011e..c471bcafb 100644 --- a/src/playlist/PlaylistPlugin.hxx +++ b/src/playlist/PlaylistPlugin.hxx @@ -6,7 +6,6 @@ #include "input/Ptr.hxx" #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include @@ -104,19 +103,19 @@ struct PlaylistPlugin { /** * Does the plugin announce the specified URI scheme? */ - gcc_pure gcc_nonnull_all + [[gnu::pure]] bool SupportsScheme(std::string_view scheme) 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; }; diff --git a/src/playlist/PlaylistStream.hxx b/src/playlist/PlaylistStream.hxx index 6be958ff9..6db730459 100644 --- a/src/playlist/PlaylistStream.hxx +++ b/src/playlist/PlaylistStream.hxx @@ -5,7 +5,6 @@ #define MPD_PLAYLIST_STREAM_HXX #include "thread/Mutex.hxx" -#include "util/Compiler.h" #include @@ -18,11 +17,10 @@ class Path; * @param path the path of the playlist file * @return a playlist, or nullptr on error */ -gcc_nonnull_all std::unique_ptr playlist_open_path(Path path, Mutex &mutex); -gcc_nonnull_all +[[gnu::nonnull]] std::unique_ptr playlist_open_remote(const char *uri, Mutex &mutex); diff --git a/src/playlist/cue/CueParser.hxx b/src/playlist/cue/CueParser.hxx index 747959b0c..baf7ac55b 100644 --- a/src/playlist/cue/CueParser.hxx +++ b/src/playlist/cue/CueParser.hxx @@ -6,7 +6,6 @@ #include "song/DetachedSong.hxx" #include "tag/Builder.hxx" -#include "util/Compiler.h" #include #include @@ -108,7 +107,7 @@ public: std::unique_ptr Get() noexcept; private: - gcc_pure + [[gnu::pure]] TagBuilder *GetCurrentTag() noexcept; /** diff --git a/src/queue/IdTable.hxx b/src/queue/IdTable.hxx index 30b68638f..97a1b0498 100644 --- a/src/queue/IdTable.hxx +++ b/src/queue/IdTable.hxx @@ -4,8 +4,6 @@ #ifndef MPD_ID_TABLE_HXX #define MPD_ID_TABLE_HXX -#include "util/Compiler.h" - #include /** diff --git a/src/queue/Playlist.hxx b/src/queue/Playlist.hxx index 5c94d9e73..2f6b67b4d 100644 --- a/src/queue/Playlist.hxx +++ b/src/queue/Playlist.hxx @@ -96,17 +96,17 @@ struct playlist { return queue.PositionToId(position); } - gcc_pure + [[gnu::pure]] int GetCurrentPosition() const noexcept; - gcc_pure + [[gnu::pure]] int GetNextPosition() const noexcept; /** * Returns the song object which is currently queued. Returns * none if there is none (yet?) or if MPD isn't playing. */ - gcc_pure + [[gnu::pure]] const DetachedSong *GetQueuedSong() const noexcept; /** diff --git a/src/queue/Queue.hxx b/src/queue/Queue.hxx index 61a8c6ff6..4fbcc7c96 100644 --- a/src/queue/Queue.hxx +++ b/src/queue/Queue.hxx @@ -4,7 +4,6 @@ #ifndef MPD_QUEUE_HXX #define MPD_QUEUE_HXX -#include "util/Compiler.h" #include "IdTable.hxx" #include "SingleMode.hxx" #include "ConsumeMode.hxx" @@ -141,14 +140,14 @@ struct Queue { return items[position].id; } - gcc_pure + [[gnu::pure]] unsigned OrderToPosition(unsigned _order) const noexcept { assert(_order < length); return order[_order]; } - gcc_pure + [[gnu::pure]] unsigned PositionToOrder(unsigned position) const noexcept { assert(position < length); @@ -160,7 +159,7 @@ struct Queue { } } - gcc_pure + [[gnu::pure]] uint8_t GetPriorityAtPosition(unsigned position) const noexcept { assert(position < length); @@ -217,7 +216,7 @@ struct Queue { * * @return the next order number, or -1 to stop playback */ - gcc_pure + [[gnu::pure]] int GetNextOrder(unsigned order) const noexcept; /** @@ -375,11 +374,11 @@ private: * Find the first item that has this specified priority or * higher. */ - gcc_pure + [[gnu::pure]] unsigned FindPriorityOrder(unsigned start_order, uint8_t priority, unsigned exclude_order) const noexcept; - gcc_pure + [[gnu::pure]] unsigned CountSamePriority(unsigned start_order, uint8_t priority) const noexcept; }; diff --git a/src/song/Escape.hxx b/src/song/Escape.hxx index 8f9c5850e..88704d663 100644 --- a/src/song/Escape.hxx +++ b/src/song/Escape.hxx @@ -4,11 +4,9 @@ #ifndef MPD_SONG_ESCAPE_HXX #define MPD_SONG_ESCAPE_HXX -#include "util/Compiler.h" - #include -gcc_pure +[[gnu::pure]] std::string EscapeFilterString(const std::string &src) noexcept; diff --git a/src/song/Filter.cxx b/src/song/Filter.cxx index fc6126814..869fdf7c3 100644 --- a/src/song/Filter.cxx +++ b/src/song/Filter.cxx @@ -45,7 +45,7 @@ enum { /** * @return #TAG_NUM_OF_ITEM_TYPES on error */ -gcc_pure +[[gnu::pure]] static unsigned locate_parse_type(const char *str) noexcept { diff --git a/src/storage/Registry.hxx b/src/storage/Registry.hxx index a35e2b324..3d7a5f9c1 100644 --- a/src/storage/Registry.hxx +++ b/src/storage/Registry.hxx @@ -4,8 +4,6 @@ #ifndef MPD_STORAGE_REGISTRY_HXX #define MPD_STORAGE_REGISTRY_HXX -#include "util/Compiler.h" - #include struct StoragePlugin; @@ -18,15 +16,15 @@ class EventLoop; */ extern const StoragePlugin *const storage_plugins[]; -gcc_nonnull_all gcc_pure +[[gnu::nonnull]] [[gnu::pure]] const StoragePlugin * GetStoragePluginByName(const char *name) noexcept; -gcc_nonnull_all gcc_pure +[[gnu::nonnull]] [[gnu::pure]] const StoragePlugin * GetStoragePluginByUri(const char *uri) noexcept; -gcc_nonnull_all +[[gnu::nonnull]] std::unique_ptr CreateStorageURI(EventLoop &event_loop, const char *uri); diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index 85d40959b..799a64bb2 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -203,7 +203,7 @@ ParseU64(const char *s, size_t length) noexcept return ParseU64(std::string(s, length).c_str()); } -gcc_pure +[[gnu::pure]] static bool IsXmlContentType(const char *content_type) noexcept { @@ -211,7 +211,7 @@ IsXmlContentType(const char *content_type) noexcept StringStartsWith(content_type, "application/xml"); } -gcc_pure +[[gnu::pure]] static bool IsXmlContentType(const Curl::Headers &headers) noexcept { @@ -456,7 +456,7 @@ CurlStorage::GetInfo(std::string_view uri_utf8, [[maybe_unused]] bool follow) return HttpGetInfoOperation(*curl, uri.c_str()).Perform(); } -gcc_pure +[[gnu::pure]] static std::string_view UriPathOrSlash(const char *uri) noexcept { @@ -494,7 +494,7 @@ private: * Convert a "href" attribute (which may be an absolute URI) * to the base file name. */ - gcc_pure + [[gnu::pure]] std::string_view HrefToEscapedName(const char *href) const noexcept { std::string_view path = uri_get_path(href); if (path.data() == nullptr) diff --git a/src/storage/plugins/LocalStorage.hxx b/src/storage/plugins/LocalStorage.hxx index f76041b97..e1f40788e 100644 --- a/src/storage/plugins/LocalStorage.hxx +++ b/src/storage/plugins/LocalStorage.hxx @@ -4,8 +4,6 @@ #ifndef MPD_STORAGE_LOCAL_HXX #define MPD_STORAGE_LOCAL_HXX -#include "util/Compiler.h" - #include struct StoragePlugin; @@ -14,7 +12,6 @@ class Path; extern const StoragePlugin local_storage_plugin; -gcc_nonnull_all std::unique_ptr CreateLocalStorage(Path base_fs); diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx index 66d66a054..882cdb2c2 100644 --- a/src/storage/plugins/NfsStorage.cxx +++ b/src/storage/plugins/NfsStorage.cxx @@ -288,7 +288,7 @@ NfsStorage::GetInfo(std::string_view uri_utf8, bool follow) return operation.GetInfo(); } -gcc_pure +[[gnu::pure]] static bool SkipNameFS(PathTraitsFS::const_pointer name) noexcept { diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx index 880bfaeaf..89945601d 100644 --- a/src/storage/plugins/SmbclientStorage.cxx +++ b/src/storage/plugins/SmbclientStorage.cxx @@ -133,7 +133,7 @@ SmbclientStorage::OpenDirectory(std::string_view uri_utf8) handle); } -gcc_pure +[[gnu::pure]] static bool SkipNameFS(PathTraitsFS::const_pointer name) noexcept { diff --git a/src/tag/Handler.hxx b/src/tag/Handler.hxx index c376020ef..c81d583d9 100644 --- a/src/tag/Handler.hxx +++ b/src/tag/Handler.hxx @@ -5,7 +5,6 @@ #define MPD_TAG_HANDLER_HXX #include "Chrono.hxx" -#include "util/Compiler.h" #include #include diff --git a/src/tag/Id3Scan.cxx b/src/tag/Id3Scan.cxx index b677fe817..9bd14fcce 100644 --- a/src/tag/Id3Scan.cxx +++ b/src/tag/Id3Scan.cxx @@ -55,7 +55,7 @@ #define ID3_FRAME_MOOD "TMOO" #endif -gcc_pure +[[gnu::pure]] static Id3String tag_id3_getstring(const struct id3_frame *frame, unsigned i) noexcept { @@ -186,7 +186,7 @@ tag_id3_import_comment(const struct id3_tag *tag, const char *id, TagType type, * Parse a TXXX name, and convert it to a TagType enum value. * Returns TAG_NUM_OF_ITEM_TYPES if the TXXX name is not understood. */ -gcc_pure +[[gnu::pure]] static TagType tag_id3_parse_txxx_name(const char *name) noexcept { diff --git a/src/tag/ReplayGainParser.cxx b/src/tag/ReplayGainParser.cxx index 626a5a44c..31b65fe36 100644 --- a/src/tag/ReplayGainParser.cxx +++ b/src/tag/ReplayGainParser.cxx @@ -43,7 +43,7 @@ ParseReplayGainTag(ReplayGainInfo &info, const char *name; const char *value; - gcc_pure + [[gnu::pure]] const char *operator[](const char *n) const noexcept { return StringEqualsCaseASCII(name, n) ? value @@ -60,7 +60,7 @@ ParseReplayGainVorbis(ReplayGainInfo &info, std::string_view entry) noexcept struct VorbisCommentEntry { std::string_view entry; - gcc_pure + [[gnu::pure]] const char *operator[](std::string_view n) const noexcept { return GetVorbisCommentValue(entry, n).data(); } diff --git a/src/util/Clamp.hxx b/src/util/Clamp.hxx index 99c9ca91c..e64bd2b98 100644 --- a/src/util/Clamp.hxx +++ b/src/util/Clamp.hxx @@ -4,20 +4,21 @@ #ifndef CLAMP_HPP #define CLAMP_HPP -#include "Compiler.h" - /** * Clamps the specified value in a range. Returns #min or #max if the * value is outside. */ template constexpr const T & -Clamp(const T &value, const T &min, const T &max) +Clamp(const T &value, const T &min, const T &max) noexcept { - return gcc_unlikely(value < min) - ? min - : (gcc_unlikely(value > max) - ? max : value); + if (value < min) [[unlikely]] + return min; + + if (value > max) [[unlikely]] + return max; + + return value; } #endif diff --git a/src/util/ReusableArray.hxx b/src/util/ReusableArray.hxx index f34b09b47..de67c8b45 100644 --- a/src/util/ReusableArray.hxx +++ b/src/util/ReusableArray.hxx @@ -4,8 +4,6 @@ #ifndef REUSABLE_ARRAY_HXX #define REUSABLE_ARRAY_HXX -#include "Compiler.h" - #include #include @@ -59,7 +57,7 @@ public: */ [[gnu::malloc]] [[gnu::returns_nonnull]] T *Get(size_t size) { - if (gcc_unlikely(size > capacity)) { + if (size > capacity) [[unlikely]] { /* too small: grow */ delete[] buffer; diff --git a/src/util/Serial.cxx b/src/util/Serial.cxx index 0f1f243f6..fb9b91b00 100644 --- a/src/util/Serial.cxx +++ b/src/util/Serial.cxx @@ -2,7 +2,6 @@ // Copyright The Music Player Daemon Project #include "Serial.hxx" -#include "Compiler.h" #include #include @@ -13,7 +12,7 @@ int GenerateSerial() noexcept { unsigned serial = ++next_serial; - if (gcc_unlikely(serial < 16)) { + if (serial < 16) [[unlikely]] { /* first-time initialization: seed with a clock value, which is random enough for our use */ diff --git a/src/util/StringUtil.hxx b/src/util/StringUtil.hxx index 590ab78f1..6752c7733 100644 --- a/src/util/StringUtil.hxx +++ b/src/util/StringUtil.hxx @@ -4,8 +4,6 @@ #ifndef STRING_UTIL_HXX #define STRING_UTIL_HXX -#include "Compiler.h" - #include #include @@ -17,7 +15,7 @@ * case-insensitive for ASCII characters * @return true if found */ -gcc_pure +[[gnu::pure]] bool StringArrayContainsCase(const char *const*haystack, std::string_view needle) noexcept; diff --git a/src/util/TruncateString.cxx b/src/util/TruncateString.cxx index 60fd71b2e..42032957d 100644 --- a/src/util/TruncateString.cxx +++ b/src/util/TruncateString.cxx @@ -2,6 +2,7 @@ // author: Max Kellermann #include "TruncateString.hxx" +#include "Compiler.h" #include diff --git a/src/util/TruncateString.hxx b/src/util/TruncateString.hxx index 100e56c54..e7a9e44b9 100644 --- a/src/util/TruncateString.hxx +++ b/src/util/TruncateString.hxx @@ -4,8 +4,6 @@ #ifndef TRUNCATE_STRING_HXX #define TRUNCATE_STRING_HXX -#include "Compiler.h" - #include /** @@ -16,7 +14,7 @@ * terminator) * @return a pointer to the null terminator */ -gcc_nonnull_all +[[gnu::nonnull]] char * CopyTruncateString(char *dest, const char *src, size_t size) noexcept; diff --git a/src/util/UTF8.cxx b/src/util/UTF8.cxx index 814ac3ab2..57e478a2a 100644 --- a/src/util/UTF8.cxx +++ b/src/util/UTF8.cxx @@ -272,9 +272,9 @@ Latin1ToUTF8(const char *gcc_restrict src, char *gcc_restrict buffer, char * UnicodeToUTF8(unsigned ch, char *q) noexcept { - if (gcc_likely(ch < 0x80)) { + if (ch < 0x80) [[likely]] { *q++ = (char)ch; - } else if (gcc_likely(ch < 0x800)) { + } else if (ch < 0x800) [[likely]] { *q++ = MakeLeading1(ch >> 6); *q++ = MakeContinuation(ch); } else if (ch < 0x10000) { diff --git a/src/win32/Win32Main.cxx b/src/win32/Win32Main.cxx index 2bd63452e..b8747613b 100644 --- a/src/win32/Win32Main.cxx +++ b/src/win32/Win32Main.cxx @@ -2,7 +2,6 @@ // Copyright The Music Player Daemon Project #include "Main.hxx" -#include "util/Compiler.h" #include "Instance.hxx" #include "system/Error.hxx" #include "Log.hxx" diff --git a/src/zeroconf/Bonjour.cxx b/src/zeroconf/Bonjour.cxx index fa775aaf3..b8297b107 100644 --- a/src/zeroconf/Bonjour.cxx +++ b/src/zeroconf/Bonjour.cxx @@ -4,7 +4,6 @@ #include "Bonjour.hxx" #include "util/Domain.hxx" #include "Log.hxx" -#include "util/Compiler.h" #include diff --git a/src/zeroconf/Glue.cxx b/src/zeroconf/Glue.cxx index f3a3e0c0a..4db46aba2 100644 --- a/src/zeroconf/Glue.cxx +++ b/src/zeroconf/Glue.cxx @@ -8,7 +8,6 @@ #include "Listen.hxx" #include "util/Domain.hxx" #include "Log.hxx" -#include "util/Compiler.h" #ifdef HAVE_AVAHI #include "avahi/Helper.hxx" diff --git a/test/DumpDecoderClient.cxx b/test/DumpDecoderClient.cxx index 4dacc56fa..bc35399b5 100644 --- a/test/DumpDecoderClient.cxx +++ b/test/DumpDecoderClient.cxx @@ -6,7 +6,6 @@ #include "input/InputStream.hxx" #include "tag/Names.hxx" #include "util/StringBuffer.hxx" -#include "util/Compiler.h" #include #include diff --git a/test/MakeTag.hxx b/test/MakeTag.hxx index 1371ffcf9..20317df3b 100644 --- a/test/MakeTag.hxx +++ b/test/MakeTag.hxx @@ -3,7 +3,6 @@ #include "tag/Builder.hxx" #include "tag/Tag.hxx" -#include "util/Compiler.h" inline void BuildTag([[maybe_unused]] TagBuilder &tag) noexcept diff --git a/test/fs/TestLookupFile.cxx b/test/fs/TestLookupFile.cxx index aab42ac20..1efc64afc 100644 --- a/test/fs/TestLookupFile.cxx +++ b/test/fs/TestLookupFile.cxx @@ -1,5 +1,4 @@ #include "fs/LookupFile.hxx" -#include "util/Compiler.h" #include diff --git a/test/util/test_byte_reverse.cxx b/test/util/test_byte_reverse.cxx index 8f168c619..18be7c6a7 100644 --- a/test/util/test_byte_reverse.cxx +++ b/test/util/test_byte_reverse.cxx @@ -2,7 +2,6 @@ // Copyright The Music Player Daemon Project #include "util/ByteReverse.hxx" -#include "util/Compiler.h" #include