1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 /**
6  * @file
7  * Definitions of DPDK version numbers
8  */
9 
10 #ifndef _RTE_VERSION_H_
11 #define _RTE_VERSION_H_
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #include <stdint.h>
18 #include <string.h>
19 #include <stdio.h>
20 #include <rte_common.h>
21 
22 /**
23  * Macro to compute a version number usable for comparisons
24  */
25 #define RTE_VERSION_NUM(a,b,c,d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
26 
27 /**
28  * All version numbers in one to compare with RTE_VERSION_NUM()
29  */
30 #define RTE_VERSION RTE_VERSION_NUM( \
31 			RTE_VER_YEAR, \
32 			RTE_VER_MONTH, \
33 			RTE_VER_MINOR, \
34 			RTE_VER_RELEASE)
35 
36 /**
37  * Function returning version string
38  * @return
39  *     string
40  */
41 static inline const char *
rte_version(void)42 rte_version(void)
43 {
44 	static char version[32];
45 	if (version[0] != 0)
46 		return version;
47 	if (strlen(RTE_VER_SUFFIX) == 0)
48 		snprintf(version, sizeof(version), "%s %d.%02d.%d",
49 			RTE_VER_PREFIX,
50 			RTE_VER_YEAR,
51 			RTE_VER_MONTH,
52 			RTE_VER_MINOR);
53 	else
54 		snprintf(version, sizeof(version), "%s %d.%02d.%d%s%d",
55 			RTE_VER_PREFIX,
56 			RTE_VER_YEAR,
57 			RTE_VER_MONTH,
58 			RTE_VER_MINOR,
59 			RTE_VER_SUFFIX,
60 			RTE_VER_RELEASE);
61 	return version;
62 }
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif /* RTE_VERSION_H */
69