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:

committed by
Max Kellermann

parent
01af2778ab
commit
6cdb3ff21e
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user