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

@@ -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<Mutex> lock(mutex);
return active;
}
gcc_pure
[[gnu::pure]]
bool LockIsActiveAndNotWaiting() const noexcept {
const std::scoped_lock<Mutex> 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
{

View File

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

View File

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

View File

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

View File

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

View File

@@ -72,7 +72,7 @@ private:
std::size_t Play(std::span<const std::byte> src) override;
[[nodiscard]] gcc_pure
[[nodiscard]] [[gnu::pure]]
bool HasDynamicPath() const noexcept {
return !format_path.empty();
}

View File

@@ -8,8 +8,6 @@
#ifdef ENABLE_WINMM_OUTPUT
#include "util/Compiler.h"
#include <windef.h>
#include <mmsystem.h>
@@ -17,7 +15,7 @@ class WinmmOutput;
extern const struct AudioOutputPlugin winmm_output_plugin;
gcc_pure
[[gnu::pure]]
HWAVEOUT
winmm_output_get_handle(WinmmOutput &output);

View File

@@ -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: {}",

View File

@@ -6,7 +6,6 @@
#include "Page.hxx"
#include "event/BufferedSocket.hxx"
#include "util/Compiler.h"
#include "util/IntrusiveList.hxx"
#include <cstddef>
@@ -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;

View File

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