Convert non-mandatory attributes to macros
They're shorter and more portable. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
5f57cb41f9
commit
e58cbf8add
2
src/c2.c
2
src/c2.c
|
@ -344,7 +344,7 @@ c2_dump_raw(c2_ptr_t p);
|
||||||
/**
|
/**
|
||||||
* Wrapper of c2_dump_raw().
|
* Wrapper of c2_dump_raw().
|
||||||
*/
|
*/
|
||||||
static inline void __attribute__((unused))
|
static inline void attr_unused
|
||||||
c2_dump(c2_ptr_t p) {
|
c2_dump(c2_ptr_t p) {
|
||||||
c2_dump_raw(p);
|
c2_dump_raw(p);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
|
@ -1524,7 +1524,7 @@ xr_sync(session_t *ps, Drawable d, XSyncFence *pfence) {
|
||||||
if (!*pfence)
|
if (!*pfence)
|
||||||
*pfence = XSyncCreateFence(ps->dpy, d, False);
|
*pfence = XSyncCreateFence(ps->dpy, d, False);
|
||||||
if (*pfence) {
|
if (*pfence) {
|
||||||
Bool __attribute__((unused)) triggered = False;
|
Bool attr_unused triggered = False;
|
||||||
/* if (XSyncQueryFence(ps->dpy, *pfence, &triggered) && triggered)
|
/* if (XSyncQueryFence(ps->dpy, *pfence, &triggered) && triggered)
|
||||||
XSyncResetFence(ps->dpy, *pfence); */
|
XSyncResetFence(ps->dpy, *pfence); */
|
||||||
// The fence may fail to be created (e.g. because of died drawable)
|
// The fence may fail to be created (e.g. because of died drawable)
|
||||||
|
|
|
@ -1271,7 +1271,7 @@ root_damaged(session_t *ps) {
|
||||||
* Xlib error handler function.
|
* Xlib error handler function.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xerror(Display __attribute__((unused)) *dpy, XErrorEvent *ev) {
|
xerror(Display attr_unused *dpy, XErrorEvent *ev) {
|
||||||
if (!should_ignore(ps_g, ev->serial))
|
if (!should_ignore(ps_g, ev->serial))
|
||||||
x_print_error(ev->serial, ev->request_code, ev->minor_code, ev->error_code);
|
x_print_error(ev->serial, ev->request_code, ev->minor_code, ev->error_code);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1281,7 +1281,7 @@ xerror(Display __attribute__((unused)) *dpy, XErrorEvent *ev) {
|
||||||
* XCB error handler function.
|
* XCB error handler function.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ev_xcb_error(session_t __attribute__((unused)) *ps, xcb_generic_error_t *err) {
|
ev_xcb_error(session_t attr_unused *ps, xcb_generic_error_t *err) {
|
||||||
if (!should_ignore(ps, err->sequence))
|
if (!should_ignore(ps, err->sequence))
|
||||||
x_print_error(err->sequence, err->major_code, err->minor_code, err->error_code);
|
x_print_error(err->sequence, err->major_code, err->minor_code, err->error_code);
|
||||||
}
|
}
|
||||||
|
@ -1395,12 +1395,12 @@ opts_set_no_fading_openclose(session_t *ps, bool newval) {
|
||||||
//!@}
|
//!@}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline int __attribute__((unused))
|
static inline int attr_unused
|
||||||
ev_serial(xcb_generic_event_t *ev) {
|
ev_serial(xcb_generic_event_t *ev) {
|
||||||
return ev->full_sequence;
|
return ev->full_sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char * __attribute__((unused))
|
static inline const char * attr_unused
|
||||||
ev_name(session_t *ps, xcb_generic_event_t *ev) {
|
ev_name(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
switch (ev->response_type & 0x7f) {
|
switch (ev->response_type & 0x7f) {
|
||||||
|
@ -1437,7 +1437,7 @@ ev_name(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Window __attribute__((unused))
|
static inline Window attr_unused
|
||||||
ev_window(session_t *ps, xcb_generic_event_t *ev) {
|
ev_window(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
switch (ev->response_type) {
|
switch (ev->response_type) {
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
|
@ -1504,7 +1504,7 @@ ev_focus_detail_name(xcb_focus_in_event_t* ev) {
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void __attribute__((unused))
|
static inline void attr_unused
|
||||||
ev_focus_report(xcb_focus_in_event_t *ev) {
|
ev_focus_report(xcb_focus_in_event_t *ev) {
|
||||||
printf(" { mode: %s, detail: %s }\n", ev_focus_mode_name(ev),
|
printf(" { mode: %s, detail: %s }\n", ev_focus_mode_name(ev),
|
||||||
ev_focus_detail_name(ev));
|
ev_focus_detail_name(ev));
|
||||||
|
@ -1850,7 +1850,7 @@ ev_shape_notify(session_t *ps, xcb_shape_notify_event_t *ev) {
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
ev_screen_change_notify(session_t *ps,
|
ev_screen_change_notify(session_t *ps,
|
||||||
xcb_randr_screen_change_notify_event_t __attribute__((unused)) *ev) {
|
xcb_randr_screen_change_notify_event_t attr_unused *ev) {
|
||||||
if (ps->o.xinerama_shadow_crop)
|
if (ps->o.xinerama_shadow_crop)
|
||||||
cxinerama_upd_scrs(ps);
|
cxinerama_upd_scrs(ps);
|
||||||
|
|
||||||
|
@ -1865,7 +1865,7 @@ ev_screen_change_notify(session_t *ps,
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
ev_selection_clear(session_t *ps,
|
ev_selection_clear(session_t *ps,
|
||||||
xcb_selection_clear_event_t __attribute__((unused)) *ev) {
|
xcb_selection_clear_event_t attr_unused *ev) {
|
||||||
// The only selection we own is the _NET_WM_CM_Sn selection.
|
// The only selection we own is the _NET_WM_CM_Sn selection.
|
||||||
// If we lose that one, we should exit.
|
// If we lose that one, we should exit.
|
||||||
fprintf(stderr, "Another composite manager started and "
|
fprintf(stderr, "Another composite manager started and "
|
||||||
|
@ -1876,7 +1876,7 @@ ev_selection_clear(session_t *ps,
|
||||||
/**
|
/**
|
||||||
* Get a window's name from window ID.
|
* Get a window's name from window ID.
|
||||||
*/
|
*/
|
||||||
static inline void __attribute__((unused))
|
static inline void attr_unused
|
||||||
ev_window_name(session_t *ps, Window wid, char **name) {
|
ev_window_name(session_t *ps, Window wid, char **name) {
|
||||||
*name = "";
|
*name = "";
|
||||||
if (wid) {
|
if (wid) {
|
||||||
|
@ -4090,7 +4090,7 @@ session_run(session_t *ps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sigint_handler(int __attribute__((unused)) signum) {
|
sigint_handler(int attr_unused signum) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ void map_win(session_t *ps, Window id);
|
||||||
*
|
*
|
||||||
* Truncate to 0 if the result is negative.
|
* Truncate to 0 if the result is negative.
|
||||||
*/
|
*/
|
||||||
static inline unsigned long __attribute__((const))
|
static inline unsigned long attr_const
|
||||||
sub_unslong(unsigned long a, unsigned long b) {
|
sub_unslong(unsigned long a, unsigned long b) {
|
||||||
return (a > b) ? a - b : 0;
|
return (a > b) ? a - b : 0;
|
||||||
}
|
}
|
||||||
|
|
12
src/kernel.c
12
src/kernel.c
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A picture will help
|
* A picture will help
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
* center +-----+-------------------+-----+
|
* center +-----+-------------------+-----+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
double
|
double attr_const attr_pure sum_kernel(const conv *map, int x, int y, int width,
|
||||||
sum_kernel(conv *map, int x, int y, int width, int height) {
|
int height) {
|
||||||
int fx, fy;
|
int fx, fy;
|
||||||
double *g_data;
|
const double *g_data;
|
||||||
double *g_line = map->data;
|
const double *g_line = map->data;
|
||||||
int g_size = map->size;
|
int g_size = map->size;
|
||||||
int center = g_size / 2;
|
int center = g_size / 2;
|
||||||
int fx_start, fx_end;
|
int fx_start, fx_end;
|
||||||
|
@ -77,7 +77,7 @@ sum_kernel(conv *map, int x, int y, int width, int height) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double __attribute__((const)) gaussian(double r, double x, double y) {
|
static double attr_const attr_pure gaussian(double r, double x, double y) {
|
||||||
// Formula can be found here:
|
// Formula can be found here:
|
||||||
// https://en.wikipedia.org/wiki/Gaussian_blur#Mathematics
|
// https://en.wikipedia.org/wiki/Gaussian_blur#Mathematics
|
||||||
// Except a special case for r == 0 to produce sharp shadows
|
// Except a special case for r == 0 to produce sharp shadows
|
||||||
|
|
|
@ -2,18 +2,19 @@
|
||||||
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
|
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "compiler.h"
|
||||||
|
|
||||||
/// Code for generating convolution kernels
|
/// Code for generating convolution kernels
|
||||||
|
|
||||||
typedef struct conv {
|
typedef struct conv {
|
||||||
int size;
|
int size;
|
||||||
double data[];
|
double data[];
|
||||||
} conv;
|
} conv;
|
||||||
|
|
||||||
/// Calculate the sum of a rectangle part of the convolution kernel
|
/// Calculate the sum of a rectangle part of the convolution kernel
|
||||||
/// the rectangle is defined by top left (x, y), and a size (width x height)
|
/// the rectangle is defined by top left (x, y), and a size (width x height)
|
||||||
double
|
double attr_const attr_pure sum_kernel(const conv *map, int x, int y, int width,
|
||||||
sum_kernel(conv *map, int x, int y, int width, int height);
|
int height);
|
||||||
|
|
||||||
/// Create a kernel with gaussian distribution of radius r
|
/// Create a kernel with gaussian distribution of radius r
|
||||||
conv *gaussian_kernel(double r);
|
conv *gaussian_kernel(double r);
|
||||||
|
|
|
@ -166,7 +166,7 @@ void
|
||||||
glx_release_pixmap(session_t *ps, glx_texture_t *ptex);
|
glx_release_pixmap(session_t *ps, glx_texture_t *ptex);
|
||||||
|
|
||||||
void glx_paint_pre(session_t *ps, region_t *preg)
|
void glx_paint_pre(session_t *ps, region_t *preg)
|
||||||
__attribute__((nonnull(1, 2)));
|
attr_nonnull(1, 2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a texture is binded, or is binded to the given pixmap.
|
* Check if a texture is binded, or is binded to the given pixmap.
|
||||||
|
|
|
@ -51,7 +51,7 @@ static inline void xrfilter_reset(session_t *ps, xcb_render_picture_t p) {
|
||||||
#undef FILTER
|
#undef FILTER
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void __attribute__((nonnull(1, 2)))
|
static inline void attr_nonnull(1, 2)
|
||||||
set_tgt_clip(session_t *ps, region_t *reg) {
|
set_tgt_clip(session_t *ps, region_t *reg) {
|
||||||
switch (ps->o.backend) {
|
switch (ps->o.backend) {
|
||||||
case BKEND_XRENDER:
|
case BKEND_XRENDER:
|
||||||
|
|
14
src/utils.h
14
src/utils.h
|
@ -36,7 +36,7 @@ static inline bool safe_isnan(double a) {
|
||||||
* @param max maximum value
|
* @param max maximum value
|
||||||
* @return normalized value
|
* @return normalized value
|
||||||
*/
|
*/
|
||||||
static inline int __attribute__((const))
|
static inline int attr_const
|
||||||
normalize_i_range(int i, int min, int max) {
|
normalize_i_range(int i, int min, int max) {
|
||||||
if (i > max) return max;
|
if (i > max) return max;
|
||||||
if (i < min) return min;
|
if (i < min) return min;
|
||||||
|
@ -46,7 +46,7 @@ normalize_i_range(int i, int min, int max) {
|
||||||
/**
|
/**
|
||||||
* Select the larger integer of two.
|
* Select the larger integer of two.
|
||||||
*/
|
*/
|
||||||
static inline int __attribute__((const))
|
static inline int attr_const
|
||||||
max_i(int a, int b) {
|
max_i(int a, int b) {
|
||||||
return (a > b ? a : b);
|
return (a > b ? a : b);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ max_i(int a, int b) {
|
||||||
/**
|
/**
|
||||||
* Select the smaller integer of two.
|
* Select the smaller integer of two.
|
||||||
*/
|
*/
|
||||||
static inline int __attribute__((const))
|
static inline int attr_const
|
||||||
min_i(int a, int b) {
|
min_i(int a, int b) {
|
||||||
return (a > b ? b : a);
|
return (a > b ? b : a);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ min_i(int a, int b) {
|
||||||
/**
|
/**
|
||||||
* Select the larger long integer of two.
|
* Select the larger long integer of two.
|
||||||
*/
|
*/
|
||||||
static inline long __attribute__((const))
|
static inline long attr_const
|
||||||
max_l(long a, long b) {
|
max_l(long a, long b) {
|
||||||
return (a > b ? a : b);
|
return (a > b ? a : b);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ max_l(long a, long b) {
|
||||||
/**
|
/**
|
||||||
* Select the smaller long integer of two.
|
* Select the smaller long integer of two.
|
||||||
*/
|
*/
|
||||||
static inline long __attribute__((const))
|
static inline long attr_const
|
||||||
min_l(long a, long b) {
|
min_l(long a, long b) {
|
||||||
return (a > b ? b : a);
|
return (a > b ? b : a);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ min_l(long a, long b) {
|
||||||
* @param max maximum value
|
* @param max maximum value
|
||||||
* @return normalized value
|
* @return normalized value
|
||||||
*/
|
*/
|
||||||
static inline double __attribute__((const))
|
static inline double attr_const
|
||||||
normalize_d_range(double d, double min, double max) {
|
normalize_d_range(double d, double min, double max) {
|
||||||
if (d > max) return max;
|
if (d > max) return max;
|
||||||
if (d < min) return min;
|
if (d < min) return min;
|
||||||
|
@ -96,7 +96,7 @@ normalize_d_range(double d, double min, double max) {
|
||||||
* @param d double value to normalize
|
* @param d double value to normalize
|
||||||
* @return normalized value
|
* @return normalized value
|
||||||
*/
|
*/
|
||||||
static inline double __attribute__((const))
|
static inline double attr_const
|
||||||
normalize_d(double d) {
|
normalize_d(double d) {
|
||||||
return normalize_d_range(d, 0.0, 1.0);
|
return normalize_d_range(d, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,7 +379,7 @@ win_get_bounding_shape_global_by_val(win *w) {
|
||||||
* Calculate the extents of the frame of the given window based on EWMH
|
* Calculate the extents of the frame of the given window based on EWMH
|
||||||
* _NET_FRAME_EXTENTS and the X window border width.
|
* _NET_FRAME_EXTENTS and the X window border width.
|
||||||
*/
|
*/
|
||||||
static inline margin_t __attribute__((pure))
|
static inline margin_t attr_pure
|
||||||
win_calc_frame_extents(const win *w) {
|
win_calc_frame_extents(const win *w) {
|
||||||
margin_t result = w->frame_extents;
|
margin_t result = w->frame_extents;
|
||||||
result.top = max_i(result.top, w->g.border_width);
|
result.top = max_i(result.top, w->g.border_width);
|
||||||
|
@ -392,7 +392,7 @@ win_calc_frame_extents(const win *w) {
|
||||||
/**
|
/**
|
||||||
* Check whether a window has WM frames.
|
* Check whether a window has WM frames.
|
||||||
*/
|
*/
|
||||||
static inline bool __attribute__((pure))
|
static inline bool attr_pure
|
||||||
win_has_frame(const win *w) {
|
win_has_frame(const win *w) {
|
||||||
return w->g.border_width
|
return w->g.border_width
|
||||||
|| w->frame_extents.top || w->frame_extents.left
|
|| w->frame_extents.top || w->frame_extents.left
|
||||||
|
|
6
src/x.h
6
src/x.h
|
@ -98,19 +98,19 @@ xcb_render_picture_t x_create_picture_with_pictfmt_and_pixmap(
|
||||||
session_t *ps, xcb_render_pictforminfo_t *pictfmt,
|
session_t *ps, xcb_render_pictforminfo_t *pictfmt,
|
||||||
xcb_pixmap_t pixmap, unsigned long valuemask,
|
xcb_pixmap_t pixmap, unsigned long valuemask,
|
||||||
const xcb_render_create_picture_value_list_t *attr)
|
const xcb_render_create_picture_value_list_t *attr)
|
||||||
__attribute__((nonnull(1, 2)));
|
attr_nonnull(1, 2);
|
||||||
|
|
||||||
xcb_render_picture_t x_create_picture_with_visual_and_pixmap(
|
xcb_render_picture_t x_create_picture_with_visual_and_pixmap(
|
||||||
session_t *ps, xcb_visualid_t visual,
|
session_t *ps, xcb_visualid_t visual,
|
||||||
xcb_pixmap_t pixmap, unsigned long valuemask,
|
xcb_pixmap_t pixmap, unsigned long valuemask,
|
||||||
const xcb_render_create_picture_value_list_t *attr)
|
const xcb_render_create_picture_value_list_t *attr)
|
||||||
__attribute__((nonnull(1)));
|
attr_nonnull(1);
|
||||||
|
|
||||||
xcb_render_picture_t x_create_picture_with_standard_and_pixmap(
|
xcb_render_picture_t x_create_picture_with_standard_and_pixmap(
|
||||||
session_t *ps, xcb_pict_standard_t standard,
|
session_t *ps, xcb_pict_standard_t standard,
|
||||||
xcb_pixmap_t pixmap, unsigned long valuemask,
|
xcb_pixmap_t pixmap, unsigned long valuemask,
|
||||||
const xcb_render_create_picture_value_list_t *attr)
|
const xcb_render_create_picture_value_list_t *attr)
|
||||||
__attribute__((nonnull(1)));
|
attr_nonnull(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an picture.
|
* Create an picture.
|
||||||
|
|
Loading…
Reference in New Issue