diff --git a/gum/backend-linux/gumprocess-linux.c b/gum/backend-linux/gumprocess-linux.c index 7b1cd7b4f..25067f952 100644 --- a/gum/backend-linux/gumprocess-linux.c +++ b/gum/backend-linux/gumprocess-linux.c @@ -48,9 +48,8 @@ #ifdef HAVE_SYS_USER_H # include #endif -#ifdef HAVE_LINUX +#include #include -#endif #define GUM_PAGE_START(value, page_size) \ (GUM_ADDRESS (value) & ~GUM_ADDRESS (page_size - 1)) @@ -90,6 +89,9 @@ #ifndef NT_PRSTATUS # define NT_PRSTATUS 1 #endif +#ifndef RUSAGE_THREAD +# define RUSAGE_THREAD 1 +#endif #define GUM_TEMP_FAILURE_RETRY(expression) \ ({ \ diff --git a/gum/backend-windows/gumprocess-windows.c b/gum/backend-windows/gumprocess-windows.c index a4197ef4d..c5d926c33 100644 --- a/gum/backend-windows/gumprocess-windows.c +++ b/gum/backend-windows/gumprocess-windows.c @@ -643,7 +643,7 @@ gum_thread_resume (GumThreadId thread_id, guint64 gum_thead_get_user_time (void) { - static gboolean initialized = false; + static gboolean initialized = FALSE; static GetThreadTimesFunc get_thread_times = NULL; HMODULE mod; @@ -668,7 +668,7 @@ gum_thead_get_user_time (void) if (!get_thread_times (GetCurrentThread (), NULL, NULL, NULL, &userTime)) return 0; - result = ((guint64) userTime.dwHighDateTime) << 32 + userTime.dwLowDateTime; + result = (((guint64) userTime.dwHighDateTime) << 32) + userTime.dwLowDateTime; /* Timings on Windows are to 100-nanosecond granularity. Convert to u-secs */ return result / 10; diff --git a/tests/gumjs/script.c b/tests/gumjs/script.c index 4d2fc5c95..c5eacfe2c 100644 --- a/tests/gumjs/script.c +++ b/tests/gumjs/script.c @@ -5194,22 +5194,25 @@ TESTCASE (process_threads_get_user_time) TESTCASE (process_threads_get_user_time_other_thread) { +#if defined (HAVE_LINUX) && !defined (HAVE_PTHREAD_SETNAME_NP) + g_print (" "); +#else GumNamedSleeperContext ctx; GThread * thread; double user_time_a = 0, user_time_b = 0; -#ifdef HAVE_LINUX +# ifdef HAVE_LINUX if (!check_exception_handling_testable ()) return; -#endif +# endif -#ifdef HAVE_MIPS +# ifdef HAVE_MIPS if (!g_test_slow ()) { g_print (" "); return; } -#endif +# endif ctx.controller_messages = g_async_queue_new (); ctx.sleeper_messages = g_async_queue_new (); @@ -5251,13 +5254,14 @@ TESTCASE (process_threads_get_user_time_other_thread) g_async_queue_unref (ctx.sleeper_messages); g_async_queue_unref (ctx.controller_messages); -#if defined (HAVE_LINUX) || defined (HAVE_DARWIN) || defined (HAVE_FREEBSD) \ +# if defined (HAVE_LINUX) || defined (HAVE_DARWIN) || defined (HAVE_FREEBSD) \ || defined (HAVE_WINDOWS) g_assert_true (user_time_a != 0); g_assert_true (user_time_b > user_time_a); -#else +# else g_assert_cmpuint (user_time_a, ==, 0); g_assert_cmpuint (user_time_b, ==, 0); +# endif #endif } @@ -5271,7 +5275,7 @@ user_time (gpointer data) * to GLib potentially having been prebuilt against an old libc. Therefore we * set the name manually using pthreads. */ -#ifdef HAVE_LINUX +#if defined (HAVE_LINUX) && defined (HAVE_PTHREAD_SETNAME_NP) pthread_setname_np (pthread_self (), "user-time"); #endif @@ -5304,21 +5308,24 @@ do_work (void) TESTCASE (process_threads_find_busy_thread) { +#if defined (HAVE_LINUX) && !defined (HAVE_PTHREAD_SETNAME_NP) + g_print (" "); +#else GumHotNamedSleeperContext ctx[NUM_THREADS]; GThread * thread[NUM_THREADS]; -#ifdef HAVE_LINUX +# ifdef HAVE_LINUX if (!check_exception_handling_testable ()) return; -#endif +# endif -#ifdef HAVE_MIPS +# ifdef HAVE_MIPS if (!g_test_slow ()) { g_print (" "); return; } -#endif +# endif guint rand = g_random_int_range (0, 10); @@ -5362,9 +5369,10 @@ TESTCASE (process_threads_find_busy_thread) g_async_queue_unref (ctx[i].controller_messages); } -#if defined (HAVE_LINUX) || defined (HAVE_DARWIN) || defined (HAVE_FREEBSD) \ +# if defined (HAVE_LINUX) || defined (HAVE_DARWIN) || defined (HAVE_FREEBSD) \ || defined (HAVE_WINDOWS) EXPECT_SEND_MESSAGE_WITH ("%" G_GSIZE_MODIFIER "u", ctx[rand].id); +# endif #endif }