You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2023/05/01 00:13:09 UTC

[trafficserver] branch master updated: Prefer the __linux__ macro over linux. (#9656)

This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f859898fd4 Prefer the __linux__ macro over linux. (#9656)
f859898fd4 is described below

commit f859898fd4e441ef96d9d1442f1981258b6ef6ea
Author: James Peach <jp...@apache.org>
AuthorDate: Mon May 1 10:13:01 2023 +1000

    Prefer the __linux__ macro over linux. (#9656)
    
    Depending on the standards mode, GCC may not predefine the "linux"
    macro. However, "__linux__" is always predefined, so we can use that
    consistently and reliably.
    
    Signed-off-by: James Peach <jp...@apache.org>
---
 include/tscore/ink_platform.h        | 4 ++--
 include/tscore/ink_rwlock.h          | 2 +-
 include/tscpp/util/TsSharedMutex.h   | 2 +-
 iocore/cache/Store.cc                | 2 +-
 iocore/eventsystem/I_SocketManager.h | 2 +-
 iocore/net/P_UnixNet.h               | 2 +-
 iocore/net/UnixNetAccept.cc          | 2 +-
 mgmt/utils/MgmtSocket.cc             | 2 +-
 proxy/logging/LogBuffer.h            | 2 +-
 proxy/logging/LogFormat.cc           | 2 +-
 src/traffic_server/traffic_server.cc | 4 ++--
 src/tscore/ink_file.cc               | 4 ++--
 src/tscore/ink_memory.cc             | 4 ++--
 src/tscore/ink_res_mkquery.cc        | 2 +-
 tools/http_load/port.h               | 2 +-
 15 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/include/tscore/ink_platform.h b/include/tscore/ink_platform.h
index ad72011ee3..5ceab569aa 100644
--- a/include/tscore/ink_platform.h
+++ b/include/tscore/ink_platform.h
@@ -146,7 +146,7 @@ struct ifafilt;
 #include <sys/sockio.h>
 #endif
 
-#if defined(linux)
+#if defined(__linux__)
 typedef unsigned int in_addr_t;
 #endif
 
@@ -192,7 +192,7 @@ typedef unsigned int in_addr_t;
 
 // This is a little bit of a hack for now, until MPTCP has landed upstream in Linux land.
 #ifndef MPTCP_ENABLED
-#if defined(linux)
+#if defined(__linux__)
 #define MPTCP_ENABLED 42
 #else
 #define MPTCP_ENABLED 0
diff --git a/include/tscore/ink_rwlock.h b/include/tscore/ink_rwlock.h
index cbe150c362..dfc6892c16 100644
--- a/include/tscore/ink_rwlock.h
+++ b/include/tscore/ink_rwlock.h
@@ -40,7 +40,7 @@ void ink_rwlock_destroy(ink_rwlock *rw);
 // Instead of calling ink_rwlock_init(), an ink_rwlock instance can be initialized with one of thsee values.
 //
 ink_rwlock const INK_RWLOCK_INIT = PTHREAD_RWLOCK_INITIALIZER;
-#if defined(linux)
+#if defined(__linux__)
 ink_rwlock const INK_RWLOCK_INIT_NO_WRITER_STARVATION = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
 #else
 // Testing indicates that for MacOS/Darwin and FreeBSD, pthread rwlocks always prevent writer starvation.
diff --git a/include/tscpp/util/TsSharedMutex.h b/include/tscpp/util/TsSharedMutex.h
index e43c4347c6..36e3b15083 100644
--- a/include/tscpp/util/TsSharedMutex.h
+++ b/include/tscpp/util/TsSharedMutex.h
@@ -168,7 +168,7 @@ private:
     }
   }
 
-#if defined(linux)
+#if defined(__linux__)
   // Use the initializer that prevents writer starvation.
   //
   pthread_rwlock_t _lock = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
index d04dd5c664..b85c517583 100644
--- a/iocore/cache/Store.cc
+++ b/iocore/cache/Store.cc
@@ -486,7 +486,7 @@ Span::init(const char *path, int64_t size)
   case S_IFBLK:
   case S_IFCHR:
 
-#if defined(linux)
+#if defined(__linux__)
     if (major(sbuf.st_rdev) == RAW_MAJOR && minor(sbuf.st_rdev) == 0) {
       Warning("cache %s '%s' is the raw device control interface", span_file_typename(sbuf.st_mode), path);
       serr = SPAN_ERROR_UNSUPPORTED_DEVTYPE;
diff --git a/iocore/eventsystem/I_SocketManager.h b/iocore/eventsystem/I_SocketManager.h
index 718293f836..591bd2ac23 100644
--- a/iocore/eventsystem/I_SocketManager.h
+++ b/iocore/eventsystem/I_SocketManager.h
@@ -43,7 +43,7 @@
 #endif
 
 #ifndef MSG_FASTOPEN
-#if defined(linux)
+#if defined(__linux__)
 #define MSG_FASTOPEN 0x20000000
 #else
 #define MSG_FASTOPEN 0
diff --git a/iocore/net/P_UnixNet.h b/iocore/net/P_UnixNet.h
index ebea893ef4..fc890c2930 100644
--- a/iocore/net/P_UnixNet.h
+++ b/iocore/net/P_UnixNet.h
@@ -528,7 +528,7 @@ check_transient_accept_error(int res)
   if (!last_transient_accept_error || t - last_transient_accept_error > TRANSIENT_ACCEPT_ERROR_MESSAGE_EVERY) {
     last_transient_accept_error = t;
     Warning("accept thread received transient error: errno = %d", -res);
-#if defined(linux)
+#if defined(__linux__)
     if (res == -ENOBUFS || res == -ENFILE)
       Warning("errno : %d consider a memory upgrade", -res);
 #endif
diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc
index 0250d3af49..78e18bd1ff 100644
--- a/iocore/net/UnixNetAccept.cc
+++ b/iocore/net/UnixNetAccept.cc
@@ -475,7 +475,7 @@ NetAccept::acceptFastEvent(int event, void *ep)
       Debug("iocore_net", "received : %s", strerror(errno));
       res = -errno;
       if (res == -EAGAIN || res == -ECONNABORTED
-#if defined(linux)
+#if defined(__linux__)
           || res == -EPIPE
 #endif
       ) {
diff --git a/mgmt/utils/MgmtSocket.cc b/mgmt/utils/MgmtSocket.cc
index 43c6df45e4..385a2e1870 100644
--- a/mgmt/utils/MgmtSocket.cc
+++ b/mgmt/utils/MgmtSocket.cc
@@ -189,7 +189,7 @@ mgmt_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struc
 // mgmt_select call will still timeout correctly, rather than
 // possibly extending our timeout period by up to
 // MGMT_MAX_TRANSIENT_ERRORS times.
-#if defined(linux)
+#if defined(__linux__)
   int r, retries;
   for (retries = 0; retries < MGMT_MAX_TRANSIENT_ERRORS; retries++) {
     r = ::select(nfds, readfds, writefds, errorfds, timeout);
diff --git a/proxy/logging/LogBuffer.h b/proxy/logging/LogBuffer.h
index 4fe7530d2c..8a67c7e057 100644
--- a/proxy/logging/LogBuffer.h
+++ b/proxy/logging/LogBuffer.h
@@ -37,7 +37,7 @@ class LogBufferIterator;
 #define LOG_SEGMENT_COOKIE  0xaceface
 #define LOG_SEGMENT_VERSION 2
 
-#if defined(linux)
+#if defined(__linux__)
 #define LB_DEFAULT_ALIGN 512
 #else
 #define LB_DEFAULT_ALIGN 8
diff --git a/proxy/logging/LogFormat.cc b/proxy/logging/LogFormat.cc
index baa6424e6a..b34fc77a3c 100644
--- a/proxy/logging/LogFormat.cc
+++ b/proxy/logging/LogFormat.cc
@@ -108,7 +108,7 @@ LogFormat::id_from_name(const char *name)
   if (name) {
     CryptoHash hash;
     CryptoContext().hash_immediate(hash, name, static_cast<int>(strlen(name)));
-#if defined(linux)
+#if defined(__linux__)
     /* Mask most significant bit so that return value of this function
      * is not sign extended to be a negative number.
      * This problem is only known to occur on Linux which
diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc
index 2674b86b92..64d83e6230 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -51,11 +51,11 @@
 #include <list>
 #include <string>
 
-#if !defined(linux)
+#if !defined(__linux__)
 #include <sys/lock.h>
 #endif
 
-#if defined(linux)
+#if defined(__linux__)
 extern "C" int plock(int);
 #else
 #include <sys/filio.h>
diff --git a/src/tscore/ink_file.cc b/src/tscore/ink_file.cc
index c8643628ff..1b2665426a 100644
--- a/src/tscore/ink_file.cc
+++ b/src/tscore/ink_file.cc
@@ -418,7 +418,7 @@ ink_file_is_mmappable(mode_t st_mode)
     return true;
   }
 
-#if defined(linux)
+#if defined(__linux__)
   // Disks cannot be mmapped.
   if (S_ISBLK(st_mode)) {
     return false;
@@ -458,7 +458,7 @@ ink_file_get_geometry(int fd ATS_UNUSED, ink_device_geometry &geometry)
   errno = ENOTSUP;
 #endif
 
-#elif defined(linux)
+#elif defined(__linux__)
   ioctl_arg_t arg;
 
   // The following set of ioctls work for both block and character devices. You can use the
diff --git a/src/tscore/ink_memory.cc b/src/tscore/ink_memory.cc
index 1d8dbaf90e..772f59190d 100644
--- a/src/tscore/ink_memory.cc
+++ b/src/tscore/ink_memory.cc
@@ -37,7 +37,7 @@
 #endif
 
 #include <cassert>
-#if defined(linux)
+#if defined(__linux__)
 // XXX: Shouldn't that be part of CPPFLAGS?
 #ifndef _XOPEN_SOURCE
 #define _XOPEN_SOURCE 600
@@ -154,7 +154,7 @@ ats_msync(caddr_t addr, size_t len, caddr_t end, int flags)
   if ((a + l) > end) {
     l = end - a; // strict limit
   }
-#if defined(linux)
+#if defined(__linux__)
 /* Fix INKqa06500
    Under Linux, msync(..., MS_SYNC) calls are painfully slow, even on
    non-dirty buffers. This is true as of kernel 2.2.12. We sacrifice
diff --git a/src/tscore/ink_res_mkquery.cc b/src/tscore/ink_res_mkquery.cc
index bba692e95b..ace482d414 100644
--- a/src/tscore/ink_res_mkquery.cc
+++ b/src/tscore/ink_res_mkquery.cc
@@ -417,7 +417,7 @@ ink_ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
  *\li	The root is returned as "."
  *\li	All other domains are returned in non absolute form
  */
-#if defined(linux)
+#if defined(__linux__)
 int
 ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) __THROW
 #else
diff --git a/tools/http_load/port.h b/tools/http_load/port.h
index bae8cd2be9..590ff012eb 100644
--- a/tools/http_load/port.h
+++ b/tools/http_load/port.h
@@ -36,7 +36,7 @@
 #elif defined(__NetBSD__)
 #define OS_NetBSD
 #define ARCH "NetBSD"
-#elif defined(linux)
+#elif defined(__linux__)
 #define OS_Linux
 #define ARCH "Linux"
 #else