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 521421 7b85bf9c5210
parent 521420 96e78962a053
child 521422 9ff4178c5e2d
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [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