aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-28 09:19:05 +0100
committerMattias Andrée <maandree@kth.se>2023-01-28 09:31:28 +0100
commit575e3ad31dd8ccf2afdd5c8a8d2dbf8d57241c5d (patch)
tree45b154e54eb7caa0300e5176237cb84257da138e
parentlibglitter.7: add application usage section (diff)
downloadlibglitter-575e3ad31dd8ccf2afdd5c8a8d2dbf8d57241c5d.tar.gz
libglitter-575e3ad31dd8ccf2afdd5c8a8d2dbf8d57241c5d.tar.bz2
libglitter-575e3ad31dd8ccf2afdd5c8a8d2dbf8d57241c5d.tar.xz
Fix warnings, add restrict, and add function attributes1.0
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--common.h25
-rw-r--r--libglitter.h108
-rw-r--r--libglitter_colour_model_convert_rasters_double.c22
-rw-r--r--libglitter_compose_double.c14
-rw-r--r--libglitter_compose_uint64.c10
-rw-r--r--libglitter_create_render_context.c3
-rw-r--r--libglitter_desaturate_double.c23
-rw-r--r--libglitter_enable_acceleration.c18
-rw-r--r--libglitter_get_colour_model_conversion_matrix_double.c19
-rw-r--r--libglitter_per_channel_desaturate_double.c8
-rw-r--r--libglitter_split_uint64_raster.c18
11 files changed, 164 insertions, 104 deletions
diff --git a/common.h b/common.h
index e36f7b9..3a70c71 100644
--- a/common.h
+++ b/common.h
@@ -12,6 +12,21 @@
#include <string.h>
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wunsuffixed-float-constants"
+# pragma GCC diagnostic ignored "-Wunused-macros"
+# pragma GCC diagnostic ignored "-Wpadded"
+#elif defined(__clang__)
+# pragma clang diagnostic ignored "-Wunused-macros"
+# pragma clang diagnostic ignored "-Wkeyword-macro"
+# pragma clang diagnostic ignored "-Walloca"
+# pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
+# pragma clang diagnostic ignored "-Wcomma"
+# pragma clang diagnostic ignored "-Wpadded"
+# pragma clang diagnostic ignored "-Wvla"
+#endif
+
+
#define RENDER_METHOD_VSTRIPS 0
#define RENDER_METHOD_HSTRIPS 1
#define RENDER_METHOD_SIMPLE 2
@@ -34,6 +49,16 @@ struct libglitter_render_context {
#ifdef TEST
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wfloat-equal"
+# pragma GCC diagnostic ignored "-Wfloat-conversion"
+# pragma GCC diagnostic ignored "-Wdouble-promotion"
+#elif defined(__clang__)
+# pragma clang diagnostic ignored "-Wfloat-equal"
+# pragma clang diagnostic ignored "-Wdouble-promotion"
+# pragma clang diagnostic ignored "-Wimplicit-float-conversion"
+#endif
+
# define ASSERT(ASSERTION)\
do {\
if (!(ASSERTION)) {\
diff --git a/libglitter.h b/libglitter.h
index 27dfd0d..d285104 100644
--- a/libglitter.h
+++ b/libglitter.h
@@ -6,6 +6,25 @@
#include <stdint.h>
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wpadded"
+#elif defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wpadded"
+# pragma clang diagnostic ignored "-Wdocumentation"
+# pragma clang diagnostic ignored "-Wvla"
+#endif
+
+
+
+#if defined(__GNUC__) && !defined(__clang__)
+# define LIBGLITTER_GCC_ATTRS__(...) __attribute__((__VA_ARGS__))
+#else
+# define LIBGLITTER_GCC_ATTRS__(...)
+#endif
+
+
/**
* The application will use `double`-typed rasters
*/
@@ -147,6 +166,13 @@ int libglitter_enable_acceleration(uint64_t, int, void (*)(int, int, void *), vo
/**
+ * Deallocates a render context (created by `libglitter_create_render_context`)
+ *
+ * @param this The render context to deallocate
+ */
+void libglitter_free_render_context(LIBGLITTER_RENDER_CONTEXT *);
+
+/**
* Create a render context for an input raster's specifications
*
* Render context's are thread-safe
@@ -175,6 +201,7 @@ int libglitter_enable_acceleration(uint64_t, int, void (*)(int, int, void *), vo
*
* The returned object will contain references to `cellmap` and `ncellvalues`
*/
+LIBGLITTER_GCC_ATTRS__(nonnull, warn_unused_result, malloc, malloc(libglitter_free_render_context, 1))
LIBGLITTER_RENDER_CONTEXT *libglitter_create_render_context(size_t, size_t, size_t, size_t,
const uint8_t *, const uint8_t *);
@@ -189,13 +216,6 @@ LIBGLITTER_RENDER_CONTEXT *libglitter_create_render_context(size_t, size_t, size
*/
void libglitter_update_render_context(LIBGLITTER_RENDER_CONTEXT *, size_t);
-/**
- * Deallocates a render context (created by `libglitter_create_render_context`)
- *
- * @param this The render context to deallocate
- */
-void libglitter_free_render_context(LIBGLITTER_RENDER_CONTEXT *);
-
/**
* Create one raster per monitor colour from a raster of
@@ -221,16 +241,18 @@ void libglitter_free_render_context(LIBGLITTER_RENDER_CONTEXT *);
* @param render_ctx Rendering context created for the input raster's
* specification
*/
-void libglitter_compose_double(double **, const double *restrict, size_t, size_t,
- size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *);
+LIBGLITTER_GCC_ATTRS__(nonnull)
+void libglitter_compose_double(double *restrict*, const double *restrict, size_t, size_t,
+ size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *restrict);
/**
* This value is identical to `libglitter_compose_double`,
* apart from it parameter types, see `libglitter_compose_double`
* for details about this function
*/
-void libglitter_compose_float(float **, const float *restrict, size_t, size_t,
- size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *);
+LIBGLITTER_GCC_ATTRS__(nonnull)
+void libglitter_compose_float(float *restrict*, const float *restrict, size_t, size_t,
+ size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *restrict);
/**
* Create one raster per monitor colour from a raster of
@@ -256,32 +278,36 @@ void libglitter_compose_float(float **, const float *restrict, size_t, size_t,
* @param render_ctx Rendering context created for the input raster's
* specification
*/
-void libglitter_compose_uint64(uint64_t **, const uint64_t *restrict, size_t, size_t,
- size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *);
+LIBGLITTER_GCC_ATTRS__(nonnull)
+void libglitter_compose_uint64(uint64_t *restrict *, const uint64_t *restrict, size_t, size_t,
+ size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *restrict);
/**
* This value is identical to `libglitter_compose_uint64`,
* apart from it parameter types, see `libglitter_compose_uint64`
* for details about this function
*/
-void libglitter_compose_uint32(uint32_t **, const uint32_t *restrict, size_t, size_t,
- size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *);
+LIBGLITTER_GCC_ATTRS__(nonnull)
+void libglitter_compose_uint32(uint32_t *restrict *, const uint32_t *restrict, size_t, size_t,
+ size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *restrict);
/**
* This value is identical to `libglitter_compose_uint64`,
* apart from it parameter types, see `libglitter_compose_uint64`
* for details about this function
*/
-void libglitter_compose_uint16(uint16_t **, const uint16_t *restrict, size_t, size_t,
- size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *);
+LIBGLITTER_GCC_ATTRS__(nonnull)
+void libglitter_compose_uint16(uint16_t *restrict *, const uint16_t *restrict, size_t, size_t,
+ size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *restrict);
/**
* This value is identical to `libglitter_compose_uint64`,
* apart from it parameter types, see `libglitter_compose_uint64`
* for details about this function
*/
-void libglitter_compose_uint8(uint8_t **, const uint8_t *restrict, size_t, size_t,
- size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *);
+LIBGLITTER_GCC_ATTRS__(nonnull)
+void libglitter_compose_uint8(uint8_t *restrict *, const uint8_t *restrict, size_t, size_t,
+ size_t, size_t, const LIBGLITTER_RENDER_CONTEXT *restrict);
/**
@@ -305,6 +331,7 @@ void libglitter_compose_uint8(uint8_t **, const uint8_t *restrict, size_t, size_
*
* The values `colour1`, `colour2`, `colour3` must be valid but distinct
*/
+LIBGLITTER_GCC_ATTRS__(nonnull)
void libglitter_reorder_rasters(void **, enum libglitter_colour, enum libglitter_colour, enum libglitter_colour);
@@ -322,6 +349,7 @@ void libglitter_reorder_rasters(void **, enum libglitter_colour, enum libglitter
* @param blue The value `0xFFFF` shifted such that value
* expresses pure blue (closest primary colour)
*/
+LIBGLITTER_GCC_ATTRS__(nonnull(1, 3))
void libglitter_split_uint64_raster(uint16_t *[3], uint16_t **, uint64_t *, uint64_t, uint64_t, uint64_t);
/**
@@ -338,6 +366,7 @@ void libglitter_split_uint64_raster(uint16_t *[3], uint16_t **, uint64_t *, uint
* @param blue The value `0xFF` shifted such that value
* expresses pure blue (closest primary colour)
*/
+LIBGLITTER_GCC_ATTRS__(nonnull(1, 3))
void libglitter_split_uint32_raster(uint8_t *[3], uint8_t **, uint32_t *, uint32_t, uint32_t, uint32_t);
@@ -365,14 +394,18 @@ void libglitter_split_uint32_raster(uint8_t *[3], uint8_t **, uint32_t *, uint32
* each subpixel colour; or `NULL` for the sRGB values
* (this is only allowed if there are exactly 3 rasters)
*/
-void libglitter_desaturate_double(double **, size_t, size_t, size_t, size_t, size_t, double, const double *restrict);
+LIBGLITTER_GCC_ATTRS__(nonnull(1))
+void libglitter_desaturate_double(double *restrict *, size_t, size_t, size_t, size_t, size_t,
+ double, const double *restrict);
/**
* This value is identical to `libglitter_desaturate_double`,
* apart from it parameter types, see `libglitter_desaturate_double`
* for details about this function
*/
-void libglitter_desaturate_float(float **, size_t, size_t, size_t, size_t, size_t, float, const float *restrict);
+LIBGLITTER_GCC_ATTRS__(nonnull(1))
+void libglitter_desaturate_float(float *restrict *, size_t, size_t, size_t, size_t, size_t,
+ float, const float *restrict);
/**
* Transform rasters from fully using subpixel rendering to
@@ -398,7 +431,8 @@ void libglitter_desaturate_float(float **, size_t, size_t, size_t, size_t, size_
* each subpixel colour; or `NULL` for the sRGB values
* (this is only allowed if there are exactly 3 rasters)
*/
-void libglitter_per_channel_desaturate_double(double **, size_t, size_t, size_t, size_t, size_t,
+LIBGLITTER_GCC_ATTRS__(nonnull(1, 7))
+void libglitter_per_channel_desaturate_double(double *restrict *, size_t, size_t, size_t, size_t, size_t,
const double *restrict, const double *restrict);
/**
@@ -406,7 +440,8 @@ void libglitter_per_channel_desaturate_double(double **, size_t, size_t, size_t,
* apart from it parameter types, see `libglitter_per_channel_desaturate_double`
* for details about this function
*/
-void libglitter_per_channel_desaturate_float(float **, size_t, size_t, size_t, size_t, size_t,
+LIBGLITTER_GCC_ATTRS__(nonnull(1, 7))
+void libglitter_per_channel_desaturate_float(float *restrict *, size_t, size_t, size_t, size_t, size_t,
const float *restrict, const float *restrict);
@@ -443,18 +478,20 @@ void libglitter_per_channel_desaturate_float(float **, size_t, size_t, size_t, s
* `white_x, white_y, white_Y` (it expands to three arguments)
* if the output's whitepoint is the D65 illuminant
*/
+LIBGLITTER_GCC_ATTRS__(nonnull(1))
void libglitter_get_colour_model_conversion_matrix_double(double[3][3], double, double, double, double,
double, double, double, double, double, int,
- double *, double *, double *);
+ double *restrict, double *restrict, double *restrict);
/**
* This value is identical to `libglitter_get_colour_model_conversion_matrix_double`,
* apart from it parameter types, see `libglitter_get_colour_model_conversion_matrix_double`
* for details about this function
*/
+LIBGLITTER_GCC_ATTRS__(nonnull(1))
void libglitter_get_colour_model_conversion_matrix_float(float[3][3], float, float, float, float,
float, float, float, float, float, int,
- float *, float *, float *);
+ float *restrict, float *restrict, float *restrict);
/**
@@ -486,17 +523,28 @@ void libglitter_get_colour_model_conversion_matrix_float(float[3][3], float, flo
* @param height The vertical number of pixels in the rasters
* @param matrix Colour model conversion matrix, in column-major order
*/
-void libglitter_colour_model_convert_rasters_double(size_t n, size_t m, double **, const double **, size_t,
- size_t, size_t, size_t, size_t, size_t, const double[m][n]);
+LIBGLITTER_GCC_ATTRS__(nonnull(3, 4, 11))
+void libglitter_colour_model_convert_rasters_double(size_t, size_t m, double *restrict *restrict,
+ const double *restrict *restrict, size_t, size_t,
+ size_t, size_t, size_t, size_t, const double (*)[m]);
/**
* This value is identical to `libglitter_colour_model_convert_rasters_double`,
* apart from it parameter types, see `libglitter_colour_model_convert_rasters_double`
* for details about this function
*/
-void libglitter_colour_model_convert_rasters_float(size_t n, size_t m, float **, const float **, size_t,
- size_t, size_t, size_t, size_t, size_t, const float[m][n]);
+LIBGLITTER_GCC_ATTRS__(nonnull(3, 4, 11))
+void libglitter_colour_model_convert_rasters_float(size_t, size_t m, float *restrict *restrict,
+ const float *restrict *restrict, size_t, size_t,
+ size_t, size_t, size_t, size_t, const float (*)[m]);
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic pop
+#elif defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
+#undef LIBGLITTER_GCC_ATTRS__
#endif
-/* TODO add `restrict` where appropriate */
diff --git a/libglitter_colour_model_convert_rasters_double.c b/libglitter_colour_model_convert_rasters_double.c
index 242a738..dcd9f47 100644
--- a/libglitter_colour_model_convert_rasters_double.c
+++ b/libglitter_colour_model_convert_rasters_double.c
@@ -4,7 +4,8 @@
static void
-multiply_33(double **outputs, size_t opos, const double **inputs, size_t ipos, const double matrix[3][3])
+multiply_33(double *restrict *restrict outputs, size_t opos,
+ const double *restrict *restrict inputs, size_t ipos, const double matrix[3][3])
{
double i0 = inputs[0][ipos], i1 = inputs[1][ipos], i2 = inputs[2][ipos];
outputs[0][opos] = i0 * matrix[0][0] + i1 * matrix[0][1] + i2 * matrix[0][2];
@@ -14,8 +15,9 @@ multiply_33(double **outputs, size_t opos, const double **inputs, size_t ipos, c
static void
-multiply_nn(size_t n, double **outputs, size_t opos, const double **inputs, size_t ipos,
- const double matrix[n][n], double buffer[n])
+multiply_nn(size_t n, double *restrict *restrict outputs, size_t opos,
+ const double *restrict *restrict inputs, size_t ipos,
+ const double matrix[n][n], double buffer[restrict n])
{
size_t i, j;
for (j = 0; j < n; j++)
@@ -29,8 +31,9 @@ multiply_nn(size_t n, double **outputs, size_t opos, const double **inputs, size
static void
-multiply_nm(size_t n, size_t m, double **outputs /* m */, size_t opos, const double **inputs /* n */,
- size_t ipos, const double matrix[m][n], double buffer[n])
+multiply_nm(size_t n, size_t m, double *restrict *restrict outputs /* m */, size_t opos,
+ const double *restrict *restrict inputs /* n */, size_t ipos,
+ const double matrix[m][n], double buffer[restrict n])
{
size_t i, j;
for (j = 0; j < n; j++)
@@ -44,9 +47,10 @@ multiply_nm(size_t n, size_t m, double **outputs /* m */, size_t opos, const dou
void
-libglitter_colour_model_convert_rasters_double(size_t n, size_t m, double **outputs /* m */, const double **inputs /* n */,
- size_t output_rowsize, size_t output_cellsize, size_t input_rowsize,
- size_t input_cellsize, size_t width, size_t height, const double matrix[m][n])
+libglitter_colour_model_convert_rasters_double(size_t n, size_t m, double *restrict *restrict outputs /* m */,
+ const double *restrict *restrict inputs /* n */, size_t output_rowsize,
+ size_t output_cellsize, size_t input_rowsize, size_t input_cellsize,
+ size_t width, size_t height, const double (*matrix)[m] /* n */)
{
size_t y, x, output_i, input_i, output_blanking, input_blanking;
double *buffer;
@@ -159,7 +163,7 @@ check(int same_rasters)
mat[i][j] = matrix[i][j];\
libglitter_colour_model_convert_rasters_double(NINPUTS, NOUTPUTS, outputs, (void *)inputs,\
same_rasters ? 15 : 14, same_rasters ? 3 : 4,\
- 15, 3, 5, 3, mat);\
+ 15, 3, 5, 3, (void *)mat);\
inputs[0] = input1;\
inputs[1] = input2;\
inputs[2] = input3;\
diff --git a/libglitter_compose_double.c b/libglitter_compose_double.c
index 0419f4a..8c5cfff 100644
--- a/libglitter_compose_double.c
+++ b/libglitter_compose_double.c
@@ -4,10 +4,10 @@
static void
-vstrips(double **outputs_, const double *restrict input, size_t output_rowsize, size_t output_cellsize,
+vstrips(double *restrict *outputs_, const double *restrict input, size_t output_rowsize, size_t output_cellsize,
size_t input_rowsize, size_t width, size_t height, const uint8_t *restrict cellmap)
{
- double *outputs[3];
+ double *restrict outputs[3];
size_t y, x, output_y, output_i, input_blanking;
outputs[0] = outputs_[cellmap[0]];
@@ -31,10 +31,10 @@ vstrips(double **outputs_, const double *restrict input, size_t output_rowsize,
static void
-hstrips(double **outputs_, const double *restrict input, size_t output_rowsize, size_t output_cellsize,
+hstrips(double *restrict *outputs_, const double *restrict input, size_t output_rowsize, size_t output_cellsize,
size_t input_rowsize, size_t width, size_t height, const uint8_t *restrict cellmap)
{
- double *outputs[3];
+ double *restrict outputs[3];
size_t y, x, output_y, output_i, input_blanking;
outputs[0] = outputs_[cellmap[0]];
@@ -61,7 +61,7 @@ hstrips(double **outputs_, const double *restrict input, size_t output_rowsize,
static void
-generic(double **outputs, size_t noutputs, const double *restrict input,
+generic(double *restrict *outputs, size_t noutputs, const double *restrict input,
size_t output_rowsize, size_t output_cellsize, size_t input_rowsize,
size_t width, size_t height, size_t widthmul, size_t heightmul,
const uint8_t *restrict cellmap, const double *restrict cellweights)
@@ -96,8 +96,8 @@ generic(double **outputs, size_t noutputs, const double *restrict input,
void
-libglitter_compose_double(double **outputs, const double *restrict input, size_t output_rowsize, size_t output_cellsize,
- size_t width, size_t height, const LIBGLITTER_RENDER_CONTEXT *render_ctx)
+libglitter_compose_double(double *restrict *outputs, const double *restrict input, size_t output_rowsize, size_t output_cellsize,
+ size_t width, size_t height, const LIBGLITTER_RENDER_CONTEXT *restrict render_ctx)
{
if (render_ctx->render_method == RENDER_METHOD_VSTRIPS) {
vstrips(outputs, input, output_rowsize, output_cellsize, render_ctx->rowsize, width, height, render_ctx->cellmap);
diff --git a/libglitter_compose_uint64.c b/libglitter_compose_uint64.c
index 323f10b..67ad096 100644
--- a/libglitter_compose_uint64.c
+++ b/libglitter_compose_uint64.c
@@ -14,8 +14,8 @@
static void
-simple(uint64_t **outputs, const uint64_t *restrict input, size_t output_rowsize, size_t output_cellsize,
- size_t input_rowsize, size_t width, size_t height, const LIBGLITTER_RENDER_CONTEXT *render_ctx)
+simple(uint64_t *restrict *outputs, const uint64_t *restrict input, size_t output_rowsize, size_t output_cellsize,
+ size_t input_rowsize, size_t width, size_t height, const LIBGLITTER_RENDER_CONTEXT *restrict render_ctx)
{
size_t y, x, output_y, output_i, input_blanking;
size_t cell00 = render_ctx->cells[0][0], cell01 = render_ctx->cells[0][1];
@@ -39,7 +39,7 @@ simple(uint64_t **outputs, const uint64_t *restrict input, size_t output_rowsize
static void
-generic(uint64_t **outputs, size_t noutputs, const uint64_t *restrict input,
+generic(uint64_t *restrict *outputs, size_t noutputs, const uint64_t *restrict input,
size_t output_rowsize, size_t output_cellsize, size_t input_rowsize,
size_t width, size_t height, size_t widthmul, size_t heightmul,
const uint8_t *restrict cellmap, const uint8_t *restrict ncellvalues)
@@ -77,8 +77,8 @@ generic(uint64_t **outputs, size_t noutputs, const uint64_t *restrict input,
void
-libglitter_compose_uint64(uint64_t **outputs, const uint64_t *restrict input, size_t output_rowsize, size_t output_cellsize,
- size_t width, size_t height, const LIBGLITTER_RENDER_CONTEXT *render_ctx)
+libglitter_compose_uint64(uint64_t *restrict *outputs, const uint64_t *restrict input, size_t output_rowsize, size_t output_cellsize,
+ size_t width, size_t height, const LIBGLITTER_RENDER_CONTEXT *restrict render_ctx)
{
if (render_ctx->render_method == RENDER_METHOD_VSTRIPS) {
vstrips(outputs, input, output_rowsize, output_cellsize, render_ctx->rowsize, width, height, render_ctx->cellmap);
diff --git a/libglitter_create_render_context.c b/libglitter_create_render_context.c
index 9dd7871..63ece5a 100644
--- a/libglitter_create_render_context.c
+++ b/libglitter_create_render_context.c
@@ -43,7 +43,8 @@ libglitter_create_render_context(size_t noutputs, size_t rowsize, size_t widthmu
return this;
fail:
- libglitter_free_render_context(this);
+ free(this->cellweights_double);
+ free(this);
return NULL;
}
diff --git a/libglitter_desaturate_double.c b/libglitter_desaturate_double.c
index 0797ddc..2b4c892 100644
--- a/libglitter_desaturate_double.c
+++ b/libglitter_desaturate_double.c
@@ -3,13 +3,8 @@
#ifndef TEST
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic ignored "-Wunsuffixed-float-constants"
-#endif
-
-
void
-libglitter_desaturate_double(double **rasters, size_t nrasters, size_t rowsize, size_t cellsize,
+libglitter_desaturate_double(double *restrict *rasters, size_t nrasters, size_t rowsize, size_t cellsize,
size_t width, size_t height, double saturation, const double *restrict primary_ys)
{
size_t y, x, ch, raster_y, raster_i;
@@ -58,6 +53,7 @@ main(void)
double rasters1[4 * 10 * 3][4], *rasters1list[4], primary_ys[4], saturation;
double rasters2[4 * 10 * 3][4], *rasters2list[4], saturations[4];
size_t i, j;
+ int randint;
void *randptr = malloc(1);
srand((unsigned int)(uintptr_t)randptr);
@@ -73,24 +69,27 @@ main(void)
for (i = 0; i < 4; i++) {\
rasters1list[i] = rasters1[i];\
rasters2list[i] = rasters2[i];\
- primary_ys[i] = rand() / (double)RAND_MAX;\
- for (j = 0; j < 4 * 10 * 3; j++)\
- rasters1[j][i] = rand() / (double)RAND_MAX;\
+ randint = rand();\
+ primary_ys[i] = (double)randint / (double)RAND_MAX;\
+ for (j = 0; j < 4 * 10 * 3; j++) {\
+ randint = rand();\
+ rasters1[j][i] = (double)randint / (double)RAND_MAX;\
+ }\
}\
memcpy(rasters2, rasters1, sizeof(rasters1));\
} while (0)
- RANDOMISE(rand() / (double)RAND_MAX);
+ RANDOMISE((double)(randint = rand(), randint) / (double)RAND_MAX);
libglitter_desaturate_double(rasters1list, 4, 10, 3, 7, 4, saturation, primary_ys);
libglitter_per_channel_desaturate_double(rasters2list, 4, 10, 3, 7, 4, saturations, primary_ys);
ASSERT(!memcmp(rasters1, rasters2, sizeof(rasters1)));
- RANDOMISE(rand() / (double)RAND_MAX);
+ RANDOMISE((double)(randint = rand(), randint) / (double)RAND_MAX);
libglitter_desaturate_double(rasters1list, 3, 10, 3, 7, 4, saturation, primary_ys);
libglitter_per_channel_desaturate_double(rasters2list, 3, 10, 3, 7, 4, saturations, primary_ys);
ASSERT(!memcmp(rasters1, rasters2, sizeof(rasters1)));
- RANDOMISE(rand() / (double)RAND_MAX);
+ RANDOMISE((double)(randint = rand(), randint) / (double)RAND_MAX);
libglitter_desaturate_double(rasters1list, 3, 10, 3, 7, 4, saturation, NULL);
libglitter_per_channel_desaturate_double(rasters2list, 3, 10, 3, 7, 4, saturations, NULL);
ASSERT(!memcmp(rasters1, rasters2, sizeof(rasters1)));
diff --git a/libglitter_enable_acceleration.c b/libglitter_enable_acceleration.c
index 5539116..bfa7929 100644
--- a/libglitter_enable_acceleration.c
+++ b/libglitter_enable_acceleration.c
@@ -45,31 +45,33 @@ callback_null(int ret, int err, void *user)
int
main(void)
{
+#define ALL (~UINT64_C(0))
+
char data = 'u';
ASSERT(!libglitter_enable_acceleration(0, 0, NULL, NULL, NULL));
ASSERT(!libglitter_enable_acceleration(0, 1, NULL, NULL, NULL));
- ASSERT(!libglitter_enable_acceleration(~0, 0, NULL, NULL, NULL));
- ASSERT(!libglitter_enable_acceleration(~0, 1, NULL, NULL, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 0, NULL, NULL, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 1, NULL, NULL, NULL));
ASSERT(!libglitter_enable_acceleration(0, 0, NULL, &data, NULL));
ASSERT(!libglitter_enable_acceleration(0, 1, NULL, &data, NULL));
- ASSERT(!libglitter_enable_acceleration(~0, 0, NULL, &data, NULL));
- ASSERT(!libglitter_enable_acceleration(~0, 1, NULL, &data, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 0, NULL, &data, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 1, NULL, &data, NULL));
ASSERT(callback_calls == 0);
ASSERT(!libglitter_enable_acceleration(0, 0, callback, &data, NULL));
ASSERT(callback_calls == 1);
ASSERT(!libglitter_enable_acceleration(0, 1, callback, &data, NULL));
ASSERT(callback_calls == 2);
- ASSERT(!libglitter_enable_acceleration(~0, 0, callback, &data, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 0, callback, &data, NULL));
ASSERT(callback_calls == 3);
- ASSERT(!libglitter_enable_acceleration(~0, 1, callback, &data, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 1, callback, &data, NULL));
ASSERT(callback_calls == 4);
ASSERT(!libglitter_enable_acceleration(0, 0, callback_null, NULL, NULL));
ASSERT(callback_calls == 5);
ASSERT(!libglitter_enable_acceleration(0, 1, callback_null, NULL, NULL));
ASSERT(callback_calls == 6);
- ASSERT(!libglitter_enable_acceleration(~0, 0, callback_null, NULL, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 0, callback_null, NULL, NULL));
ASSERT(callback_calls == 7);
- ASSERT(!libglitter_enable_acceleration(~0, 1, callback_null, NULL, NULL));
+ ASSERT(!libglitter_enable_acceleration(ALL, 1, callback_null, NULL, NULL));
ASSERT(callback_calls == 8);
return 0;
}
diff --git a/libglitter_get_colour_model_conversion_matrix_double.c b/libglitter_get_colour_model_conversion_matrix_double.c
index 13ae07b..127ae10 100644
--- a/libglitter_get_colour_model_conversion_matrix_double.c
+++ b/libglitter_get_colour_model_conversion_matrix_double.c
@@ -3,12 +3,6 @@
#ifndef TEST
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wunsuffixed-float-constants"
-#endif
-
-
/**
* CIE XYZ-to-sRGB conversion matrix,
* in column-major order
@@ -19,11 +13,6 @@ static const double srgb[3][3] = {
{-0.498530193022728773666329971093, 0.041556042214430065351304932619, 1.057226567722703292062647051353}};
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic pop
-#endif
-
-
static void
eliminate(double m[3][4]) /* row-major order */
{
@@ -45,10 +34,9 @@ eliminate(double m[3][4]) /* row-major order */
void
-libglitter_get_colour_model_conversion_matrix_double(double matrix[3][3], double c1x, double c1y,
- double c2x, double c2y, double c3x, double c3y,
- double white_x, double white_y, double white_Y,
- int xyz, double *c1Yp, double *c2Yp, double *c3Yp)
+libglitter_get_colour_model_conversion_matrix_double(double matrix[3][3], double c1x, double c1y, double c2x, double c2y,
+ double c3x, double c3y, double white_x, double white_y, double white_Y,
+ int xyz, double *restrict c1Yp, double *restrict c2Yp, double *restrict c3Yp)
{
double mat[3][4];
double x1, x2, x3;
@@ -116,7 +104,6 @@ libglitter_get_colour_model_conversion_matrix_double(double matrix[3][3], double
#define TOLERANCE 0.0001
-#define TOL 4
#define RX 0.412457445582367576708548995157
#define GX 0.357575865245515878143578447634
diff --git a/libglitter_per_channel_desaturate_double.c b/libglitter_per_channel_desaturate_double.c
index a9bafb9..85282b6 100644
--- a/libglitter_per_channel_desaturate_double.c
+++ b/libglitter_per_channel_desaturate_double.c
@@ -3,13 +3,8 @@
#ifndef TEST
-#if defined(__GNUC__) && !defined(__clang__)
-# pragma GCC diagnostic ignored "-Wunsuffixed-float-constants"
-#endif
-
-
void
-libglitter_per_channel_desaturate_double(double **rasters, size_t nrasters, size_t rowsize, size_t cellsize,
+libglitter_per_channel_desaturate_double(double *restrict *rasters, size_t nrasters, size_t rowsize, size_t cellsize,
size_t width, size_t height, const double *restrict saturations,
const double *restrict primary_ys)
{
@@ -54,7 +49,6 @@ libglitter_per_channel_desaturate_double(double **rasters, size_t nrasters, size
#define TOLERANCE 0.0001
-#define TOL 4
#define RY 0.212673370378408277403536885686
#define GY 0.715151730491031756287156895269
diff --git a/libglitter_split_uint64_raster.c b/libglitter_split_uint64_raster.c
index 75ec90b..bdcd427 100644
--- a/libglitter_split_uint64_raster.c
+++ b/libglitter_split_uint64_raster.c
@@ -38,15 +38,15 @@ libglitter_split_uint64_raster(uint16_t *rasters[3], uint16_t **alphap, uint64_t
static void
check(int with_alpha, int r, int g, int b, int a)
{
- int red_shift = r * sizeof(uint16_t) * 8;
- int green_shift = g * sizeof(uint16_t) * 8;
- int blue_shift = b * sizeof(uint16_t) * 8;
- int alpha_shift = a * sizeof(uint16_t) * 8;
- uint16_t full = ~(uint16_t)0;
- uint16_t red = (uint16_t)~0 / (uint16_t)0xF * (uint16_t)0x5;
- uint16_t green = (uint16_t)~0 / (uint16_t)0xF * (uint16_t)0x8;
- uint16_t blue = (uint16_t)~0 / (uint16_t)0xF * (uint16_t)0xA;
- uint16_t alpha = (uint16_t)~0 / (uint16_t)0xF * (uint16_t)0x9;
+ int red_shift = r * (int)sizeof(uint16_t) * 8;
+ int green_shift = g * (int)sizeof(uint16_t) * 8;
+ int blue_shift = b * (int)sizeof(uint16_t) * 8;
+ int alpha_shift = a * (int)sizeof(uint16_t) * 8;
+ uint16_t full = (uint16_t)~0U;
+ uint16_t red = (uint16_t)~0U / (uint16_t)0xF * (uint16_t)0x5;
+ uint16_t green = (uint16_t)~0U / (uint16_t)0xF * (uint16_t)0x8;
+ uint16_t blue = (uint16_t)~0U / (uint16_t)0xF * (uint16_t)0xA;
+ uint16_t alpha = (uint16_t)~0U / (uint16_t)0xF * (uint16_t)0x9;
uint64_t red_mask = (uint64_t)red << red_shift;
uint64_t green_mask = (uint64_t)green << green_shift;
uint64_t blue_mask = (uint64_t)blue << blue_shift;