forked from falcosecurity/libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppm_api_version.h
60 lines (49 loc) · 2.24 KB
/
ppm_api_version.h
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
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/*
* Copyright (C) 2023 The Falco Authors.
*
* This file is dual licensed under either the MIT or GPL 2. See MIT.txt
* or GPL2.txt for full copies of the license.
*/
#ifndef PPM_API_VERSION_H
#define PPM_API_VERSION_H
/*
* API version component macros
*
* The version is a single uint64_t, structured as follows:
* bit 63: unused (so the version number is always positive)
* bits 44-62: major version
* bits 24-43: minor version
* bits 0-23: patch version
*/
#define PPM_VERSION_PACK(val, bits, shift) \
((((unsigned long long)(val)) & ((1ULL << (bits)) - 1)) << (shift))
#define PPM_VERSION_UNPACK(val, bits, shift) \
((((unsigned long long)(val)) >> (shift)) & ((1ULL << (bits)) - 1))
/* extract components from an API version number */
#define PPM_API_VERSION_MAJOR(ver) PPM_VERSION_UNPACK(ver, 19, 44)
#define PPM_API_VERSION_MINOR(ver) PPM_VERSION_UNPACK(ver, 20, 24)
#define PPM_API_VERSION_PATCH(ver) PPM_VERSION_UNPACK(ver, 24, 0)
/* build an API version number from components */
#define PPM_API_VERSION(major, minor, patch) \
PPM_VERSION_PACK(major, 19, 44) | PPM_VERSION_PACK(minor, 20, 24) | \
PPM_VERSION_PACK(patch, 24, 0)
#define PPM_API_CURRENT_VERSION \
PPM_API_VERSION(PPM_API_CURRENT_VERSION_MAJOR, \
PPM_API_CURRENT_VERSION_MINOR, \
PPM_API_CURRENT_VERSION_PATCH)
#define PPM_SCHEMA_CURRENT_VERSION \
PPM_API_VERSION(PPM_SCHEMA_CURRENT_VERSION_MAJOR, \
PPM_SCHEMA_CURRENT_VERSION_MINOR, \
PPM_SCHEMA_CURRENT_VERSION_PATCH)
#define __PPM_STRINGIFY1(x) #x
#define __PPM_STRINGIFY(x) __PPM_STRINGIFY1(x)
#define PPM_API_CURRENT_VERSION_STRING \
__PPM_STRINGIFY(PPM_API_CURRENT_VERSION_MAJOR) \
"." __PPM_STRINGIFY(PPM_API_CURRENT_VERSION_MINOR) "." __PPM_STRINGIFY( \
PPM_API_CURRENT_VERSION_PATCH)
#define PPM_SCHEMA_CURRENT_VERSION_STRING \
__PPM_STRINGIFY(PPM_SCHEMA_CURRENT_VERSION_MAJOR) \
"." __PPM_STRINGIFY(PPM_SCHEMA_CURRENT_VERSION_MINOR) "." __PPM_STRINGIFY( \
PPM_SCHEMA_CURRENT_VERSION_PATCH)
#endif