clang-format-3.5 **/*.h **/*.c
This should be the last commit that formats a big bunch of files. From here on, whenever I merge patches, I’ll run clang-format like described in the title.
This commit is contained in:
parent
4211274fcd
commit
4c06e7a573
|
@ -3,12 +3,12 @@
|
|||
#include <err.h>
|
||||
|
||||
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
||||
#define FREE(pointer) do { \
|
||||
#define FREE(pointer) \
|
||||
do { \
|
||||
if (pointer != NULL) { \
|
||||
free(pointer); \
|
||||
pointer = NULL; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
} while (0)
|
||||
|
||||
extern xcb_window_t root;
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
#include <err.h>
|
||||
|
||||
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
||||
#define FREE(pointer) do { \
|
||||
#define FREE(pointer) \
|
||||
do { \
|
||||
if (pointer != NULL) { \
|
||||
free(pointer); \
|
||||
pointer = NULL; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
} while (0)
|
||||
|
||||
#define xmacro(atom) xcb_atom_t A_##atom;
|
||||
#include "atoms.xmacro"
|
||||
|
|
|
@ -18,7 +18,9 @@ typedef enum {
|
|||
} position_t;
|
||||
|
||||
/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
|
||||
typedef enum { M_DOCK = 0, M_HIDE = 1, M_INVISIBLE = 2 } bar_display_mode_t;
|
||||
typedef enum { M_DOCK = 0,
|
||||
M_HIDE = 1,
|
||||
M_INVISIBLE = 2 } bar_display_mode_t;
|
||||
|
||||
typedef struct config_t {
|
||||
int modifier;
|
||||
|
@ -38,7 +40,8 @@ typedef struct config_t {
|
|||
bar_display_mode_t hide_on_modifier;
|
||||
|
||||
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
|
||||
enum { S_HIDE = 0, S_SHOW = 1 } hidden_state;
|
||||
enum { S_HIDE = 0,
|
||||
S_SHOW = 1 } hidden_state;
|
||||
} config_t;
|
||||
|
||||
config_t config;
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#define STARTS_WITH(string, len, needle) ((len >= strlen(needle)) && strncasecmp(string, needle, strlen(needle)) == 0)
|
||||
|
||||
/* Securely free p */
|
||||
#define FREE(p) do { \
|
||||
#define FREE(p) \
|
||||
do { \
|
||||
if (p != NULL) { \
|
||||
free(p); \
|
||||
p = NULL; \
|
||||
|
@ -26,7 +27,8 @@
|
|||
} while (0)
|
||||
|
||||
/* Securely fee single-linked list */
|
||||
#define FREE_SLIST(l, type) do { \
|
||||
#define FREE_SLIST(l, type) \
|
||||
do { \
|
||||
type *walk = SLIST_FIRST(l); \
|
||||
while (!SLIST_EMPTY(l)) { \
|
||||
SLIST_REMOVE_HEAD(l, slist); \
|
||||
|
@ -36,7 +38,8 @@
|
|||
} while (0)
|
||||
|
||||
/* Securely fee tail-queues */
|
||||
#define FREE_TAILQ(l, type) do { \
|
||||
#define FREE_TAILQ(l, type) \
|
||||
do { \
|
||||
type *walk = TAILQ_FIRST(l); \
|
||||
while (!TAILQ_EMPTY(l)) { \
|
||||
TAILQ_REMOVE(l, TAILQ_FIRST(l), tailq); \
|
||||
|
@ -49,7 +52,8 @@
|
|||
#undef DLOG
|
||||
#endif
|
||||
/* Use cool logging-macros */
|
||||
#define DLOG(fmt, ...) do { \
|
||||
#define DLOG(fmt, ...) \
|
||||
do { \
|
||||
if (config.verbose) { \
|
||||
printf("[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
} \
|
||||
|
@ -60,6 +64,7 @@
|
|||
#if defined(ELOG)
|
||||
#undef ELOG
|
||||
#endif
|
||||
#define ELOG(fmt, ...) do { \
|
||||
#define ELOG(fmt, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "[%s:%d] ERROR: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
Con *con_new_skeleton(Con *parent, i3Window *window);
|
||||
|
||||
|
||||
/* A wrapper for con_new_skeleton, to retain the old con_new behaviour
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -241,10 +241,13 @@ struct Barconfig {
|
|||
char *socket_path;
|
||||
|
||||
/** Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
|
||||
enum { M_DOCK = 0, M_HIDE = 1, M_INVISIBLE = 2 } mode;
|
||||
enum { M_DOCK = 0,
|
||||
M_HIDE = 1,
|
||||
M_INVISIBLE = 2 } mode;
|
||||
|
||||
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
|
||||
enum { S_HIDE = 0, S_SHOW = 1 } hidden_state;
|
||||
enum { S_HIDE = 0,
|
||||
S_SHOW = 1 } hidden_state;
|
||||
|
||||
/** Bar modifier (to show bar when in hide mode). */
|
||||
enum {
|
||||
|
@ -259,7 +262,8 @@ struct Barconfig {
|
|||
} modifier;
|
||||
|
||||
/** Bar position (bottom by default). */
|
||||
enum { P_BOTTOM = 0, P_TOP = 1 } position;
|
||||
enum { P_BOTTOM = 0,
|
||||
P_TOP = 1 } position;
|
||||
|
||||
/** Command that should be run to execute i3bar, give a full path if i3bar is not
|
||||
* in your $PATH.
|
||||
|
|
|
@ -47,17 +47,25 @@ typedef struct Match Match;
|
|||
typedef struct Assignment Assignment;
|
||||
typedef struct Window i3Window;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Helper types
|
||||
*****************************************************************************/
|
||||
typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
|
||||
typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t;
|
||||
typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_PIXEL = 2 } border_style_t;
|
||||
typedef enum { D_LEFT,
|
||||
D_RIGHT,
|
||||
D_UP,
|
||||
D_DOWN } direction_t;
|
||||
typedef enum { NO_ORIENTATION = 0,
|
||||
HORIZ,
|
||||
VERT } orientation_t;
|
||||
typedef enum { BS_NORMAL = 0,
|
||||
BS_NONE = 1,
|
||||
BS_PIXEL = 2 } border_style_t;
|
||||
|
||||
/** parameter to specify whether tree_close() and x_window_kill() should kill
|
||||
* only this specific window or the whole X11 client */
|
||||
typedef enum { DONT_KILL_WINDOW = 0, KILL_WINDOW = 1, KILL_CLIENT = 2 } kill_window_t;
|
||||
typedef enum { DONT_KILL_WINDOW = 0,
|
||||
KILL_WINDOW = 1,
|
||||
KILL_CLIENT = 2 } kill_window_t;
|
||||
|
||||
/** describes if the window is adjacent to the output (physical screen) edges. */
|
||||
typedef enum { ADJ_NONE = 0,
|
||||
|
@ -267,7 +275,6 @@ struct Binding {
|
|||
* This is an array of number_keycodes size. */
|
||||
xcb_keycode_t *translated_to;
|
||||
|
||||
|
||||
/** Command, like in command mode */
|
||||
char *command;
|
||||
|
||||
|
@ -367,7 +374,9 @@ struct Window {
|
|||
bool doesnt_accept_focus;
|
||||
|
||||
/** Whether the window says it is a dock window */
|
||||
enum { W_NODOCK = 0, W_DOCK_TOP = 1, W_DOCK_BOTTOM = 2 } dock;
|
||||
enum { W_NODOCK = 0,
|
||||
W_DOCK_TOP = 1,
|
||||
W_DOCK_BOTTOM = 2 } dock;
|
||||
|
||||
/** When this window was marked urgent. 0 means not urgent */
|
||||
struct timeval urgent;
|
||||
|
@ -407,7 +416,9 @@ struct Match {
|
|||
M_DOCK_BOTTOM = 3
|
||||
} dock;
|
||||
xcb_window_t id;
|
||||
enum { M_ANY = 0, M_TILING, M_FLOATING } floating;
|
||||
enum { M_ANY = 0,
|
||||
M_TILING,
|
||||
M_FLOATING } floating;
|
||||
Con *con_id;
|
||||
|
||||
/* Where the window looking for a match should be inserted:
|
||||
|
@ -419,7 +430,9 @@ struct Match {
|
|||
* (dockareas)
|
||||
*
|
||||
*/
|
||||
enum { M_HERE = 0, M_ASSIGN_WS, M_BELOW } insert_where;
|
||||
enum { M_HERE = 0,
|
||||
M_ASSIGN_WS,
|
||||
M_BELOW } insert_where;
|
||||
|
||||
TAILQ_ENTRY(Match) matches;
|
||||
|
||||
|
@ -470,7 +483,9 @@ struct Assignment {
|
|||
};
|
||||
|
||||
/** Fullscreen modes. Used by Con.fullscreen_mode. */
|
||||
typedef enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode_t;
|
||||
typedef enum { CF_NONE = 0,
|
||||
CF_OUTPUT = 1,
|
||||
CF_GLOBAL = 2 } fullscreen_mode_t;
|
||||
|
||||
/**
|
||||
* A 'Con' represents everything from the X11 root window down to a single X11 window.
|
||||
|
|
132
include/queue.h
132
include/queue.h
|
@ -124,29 +124,35 @@ struct { \
|
|||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#define SLIST_INIT(head) { \
|
||||
#define SLIST_INIT(head) \
|
||||
{ \
|
||||
SLIST_FIRST(head) = SLIST_END(head); \
|
||||
}
|
||||
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
||||
(slistelm)->field.sle_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sle_next = (head)->slh_first; \
|
||||
(head)->slh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_NEXT(head, elm, field) do { \
|
||||
#define SLIST_REMOVE_NEXT(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
#define SLIST_REMOVE_HEAD(head, field) \
|
||||
do { \
|
||||
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
#define SLIST_REMOVE(head, elm, type, field) \
|
||||
do { \
|
||||
if ((head)->slh_first == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} else { \
|
||||
|
@ -154,8 +160,7 @@ struct { \
|
|||
\
|
||||
while (curelm->field.sle_next != (elm)) \
|
||||
curelm = curelm->field.sle_next; \
|
||||
curelm->field.sle_next = \
|
||||
curelm->field.sle_next->field.sle_next; \
|
||||
curelm->field.sle_next = curelm->field.sle_next->field.sle_next; \
|
||||
_Q_INVALIDATE((elm)->field.sle_next); \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -193,45 +198,48 @@ struct { \
|
|||
/*
|
||||
* List functions.
|
||||
*/
|
||||
#define LIST_INIT(head) do { \
|
||||
#define LIST_INIT(head) \
|
||||
do { \
|
||||
LIST_FIRST(head) = LIST_END(head); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
||||
(listelm)->field.le_next->field.le_prev = \
|
||||
&(elm)->field.le_next; \
|
||||
(listelm)->field.le_next->field.le_prev = &(elm)->field.le_next; \
|
||||
(listelm)->field.le_next = (elm); \
|
||||
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||
(elm)->field.le_next = (listelm); \
|
||||
*(listelm)->field.le_prev = (elm); \
|
||||
(listelm)->field.le_prev = &(elm)->field.le_next; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
||||
#define LIST_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
||||
(head)->lh_first->field.le_prev = &(elm)->field.le_next; \
|
||||
(head)->lh_first = (elm); \
|
||||
(elm)->field.le_prev = &(head)->lh_first; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
#define LIST_REMOVE(elm, field) \
|
||||
do { \
|
||||
if ((elm)->field.le_next != NULL) \
|
||||
(elm)->field.le_next->field.le_prev = \
|
||||
(elm)->field.le_prev; \
|
||||
(elm)->field.le_next->field.le_prev = (elm)->field.le_prev; \
|
||||
*(elm)->field.le_prev = (elm)->field.le_next; \
|
||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||
_Q_INVALIDATE((elm)->field.le_next); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_REPLACE(elm, elm2, field) do { \
|
||||
#define LIST_REPLACE(elm, elm2, field) \
|
||||
do { \
|
||||
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
|
||||
(elm2)->field.le_next->field.le_prev = \
|
||||
&(elm2)->field.le_next; \
|
||||
(elm2)->field.le_next->field.le_prev = &(elm2)->field.le_next; \
|
||||
(elm2)->field.le_prev = (elm)->field.le_prev; \
|
||||
*(elm2)->field.le_prev = (elm2); \
|
||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||
|
@ -271,30 +279,35 @@ struct { \
|
|||
/*
|
||||
* Simple queue functions.
|
||||
*/
|
||||
#define SIMPLEQ_INIT(head) do { \
|
||||
#define SIMPLEQ_INIT(head) \
|
||||
do { \
|
||||
(head)->sqh_first = NULL; \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
#define SIMPLEQ_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(head)->sqh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
#define SIMPLEQ_INSERT_TAIL(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sqe_next = NULL; \
|
||||
*(head)->sqh_last = (elm); \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(listelm)->field.sqe_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
|
||||
#define SIMPLEQ_REMOVE_HEAD(head, field) \
|
||||
do { \
|
||||
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (0)
|
||||
|
@ -344,49 +357,52 @@ struct { \
|
|||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#define TAILQ_INIT(head) do { \
|
||||
#define TAILQ_INIT(head) \
|
||||
do { \
|
||||
(head)->tqh_first = NULL; \
|
||||
(head)->tqh_last = &(head)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
||||
(head)->tqh_first->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
(head)->tqh_first->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(head)->tqh_first = (elm); \
|
||||
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.tqe_next = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
(elm)->field.tqe_next->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(listelm)->field.tqe_next = (elm); \
|
||||
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||
(elm)->field.tqe_next = (listelm); \
|
||||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
#define TAILQ_REMOVE(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
(elm)->field.tqe_next->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||
else \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||
|
@ -394,10 +410,10 @@ struct { \
|
|||
_Q_INVALIDATE((elm)->field.tqe_next); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_REPLACE(head, elm, elm2, field) do { \
|
||||
#define TAILQ_REPLACE(head, elm, elm2, field) \
|
||||
do { \
|
||||
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
|
||||
(elm2)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm2)->field.tqe_next; \
|
||||
(elm2)->field.tqe_next->field.tqe_prev = &(elm2)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm2)->field.tqe_next; \
|
||||
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||
|
@ -407,7 +423,8 @@ struct { \
|
|||
} while (0)
|
||||
|
||||
/* Swaps two consecutive elements. 'second' *MUST* follow 'first' */
|
||||
#define TAILQ_SWAP(first, second, head, field) do { \
|
||||
#define TAILQ_SWAP(first, second, head, field) \
|
||||
do { \
|
||||
*((first)->field.tqe_prev) = (second); \
|
||||
(second)->field.tqe_prev = (first)->field.tqe_prev; \
|
||||
(first)->field.tqe_prev = &((second)->field.tqe_next); \
|
||||
|
@ -461,12 +478,14 @@ struct { \
|
|||
/*
|
||||
* Circular queue functions.
|
||||
*/
|
||||
#define CIRCLEQ_INIT(head) do { \
|
||||
#define CIRCLEQ_INIT(head) \
|
||||
do { \
|
||||
(head)->cqh_first = CIRCLEQ_END(head); \
|
||||
(head)->cqh_last = CIRCLEQ_END(head); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
||||
(elm)->field.cqe_prev = (listelm); \
|
||||
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||
|
@ -476,7 +495,8 @@ struct { \
|
|||
(listelm)->field.cqe_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = (listelm); \
|
||||
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
||||
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||
|
@ -486,7 +506,8 @@ struct { \
|
|||
(listelm)->field.cqe_prev = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = (head)->cqh_first; \
|
||||
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
|
||||
if ((head)->cqh_last == CIRCLEQ_END(head)) \
|
||||
|
@ -496,7 +517,8 @@ struct { \
|
|||
(head)->cqh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = CIRCLEQ_END(head); \
|
||||
(elm)->field.cqe_prev = (head)->cqh_last; \
|
||||
if ((head)->cqh_first == CIRCLEQ_END(head)) \
|
||||
|
@ -506,29 +528,27 @@ struct { \
|
|||
(head)->cqh_last = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_REMOVE(head, elm, field) do { \
|
||||
#define CIRCLEQ_REMOVE(head, elm, field) \
|
||||
do { \
|
||||
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_last = (elm)->field.cqe_prev; \
|
||||
else \
|
||||
(elm)->field.cqe_next->field.cqe_prev = \
|
||||
(elm)->field.cqe_prev; \
|
||||
(elm)->field.cqe_next->field.cqe_prev = (elm)->field.cqe_prev; \
|
||||
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_first = (elm)->field.cqe_next; \
|
||||
else \
|
||||
(elm)->field.cqe_prev->field.cqe_next = \
|
||||
(elm)->field.cqe_next; \
|
||||
(elm)->field.cqe_prev->field.cqe_next = (elm)->field.cqe_next; \
|
||||
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
||||
_Q_INVALIDATE((elm)->field.cqe_next); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
|
||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
|
||||
CIRCLEQ_END(head)) \
|
||||
#define CIRCLEQ_REPLACE(head, elm, elm2, field) \
|
||||
do { \
|
||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_last = (elm2); \
|
||||
else \
|
||||
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
|
||||
CIRCLEQ_END(head)) \
|
||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_first = (elm2); \
|
||||
else \
|
||||
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
||||
|
|
|
@ -15,12 +15,14 @@
|
|||
#include "data.h"
|
||||
|
||||
#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
|
||||
#define exit_if_null(pointer, ...) { if (pointer == NULL) die(__VA_ARGS__); }
|
||||
#define exit_if_null(pointer, ...) \
|
||||
{ \
|
||||
if (pointer == NULL) \
|
||||
die(__VA_ARGS__); \
|
||||
}
|
||||
#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)
|
||||
#define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? \
|
||||
CIRCLEQ_NEXT(elm, field) : NULL)
|
||||
#define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? \
|
||||
CIRCLEQ_PREV(elm, field) : NULL)
|
||||
#define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? CIRCLEQ_NEXT(elm, field) : NULL)
|
||||
#define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? CIRCLEQ_PREV(elm, field) : NULL)
|
||||
#define FOR_TABLE(workspace) \
|
||||
for (int cols = 0; cols < (workspace)->cols; cols++) \
|
||||
for (int rows = 0; rows < (workspace)->rows; rows++)
|
||||
|
@ -43,13 +45,13 @@
|
|||
break; \
|
||||
}
|
||||
|
||||
#define FREE(pointer) do { \
|
||||
#define FREE(pointer) \
|
||||
do { \
|
||||
if (pointer != NULL) { \
|
||||
free(pointer); \
|
||||
pointer = NULL; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
} while (0)
|
||||
|
||||
#define CALL(obj, member, ...) obj->member(obj, ##__VA_ARGS__)
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ void workspace_back_and_forth(void);
|
|||
*/
|
||||
Con *workspace_back_and_forth_get(void);
|
||||
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Assigns the given workspace to the given screen by correctly updating its
|
||||
|
|
|
@ -108,7 +108,6 @@ void xcb_raise_window(xcb_connection_t *conn, xcb_window_t window);
|
|||
*/
|
||||
void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r);
|
||||
|
||||
|
||||
bool xcb_reply_contains_atom(xcb_get_property_reply_t *prop, xcb_atom_t atom);
|
||||
|
||||
/**
|
||||
|
|
129
tests/queue.h
129
tests/queue.h
|
@ -124,29 +124,35 @@ struct { \
|
|||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#define SLIST_INIT(head) { \
|
||||
#define SLIST_INIT(head) \
|
||||
{ \
|
||||
SLIST_FIRST(head) = SLIST_END(head); \
|
||||
}
|
||||
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sle_next = (slistelm)->field.sle_next; \
|
||||
(slistelm)->field.sle_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sle_next = (head)->slh_first; \
|
||||
(head)->slh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_NEXT(head, elm, field) do { \
|
||||
#define SLIST_REMOVE_NEXT(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
#define SLIST_REMOVE_HEAD(head, field) \
|
||||
do { \
|
||||
(head)->slh_first = (head)->slh_first->field.sle_next; \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
#define SLIST_REMOVE(head, elm, type, field) \
|
||||
do { \
|
||||
if ((head)->slh_first == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} else { \
|
||||
|
@ -154,8 +160,7 @@ struct { \
|
|||
\
|
||||
while (curelm->field.sle_next != (elm)) \
|
||||
curelm = curelm->field.sle_next; \
|
||||
curelm->field.sle_next = \
|
||||
curelm->field.sle_next->field.sle_next; \
|
||||
curelm->field.sle_next = curelm->field.sle_next->field.sle_next; \
|
||||
_Q_INVALIDATE((elm)->field.sle_next); \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -193,45 +198,48 @@ struct { \
|
|||
/*
|
||||
* List functions.
|
||||
*/
|
||||
#define LIST_INIT(head) do { \
|
||||
#define LIST_INIT(head) \
|
||||
do { \
|
||||
LIST_FIRST(head) = LIST_END(head); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
||||
(listelm)->field.le_next->field.le_prev = \
|
||||
&(elm)->field.le_next; \
|
||||
(listelm)->field.le_next->field.le_prev = &(elm)->field.le_next; \
|
||||
(listelm)->field.le_next = (elm); \
|
||||
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||
(elm)->field.le_next = (listelm); \
|
||||
*(listelm)->field.le_prev = (elm); \
|
||||
(listelm)->field.le_prev = &(elm)->field.le_next; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
||||
#define LIST_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
||||
(head)->lh_first->field.le_prev = &(elm)->field.le_next; \
|
||||
(head)->lh_first = (elm); \
|
||||
(elm)->field.le_prev = &(head)->lh_first; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
#define LIST_REMOVE(elm, field) \
|
||||
do { \
|
||||
if ((elm)->field.le_next != NULL) \
|
||||
(elm)->field.le_next->field.le_prev = \
|
||||
(elm)->field.le_prev; \
|
||||
(elm)->field.le_next->field.le_prev = (elm)->field.le_prev; \
|
||||
*(elm)->field.le_prev = (elm)->field.le_next; \
|
||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||
_Q_INVALIDATE((elm)->field.le_next); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_REPLACE(elm, elm2, field) do { \
|
||||
#define LIST_REPLACE(elm, elm2, field) \
|
||||
do { \
|
||||
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
|
||||
(elm2)->field.le_next->field.le_prev = \
|
||||
&(elm2)->field.le_next; \
|
||||
(elm2)->field.le_next->field.le_prev = &(elm2)->field.le_next; \
|
||||
(elm2)->field.le_prev = (elm)->field.le_prev; \
|
||||
*(elm2)->field.le_prev = (elm2); \
|
||||
_Q_INVALIDATE((elm)->field.le_prev); \
|
||||
|
@ -271,30 +279,35 @@ struct { \
|
|||
/*
|
||||
* Simple queue functions.
|
||||
*/
|
||||
#define SIMPLEQ_INIT(head) do { \
|
||||
#define SIMPLEQ_INIT(head) \
|
||||
do { \
|
||||
(head)->sqh_first = NULL; \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
#define SIMPLEQ_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(head)->sqh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
#define SIMPLEQ_INSERT_TAIL(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.sqe_next = NULL; \
|
||||
*(head)->sqh_last = (elm); \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \
|
||||
(head)->sqh_last = &(elm)->field.sqe_next; \
|
||||
(listelm)->field.sqe_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
|
||||
#define SIMPLEQ_REMOVE_HEAD(head, field) \
|
||||
do { \
|
||||
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
|
||||
(head)->sqh_last = &(head)->sqh_first; \
|
||||
} while (0)
|
||||
|
@ -344,49 +357,52 @@ struct { \
|
|||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#define TAILQ_INIT(head) do { \
|
||||
#define TAILQ_INIT(head) \
|
||||
do { \
|
||||
(head)->tqh_first = NULL; \
|
||||
(head)->tqh_last = &(head)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
||||
(head)->tqh_first->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
(head)->tqh_first->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(head)->tqh_first = (elm); \
|
||||
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.tqe_next = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
(elm)->field.tqe_next->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(listelm)->field.tqe_next = (elm); \
|
||||
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||
(elm)->field.tqe_next = (listelm); \
|
||||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
#define TAILQ_REMOVE(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
(elm)->field.tqe_next->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||
else \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||
|
@ -394,10 +410,10 @@ struct { \
|
|||
_Q_INVALIDATE((elm)->field.tqe_next); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_REPLACE(head, elm, elm2, field) do { \
|
||||
#define TAILQ_REPLACE(head, elm, elm2, field) \
|
||||
do { \
|
||||
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
|
||||
(elm2)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm2)->field.tqe_next; \
|
||||
(elm2)->field.tqe_next->field.tqe_prev = &(elm2)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm2)->field.tqe_next; \
|
||||
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||
|
@ -448,12 +464,14 @@ struct { \
|
|||
/*
|
||||
* Circular queue functions.
|
||||
*/
|
||||
#define CIRCLEQ_INIT(head) do { \
|
||||
#define CIRCLEQ_INIT(head) \
|
||||
do { \
|
||||
(head)->cqh_first = CIRCLEQ_END(head); \
|
||||
(head)->cqh_last = CIRCLEQ_END(head); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
||||
(elm)->field.cqe_prev = (listelm); \
|
||||
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||
|
@ -463,7 +481,8 @@ struct { \
|
|||
(listelm)->field.cqe_next = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = (listelm); \
|
||||
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
||||
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||
|
@ -473,7 +492,8 @@ struct { \
|
|||
(listelm)->field.cqe_prev = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = (head)->cqh_first; \
|
||||
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
|
||||
if ((head)->cqh_last == CIRCLEQ_END(head)) \
|
||||
|
@ -483,7 +503,8 @@ struct { \
|
|||
(head)->cqh_first = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
|
||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.cqe_next = CIRCLEQ_END(head); \
|
||||
(elm)->field.cqe_prev = (head)->cqh_last; \
|
||||
if ((head)->cqh_first == CIRCLEQ_END(head)) \
|
||||
|
@ -493,29 +514,27 @@ struct { \
|
|||
(head)->cqh_last = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_REMOVE(head, elm, field) do { \
|
||||
#define CIRCLEQ_REMOVE(head, elm, field) \
|
||||
do { \
|
||||
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_last = (elm)->field.cqe_prev; \
|
||||
else \
|
||||
(elm)->field.cqe_next->field.cqe_prev = \
|
||||
(elm)->field.cqe_prev; \
|
||||
(elm)->field.cqe_next->field.cqe_prev = (elm)->field.cqe_prev; \
|
||||
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_first = (elm)->field.cqe_next; \
|
||||
else \
|
||||
(elm)->field.cqe_prev->field.cqe_next = \
|
||||
(elm)->field.cqe_next; \
|
||||
(elm)->field.cqe_prev->field.cqe_next = (elm)->field.cqe_next; \
|
||||
_Q_INVALIDATE((elm)->field.cqe_prev); \
|
||||
_Q_INVALIDATE((elm)->field.cqe_next); \
|
||||
} while (0)
|
||||
|
||||
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
|
||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
|
||||
CIRCLEQ_END(head)) \
|
||||
#define CIRCLEQ_REPLACE(head, elm, elm2, field) \
|
||||
do { \
|
||||
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_last = (elm2); \
|
||||
else \
|
||||
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
|
||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
|
||||
CIRCLEQ_END(head)) \
|
||||
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == CIRCLEQ_END(head)) \
|
||||
(head)->cqh_first = (elm2); \
|
||||
else \
|
||||
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
|
||||
|
|
Loading…
Reference in New Issue