Skip to content

Commit 903ed4e

Browse files
add ocloc versioning
Adds versioning of ocloc and new api function returning ocloc version.
1 parent c308359 commit 903ed4e

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ extern Environment *gEnvironment;
1919

2020
using namespace std::string_literals;
2121

22+
TEST(OclocApiTests, WhenOclocVersionIsCalledThenCurrentOclocVersionIsReturned) {
23+
EXPECT_EQ(ocloc_version_t::OCLOC_VERSION_CURRENT, oclocVersion());
24+
}
25+
2226
TEST(OclocApiTests, WhenGoodArgsAreGivenThenSuccessIsReturned) {
2327
const char *argv[] = {
2428
"ocloc",

shared/offline_compiler/source/ocloc_api.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@ int oclocFreeOutput(uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **len
149149
delete[](*nameOutputs);
150150
return 0;
151151
}
152+
153+
int oclocVersion() {
154+
return static_cast<int>(ocloc_version_t::OCLOC_VERSION_CURRENT);
155+
}
152156
}

shared/offline_compiler/source/ocloc_api.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
#include <cstdint>
99

10+
#ifndef OCLOC_MAKE_VERSION
11+
/// Generates ocloc API versions
12+
#define OCLOC_MAKE_VERSION(_major, _minor) ((_major << 16) | (_minor & 0x0000ffff))
13+
#endif // OCLOC_MAKE_VERSION
14+
15+
typedef enum _ocloc_version_t {
16+
OCLOC_VERSION_1_0 = OCLOC_MAKE_VERSION(1, 0), ///< version 1.0
17+
OCLOC_VERSION_CURRENT = OCLOC_MAKE_VERSION(1, 0), ///< latest known version
18+
OCLOC_VERSION_FORCE_UINT32 = 0x7fffffff
19+
} ocloc_version_t;
20+
1021
#ifdef _WIN32
1122
#define SIGNATURE __declspec(dllexport) int __cdecl
1223
#else
@@ -82,4 +93,7 @@ SIGNATURE oclocInvoke(unsigned int numArgs, const char *argv[],
8293
///
8394
/// \returns 0 on succes. Returns non-0 in case of failure.
8495
SIGNATURE oclocFreeOutput(uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs);
96+
97+
/// Returns the current version of oclock
98+
SIGNATURE oclocVersion();
8599
}

0 commit comments

Comments
 (0)