perfetto: fix macos compile

On macos, <sys/types.h> does not declare clockid_t,
but it's instead in <time.h>, which also includes
<sys/types.h> on Linux, so just include <time.h> on
all UNIX platforms.

Fixes: a871eabc
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12064
Tested-by: Vinson Lee <vlee@freedesktop.org>
(cherry picked from commit ae9d365686)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32119>
This commit is contained in:
Russell Greene 2024-10-28 21:24:12 -06:00 committed by Dylan Baker
parent 349687c73a
commit dd14b60b49
2 changed files with 4 additions and 3 deletions

View file

@ -924,7 +924,7 @@
"description": "perfetto: fix macos compile",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "a871eabcedffb4f817033b393e25ce373d977b1a",
"notes": null

View file

@ -25,11 +25,12 @@
#define _UTIL_PERFETTO_H
#include "util/u_atomic.h"
#include "util/detect_os.h"
// On Unix, pass a clockid_t to designate which clock was used to gather the timestamp
// On Windows, this paramter is ignored, and it's expected that `timestamp` comes from QueryPerformanceCounter
#ifndef _WIN32
#include <sys/types.h>
#if DETECT_OS_POSIX
#include <time.h>
typedef clockid_t perfetto_clock_id;
#else
typedef int32_t perfetto_clock_id;