rocprofiler-sdk-roctx/defines.h Source File

rocprofiler-sdk-roctx/defines.h Source File#

ROCTx developer API: rocprofiler-sdk-roctx/defines.h Source File
ROCTx developer API 1.0.0
ROCm Profiling API and tools
defines.h
1// MIT License
2//
3// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#pragma once
24
25/**
26 * @defgroup SYMBOL_VERSIONING_GROUP Symbol Versions
27 *
28 * @brief The names used for the shared library versioned symbols.
29 *
30 * Every function is annotated with one of the version macros defined in this
31 * section. Each macro specifies a corresponding symbol version string. After
32 * dynamically loading the shared library with @p dlopen, the address of each
33 * function can be obtained using @p dlsym with the name of the function and
34 * its corresponding symbol version string. An error will be reported by @p
35 * dlsym if the installed library does not support the version for the
36 * function specified in this version of the interface.
37 *
38 * @{
39 */
40
41/**
42 * @brief The function was introduced in version 0.0 of the interface and has the
43 * symbol version string of ``"ROCPROFILER_SDK_ROCTX_0.0"``.
44 */
45#define ROCPROFILER_SDK_ROCTX_VERSION_0_0
46
47/** @} */
48
49#if !defined(ROCTX_ATTRIBUTE)
50# if defined(_MSC_VER)
51# define ROCTX_ATTRIBUTE(...) __declspec(__VA_ARGS__)
52# else
53# define ROCTX_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
54# endif
55#endif
56
57#if !defined(ROCTX_PUBLIC_API)
58# if defined(_MSC_VER)
59# define ROCTX_PUBLIC_API ROCTX_ATTRIBUTE(dllexport)
60# else
61# define ROCTX_PUBLIC_API ROCTX_ATTRIBUTE(visibility("default"))
62# endif
63#endif
64
65#if !defined(ROCTX_HIDDEN_API)
66# if defined(_MSC_VER)
67# define ROCTX_HIDDEN_API
68# else
69# define ROCTX_HIDDEN_API ROCTX_ATTRIBUTE(visibility("hidden"))
70# endif
71#endif
72
73#if !defined(ROCTX_EXPORT_DECORATOR)
74# define ROCTX_EXPORT_DECORATOR ROCTX_PUBLIC_API
75#endif
76
77#if !defined(ROCTX_IMPORT_DECORATOR)
78# if defined(_MSC_VER)
79# define ROCTX_IMPORT_DECORATOR ROCTX_ATTRIBUTE(dllimport)
80# else
81# define ROCTX_IMPORT_DECORATOR
82# endif
83#endif
84
85#define ROCTX_EXPORT ROCTX_EXPORT_DECORATOR
86#define ROCTX_IMPORT ROCTX_IMPORT_DECORATOR
87
88#if !defined(ROCTX_API)
89# if defined(roctx_EXPORTS)
90# define ROCTX_API ROCTX_EXPORT
91# else
92# define ROCTX_API ROCTX_IMPORT
93# endif
94#endif
95
96#if defined(__has_attribute)
97# if __has_attribute(nonnull)
98# define ROCTX_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
99# else
100# define ROCTX_NONNULL(...)
101# endif
102#else
103# if defined(__GNUC__)
104# define ROCTX_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
105# else
106# define ROCTX_NONNULL(...)
107# endif
108#endif
109
110#ifdef __cplusplus
111# define ROCTX_EXTERN_C_INIT extern "C" {
112# define ROCTX_EXTERN_C_FINI }
113#else
114# define ROCTX_EXTERN_C_INIT
115# define ROCTX_EXTERN_C_FINI
116#endif