aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2021-01-03 08:56:47 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2021-01-03 08:56:47 +0000
commit39b2e46e72ad82ec2971b859eae75562751f8464 (patch)
treeb9e7a0ebefda5d9e485f4c779ddc3ee80c85ed17
parentmacros: add wrappers for more GCC/Clang attributes/pragmas/builtins (diff)
Use wrappers from macros.h instead of bare GCC attributes/pragmas
-rw-r--r--box-drawing.c9
-rw-r--r--macros.h12
-rw-r--r--render.c2
-rw-r--r--vt.c9
4 files changed, 17 insertions, 15 deletions
diff --git a/box-drawing.c b/box-drawing.c
index e655bfdc..8640fc4c 100644
--- a/box-drawing.c
+++ b/box-drawing.c
@@ -1861,10 +1861,7 @@ draw_sextant(wchar_t wc, struct buf *buf)
static void
draw_glyph(wchar_t wc, struct buf *buf)
{
-#if defined(__GNUC__)
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wpedantic"
-#endif
+ IGNORE_WARNING("-Wpedantic")
switch (wc) {
case 0x2500: draw_box_drawings_light_horizontal(buf); break;
@@ -2037,9 +2034,7 @@ draw_glyph(wchar_t wc, struct buf *buf)
case 0x1fb00 ... 0x1fb3b: draw_sextant(wc, buf); break;
}
-#if defined(__GNUC__)
- #pragma GCC diagnostic pop
-#endif
+ UNIGNORE_WARNINGS
}
struct fcft_glyph * COLD
diff --git a/macros.h b/macros.h
index 0a355ceb..1fd82b77 100644
--- a/macros.h
+++ b/macros.h
@@ -45,6 +45,18 @@
#define MALLOC
#endif
+#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(constructor)
+ #define CONSTRUCTOR __attribute__((__constructor__))
+#else
+ #define CONSTRUCTOR
+#endif
+
+#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(destructor)
+ #define DESTRUCTOR __attribute__((__destructor__))
+#else
+ #define DESTRUCTOR
+#endif
+
#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(format)
#define PRINTF(x) __attribute__((__format__(__printf__, (x), (x + 1))))
#define VPRINTF(x) __attribute__((__format__(__printf__, (x), 0)))
diff --git a/render.c b/render.c
index 680dd278..ed4854f0 100644
--- a/render.c
+++ b/render.c
@@ -80,7 +80,7 @@ render_destroy(struct renderer *renderer)
free(renderer);
}
-static void __attribute__((destructor))
+static void DESTRUCTOR
log_presentation_statistics(void)
{
if (presentation_statistics.total == 0)
diff --git a/vt.c b/vt.c
index 120b9c98..e8e10b2f 100644
--- a/vt.c
+++ b/vt.c
@@ -750,10 +750,7 @@ action_utf8_44(struct terminal *term, uint8_t c)
action_utf8_print(term, term->vt.utf8);
}
-#if defined(__GNUC__)
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wpedantic"
-#endif
+IGNORE_WARNING("-Wpedantic")
static enum state
state_ground_switch(struct terminal *term, uint8_t data)
@@ -1277,9 +1274,7 @@ state_utf8_43_switch(struct terminal *term, uint8_t data)
}
}
-#if defined(__GNUC__)
- #pragma GCC diagnostic pop
-#endif
+UNIGNORE_WARNINGS
void
vt_from_slave(struct terminal *term, const uint8_t *data, size_t len)