FreeRDP
Loading...
Searching...
No Matches
include/freerdp/api.h
1
20#ifndef FREERDP_API_H
21#define FREERDP_API_H
22
23#include <winpr/winpr.h>
24#include <winpr/wlog.h>
25#include <winpr/platform.h>
26
27/* To silence missing prototype warnings for library entry points use this macro.
28 * It first declares the function as prototype and then again as function implementation
29 */
30#define FREERDP_ENTRY_POINT(fkt) \
31 fkt; \
32 fkt
33
34#ifdef _WIN32
35#define FREERDP_CC __cdecl
36#else
37#define FREERDP_CC
38#endif
39
40#if defined _WIN32 || defined __CYGWIN__
41#ifdef FREERDP_EXPORTS
42#ifdef __GNUC__
43#define FREERDP_API __attribute__((dllexport))
44#else
45#define FREERDP_API __declspec(dllexport)
46#endif
47#else
48#ifdef __GNUC__
49#define FREERDP_API __attribute__((dllimport))
50#else
51#define FREERDP_API __declspec(dllimport)
52#endif
53#endif
54#else
55#if defined(__GNUC__) && (__GNUC__ >= 4)
56#define FREERDP_API __attribute__((visibility("default")))
57#else
58#define FREERDP_API
59#endif
60#endif
61
62#if defined(EXPORT_ALL_SYMBOLS)
63#define FREERDP_LOCAL FREERDP_API
64#else
65#if defined _WIN32 || defined __CYGWIN__
66#define FREERDP_LOCAL
67#else
68#if defined(__GNUC__) && (__GNUC__ >= 4)
69#define FREERDP_LOCAL __attribute__((visibility("hidden")))
70#else
71#define FREERDP_LOCAL
72#endif
73#endif
74#endif
75
76#define IFCALL(_cb, ...) \
77 do \
78 { \
79 if (_cb != NULL) \
80 _cb(__VA_ARGS__); \
81 else \
82 WLog_VRB("com.freerdp.api", "IFCALL(" #_cb ") == NULL"); \
83 } while (0)
84#define IFCALLRET(_cb, _ret, ...) \
85 do \
86 { \
87 if (_cb != NULL) \
88 _ret = _cb(__VA_ARGS__); \
89 else \
90 WLog_VRB("com.freerdp.api", "IFCALLRET(" #_cb ") == NULL"); \
91 } while (0)
92
93#if defined(__GNUC__) || defined(__clang__)
94#define IFCALLRESULT(_default_return, _cb, ...) \
95 __extension__({ \
96 if (_cb == NULL) \
97 { \
98 WLog_VRB("com.freerdp.api", "IFCALLRESULT(" #_cb ") == NULL"); \
99 } \
100 ((_cb != NULL) ? _cb(__VA_ARGS__) : (_default_return)); \
101 })
102#else
103#define IFCALLRESULT(_default_return, _cb, ...) \
104 ((_cb != NULL) ? _cb(__VA_ARGS__) : (_default_return))
105#endif
106
107#if defined(__GNUC__) || defined(__clang__)
108#define ALIGN64 __attribute__((aligned(8)))
109#else
110#ifdef _WIN32
111#define ALIGN64 __declspec(align(8))
112#else
113#define ALIGN64
114#endif
115#endif
116
117#endif /* FREERDP_API */