File: rocm_version.cpp

package info (click to toggle)
rocm-core 6.4.4-1~exp6
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 264 kB
  • sloc: cpp: 139; sh: 130; python: 123; makefile: 11
file content (77 lines) | stat: -rw-r--r-- 1,691 bytes parent folder | download
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
#include "rocm_version.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>


#define NULL_CHECK(ptr)	if(!ptr) return VerIncorrecPararmeters;


#define CHECK_AND_REPORT_API_RESULT(val)	do {					\
							if(VerSuccess != val) {	\
								const char *ErrStrings[VerErrorMAX]= { "VerSuccess", "VerIncorrecPararmeters", "VerValuesNotDefined" }; 	\
								fprintf(stderr, " API returned : %s \n", ErrStrings[val]);	\
								fflush(stderr);		\
								return val;		\
							}				\
						}while(0);



VerErrors getROCmVersion(unsigned int* Major, unsigned int* Minor, unsigned int* Patch) {

	NULL_CHECK(Major)
	NULL_CHECK(Minor)
	NULL_CHECK(Patch)

	*Major=ROCM_VERSION_MAJOR;
	*Minor=ROCM_VERSION_MINOR;
	*Patch=ROCM_VERSION_PATCH;

	return	VerSuccess;
}



static VerErrors getBuildInfoLen( int* InfoStrlen ) {

	NULL_CHECK(InfoStrlen);
#if defined(ROCM_BUILD_INFO)
	*InfoStrlen = 1 + strlen(ROCM_BUILD_INFO);//additional char for null termination
#else
	return VerValuesNotDefined;
#endif //end defination checker
	return	VerSuccess;
}

static VerErrors getBuildInfo( char* InfoString, int len ) {

	NULL_CHECK(InfoString);
#if defined(ROCM_BUILD_INFO)

	strcpy(InfoString,ROCM_BUILD_INFO);
	InfoString[len]='\0';
#else
	return VerValuesNotDefined;
#endif //end defination checker
	return	VerSuccess;
}

VerErrors printBuildInfo() {

	int lenstr=0;
        VerErrors apiret=VerSuccess;

	apiret=getBuildInfoLen(&lenstr);
	CHECK_AND_REPORT_API_RESULT(apiret);

	char* cstr=(char*) malloc(lenstr*sizeof(char));
        apiret=getBuildInfo(cstr,lenstr);
	CHECK_AND_REPORT_API_RESULT(apiret);

	printf("\n Build Info of lib = [%s] \n",cstr);

        free(cstr);

	return VerSuccess;
}