public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Lyude <lyude@redhat.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>, Daniel Vetter <daniel@ffwll.ch>
Subject: [igt-dev] [PATCH i-g-t v3 2/9] Use gettid() wrapper everywhere
Date: Wed, 24 Apr 2019 16:20:26 -0400	[thread overview]
Message-ID: <20190424202033.7601-3-lyude@redhat.com> (raw)
In-Reply-To: <20190424202033.7601-1-lyude@redhat.com>

From: Lyude Paul <lyude@redhat.com>

Currently we have multiple different parts of IGT that define their own
wrapper around the gettid() syscall (or just call it directly with no
wrapper).

Additionally, add the appropriate #includes for igt_aux.h to make sure
syscall() is available.

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 benchmarks/gem_syslatency.c | 1 -
 lib/igt_aux.h               | 7 ++++++-
 lib/igt_core.c              | 2 +-
 tests/core_auth.c           | 6 ++----
 tests/drm_import_export.c   | 2 +-
 tests/i915/gem_close_race.c | 1 -
 6 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/benchmarks/gem_syslatency.c b/benchmarks/gem_syslatency.c
index ba5d32a9..7671dc43 100644
--- a/benchmarks/gem_syslatency.c
+++ b/benchmarks/gem_syslatency.c
@@ -44,7 +44,6 @@
 
 #include <linux/unistd.h>
 
-#define gettid() syscall(__NR_gettid)
 #define sigev_notify_thread_id _sigev_un._tid
 
 static volatile int done;
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 55392790..cbcb1844 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -32,11 +32,16 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <sys/time.h>
+#ifdef __linux__
+# include <sys/syscall.h>
+#endif
 
 #include <i915/gem_submission.h>
 
 /* signal interrupt helpers */
-#define gettid() syscall(__NR_gettid)
+#ifdef __linux__
+# define gettid() syscall(__NR_gettid)
+#endif
 #define sigev_notify_thread_id _sigev_un._tid
 
 /* auxialiary igt helpers from igt_aux.c */
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 3141d923..43fa197f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1992,7 +1992,7 @@ static void fatal_sig_handler(int sig)
 #ifdef __linux__
 	/* Workaround cached PID and TID races on glibc and Bionic libc. */
 		pid_t pid = syscall(SYS_getpid);
-		pid_t tid = syscall(SYS_gettid);
+		pid_t tid = gettid();
 
 		syscall(SYS_tgkill, pid, tid, sig);
 #else
diff --git a/tests/core_auth.c b/tests/core_auth.c
index 1bdc2261..49cad7cd 100644
--- a/tests/core_auth.c
+++ b/tests/core_auth.c
@@ -46,9 +46,7 @@
 #include <sys/sysmacros.h>
 #include "drm.h"
 
-#ifdef __linux__
-# include <sys/syscall.h>
-#else
+#ifndef __linux__
 # include <pthread.h>
 #endif
 
@@ -62,7 +60,7 @@ is_local_tid(pid_t tid)
 #else
 	/* On Linux systems, drmGetClient() would return the thread ID
 	   instead of the actual process ID */
-	return syscall(SYS_gettid) == tid;
+	return gettid() == tid;
 #endif
 }
 
diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c
index 4bc7b7d4..e1b0abae 100644
--- a/tests/drm_import_export.c
+++ b/tests/drm_import_export.c
@@ -120,7 +120,7 @@ static void start_test(void)
 static void * test_thread(void * par)
 {
 #ifdef __linux__
-	igt_debug("start %ld\n", syscall(SYS_gettid));
+	igt_debug("start %ld\n", gettid());
 #else
 	igt_debug("start %ld\n", (long) pthread_self());
 #endif
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 11d626dc..57e00480 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -51,7 +51,6 @@
 static uint32_t devid;
 static bool has_64bit_relocations;
 
-#define gettid() syscall(__NR_gettid)
 #define sigev_notify_thread_id _sigev_un._tid
 
 static void selfcopy(int fd, uint32_t handle, int loops)
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-04-24 20:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24 20:20 [igt-dev] [PATCH i-g-t v3 0/9] Fixes from updating igt packaging in Fedora Lyude
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 1/9] lib/tests: Fix test failures with meson 0.50.0 Lyude
2019-04-24 20:20 ` Lyude [this message]
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 3/9] lib/aux: Typecast gettid() as pid_t Lyude
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 4/9] meson: Don't redefine gettid if the C library provides it Lyude
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 5/9] meson: Add .so versioning Lyude
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 6/9] meson: Don't allow building with NDEBUG, ever Lyude
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 7/9] lib/igt_core: Just use igt_can_fail() in __igt_run_subtest() Lyude
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 8/9] Use pkgconfig() macros with dnf in Fedora Dockerfile Lyude
2019-04-24 20:20 ` [igt-dev] [PATCH i-g-t v3 9/9] Update Dockerfile.fedora to Fedora 29 Lyude
2019-04-24 21:14 ` [igt-dev] ✓ Fi.CI.BAT: success for Fixes from updating igt packaging in Fedora (rev2) Patchwork
2019-04-25 10:12 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190424202033.7601-3-lyude@redhat.com \
    --to=lyude@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox