EM-ODP
4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
environment.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015-2026, Nokia Solutions and Networks
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
*
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* * Neither the name of the copyright holder nor the names of its
15
* contributors may be used to endorse or promote products derived
16
* from this software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#ifndef _ENVIRONMENT_H_
32
#define _ENVIRONMENT_H_
33
34
#pragma GCC visibility push(default)
35
36
/**
37
* @file
38
*
39
* Environment header file
40
*/
41
#include <stdlib.h>
42
#include <odp_api.h>
43
44
/*
45
* env helper include files - don't include these files directly,
46
* instead #include <environment.h>
47
*
48
* env_conf.h provides ENV_DEPRECATED_API (derived from EM_DEPRECATED_API)
49
* and must be included before the conditional env_atomic.h below.
50
*/
51
#include <event_machine/platform/env/env_conf.h>
52
#include <event_machine/platform/env/env_macros.h>
53
#if ENV_DEPRECATED_API
54
#include <event_machine/platform/env/env_atomic.h>
55
#endif
56
#include <
event_machine/platform/env/env_bitmask.h
>
57
#include <event_machine/platform/env/env_barrier.h>
58
#include <event_machine/platform/env/env_sharedmem.h>
59
#include <event_machine/platform/env/env_spinlock.h>
60
#include <
event_machine/platform/env/env_time.h
>
61
62
#ifdef __cplusplus
63
extern
"C"
{
64
#endif
65
66
/**
67
* Get the current cpu cycle count
68
*
69
* The cycle count frequency follows the cpu frequency and may thus change at
70
* any time. The cycle count should not be used for time measurements due to
71
* the possibility of frequency variation.
72
* The count may advance in steps larger than one.
73
*
74
* @return Current cycle count on the cpu the caller is running on
75
* @retval 0 if the cpu cycle counter is not supported
76
*/
77
static
inline
uint64_t env_get_cycle(
void
)
78
{
79
return
odp_cpu_cycles();
80
}
81
82
/**
83
* Returns difference of cpu cycles (cycles2 - cycles1).
84
*
85
* @param cycles2 Second cycle count
86
* @param cycles1 First cycle count
87
*
88
* @return Difference between given cpu cycles
89
*/
90
static
inline
uint64_t env_cycles_diff(uint64_t cycles2, uint64_t cycles1)
91
{
92
return
odp_cpu_cycles_diff(cycles2, cycles1);
93
}
94
95
static
inline
void
env_sync_mem(
void
)
96
{
97
odp_mb_full();
98
}
99
100
static
inline
uint64_t env_core_hz(
void
)
101
{
102
return
odp_cpu_hz();
103
}
104
105
#ifdef __cplusplus
106
}
107
#endif
108
109
#pragma GCC visibility pop
110
#endif
/* _ENVIRONMENT_H_ */
env_bitmask.h
env_time.h