extern "C" {
#endif
-#define TDM_DUMP_DIR "/tmp"
-
-#define TDM_SERVER_REPLY_MSG_LEN 8192
-#define TDM_DEBUG_REPLY_MSG_LEN 2048
-
-#undef EXTERN
-#undef DEPRECATED
-#undef INTERN
-
-#if defined(__GNUC__) && __GNUC__ >= 4
-#define EXTERN __attribute__ ((visibility("default")))
-#else
-#define EXTERN
-#endif
-
-#if defined(__GNUC__) && __GNUC__ >= 4
-#define INTERN __attribute__ ((visibility("hidden")))
-#else
-#define INTERN
-#endif
-
-#if defined(__GNUC__) && __GNUC__ >= 4
-#define DEPRECATED __attribute__ ((deprecated))
-#else
-#define DEPRECATED
-#endif
-
-/* check condition */
-#define TDM_RETURN_IF_FAIL(cond) { \
- if (!(cond)) { \
- TDM_ERR("'%s' failed", #cond); \
- return; \
- } \
-}
-#define TDM_RETURN_VAL_IF_FAIL(cond, val) { \
- if (!(cond)) { \
- TDM_ERR("'%s' failed", #cond); \
- return val; \
- } \
-}
-#define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) { \
- if (!(cond)) { \
- TDM_ERR("'%s' failed", #cond); \
- ret = error_v; \
- if (error) *error = ret; \
- return val; \
- } \
-}
-
-#define TDM_WARNING_IF_FAIL(cond) { \
- if (!(cond)) \
- TDM_WRN("'%s' failed", #cond); \
-}
-#define TDM_GOTO_IF_FAIL(cond, dst) { \
- if (!(cond)) { \
- TDM_ERR("'%s' failed", #cond); \
- goto dst; \
- } \
-}
-#define TDM_EXIT_IF_FAIL(cond) { \
- if (!(cond)) { \
- TDM_ERR("'%s' failed", #cond); \
- exit(0); \
- } \
-}
-
-#define TDM_NEVER_GET_HERE() TDM_WRN("** NEVER GET HERE **")
-
-#define TDM_SNPRINTF(p, len, fmt, ARG...) \
- do { \
- if (p && len && *len > 0) { \
- int s = snprintf(p, *len, fmt, ##ARG); \
- p += s; \
- *len -= s; \
- } \
- } while (0)
-
-#define TDM_DBG_RETURN_IF_FAIL(cond) { \
- if (!(cond)) { \
- TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \
- return; \
- } \
-}
-#define TDM_DBG_GOTO_IF_FAIL(cond, dst) { \
- if (!(cond)) { \
- TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \
- goto dst; \
- } \
-}
-
+/* not-categorized **********************************************************/
#define TDM_NOT_DEFINED_VALUE (-1)
#define TDM_FRONT_VALUE(n) (((n) > 0) ? (n) : TDM_NOT_DEFINED_VALUE)
#define TDM_SWAP(a, b) ({ int t; t = a; a = b; b = t; })
#define TDM_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#define TDM_NEVER_GET_HERE() TDM_WRN("** NEVER GET HERE **")
+
+#define TDM_SNPRINTF(p, len, fmt, ARG...) \
+ do { \
+ if (p && len && *len > 0) { \
+ int s = snprintf(p, *len, fmt, ##ARG); \
+ p += s; \
+ *len -= s; \
+ } \
+ } while (0)
+
+/* dump directory ***********************************************************/
+#define TDM_DUMP_DIR "/tmp"
+
+/* message length ***********************************************************/
+#define TDM_SERVER_REPLY_MSG_LEN 8192
+#define TDM_DEBUG_REPLY_MSG_LEN 2048
+
+/* DPMS *********************************************************************/
/* can't export VSYNC macro because we can't define the exact meaning of vsync off
* at this time. Does committing in standy mode work? Doesn't committing in suspend mode work?
*/
#define TDM_OUTPUT_DPMS_VSYNC_OFF_MASK 0x2
#define TDM_OUTPUT_DPMS_VSYNC_IS_OFF(dpms) ((dpms) & TDM_OUTPUT_DPMS_VSYNC_OFF_MASK)
+/* strtostr *****************************************************************/
+static inline char*
+strtostr(char *buf, int len, char *str, char *delim)
+{
+ char *end;
+ end = strpbrk(str, delim);
+ if (end)
+ len = ((end - str + 1) < len) ? (end - str + 1) : len;
+ else {
+ int l = strlen(str);
+ len = ((l + 1) < len) ? (l + 1) : len;
+ }
+ snprintf(buf, len, "%s", str);
+ return str + len - 1;
+}
+
+/* EXTERN, INTERN, DEPRECATED ***********************************************/
+#undef EXTERN
+#undef DEPRECATED
+#undef INTERN
+
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define EXTERN __attribute__ ((visibility("default")))
+#else
+#define EXTERN
+#endif
+
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define INTERN __attribute__ ((visibility("hidden")))
+#else
+#define INTERN
+#endif
+
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define DEPRECATED __attribute__ ((deprecated))
+#else
+#define DEPRECATED
+#endif
+
+/* type to string ***********************************************************/
struct tdm_type_name {
int type;
const char *name;
};
TDM_BIT_NAME_FB(capture_caps)
-static inline char*
-strtostr(char *buf, int len, char *str, char *delim)
-{
- char *end;
- end = strpbrk(str, delim);
- if (end)
- len = ((end - str + 1) < len) ? (end - str + 1) : len;
- else {
- int l = strlen(str);
- len = ((l + 1) < len) ? (l + 1) : len;
- }
- snprintf(buf, len, "%s", str);
- return str + len - 1;
+/* check condition **********************************************************/
+#define TDM_RETURN_IF_FAIL(cond) { \
+ if (!(cond)) { \
+ TDM_ERR("'%s' failed", #cond); \
+ return; \
+ } \
+}
+#define TDM_RETURN_VAL_IF_FAIL(cond, val) { \
+ if (!(cond)) { \
+ TDM_ERR("'%s' failed", #cond); \
+ return val; \
+ } \
+}
+#define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) { \
+ if (!(cond)) { \
+ TDM_ERR("'%s' failed", #cond); \
+ ret = error_v; \
+ if (error) *error = ret; \
+ return val; \
+ } \
+}
+#define TDM_WARNING_IF_FAIL(cond) { \
+ if (!(cond)) \
+ TDM_WRN("'%s' failed", #cond); \
+}
+#define TDM_GOTO_IF_FAIL(cond, dst) { \
+ if (!(cond)) { \
+ TDM_ERR("'%s' failed", #cond); \
+ goto dst; \
+ } \
+}
+#define TDM_EXIT_IF_FAIL(cond) { \
+ if (!(cond)) { \
+ TDM_ERR("'%s' failed", #cond); \
+ exit(0); \
+ } \
+}
+#define TDM_DBG_RETURN_IF_FAIL(cond) { \
+ if (!(cond)) { \
+ TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \
+ return; \
+ } \
+}
+#define TDM_DBG_GOTO_IF_FAIL(cond, dst) { \
+ if (!(cond)) { \
+ TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \
+ goto dst; \
+ } \
}
+/* trace ********************************************************************/
#ifdef HAVE_TTRACE
#include <ttrace.h>
#define TDM_TRACE_BEGIN(fmt, ...) traceBegin(TTRACE_TAG_GRAPHICS, fmt, ##__VA_ARGS__)
#define TDM_TRACE_MARK(fmt, ...)
#endif
-
+/* display mutex ************************************************************/
extern pthread_mutex_t tdm_mutex_check_lock;
extern int tdm_mutex_locked;
extern const char *tdm_mutex_lock_func;
#define tdm_display_lock(dpy) _pthread_mutex_lock(&((tdm_private_display *)dpy)->lock)
#define tdm_display_unlock(dpy) _pthread_mutex_unlock(&((tdm_private_display *)dpy)->lock)
+
#ifdef __cplusplus
}
#endif