use [[gnu::pure]] instead of gcc_pure
This is semi-standard and doesn't require the util/Compiler.h header.
This commit is contained in:
parent
01af2778ab
commit
6cdb3ff21e
@ -30,8 +30,6 @@
|
||||
#ifndef FILE_DESCRIPTOR_HXX
|
||||
#define FILE_DESCRIPTOR_HXX
|
||||
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
@ -76,25 +74,25 @@ public:
|
||||
/**
|
||||
* Ask the kernel whether this is a valid file descriptor.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsValid() const noexcept;
|
||||
|
||||
/**
|
||||
* Ask the kernel whether this is a regular file.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsRegularFile() const noexcept;
|
||||
|
||||
/**
|
||||
* Ask the kernel whether this is a pipe.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsPipe() const noexcept;
|
||||
|
||||
/**
|
||||
* Ask the kernel whether this is a socket descriptor.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsSocket() const noexcept;
|
||||
#endif
|
||||
|
||||
@ -219,7 +217,7 @@ public:
|
||||
return lseek(Get(), offset, SEEK_CUR);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
off_t Tell() const noexcept {
|
||||
return lseek(Get(), 0, SEEK_CUR);
|
||||
}
|
||||
@ -227,7 +225,7 @@ public:
|
||||
/**
|
||||
* Returns the size of the file in bytes, or -1 on error.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
off_t GetSize() const noexcept;
|
||||
|
||||
ssize_t Read(void *buffer, std::size_t length) noexcept {
|
||||
@ -256,7 +254,7 @@ public:
|
||||
int WaitReadable(int timeout) const noexcept;
|
||||
int WaitWritable(int timeout) const noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsReadyForWriting() const noexcept;
|
||||
#endif
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2016-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2016-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -31,7 +31,6 @@
|
||||
#define NET_ADDRESS_INFO_HXX
|
||||
|
||||
#include "SocketAddress.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@ -109,7 +108,7 @@ public:
|
||||
* to an IPv6 wildcard address also allows accepting IPv4
|
||||
* connections.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
const AddressInfo &GetBest() const;
|
||||
|
||||
class const_iterator {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "SocketAddress.hxx" // IWYU pragma: export
|
||||
#include "Features.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@ -87,18 +86,18 @@ public:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool operator==(T &&other) const noexcept {
|
||||
return (SocketAddress)*this == std::forward<T>(other);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool operator!=(T &&other) const noexcept {
|
||||
return !(*this == std::forward<T>(other));
|
||||
}
|
||||
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
static AllocatedSocketAddress Null() noexcept {
|
||||
return AllocatedSocketAddress(nullptr, 0);
|
||||
}
|
||||
@ -145,13 +144,13 @@ public:
|
||||
/**
|
||||
* @see SocketAddress::GetLocalRaw()
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
StringView GetLocalRaw() const noexcept;
|
||||
|
||||
/**
|
||||
* @see SocketAddress::GetLocalPath()
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
const char *GetLocalPath() const noexcept {
|
||||
return ((SocketAddress)*this).GetLocalPath();
|
||||
}
|
||||
@ -176,7 +175,7 @@ public:
|
||||
/**
|
||||
* Extract the port number. Returns 0 if not applicable.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
unsigned GetPort() const noexcept {
|
||||
return ((SocketAddress)*this).GetPort();
|
||||
}
|
||||
|
@ -34,7 +34,6 @@
|
||||
#define NET_HOST_PARSER_HXX
|
||||
|
||||
#include "util/StringView.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
/**
|
||||
* Result type for ExtractHost().
|
||||
@ -69,7 +68,7 @@ struct ExtractHostResult {
|
||||
*
|
||||
* @param src the input string
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
ExtractHostResult
|
||||
ExtractHost(const char *src) noexcept;
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
#include "SocketAddress.hxx"
|
||||
#include "util/ByteOrder.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@ -179,7 +178,7 @@ public:
|
||||
/**
|
||||
* Is this the IPv6 wildcard address (in6addr_any)?
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsAny() const noexcept;
|
||||
|
||||
/**
|
||||
@ -195,14 +194,14 @@ public:
|
||||
/**
|
||||
* Convert "::ffff:127.0.0.1" to "127.0.0.1".
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
IPv4Address UnmapV4() const noexcept;
|
||||
|
||||
/**
|
||||
* Bit-wise AND of two addresses. This is useful for netmask
|
||||
* calculations.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
IPv6Address operator&(const IPv6Address &other) const;
|
||||
|
||||
private:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -31,7 +31,6 @@
|
||||
#define SOCKET_ADDRESS_HXX
|
||||
|
||||
#include "Features.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@ -118,14 +117,14 @@ public:
|
||||
* "size" attribute includes the null terminator. Returns
|
||||
* nullptr if not applicable.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
StringView GetLocalRaw() const noexcept;
|
||||
|
||||
/**
|
||||
* Returns the local socket path or nullptr if not applicable
|
||||
* (or if the path is corrupt).
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
const char *GetLocalPath() const noexcept;
|
||||
#endif
|
||||
|
||||
@ -133,25 +132,25 @@ public:
|
||||
/**
|
||||
* Is this the IPv6 wildcard address (in6addr_any)?
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsV6Any() const noexcept;
|
||||
|
||||
/**
|
||||
* Is this an IPv4 address mapped inside struct sockaddr_in6?
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsV4Mapped() const noexcept;
|
||||
|
||||
/**
|
||||
* Convert "::ffff:127.0.0.1" to "127.0.0.1".
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
IPv4Address UnmapV4() const noexcept;
|
||||
|
||||
/**
|
||||
* Extract the port number. Returns 0 if not applicable.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
unsigned GetPort() const noexcept;
|
||||
#endif
|
||||
|
||||
@ -162,10 +161,10 @@ public:
|
||||
* much for anything else. Returns nullptr if the address is
|
||||
* not supported.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
ConstBuffer<void> GetSteadyPart() const noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool operator==(const SocketAddress other) const noexcept;
|
||||
|
||||
bool operator!=(const SocketAddress other) const noexcept {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -90,13 +90,13 @@ public:
|
||||
* Determine the socket type, i.e. SOCK_STREAM, SOCK_DGRAM or
|
||||
* SOCK_SEQPACKET. Returns -1 on error.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
int GetType() const noexcept;
|
||||
|
||||
/**
|
||||
* Is this a stream socket?
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool IsStream() const noexcept;
|
||||
|
||||
using FileDescriptor::Get;
|
||||
@ -167,7 +167,7 @@ public:
|
||||
* Receive peer credentials (SO_PEERCRED). On error, the pid
|
||||
* is -1.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
struct ucred GetPeerCredentials() const noexcept;
|
||||
#endif
|
||||
|
||||
@ -226,10 +226,10 @@ public:
|
||||
|
||||
bool Connect(SocketAddress address) noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
StaticSocketAddress GetLocalAddress() const noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
StaticSocketAddress GetPeerAddress() const noexcept;
|
||||
|
||||
ssize_t Read(void *buffer, size_t length) noexcept;
|
||||
|
@ -30,7 +30,6 @@
|
||||
#ifndef SOCKET_ERROR_HXX
|
||||
#define SOCKET_ERROR_HXX
|
||||
|
||||
#include "util/Compiler.h"
|
||||
#include "system/Error.hxx"
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -41,7 +40,7 @@ typedef DWORD socket_error_t;
|
||||
typedef int socket_error_t;
|
||||
#endif
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
static inline socket_error_t
|
||||
GetSocketError() noexcept
|
||||
{
|
||||
@ -128,7 +127,7 @@ IsSocketErrorAcceptWouldBlock(socket_error_t code) noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
static inline bool
|
||||
IsSocketErrorInterruped(socket_error_t code) noexcept
|
||||
{
|
||||
@ -139,7 +138,7 @@ IsSocketErrorInterruped(socket_error_t code) noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
static inline bool
|
||||
IsSocketErrorClosed(socket_error_t code) noexcept
|
||||
{
|
||||
@ -171,7 +170,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
static inline std::system_error
|
||||
MakeSocketError(socket_error_t code, const char *msg) noexcept
|
||||
{
|
||||
@ -182,7 +181,7 @@ MakeSocketError(socket_error_t code, const char *msg) noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
static inline std::system_error
|
||||
MakeSocketError(const char *msg) noexcept
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2012-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "SocketAddress.hxx" // IWYU pragma: export
|
||||
#include "Features.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@ -120,7 +119,7 @@ public:
|
||||
/**
|
||||
* @see SocketAddress::GetLocalRaw()
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
StringView GetLocalRaw() const noexcept;
|
||||
#endif
|
||||
|
||||
@ -128,7 +127,7 @@ public:
|
||||
/**
|
||||
* Extract the port number. Returns 0 if not applicable.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
unsigned GetPort() const noexcept {
|
||||
return ((SocketAddress)*this).GetPort();
|
||||
}
|
||||
@ -140,7 +139,7 @@ public:
|
||||
bool SetPort(unsigned port) noexcept;
|
||||
#endif
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool operator==(SocketAddress other) const noexcept {
|
||||
return (SocketAddress)*this == other;
|
||||
}
|
||||
|
@ -30,8 +30,6 @@
|
||||
#ifndef SYSTEM_ERROR_HXX
|
||||
#define SYSTEM_ERROR_HXX
|
||||
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <system_error> // IWYU pragma: export
|
||||
#include <utility>
|
||||
|
||||
@ -160,7 +158,7 @@ FormatFileNotFound(const char *fmt, Args&&... args) noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
inline bool
|
||||
IsErrno(const std::system_error &e, int code) noexcept
|
||||
{
|
||||
@ -168,7 +166,7 @@ IsErrno(const std::system_error &e, int code) noexcept
|
||||
e.code().value() == code;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
static inline bool
|
||||
IsFileNotFound(const std::system_error &e) noexcept
|
||||
{
|
||||
@ -180,7 +178,7 @@ IsFileNotFound(const std::system_error &e) noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
static inline bool
|
||||
IsPathNotFound(const std::system_error &e) noexcept
|
||||
{
|
||||
@ -192,7 +190,7 @@ IsPathNotFound(const std::system_error &e) noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
static inline bool
|
||||
IsAccessDenied(const std::system_error &e) noexcept
|
||||
{
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <sys/utsname.h>
|
||||
#include <stdio.h>
|
||||
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
static KernelVersionCode
|
||||
GetKernelVersionCode() noexcept
|
||||
{
|
||||
|
@ -32,8 +32,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "util/Compiler.h"
|
||||
|
||||
class KernelVersionCode {
|
||||
unsigned value = 0;
|
||||
|
||||
@ -53,6 +51,6 @@ public:
|
||||
/**
|
||||
* Is the currently running Linux kernel at least the given version?
|
||||
*/
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
bool
|
||||
IsKernelVersionOrNewer(KernelVersionCode v) noexcept;
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
ClockCache(const ClockCache &) = delete;
|
||||
ClockCache &operator=(const ClockCache &) = delete;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
const auto &now() const noexcept {
|
||||
if (value <= value_type())
|
||||
value = Clock::now();
|
||||
|
@ -72,7 +72,7 @@ LocalTime(std::chrono::system_clock::time_point tp)
|
||||
/**
|
||||
* Determine the time zone offset in a portable way.
|
||||
*/
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
static time_t
|
||||
GetTimeZoneOffset() noexcept
|
||||
{
|
||||
|
@ -33,8 +33,6 @@
|
||||
#ifndef TIME_CONVERT_HXX
|
||||
#define TIME_CONVERT_HXX
|
||||
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
/**
|
||||
@ -56,18 +54,18 @@ LocalTime(std::chrono::system_clock::time_point tp);
|
||||
/**
|
||||
* Convert a UTC-based "struct tm" to a UTC-based time point.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
std::chrono::system_clock::time_point
|
||||
TimeGm(struct tm &tm) noexcept;
|
||||
|
||||
/**
|
||||
* Convert a local "struct tm" to a UTC-based time point.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
std::chrono::system_clock::time_point
|
||||
MakeTime(struct tm &tm) noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
std::chrono::steady_clock::duration
|
||||
ToSteadyClockDuration(const struct timeval &tv) noexcept;
|
||||
|
||||
|
@ -33,8 +33,6 @@
|
||||
#ifndef TIME_ISO8601_HXX
|
||||
#define TIME_ISO8601_HXX
|
||||
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
@ -42,11 +40,11 @@
|
||||
struct tm;
|
||||
template<size_t CAPACITY> class StringBuffer;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
StringBuffer<64>
|
||||
FormatISO8601(const struct tm &tm) noexcept;
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
StringBuffer<64>
|
||||
FormatISO8601(std::chrono::system_clock::time_point tp);
|
||||
|
||||
|
@ -32,8 +32,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
struct tm;
|
||||
@ -42,7 +40,7 @@ struct tm;
|
||||
* Calculates the preceding midnight time point in the current time
|
||||
* zone.
|
||||
*/
|
||||
gcc_const
|
||||
[[gnu::const]]
|
||||
std::chrono::system_clock::time_point
|
||||
PrecedingMidnightLocal(std::chrono::system_clock::time_point t) noexcept;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user