[goffice] GOQuad: don't try to change const objects.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOQuad: don't try to change const objects.
- Date: Sun, 17 May 2015 23:30:02 +0000 (UTC)
commit 3c41c93fd72129621eb329b131f18bdb6e2b190b
Author: Morten Welinder <terra gnome org>
Date: Sun May 17 19:29:24 2015 -0400
GOQuad: don't try to change const objects.
That's naughty.
ChangeLog | 5 +++++
NEWS | 1 +
goffice/math/go-quad.c | 31 +++++++++++++++++++------------
goffice/math/go-quad.h | 28 ++++++++++++++++------------
4 files changed, 41 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a04c67f..0a5a4ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-17 Morten Welinder <terra gnome org>
+
+ * goffice/math/go-quad.c (go_quad_start): Initialize constants via
+ non-const objects. See bug #749463.
+
2015-05-16 Morten Welinder <terra gnome org>
* goffice/graph/gog-theme.c (theme_load_from_uri): Avoid double
diff --git a/NEWS b/NEWS
index a7aaa3c..8a460d9 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Morten:
* Fix ABR [#749167]
* Shield Cairo from image sizes it cannot handle. [#749274]
* Plug leak. [#749395]
+ * Portability problem affecting macs. [#749463]
--------------------------------------------------------------------------
goffice 0.10.22:
diff --git a/goffice/math/go-quad.c b/goffice/math/go-quad.c
index fa54e58..7bfe964 100644
--- a/goffice/math/go-quad.c
+++ b/goffice/math/go-quad.c
@@ -31,6 +31,8 @@
* Note: the compiler should not rearrange expressions.
*/
+#define GO_QUAD_IMPL
+
#include <goffice/goffice-config.h>
#include <goffice/goffice.h>
#include <math.h>
@@ -209,37 +211,37 @@ SUFFIX(go_quad_start) (void)
if (first) {
first = FALSE;
SUFFIX(CST) = 1 + SUFFIX(ldexp) (1.0, (DOUBLE_MANT_DIG + 1) / 2);
- SUFFIX(go_quad_constant8) ((QUAD *)&SUFFIX(go_quad_pi),
+ SUFFIX(go_quad_constant8) (&SUFFIX(go_quad_pi),
pi_hex_digits,
G_N_ELEMENTS (pi_hex_digits),
256.0,
256.0);
- SUFFIX(go_quad_constant8) ((QUAD *)&SUFFIX(go_quad_2pi),
+ SUFFIX(go_quad_constant8) (&SUFFIX(go_quad_2pi),
pi_hex_digits,
G_N_ELEMENTS (pi_hex_digits),
256.0,
512.0);
- SUFFIX(go_quad_constant8) ((QUAD *)&SUFFIX(go_quad_e),
+ SUFFIX(go_quad_constant8) (&SUFFIX(go_quad_e),
e_hex_digits,
G_N_ELEMENTS (e_hex_digits),
256.0,
256.0);
- SUFFIX(go_quad_constant8) ((QUAD *)&SUFFIX(go_quad_ln2),
+ SUFFIX(go_quad_constant8) (&SUFFIX(go_quad_ln2),
ln2_hex_digits,
G_N_ELEMENTS (ln2_hex_digits),
256.0,
1);
- SUFFIX(go_quad_constant8) ((QUAD *)&SUFFIX(go_quad_sqrt2),
+ SUFFIX(go_quad_constant8) (&SUFFIX(go_quad_sqrt2),
sqrt2_hex_digits,
G_N_ELEMENTS (sqrt2_hex_digits),
256.0,
256.0);
- SUFFIX(go_quad_constant8) ((QUAD *)&SUFFIX(go_quad_euler),
+ SUFFIX(go_quad_constant8) (&SUFFIX(go_quad_euler),
euler_hex_digits,
G_N_ELEMENTS (euler_hex_digits),
256.0,
@@ -273,12 +275,17 @@ SUFFIX(go_quad_end) (void *state)
const QUAD SUFFIX(go_quad_zero) = { 0, 0 };
const QUAD SUFFIX(go_quad_one) = { 1, 0 };
-const QUAD SUFFIX(go_quad_pi);
-const QUAD SUFFIX(go_quad_2pi);
-const QUAD SUFFIX(go_quad_e);
-const QUAD SUFFIX(go_quad_ln2);
-const QUAD SUFFIX(go_quad_sqrt2);
-const QUAD SUFFIX(go_quad_euler);
+/*
+ * The following are non-const so we can initialize them. However,
+ * from other compilation units there are const. My reading of C99
+ * Section 6.2.7 says that is allowed.
+ */
+QUAD SUFFIX(go_quad_pi);
+QUAD SUFFIX(go_quad_2pi);
+QUAD SUFFIX(go_quad_e);
+QUAD SUFFIX(go_quad_ln2);
+QUAD SUFFIX(go_quad_sqrt2);
+QUAD SUFFIX(go_quad_euler);
/**
* go_quad_init: (skip)
diff --git a/goffice/math/go-quad.h b/goffice/math/go-quad.h
index 2f7240f..3f729ce 100644
--- a/goffice/math/go-quad.h
+++ b/goffice/math/go-quad.h
@@ -44,14 +44,18 @@ void go_quad_dot_product (GOQuad *res, const GOQuad *a, const GOQuad *b, int n);
void go_quad_constant8 (GOQuad *res, const guint8 *data, gsize n, double base, double scale);
+#ifndef GO_QUAD_IMPL
+#define GO_QUAD_IMPL const
+#endif
+
GO_VAR_DECL const GOQuad go_quad_zero;
GO_VAR_DECL const GOQuad go_quad_one;
-GO_VAR_DECL const GOQuad go_quad_pi;
-GO_VAR_DECL const GOQuad go_quad_2pi;
-GO_VAR_DECL const GOQuad go_quad_e;
-GO_VAR_DECL const GOQuad go_quad_ln2;
-GO_VAR_DECL const GOQuad go_quad_sqrt2;
-GO_VAR_DECL const GOQuad go_quad_euler;
+GO_VAR_DECL GO_QUAD_IMPL GOQuad go_quad_pi;
+GO_VAR_DECL GO_QUAD_IMPL GOQuad go_quad_2pi;
+GO_VAR_DECL GO_QUAD_IMPL GOQuad go_quad_e;
+GO_VAR_DECL GO_QUAD_IMPL GOQuad go_quad_ln2;
+GO_VAR_DECL GO_QUAD_IMPL GOQuad go_quad_sqrt2;
+GO_VAR_DECL GO_QUAD_IMPL GOQuad go_quad_euler;
#ifdef GOFFICE_WITH_LONG_DOUBLE
struct GOQuadl_ {
@@ -96,12 +100,12 @@ void go_quad_constant8l (GOQuadl *res, const guint8 *data, gsize n, long double
GO_VAR_DECL const GOQuadl go_quad_zerol;
GO_VAR_DECL const GOQuadl go_quad_onel;
-GO_VAR_DECL const GOQuadl go_quad_pil;
-GO_VAR_DECL const GOQuadl go_quad_2pil;
-GO_VAR_DECL const GOQuadl go_quad_el;
-GO_VAR_DECL const GOQuadl go_quad_ln2l;
-GO_VAR_DECL const GOQuadl go_quad_sqrt2l;
-GO_VAR_DECL const GOQuadl go_quad_eulerl;
+GO_VAR_DECL GO_QUAD_IMPL GOQuadl go_quad_pil;
+GO_VAR_DECL GO_QUAD_IMPL GOQuadl go_quad_2pil;
+GO_VAR_DECL GO_QUAD_IMPL GOQuadl go_quad_el;
+GO_VAR_DECL GO_QUAD_IMPL GOQuadl go_quad_ln2l;
+GO_VAR_DECL GO_QUAD_IMPL GOQuadl go_quad_sqrt2l;
+GO_VAR_DECL GO_QUAD_IMPL GOQuadl go_quad_eulerl;
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]