Bug 1533969 - Fix build error with newer glibc. r=nbp
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 11 Mar 2019 19:28:37 +0000
changeset 524419 7b85bf9c5210e5679fa6cfad92466a6e2ba30232
parent 524418 96e78962a05388c638385c2bad0cc772b7295291
child 524420 9ff4178c5e2d278c8b0e7a25f1f6bb5b5bd8b217
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1533969
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533969 - Fix build error with newer glibc. r=nbp New glibc versions provide a wrapper for gettid, which means that our stuff fails to build with: ``` /home/emilio/src/moz/gecko/js/src/util/NativeStack.cpp:28:14: error: static declaration of 'gettid' follows non-static declaration static pid_t gettid() { return syscall(__NR_gettid); } ^ /usr/include/bits/unistd_ext.h:34:16: note: previous declaration is here extern __pid_t gettid (void) __THROW; ``` Differential Revision: https://phabricator.services.mozilla.com/D22829
js/src/util/NativeStack.cpp
tools/profiler/core/platform.h
--- a/js/src/util/NativeStack.cpp
+++ b/js/src/util/NativeStack.cpp
@@ -20,17 +20,17 @@
 #    include <sys/types.h>
 #    include <unistd.h>
 #  endif
 #  if defined(XP_LINUX) && !defined(ANDROID) && defined(__GLIBC__)
 #    include <dlfcn.h>
 #    include <sys/syscall.h>
 #    include <sys/types.h>
 #    include <unistd.h>
-static pid_t gettid() { return syscall(__NR_gettid); }
+#    define gettid() static_cast<pid_t>(syscall(__NR_gettid))
 #  endif
 #else
 #  error "Unsupported platform"
 #endif
 
 #include "jsfriendapi.h"
 
 #if defined(XP_WIN)
--- a/tools/profiler/core/platform.h
+++ b/tools/profiler/core/platform.h
@@ -34,26 +34,26 @@
 #include "mozilla/Logging.h"
 #include "mozilla/UniquePtr.h"
 #include "nsStringFwd.h"
 #include "nsTArray.h"
 
 #include <functional>
 #include <stdint.h>
 
-// We need a definition of gettid(), but glibc doesn't provide a
+// We need a definition of gettid(), but old glibc versions don't provide a
 // wrapper for it.
 #if defined(__GLIBC__)
 #  include <unistd.h>
 #  include <sys/syscall.h>
-static inline pid_t gettid() { return (pid_t)syscall(SYS_gettid); }
+#  define gettid() static_cast<pid_t>(syscall(SYS_gettid))
 #elif defined(GP_OS_darwin)
 #  include <unistd.h>
 #  include <sys/syscall.h>
-static inline pid_t gettid() { return (pid_t)syscall(SYS_thread_selfid); }
+#  define gettid() static_cast<pid_t>(syscall(SYS_thread_selfid))
 #elif defined(GP_OS_android)
 #  include <unistd.h>
 #elif defined(GP_OS_windows)
 #  include <windows.h>
 #  include <process.h>
 #  ifndef getpid
 #    define getpid _getpid
 #  endif