rocprofiler-sdk/defines.h Source File

rocprofiler-sdk/defines.h Source File#

Rocprofiler SDK Developer API: rocprofiler-sdk/defines.h Source File
Rocprofiler SDK Developer API 0.4.0
ROCm Profiling API and tools
defines.h
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2023 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#include <stdint.h>
26
27/**
28 * @defgroup SYMBOL_VERSIONING_GROUP Symbol Versions
29 *
30 * @brief The names used for the shared library versioned symbols.
31 *
32 * Every function is annotated with one of the version macros defined in this
33 * section. Each macro specifies a corresponding symbol version string. After
34 * dynamically loading the shared library with @p dlopen, the address of each
35 * function can be obtained using @p dlsym with the name of the function and
36 * its corresponding symbol version string. An error will be reported by @p
37 * dlvsym if the installed library does not support the version for the
38 * function specified in this version of the interface.
39 *
40 * @{
41 */
42
43/**
44 * @brief The function was introduced in version 0.0 of the interface and has the
45 * symbol version string of ``"ROCPROFILER_SDK_0.0"``.
46 */
47#define ROCPROFILER_SDK_VERSION_0_0
48
49/** @} */
50
51#if !defined(ROCPROFILER_ATTRIBUTE)
52# if defined(_MSC_VER)
53# define ROCPROFILER_ATTRIBUTE(...) __declspec(__VA_ARGS__)
54# else
55# define ROCPROFILER_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
56# endif
57#endif
58
59#if !defined(ROCPROFILER_PUBLIC_API)
60# if defined(_MSC_VER)
61# define ROCPROFILER_PUBLIC_API ROCPROFILER_ATTRIBUTE(dllexport)
62# else
63# define ROCPROFILER_PUBLIC_API ROCPROFILER_ATTRIBUTE(visibility("default"))
64# endif
65#endif
66
67#if !defined(ROCPROFILER_HIDDEN_API)
68# if defined(_MSC_VER)
69# define ROCPROFILER_HIDDEN_API
70# else
71# define ROCPROFILER_HIDDEN_API ROCPROFILER_ATTRIBUTE(visibility("hidden"))
72# endif
73#endif
74
75#if !defined(ROCPROFILER_EXPORT_DECORATOR)
76# define ROCPROFILER_EXPORT_DECORATOR ROCPROFILER_PUBLIC_API
77#endif
78
79#if !defined(ROCPROFILER_IMPORT_DECORATOR)
80# if defined(_MSC_VER)
81# define ROCPROFILER_IMPORT_DECORATOR ROCPROFILER_ATTRIBUTE(dllimport)
82# else
83# define ROCPROFILER_IMPORT_DECORATOR
84# endif
85#endif
86
87#define ROCPROFILER_EXPORT ROCPROFILER_EXPORT_DECORATOR
88#define ROCPROFILER_IMPORT ROCPROFILER_IMPORT_DECORATOR
89
90#if !defined(ROCPROFILER_API)
91# if defined(rocprofiler_EXPORTS)
92# define ROCPROFILER_API ROCPROFILER_EXPORT
93# else
94# define ROCPROFILER_API ROCPROFILER_IMPORT
95# endif
96#endif
97
98#if defined(__has_attribute)
99# if __has_attribute(nonnull)
100# define ROCPROFILER_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
101# else
102# define ROCPROFILER_NONNULL(...)
103# endif
104#else
105# if defined(__GNUC__)
106# define ROCPROFILER_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
107# else
108# define ROCPROFILER_NONNULL(...)
109# endif
110#endif
111
112#if __cplusplus >= 201103L // C++11
113/* c++11 allows extended initializer lists. */
114# define ROCPROFILER_HANDLE_LITERAL(type, value) (type{value})
115#elif __STDC_VERSION__ >= 199901L
116/* c99 allows compound literals. */
117# define ROCPROFILER_HANDLE_LITERAL(type, value) ((type){value})
118#else
119# define ROCPROFILER_HANDLE_LITERAL(type, value) \
120 { \
121 value \
122 }
123#endif
124
125#ifdef __cplusplus
126# define ROCPROFILER_EXTERN_C_INIT extern "C" {
127# define ROCPROFILER_EXTERN_C_FINI }
128# define ROCPROFILER_CXX_CODE(...) __VA_ARGS__
129#else
130# define ROCPROFILER_EXTERN_C_INIT
131# define ROCPROFILER_EXTERN_C_FINI
132# define ROCPROFILER_CXX_CODE(...)
133#endif
134
135#if __cplusplus
136# define ROCPROFILER_UINT64_C(value) uint64_t(value)
137#else
138# define ROCPROFILER_UINT64_C(value) UINT64_C(value)
139#endif