1
0
Fork 0

cogl: Replace custom static assertions with glib one

The displayed message is kept as a comment in the codebase
which is good enough

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3895>
This commit is contained in:
Bilal Elmoussaoui 2024-07-22 17:35:58 +02:00
parent 1acfa6def3
commit fe60ee8b90
3 changed files with 13 additions and 27 deletions

View file

@ -42,10 +42,7 @@
/* This code assumes that we can cast an unsigned long to a pointer
and back without losing any data */
_COGL_STATIC_ASSERT (sizeof (unsigned long) <= sizeof (void *),
"This toolchain breaks Cogl's assumption that it can "
"safely cast an unsigned long to a pointer without "
"losing data");
G_STATIC_ASSERT (sizeof (unsigned long) <= sizeof (void *));
#define ARRAY_INDEX(bit_num) \
((bit_num) / (sizeof (unsigned long) * 8))

View file

@ -2357,11 +2357,12 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
_cogl_pipeline_layer_hash_fragment_snippets_state;
{
/* So we get a big error if we forget to update this code! */
_COGL_STATIC_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 9,
"Don't forget to install a hash function for new "
"pipeline state and update assert at end of "
"_cogl_pipeline_init_state_hash_functions");
/* So we get a big error if we forget to update this code!
* Make sure to install a hash function for newly added
* pipeline state and update assert
* in _cogl_pipeline_init_state_hash_functions
*/
G_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 14);
}
}
@ -2465,11 +2466,12 @@ _cogl_pipeline_init_state_hash_functions (void)
_cogl_pipeline_hash_fragment_snippets_state;
{
/* So we get a big error if we forget to update this code! */
_COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 14,
"Make sure to install a hash function for "
"newly added pipeline state and update assert "
"in _cogl_pipeline_init_state_hash_functions");
/* So we get a big error if we forget to update this code!
* Make sure to install a hash function for newly added
* pipeline state and update assert
* in _cogl_pipeline_init_state_hash_functions
*/
G_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 14);
}
}

View file

@ -99,19 +99,6 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
int depth, int bpp,
int byte_order);
/* _COGL_STATIC_ASSERT:
* @expression: An expression to assert evaluates to true at compile
* time.
* @message: A message to print to the console if the assertion fails
* at compile time.
*
* Allows you to assert that an expression evaluates to true at
* compile time and aborts compilation if not. If possible message
* will also be printed if the assertion fails.
*/
#define _COGL_STATIC_ASSERT(EXPRESSION, MESSAGE) \
_Static_assert (EXPRESSION, MESSAGE);
static inline void
_cogl_util_scissor_intersect (int rect_x0,
int rect_y0,