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:
Yuxuan Shui 2018-12-19 20:50:02 +00:00
parent 5f57cb41f9
commit e58cbf8add
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
11 changed files with 38 additions and 37 deletions

View File

@ -344,7 +344,7 @@ c2_dump_raw(c2_ptr_t p);
/**
* Wrapper of c2_dump_raw().
*/
static inline void __attribute__((unused))
static inline void attr_unused
c2_dump(c2_ptr_t p) {
c2_dump_raw(p);
printf("\n");

View File

@ -1524,7 +1524,7 @@ xr_sync(session_t *ps, Drawable d, XSyncFence *pfence) {
if (!*pfence)
*pfence = XSyncCreateFence(ps->dpy, d, False);
if (*pfence) {
Bool __attribute__((unused)) triggered = False;
Bool attr_unused triggered = False;
/* if (XSyncQueryFence(ps->dpy, *pfence, &triggered) && triggered)
XSyncResetFence(ps->dpy, *pfence); */
// The fence may fail to be created (e.g. because of died drawable)

View File

@ -1271,7 +1271,7 @@ root_damaged(session_t *ps) {
* Xlib error handler function.
*/
static int
xerror(Display __attribute__((unused)) *dpy, XErrorEvent *ev) {
xerror(Display attr_unused *dpy, XErrorEvent *ev) {
if (!should_ignore(ps_g, ev->serial))
x_print_error(ev->serial, ev->request_code, ev->minor_code, ev->error_code);
return 0;
@ -1281,7 +1281,7 @@ xerror(Display __attribute__((unused)) *dpy, XErrorEvent *ev) {
* XCB error handler function.
*/
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))
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
static inline int __attribute__((unused))
static inline int attr_unused
ev_serial(xcb_generic_event_t *ev) {
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) {
static char buf[128];
switch (ev->response_type & 0x7f) {
@ -1437,7 +1437,7 @@ ev_name(session_t *ps, xcb_generic_event_t *ev) {
return buf;
}
static inline Window __attribute__((unused))
static inline Window attr_unused
ev_window(session_t *ps, xcb_generic_event_t *ev) {
switch (ev->response_type) {
case FocusIn:
@ -1504,7 +1504,7 @@ ev_focus_detail_name(xcb_focus_in_event_t* ev) {
return "Unknown";
}
static inline void __attribute__((unused))
static inline void attr_unused
ev_focus_report(xcb_focus_in_event_t *ev) {
printf(" { mode: %s, detail: %s }\n", ev_focus_mode_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
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)
cxinerama_upd_scrs(ps);
@ -1865,7 +1865,7 @@ ev_screen_change_notify(session_t *ps,
inline static void
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.
// If we lose that one, we should exit.
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.
*/
static inline void __attribute__((unused))
static inline void attr_unused
ev_window_name(session_t *ps, Window wid, char **name) {
*name = "";
if (wid) {
@ -4090,7 +4090,7 @@ session_run(session_t *ps) {
}
static void
sigint_handler(int __attribute__((unused)) signum) {
sigint_handler(int attr_unused signum) {
exit(0);
}

View File

@ -59,7 +59,7 @@ void map_win(session_t *ps, Window id);
*
* 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) {
return (a > b) ? a - b : 0;
}

View File

@ -3,8 +3,8 @@
#include <math.h>
#include "utils.h"
#include "kernel.h"
#include "utils.h"
/*
* A picture will help
@ -23,11 +23,11 @@
* center +-----+-------------------+-----+
*/
double
sum_kernel(conv *map, int x, int y, int width, int height) {
double attr_const attr_pure sum_kernel(const conv *map, int x, int y, int width,
int height) {
int fx, fy;
double *g_data;
double *g_line = map->data;
const double *g_data;
const double *g_line = map->data;
int g_size = map->size;
int center = g_size / 2;
int fx_start, fx_end;
@ -77,7 +77,7 @@ sum_kernel(conv *map, int x, int y, int width, int height) {
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:
// https://en.wikipedia.org/wiki/Gaussian_blur#Mathematics
// Except a special case for r == 0 to produce sharp shadows

View File

@ -2,18 +2,19 @@
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
#pragma once
#include "compiler.h"
/// Code for generating convolution kernels
typedef struct conv {
int size;
double data[];
int size;
double data[];
} conv;
/// 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)
double
sum_kernel(conv *map, int x, int y, int width, int height);
double attr_const attr_pure sum_kernel(const conv *map, int x, int y, int width,
int height);
/// Create a kernel with gaussian distribution of radius r
conv *gaussian_kernel(double r);

View File

@ -166,7 +166,7 @@ void
glx_release_pixmap(session_t *ps, glx_texture_t *ptex);
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.

View File

@ -51,7 +51,7 @@ static inline void xrfilter_reset(session_t *ps, xcb_render_picture_t p) {
#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) {
switch (ps->o.backend) {
case BKEND_XRENDER:

View File

@ -36,7 +36,7 @@ static inline bool safe_isnan(double a) {
* @param max maximum value
* @return normalized value
*/
static inline int __attribute__((const))
static inline int attr_const
normalize_i_range(int i, int min, int max) {
if (i > max) return max;
if (i < min) return min;
@ -46,7 +46,7 @@ normalize_i_range(int i, int min, int max) {
/**
* Select the larger integer of two.
*/
static inline int __attribute__((const))
static inline int attr_const
max_i(int a, int b) {
return (a > b ? a : b);
}
@ -54,7 +54,7 @@ max_i(int a, int b) {
/**
* Select the smaller integer of two.
*/
static inline int __attribute__((const))
static inline int attr_const
min_i(int a, int b) {
return (a > b ? b : a);
}
@ -62,7 +62,7 @@ min_i(int a, int b) {
/**
* Select the larger long integer of two.
*/
static inline long __attribute__((const))
static inline long attr_const
max_l(long a, long b) {
return (a > b ? a : b);
}
@ -70,7 +70,7 @@ max_l(long a, long b) {
/**
* Select the smaller long integer of two.
*/
static inline long __attribute__((const))
static inline long attr_const
min_l(long a, long b) {
return (a > b ? b : a);
}
@ -83,7 +83,7 @@ min_l(long a, long b) {
* @param max maximum value
* @return normalized value
*/
static inline double __attribute__((const))
static inline double attr_const
normalize_d_range(double d, double min, double max) {
if (d > max) return max;
if (d < min) return min;
@ -96,7 +96,7 @@ normalize_d_range(double d, double min, double max) {
* @param d double value to normalize
* @return normalized value
*/
static inline double __attribute__((const))
static inline double attr_const
normalize_d(double d) {
return normalize_d_range(d, 0.0, 1.0);
}

View File

@ -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
* _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) {
margin_t result = w->frame_extents;
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.
*/
static inline bool __attribute__((pure))
static inline bool attr_pure
win_has_frame(const win *w) {
return w->g.border_width
|| w->frame_extents.top || w->frame_extents.left

View File

@ -98,19 +98,19 @@ xcb_render_picture_t x_create_picture_with_pictfmt_and_pixmap(
session_t *ps, xcb_render_pictforminfo_t *pictfmt,
xcb_pixmap_t pixmap, unsigned long valuemask,
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(
session_t *ps, xcb_visualid_t visual,
xcb_pixmap_t pixmap, unsigned long valuemask,
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(
session_t *ps, xcb_pict_standard_t standard,
xcb_pixmap_t pixmap, unsigned long valuemask,
const xcb_render_create_picture_value_list_t *attr)
__attribute__((nonnull(1)));
attr_nonnull(1);
/**
* Create an picture.