aboutsummaryrefslogtreecommitdiff
path: root/include/odp/api/spec/std_types.h
blob: 5dc350a2429bda78720afbe2e878d47ab1b80808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Copyright (c) 2013-2018, Linaro Limited
 * Copyright (c) 2021, ARM Limited
 * Copyright (c) 2021, Nokia
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

/**
 * @file
 *
 * Standard C language types and definitions for ODP.
 *
 */

#ifndef ODP_API_SPEC_STD_TYPES_H_
#define ODP_API_SPEC_STD_TYPES_H_
#include <odp/visibility_begin.h>
/* uint64_t, uint32_t, etc */
#include <stdint.h>
#include <odp/api/align.h>

#ifdef __cplusplus
extern "C" {
#endif

/** @addtogroup odp_std ODP STD
 *  @{
 */

/**
 * @typedef odp_bool_t
 * Use odp boolean type to have it well-defined and known size,
 * regardless which compiler is used as this facilities interoperability
 * between e.g. different compilers.
 */

/**
 * Percentage type
 * Use odp_percent_t for specifying fields that are percentages. It is a fixed
 * point integer whose units are expressed as one-hundredth of a percent.
 * Hence 100% is represented as integer value 10000.
 */
typedef uint32_t odp_percent_t;

/** Unaligned uint16_t type */
typedef uint16_t odp_una_u16_t ODP_ALIGNED(1);

/** Unaligned uint32_t type */
typedef uint32_t odp_una_u32_t ODP_ALIGNED(1);

/** Unaligned uint64_t type */
typedef uint64_t odp_una_u64_t ODP_ALIGNED(1);

/**
 * @typedef odp_u128_t
 * 128-bit unsigned integer structure
 */

/**
 * 128-bit unsigned integer structure
 */
typedef struct ODP_ALIGNED(16) odp_u128_s {
	/** 128 bits in various sizes */
	union {
		/** 128 bits as uint64_t words */
		uint64_t u64[2];
		/** 128 bits as uint32_t words */
		uint32_t u32[4];
		/** 128 bits as uint16_t words */
		uint16_t u16[8];
		/** 128 bits as bytes */
		uint8_t  u8[16];
	};
} odp_u128_t;

/**
 * Unsigned 64 bit fractional number
 *
 * The number is composed of integer and fraction parts. The fraction part is composed of
 * two terms: numerator and denominator. Value of the number is sum of the integer and fraction
 * parts: value = integer + numer/denom. When the fraction part is zero, the numerator is zero and
 * the denominator may be zero.
 */
typedef struct odp_fract_u64_t {
		/** Integer part */
		uint64_t integer;

		/** Numerator of the fraction part */
		uint64_t numer;

		/** Denominator of the fraction part. This may be zero when the numerator
		 *  is zero. */
		uint64_t denom;

} odp_fract_u64_t;

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#include <odp/visibility_end.h>
#endif