use [[gnu::...]] attributes

This commit is contained in:
Max Kellermann
2023-03-06 15:57:36 +01:00
parent 3b9aab0684
commit 42f6a0441c
101 changed files with 167 additions and 234 deletions

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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;
/**

View File

@@ -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));

View File

@@ -17,7 +17,7 @@
using std::string_view_literals::operator""sv;
gcc_pure
[[gnu::pure]]
static TagType
ParseOpusTagName(std::string_view name) noexcept
{

View File

@@ -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
{

View File

@@ -128,7 +128,7 @@ sndfile_duration(const SF_INFO &info)
return SongTime::FromScale<uint64_t>(info.frames, info.samplerate);
}
gcc_pure
[[gnu::pure]]
static SampleFormat
sndfile_sample_format(const SF_INFO &info) noexcept
{