Version 3.0.23.01.25
[clinfo] / src / info_ret.h
1 #ifndef INFO_RET_H
2 #define INFO_RET_H
3
4 #include "ext.h"
5 #include "strbuf.h"
6
7 /* Return type of the functions that gather platform info */
8 struct platform_info_ret
9 {
10         cl_int err;
11         /* string representation of the value (if any) */
12         struct _strbuf str;
13         /* error representation of the value (if any) */
14         struct _strbuf err_str;
15         /* actual value, when not a string */
16         union {
17                 size_t s;
18                 cl_uint u32;
19                 cl_ulong u64;
20         } value;
21         /* Does this ret need escaping as JSON? */
22         cl_bool needs_escaping;
23 };
24
25 /* Return type of the functions that print device info */
26 struct device_info_ret {
27         cl_int err;
28         /* string representation of the value (if any) */
29         struct _strbuf str;
30         /* error representation of the value (if any) */
31         struct _strbuf err_str;
32         /* actual value, when not a string */
33         union {
34                 size_t s;
35                 cl_long i64;
36                 cl_ulong u64;
37                 cl_ulong2 u64v2;
38                 cl_ulong4 u64v;
39                 cl_int i32;
40                 cl_uint u32;
41                 cl_uint4 u32v;
42                 cl_bitfield bits;
43                 cl_bool b;
44                 cl_device_type devtype;
45                 cl_device_mem_cache_type cachetype;
46                 cl_device_local_mem_type lmemtype;
47                 cl_device_topology_amd devtopo_amd;
48                 cl_device_pci_bus_info_khr devtopo_khr;
49                 cl_device_scheduling_controls_capabilities_arm sched_controls;
50                 cl_device_affinity_domain affinity_domain;
51                 cl_device_fp_config fpconfig;
52                 cl_command_queue_properties qprop;
53                 cl_device_command_buffer_capabilities_khr cmdbufcap;
54                 cl_device_exec_capabilities execap;
55                 cl_device_svm_capabilities svmcap;
56                 cl_device_terminate_capability_khr termcap;
57         } value;
58         /* pointer base for array data or other auxiliary information */
59         union {
60                 void *ptr; // TODO
61                 cl_context ctx; // associated context
62         } base;
63         /* Does this ret need escaping as JSON? */
64         cl_bool needs_escaping;
65 };
66
67 /* Return type of the functions that gather ICD loader info */
68 struct icdl_info_ret
69 {
70         cl_int err;
71         /* string representation of the value (if any) */
72         struct _strbuf str;
73         /* error representation of the value (if any) */
74         struct _strbuf err_str;
75 };
76
77 #define RET_BUF(ret) (ret.err ? &ret.err_str : &ret.str)
78 #define RET_BUF_PTR(ret) (ret->err ? &ret->err_str : &ret->str)
79 #define INIT_RET(ret, msg) do { \
80         init_strbuf(&ret.str, msg " info string values"); \
81         init_strbuf(&ret.err_str, msg " info error values"); \
82 } while (0)
83
84 #define UNINIT_RET(ret) do { \
85         free_strbuf(&ret.str); \
86         free_strbuf(&ret.err_str); \
87 } while (0)
88
89
90 #endif