geopm 3.1.1.dev595+gde7d25dd
GEOPM - Global Extensible Open Power Manager
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
geopm_field.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 - 2025 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef GEOPM_FIELD_H_INCLUDE
7#define GEOPM_FIELD_H_INCLUDE
8#include <stdint.h>
9#include <string.h>
10
11#include "geopm_public.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
24static inline uint64_t geopm_signal_to_field(double signal)
25{
26 uint64_t result;
27 static_assert(sizeof result == sizeof signal,
28 "geopm_signal_to_field requires that signals and fields are the same size");
29 memcpy(&result, &signal, sizeof(result));
30 return result;
31}
32
39static inline double geopm_field_to_signal(uint64_t field)
40{
41 double result;
42 static_assert(sizeof result == sizeof field,
43 "geopm_field_to_signal requires that signals and fields are the same size");
44 memcpy(&result, &field, sizeof(result));
45 return result;
46}
47
48#ifdef __cplusplus
49}
50#endif
51#endif