comparison src/of-communications-1-catop.patch @ 5515:d46a116f2c8d

* src/of-communications-1-catop.patch: New file.
author John W. Eaton <jwe@octave.org>
date Tue, 25 Aug 2020 15:05:59 -0400
parents
children
comparison
equal deleted inserted replaced
5514:d3a47a9a1413 5515:d46a116f2c8d
1 diff -uNr a/src/config.h.in b/src/config.h.in
2 --- a/src/config.h.in 2020-01-04 12:50:13.541197341 -0500
3 +++ b/src/config.h.in 2020-08-25 14:50:29.000000000 -0400
4 @@ -26,6 +26,9 @@
5 /* Define to 1 if you have the <octave/errwarn.h> header file. */
6 #undef HAVE_OCTAVE_ERRWARN_H
7
8 +/* Define if first catop function argument is const-qualified */
9 +#undef HAVE_OCTAVE_FIRST_CATOP_ARG_CONST
10 +
11 /* Define to 1 if you have the <octave/gripes.h> header file. */
12 #undef HAVE_OCTAVE_GRIPES_H
13
14 diff -uNr a/src/configure b/src/configure
15 --- a/src/configure 2020-01-04 12:50:13.249198461 -0500
16 +++ b/src/configure 2020-08-25 13:48:13.000000000 -0400
17 @@ -4083,6 +4083,63 @@
18
19 fi
20
21 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether first catop function argument is const-qualified" >&5
22 +$as_echo_n "checking whether first catop function argument is const-qualified... " >&6; }
23 +if ${comm_cv_octave_first_catop_fcn_arg_const_qualified+:} false; then :
24 + $as_echo_n "(cached) " >&6
25 +else
26 + comm_save_CPPFLAGS=$CPPFLAGS
27 + comm_save_CXXFLAGS=$CXXFLAGS
28 + CPPFLAGS="$CPPFLAGS $HDF5_CFLAGS"
29 + CXXFLAGS="$CXXFLAGS $comm_CXXFLAGS"
30 + ac_ext=cpp
31 +ac_cpp='$CXXCPP $CPPFLAGS'
32 +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
33 +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
34 +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
35 +
36 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
37 +/* end confdefs.h. */
38 +
39 + #include <octave/oct.h>
40 + #include <octave/ov-typeinfo.h>
41 +
42 +int
43 +main ()
44 +{
45 +
46 + octave_value foobar_fcn (const octave_base_value&,
47 + const octave_base_value&,
48 + const Array<octave_idx_type>& ra_idx);
49 + octave::type_info::cat_op_fcn fcn = foobar_fcn;
50 +
51 + ;
52 + return 0;
53 +}
54 +_ACEOF
55 +if ac_fn_cxx_try_compile "$LINENO"; then :
56 + comm_cv_octave_first_catop_fcn_arg_const_qualified=yes
57 +else
58 + comm_cv_octave_first_catop_fcn_arg_const_qualified=no
59 +fi
60 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
61 + ac_ext=cpp
62 +ac_cpp='$CXXCPP $CPPFLAGS'
63 +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
64 +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
65 +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
66 +
67 + CPPFLAGS=$comm_save_CPPFLAGS
68 + CXXFLAGS=$comm_save_CXXFLAGS
69 +fi
70 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $comm_cv_octave_first_catop_fcn_arg_const_qualified" >&5
71 +$as_echo "$comm_cv_octave_first_catop_fcn_arg_const_qualified" >&6; }
72 +if test $comm_cv_octave_first_catop_fcn_arg_const_qualified = yes; then
73 +
74 +$as_echo "#define HAVE_OCTAVE_FIRST_CATOP_ARG_CONST 1" >>confdefs.h
75 +
76 +fi
77 +
78 ac_config_files="$ac_config_files Makefile"
79
80 cat >confcache <<\_ACEOF
81 diff -uNr a/src/configure.ac b/src/configure.ac
82 --- a/src/configure.ac 2020-01-04 12:49:06.000000000 -0500
83 +++ b/src/configure.ac 2020-08-25 13:47:59.000000000 -0400
84 @@ -252,5 +252,30 @@
85 AC_DEFINE([HAVE_OCTAVE_BASE_VALUE_PRINT_CONST],[1],[Define if octave_base_value::print is const-qualified])
86 fi
87
88 +AC_CACHE_CHECK([whether first catop function argument is const-qualified],
89 + [comm_cv_octave_first_catop_fcn_arg_const_qualified],
90 + [comm_save_CPPFLAGS=$CPPFLAGS
91 + comm_save_CXXFLAGS=$CXXFLAGS
92 + CPPFLAGS="$CPPFLAGS $HDF5_CFLAGS"
93 + CXXFLAGS="$CXXFLAGS $comm_CXXFLAGS"
94 + AC_LANG_PUSH(C++)
95 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
96 + #include <octave/oct.h>
97 + #include <octave/ov-typeinfo.h>
98 + ]], [[
99 + octave_value foobar_fcn (const octave_base_value&,
100 + const octave_base_value&,
101 + const Array<octave_idx_type>& ra_idx);
102 + octave::type_info::cat_op_fcn fcn = foobar_fcn;
103 + ]])],
104 + [comm_cv_octave_first_catop_fcn_arg_const_qualified=yes],
105 + [comm_cv_octave_first_catop_fcn_arg_const_qualified=no])
106 + AC_LANG_POP(C++)
107 + CPPFLAGS=$comm_save_CPPFLAGS
108 + CXXFLAGS=$comm_save_CXXFLAGS])
109 +if test $comm_cv_octave_first_catop_fcn_arg_const_qualified = yes; then
110 + AC_DEFINE([HAVE_OCTAVE_FIRST_CATOP_ARG_CONST],[1],[Define if first catop function argument is const-qualified])
111 +fi
112 +
113 AC_CONFIG_FILES([Makefile])
114 AC_OUTPUT
115 diff -uNr a/src/galois-ops.h b/src/galois-ops.h
116 --- a/src/galois-ops.h 2020-01-04 12:49:06.000000000 -0500
117 +++ b/src/galois-ops.h 2020-08-25 14:00:18.000000000 -0400
118 @@ -40,11 +40,19 @@
119 #endif
120
121 #if ! defined (CATOPDECL)
122 -# define CATOPDECL(name, a1, a2) \
123 +# if defined (HAVE_OCTAVE_FIRST_CATOP_ARG_CONST)
124 +# define CATOPDECL(name, a1, a2) \
125 + static octave_value \
126 + CONCAT2(oct_catop_, name) (const octave_base_value& a1, \
127 + const octave_base_value& a2, \
128 + const Array<octave_idx_type>& ra_idx)
129 +# else
130 +# define CATOPDECL(name, a1, a2) \
131 static octave_value \
132 CONCAT2(oct_catop_, name) (octave_base_value& a1, \
133 const octave_base_value& a2, \
134 const Array<octave_idx_type>& ra_idx)
135 +# endif
136 #endif
137
138 // Override the operator and function definition defines from Octave
139 @@ -124,7 +132,24 @@
140 return new octave_galois (f (v1.t1 ## _value (), v2.matrix_value ())); \
141 }
142
143 -#define DEFCATOP_G_FN(name, t1, t2, f) \
144 +#if defined (HAVE_OCTAVE_FIRST_CATOP_ARG_CONST)
145 +# define DEFCATOP_G_FN(name, t1, t2, f) \
146 + CATOPDECL (name, a1, a2) \
147 + { \
148 + CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
149 + return new octave_galois (f (v1.t1 ## _value (), v2.t2 ## _value (), \
150 + ra_idx)); \
151 + }
152 +
153 +#define DEFCATOP_G_METHOD(name, t1, t2, f) \
154 + CATOPDECL (name, a1, a2) \
155 + { \
156 + CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
157 + return new octave_galois (v1.t1 ## _value (). f (v2.t2 ## _value (), \
158 + ra_idx)); \
159 + }
160 +#else
161 +# define DEFCATOP_G_FN(name, t1, t2, f) \
162 CATOPDECL (name, a1, a2) \
163 { \
164 CAST_BINOP_ARGS (octave_ ## t1&, const octave_ ## t2&); \
165 @@ -139,6 +164,7 @@
166 return new octave_galois (v1.t1 ## _value (). f (v2.t2 ## _value (), \
167 ra_idx)); \
168 }
169 +#endif
170
171 #define INSTALL_G_CATOP(t1, t2, f) INSTALL_CATOP (t1, t2, f)
172
173 diff -uNr a/src/op-gm-s.cc b/src/op-gm-s.cc
174 --- a/src/op-gm-s.cc 2020-01-04 12:49:06.000000000 -0500
175 +++ b/src/op-gm-s.cc 2020-08-25 13:50:19.000000000 -0400
176 @@ -68,7 +68,11 @@
177
178 DEFCATOP (gm_s, galois, scalar)
179 {
180 +#if defined (HAVE_OCTAVE_FIRST_CATOP_ARG_CONST)
181 + CAST_BINOP_ARGS (const octave_galois&, const octave_scalar&);
182 +#else
183 CAST_BINOP_ARGS (octave_galois&, const octave_scalar&);
184 +#endif
185 return new octave_galois (v1.galois_value (). concat (v2.matrix_value (),
186 ra_idx));
187 }
188 diff -uNr a/src/op-s-gm.cc b/src/op-s-gm.cc
189 --- a/src/op-s-gm.cc 2020-01-04 12:49:06.000000000 -0500
190 +++ b/src/op-s-gm.cc 2020-08-25 14:51:01.000000000 -0400
191 @@ -81,7 +81,11 @@
192
193 DEFCATOP (s_gm, scalar, galois)
194 {
195 +#if defined (HAVE_OCTAVE_FIRST_CATOP_ARG_CONST)
196 + CAST_BINOP_ARGS (const octave_scalar&, const octave_galois&);
197 +#else
198 CAST_BINOP_ARGS (octave_scalar&, const octave_galois&);
199 +#endif
200 return new octave_galois (concat (v1.matrix_value (), v2.galois_value (),
201 ra_idx));
202 }