summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorMax Kellermann <mk@cm4all.com>2021-02-08 14:59:40 +0100
committerMax Kellermann <max@musicpd.org>2021-02-12 18:34:16 +0100
commit6cdb3ff21ed47559a055c53c3ca23f53a10930fe (patch)
tree182240d93deee559ee3a4a8d802ed31af67273c8 /src/net
parent01af2778aba837552f1cfff92b03a939a18caa67 (diff)
use [[gnu::pure]] instead of gcc_pure
This is semi-standard and doesn't require the util/Compiler.h header.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/AddressInfo.cxx2
-rw-r--r--src/net/AddressInfo.hxx5
-rw-r--r--src/net/AllocatedSocketAddress.cxx2
-rw-r--r--src/net/AllocatedSocketAddress.hxx15
-rw-r--r--src/net/HostParser.hxx3
-rw-r--r--src/net/IPv6Address.hxx7
-rw-r--r--src/net/SocketAddress.cxx2
-rw-r--r--src/net/SocketAddress.hxx19
-rw-r--r--src/net/SocketDescriptor.hxx12
-rw-r--r--src/net/SocketError.hxx11
-rw-r--r--src/net/StaticSocketAddress.hxx9
11 files changed, 40 insertions, 47 deletions
diff --git a/src/net/AddressInfo.cxx b/src/net/AddressInfo.cxx
index 9bd51dba6..11ab355d6 100644
--- a/src/net/AddressInfo.cxx
+++ b/src/net/AddressInfo.cxx
@@ -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
diff --git a/src/net/AddressInfo.hxx b/src/net/AddressInfo.hxx
index 578c53a07..259279fdc 100644
--- a/src/net/AddressInfo.hxx
+++ b/src/net/AddressInfo.hxx
@@ -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 {
diff --git a/src/net/AllocatedSocketAddress.cxx b/src/net/AllocatedSocketAddress.cxx
index 18be3d87c..8a179a72e 100644
--- a/src/net/AllocatedSocketAddress.cxx
+++ b/src/net/AllocatedSocketAddress.cxx
@@ -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
diff --git a/src/net/AllocatedSocketAddress.hxx b/src/net/AllocatedSocketAddress.hxx
index 8e9393145..591723739 100644
--- a/src/net/AllocatedSocketAddress.hxx
+++ b/src/net/AllocatedSocketAddress.hxx
@@ -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();
}
diff --git a/src/net/HostParser.hxx b/src/net/HostParser.hxx
index c7d3b8275..561beb843 100644
--- a/src/net/HostParser.hxx
+++ b/src/net/HostParser.hxx
@@ -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;
diff --git a/src/net/IPv6Address.hxx b/src/net/IPv6Address.hxx
index eaa2db867..b0c29a360 100644
--- a/src/net/IPv6Address.hxx
+++ b/src/net/IPv6Address.hxx
@@ -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:
diff --git a/src/net/SocketAddress.cxx b/src/net/SocketAddress.cxx
index 1ac78c412..c0d1737b2 100644
--- a/src/net/SocketAddress.cxx
+++ b/src/net/SocketAddress.cxx
@@ -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
diff --git a/src/net/SocketAddress.hxx b/src/net/SocketAddress.hxx
index 8e9691e8e..ccbb571fa 100644
--- a/src/net/SocketAddress.hxx
+++ b/src/net/SocketAddress.hxx
@@ -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 {
diff --git a/src/net/SocketDescriptor.hxx b/src/net/SocketDescriptor.hxx
index 647c9bdd3..a69ab068e 100644
--- a/src/net/SocketDescriptor.hxx
+++ b/src/net/SocketDescriptor.hxx
@@ -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;
diff --git a/src/net/SocketError.hxx b/src/net/SocketError.hxx
index 44989c52f..8a53c6f98 100644
--- a/src/net/SocketError.hxx
+++ b/src/net/SocketError.hxx
@@ -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
{
diff --git a/src/net/StaticSocketAddress.hxx b/src/net/StaticSocketAddress.hxx
index 85c4e98b6..dc73e30e4 100644
--- a/src/net/StaticSocketAddress.hxx
+++ b/src/net/StaticSocketAddress.hxx
@@ -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;
}