diff --git a/valgrind-3.14.0-gettid.patch b/valgrind-3.14.0-gettid.patch
new file mode 100644
index 0000000..ecdd209
--- /dev/null
+++ b/valgrind-3.14.0-gettid.patch
@@ -0,0 +1,55 @@
+commit b46023d525b6e38a096ff4fdf9e6a96c7d7b7d40
+Author: Mark Wielaard <mark@klomp.org>
+Date:   Mon Mar 4 19:47:59 2019 +0100
+
+    Rename gettid() to gettid_sys() in gdbserver_tests.
+    
+    glibc might defined gettid() itself through unistd.h:
+    https://sourceware.org/bugzilla/show_bug.cgi?id=6399
+    
+    Rename to gettid_sys() so we don't clash with the glibc definition.
+
+diff --git a/gdbserver_tests/sleepers.c b/gdbserver_tests/sleepers.c
+index 5ffc6f8..dfda828 100644
+--- a/gdbserver_tests/sleepers.c
++++ b/gdbserver_tests/sleepers.c
+@@ -15,7 +15,7 @@ static int sleepms = 1000; // in each loop, will sleep "sleepms" milliseconds
+ static int burn = 0; // after each sleep, will burn cpu in a tight 'burn' loop 
+ static void setup_sigusr_handler(void); // sigusr1 and 2 sigaction setup.
+ 
+-static pid_t gettid()
++static pid_t gettid_sys()
+ {
+ #ifdef __NR_gettid
+    return syscall(__NR_gettid);
+@@ -27,7 +27,7 @@ static pid_t gettid()
+ static void whoami(char *msg) __attribute__((unused));
+ static void whoami(char *msg)
+ {
+-   fprintf(stderr, "pid %ld Thread %ld %s\n", (long) getpid(), (long) gettid(),
++   fprintf(stderr, "pid %ld Thread %ld %s\n", (long) getpid(), (long) gettid_sys(),
+            msg);
+    fflush(stderr);
+ }
+diff --git a/gdbserver_tests/t.c b/gdbserver_tests/t.c
+index 228d4a4..b3e7a28 100644
+--- a/gdbserver_tests/t.c
++++ b/gdbserver_tests/t.c
+@@ -16,7 +16,7 @@ static int loopmain, loopt1, loopt2;
+ 
+ static double pi = 3.14159265358979323846264338327950288;
+ 
+-static pid_t gettid()
++static pid_t gettid_sys()
+ {
+ #ifdef __NT_gettid
+    return syscall(__NR_gettid);
+@@ -26,7 +26,7 @@ static pid_t gettid()
+ }
+ static void whoami(char *msg)
+ {
+-   printf("pid %ld Thread %ld %s\n", (long) getpid(), (long) gettid(), msg);
++   printf("pid %ld Thread %ld %s\n", (long) getpid(), (long) gettid_sys(), msg);
+    fflush(stdout);
+ }
+ 
diff --git a/valgrind.spec b/valgrind.spec
index 543f48b..00ba7fc 100644
--- a/valgrind.spec
+++ b/valgrind.spec
@@ -3,7 +3,7 @@
 Summary: Tool for finding memory management bugs in programs
 Name: %{?scl_prefix}valgrind
 Version: 3.14.0
-Release: 15%{?dist}
+Release: 16%{?dist}
 Epoch: 1
 License: GPLv2+
 URL: http://www.valgrind.org/
@@ -181,6 +181,9 @@ Patch37: valgrind-3.14.0-ppc-subfe.patch
 # KDE#405079 unhandled ppc64le-linux syscall: 131 (quotactl)
 Patch38: valgrind-3.14.0-ppc64-quotactl.patch
 
+# SW#6399 glibc might implement gettid itself, rename to gettid_sys.
+Patch39: valgrind-3.14.0-gettid.patch
+
 
 %if %{build_multilib}
 # Ensure glibc{,-devel} is installed for both multilib arches
@@ -349,6 +352,7 @@ Valgrind User Manual for details.
 %patch36 -p1
 %patch37 -p1
 %patch38 -p1
+%patch39 -p1
 
 %build
 CC=gcc
@@ -583,6 +587,9 @@ fi
 %endif
 
 %changelog
+* Mon Mar  4 2019 Mark Wielaard <mjw@fedoraproject.org> - 3.14.0-16
+- Add valgrind-3.14.0-gettid.patch
+
 * Mon Mar  4 2019 Mark Wielaard <mjw@fedoraproject.org> - 3.14.0-15
 - Add valgrind-3.14.0-ppc64-quotactl.patch