summaryrefslogtreecommitdiff
path: root/rts/include
diff options
context:
space:
mode:
authorNicolas Trangez <ikke@nicolast.be>2022-10-30 22:34:15 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-02 12:06:48 -0400
commit81c0c7c94a58d7ed5634abbb002ef88ef903e218 (patch)
tree03f5cd3070ba261c2fd2fb3c7f5ecb06ee6cc7d9 /rts/include
parent9ab999de7ab22dcb4e32825582203d99ce536f55 (diff)
downloadhaskell-81c0c7c94a58d7ed5634abbb002ef88ef903e218.tar.gz
rts: use `alloc_size` attribute
This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381
Diffstat (limited to 'rts/include')
-rw-r--r--rts/include/Stg.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/rts/include/Stg.h b/rts/include/Stg.h
index 4f1f9d3849..5b5ba3ddb7 100644
--- a/rts/include/Stg.h
+++ b/rts/include/Stg.h
@@ -283,6 +283,17 @@
# define STG_MALLOC2(deallocator, ptrIndex)
#endif
+/*
+ * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute
+ */
+#if stg__has_attribute(__alloc_size__)
+# define STG_ALLOC_SIZE1(position) __attribute__((__alloc_size__(position)))
+# define STG_ALLOC_SIZE2(position1, position2) __attribute__((__alloc_size__(position1, position2)))
+#else
+# define STG_ALLOC_SIZE1(position)
+# define STG_ALLOC_SIZE2(position1, position2)
+#endif
+
/* -----------------------------------------------------------------------------
Global type definitions
-------------------------------------------------------------------------- */