mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-18 05:08:06 +02:00
More code will be shared in the next patches. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29421>
32 lines
549 B
C
32 lines
549 B
C
/*
|
|
* Copyright 2024 Intel Corporation
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "intel_perf_common.h"
|
|
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
bool
|
|
read_file_uint64(const char *file, uint64_t *val)
|
|
{
|
|
char buf[32];
|
|
int fd, n;
|
|
|
|
fd = open(file, 0);
|
|
if (fd < 0)
|
|
return false;
|
|
while ((n = read(fd, buf, sizeof (buf) - 1)) < 0 &&
|
|
errno == EINTR);
|
|
close(fd);
|
|
if (n < 0)
|
|
return false;
|
|
|
|
buf[n] = '\0';
|
|
*val = strtoull(buf, NULL, 0);
|
|
|
|
return true;
|
|
}
|