New upstream version 18.11-rc1
[deb_dpdk.git] / lib / librte_eal / common / include / rte_version.h
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  * String that appears before the version number
24  */
25 #define RTE_VER_PREFIX "DPDK"
26
27 /**
28  * Major version/year number i.e. the yy in yy.mm.z
29  */
30 #define RTE_VER_YEAR 18
31
32 /**
33  * Minor version/month number i.e. the mm in yy.mm.z
34  */
35 #define RTE_VER_MONTH 11
36
37 /**
38  * Patch level number i.e. the z in yy.mm.z
39  */
40 #define RTE_VER_MINOR 0
41
42 /**
43  * Extra string to be appended to version number
44  */
45 #define RTE_VER_SUFFIX "-rc"
46
47 /**
48  * Patch release number
49  *   0-15 = release candidates
50  *   16   = release
51  */
52 #define RTE_VER_RELEASE 1
53
54 /**
55  * Macro to compute a version number usable for comparisons
56  */
57 #define RTE_VERSION_NUM(a,b,c,d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
58
59 /**
60  * All version numbers in one to compare with RTE_VERSION_NUM()
61  */
62 #define RTE_VERSION RTE_VERSION_NUM( \
63                         RTE_VER_YEAR, \
64                         RTE_VER_MONTH, \
65                         RTE_VER_MINOR, \
66                         RTE_VER_RELEASE)
67
68 /**
69  * Function returning version string
70  * @return
71  *     string
72  */
73 static inline const char *
74 rte_version(void)
75 {
76         static char version[32];
77         if (version[0] != 0)
78                 return version;
79         if (strlen(RTE_VER_SUFFIX) == 0)
80                 snprintf(version, sizeof(version), "%s %d.%02d.%d",
81                         RTE_VER_PREFIX,
82                         RTE_VER_YEAR,
83                         RTE_VER_MONTH,
84                         RTE_VER_MINOR);
85         else
86                 snprintf(version, sizeof(version), "%s %d.%02d.%d%s%d",
87                         RTE_VER_PREFIX,
88                         RTE_VER_YEAR,
89                         RTE_VER_MONTH,
90                         RTE_VER_MINOR,
91                         RTE_VER_SUFFIX,
92                         RTE_VER_RELEASE < 16 ?
93                                 RTE_VER_RELEASE :
94                                 RTE_VER_RELEASE - 16);
95         return version;
96 }
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 #endif /* RTE_VERSION_H */