1 |
commit: eb546c52164f64a28f7747a6aa4d2337eb135c5d |
2 |
Author: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com> |
3 |
AuthorDate: Sat Oct 30 19:25:29 2021 +0000 |
4 |
Commit: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com> |
5 |
CommitDate: Sat Oct 30 19:37:44 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=eb546c52 |
7 |
|
8 |
sci-libs/saclib: add stuff from qepcad bundled saclib to saclib |
9 |
|
10 |
Signed-off-by: Alessandro Barbieri <lssndrbarbieri <AT> gmail.com> |
11 |
|
12 |
sci-libs/saclib/files/makefile.patch | 12 +- |
13 |
sci-libs/saclib/files/qepcad-compat.patch | 228 ++++++++++++++++++++++++++++++ |
14 |
sci-libs/saclib/saclib-2.2.8.ebuild | 9 +- |
15 |
3 files changed, 239 insertions(+), 10 deletions(-) |
16 |
|
17 |
diff --git a/sci-libs/saclib/files/makefile.patch b/sci-libs/saclib/files/makefile.patch |
18 |
index bc49d0b62..e77576ccb 100644 |
19 |
--- a/sci-libs/saclib/files/makefile.patch |
20 |
+++ b/sci-libs/saclib/files/makefile.patch |
21 |
@@ -1,6 +1,5 @@ |
22 |
-diff -ur a/bin/mklib b/bin/mklib |
23 |
---- a/bin/mklib 2018-01-30 22:09:32.000000000 +0100 |
24 |
-+++ b/bin/mklib 2020-04-28 21:03:24.823472623 +0200 |
25 |
+--- a/bin/mklib |
26 |
++++ b/bin/mklib |
27 |
@@ -2,31 +2,17 @@ |
28 |
|
29 |
# USAGE: |
30 |
@@ -77,9 +76,8 @@ diff -ur a/bin/mklib b/bin/mklib |
31 |
popd >/dev/null |
32 |
pushd >/dev/null $saclib/lib/objo |
33 |
make CC=$CC "SACFLAG=" EXTENSION=o |
34 |
-diff -ur a/bin/mkmake b/bin/mkmake |
35 |
---- a/bin/mkmake 2018-01-30 22:09:32.000000000 +0100 |
36 |
-+++ b/bin/mkmake 2020-04-28 21:29:02.709088176 +0200 |
37 |
+--- a/bin/mkmake |
38 |
++++ b/bin/mkmake |
39 |
@@ -25,20 +25,16 @@ |
40 |
# E.g. if <flag> is -g and <character> is d, the library will be |
41 |
# compiled with the debug option set and the library name will be |
42 |
@@ -126,7 +124,7 @@ diff -ur a/bin/mkmake b/bin/mkmake |
43 |
-# ${AR} ts ${TARGET} |
44 |
-# Use "ranlib" if your system's "ar" does not have the option "s". |
45 |
- ${RANLIB} ${TARGET} |
46 |
-+ $(CC) ${OBJS1} ${OBJS2a} ${OBJS2b} ${OBJS3} ${OBJS4} -fPIC -shared ${CFLAGS} -o $@ ${LDFLAGS} -Wl,-soname,${FULLLIBNAME} |
47 |
++ $(CXX) ${OBJS1} ${OBJS2a} ${OBJS2b} ${OBJS3} ${OBJS4} ${saclib}/src/gcword.cc -I${saclib}/include -I${saclib}/src -fPIC -shared ${CXXFLAGS} -o $@ ${LDFLAGS} -Wl,-soname,${FULLLIBNAME} |
48 |
@echo "Created '${TARGET}'." |
49 |
|
50 |
EOF |
51 |
|
52 |
diff --git a/sci-libs/saclib/files/qepcad-compat.patch b/sci-libs/saclib/files/qepcad-compat.patch |
53 |
new file mode 100644 |
54 |
index 000000000..ab4700d1f |
55 |
--- /dev/null |
56 |
+++ b/sci-libs/saclib/files/qepcad-compat.patch |
57 |
@@ -0,0 +1,228 @@ |
58 |
+--- saclib2.2.8-orig/src/FAIL.c |
59 |
++++ saclib2.2.8/src/FAIL.c |
60 |
+@@ -1,7 +1,10 @@ |
61 |
+ /*====================================================================== |
62 |
+ FAIL(algName,msg,...) |
63 |
+ |
64 |
+-Failure handler. |
65 |
++Failure handler. |
66 |
++** REDEFINED FOR QEPCAD! QepcadB needs to, potentially, kill some child |
67 |
++** processes. That's what this adds. A better long-term solution is to |
68 |
++** change Saclib's FAIL to add an analogue to "atexit". |
69 |
+ |
70 |
+ Inputs |
71 |
+ algName : the name of the algorithm which called this algorithm. |
72 |
+@@ -20,12 +23,13 @@ |
73 |
+ #ifdef __STDC__ |
74 |
+ void FAIL(const char *algName, const char *msg,...) |
75 |
+ #else |
76 |
+-void FAIL(algName,msg) __noreturn |
77 |
++void FAIL(algName,msg) |
78 |
+ const char *algName; |
79 |
+ const char *msg; |
80 |
+ #endif |
81 |
+ { |
82 |
+ va_list argPtr; |
83 |
++ // extern int strcmp(); |
84 |
+ |
85 |
+ Step1: /* Basic message. */ |
86 |
+ SWRITE("\n\n"); |
87 |
+@@ -187,10 +191,16 @@ |
88 |
+ goto Abort; |
89 |
+ } |
90 |
+ |
91 |
++ /* TIMEOUT */ |
92 |
++ if (!strcmp(algName,"TIMEOUT")) { |
93 |
++ goto Exit; |
94 |
++ } |
95 |
++ |
96 |
+ Abort: /* Prepare for abort. */ |
97 |
+ SWRITE("\n\nNow the FAIL handler is aborting the program ...\n"); |
98 |
+ va_end(argPtr); |
99 |
+- abort(); |
100 |
++ //abort(); |
101 |
++ exit(2); |
102 |
+ |
103 |
+ Exit: /* Prepare for exit. */ |
104 |
+ SWRITE("\n\nNow the FAIL handler is exiting the program ...\n"); |
105 |
+--- saclib2.2.8-orig/src/GCSI.c |
106 |
++++ saclib2.2.8/src/GCSI.c |
107 |
+@@ -16,17 +16,19 @@ |
108 |
+ occurs. |
109 |
+ ======================================================================*/ |
110 |
+ #include "saclib.h" |
111 |
++extern void gcw_MARK(); |
112 |
+ |
113 |
+ void GCSI(s,EACSTACK) |
114 |
+ Word s; |
115 |
+ char *EACSTACK; |
116 |
+ { |
117 |
+- Word I,L,N,N1,Np,Np1,T,T1,c,inc; |
118 |
++ Word I,L,N,N1,Np,Np1,T,T1,c,**i,j,inc; |
119 |
+ char *a; |
120 |
+- /* hide I,L,N,N1,Np,Np1,T,T1,c,inc,a; */ |
121 |
++ GCArray *v; |
122 |
++ /* hide I,L,N,N1,Np,Np1,T,T1,c,i,j,inc,a,v; */ |
123 |
+ |
124 |
+ Step1: /* Setup. */ |
125 |
+- if (GCM == 1) { |
126 |
++ if (GCM == 1) { |
127 |
+ SWRITE("\nThe "); GWRITE(GCC+1); |
128 |
+ SWRITE("--th garbage collection....\n"); |
129 |
+ } |
130 |
+@@ -48,17 +50,8 @@ |
131 |
+ L = I; |
132 |
+ } |
133 |
+ |
134 |
+-/* Step3: /\* Mark the global variables. *\/ */ |
135 |
+-/* L = GCGLOBALS; */ |
136 |
+-/* while (L != NIL) { */ |
137 |
+-/* c = *(PTRFIRST(L)); */ |
138 |
+-/* if ((ISLIST(c) || ISGCA(c)) && !ISNIL(c)) MARK(c); */ |
139 |
+-/* #if __WORDSIZE == 64 */ |
140 |
+-/* L = -RED(L); L = -RED(L); L = -RED(L); L = -RED(L); */ |
141 |
+-/* #else /\* Assumes 32-bit pointers. *\/ */ |
142 |
+-/* L = -RED(L); L = -RED(L); */ |
143 |
+-/* #endif */ |
144 |
+-/* } */ |
145 |
++Step3b: /* Mark the GCWord variables. */ |
146 |
++ gcw_MARK(); |
147 |
+ |
148 |
+ Step4: /* Mark the cells accessible from the system stack. */ |
149 |
+ if (((BACSTACK - EACSTACK) % s) != 0) |
150 |
+@@ -113,7 +106,7 @@ |
151 |
+ |
152 |
+ Step8: /* Optional report. */ |
153 |
+ if (GCM == 1 || N <= NU / RHO) { |
154 |
+- SWRITE("** "); |
155 |
++ SWRITE("\n** "); |
156 |
+ GWRITE(N); SWRITE(" cells, "); |
157 |
+ GWRITE(Np); SWRITE(" arrays in "); |
158 |
+ GWRITE(T); SWRITE(" milliseconds.\n"); |
159 |
+--- saclib2.2.8-orig/src/gcword.cc |
160 |
++++ saclib2.2.8/src/gcword.cc |
161 |
+@@ -0,0 +1,70 @@ |
162 |
++/*************************************************************** |
163 |
++*** |
164 |
++*** gcword.cc |
165 |
++*** |
166 |
++*** This file implements the gcw_MARK() function, which is called |
167 |
++*** by the modified saclib garbage collector in order to account |
168 |
++*** for saclib Words pointed to by GCWord objects. |
169 |
++*** |
170 |
++*** This file implements the gcw_register(p) function, which is |
171 |
++*** called upon creation and upon destuction of a GCWord object. |
172 |
++*** Each call adds p, the address of the GCWord, to the vector G, |
173 |
++*** so that if a given address occurs an odd number of times, it |
174 |
++*** contains a live GCWord object ... which the garbage collector |
175 |
++*** needs to consider. |
176 |
++*** |
177 |
++*** The clean() function modifies vector G so that an address |
178 |
++*** appears in G after the call if and only if it appeared an odd |
179 |
++*** number of times before the call, and no address appears more |
180 |
++*** than once after the call. |
181 |
++*** |
182 |
++*** CWB 5/15/00 |
183 |
++***************************************************************/ |
184 |
++#include <vector> |
185 |
++#include <algorithm> |
186 |
++#include "gcword.h" |
187 |
++using namespace std; |
188 |
++ |
189 |
++extern "C" { |
190 |
++void gcw_MARK(); |
191 |
++} |
192 |
++ |
193 |
++static vector<Word*> G; |
194 |
++static int lim = 10; |
195 |
++ |
196 |
++void clean() |
197 |
++{ |
198 |
++ //-- a hack to ensure that lim ends up being NU -------------// |
199 |
++ if (lim < NU) lim = NU; |
200 |
++ |
201 |
++ sort(G.begin(),G.end()); |
202 |
++ |
203 |
++ //-- compacts sorted array by ignoring double values --------// |
204 |
++ int i,j,N = G.size()-1; |
205 |
++ for(i = 0; i < N; i++) |
206 |
++ if (G[i] == G[i+1]) { |
207 |
++ G[i] = G[i+1] = 0; |
208 |
++ i++; } |
209 |
++ for(i = 0, j = 0; j <= N; j++) |
210 |
++ if (G[j] != 0) |
211 |
++ swap(G[i++],G[j]); |
212 |
++ G.resize(i); |
213 |
++} |
214 |
++ |
215 |
++void gcw_register(Word *p) |
216 |
++{ |
217 |
++ G.push_back(p); |
218 |
++ if (G.size() == lim) |
219 |
++ clean(); |
220 |
++} |
221 |
++ |
222 |
++void gcw_MARK() |
223 |
++{ |
224 |
++ // SWRITE("gcw size is: ");IWRITE(G.size()); SWRITE("\n"); |
225 |
++ clean(); |
226 |
++ for(int i = 0; i < G.size(); i++) |
227 |
++ if (*G[i] > BETA && *G[i] < BETAp && (*G[i] & 1)) |
228 |
++ MARK(*G[i]); |
229 |
++ |
230 |
++ return; |
231 |
++} |
232 |
+--- saclib2.2.8-orig/src/gcword.h |
233 |
++++ saclib2.2.8/src/gcword.h |
234 |
+@@ -0,0 +1,51 @@ |
235 |
++/*************************************************************** |
236 |
++*** |
237 |
++*** gcword.h |
238 |
++*** |
239 |
++*** This file defines the class GCWord, or "garbage collected |
240 |
++*** word". It is designed to be used in conjunction with |
241 |
++*** saclib to provide an easy way to incoporate garbage |
242 |
++*** collected saclib lists into class definitions and arrays. |
243 |
++*** It even makes global variables easier to define. |
244 |
++*** |
245 |
++*** An object of type GCWord behaves just like a "Word", except |
246 |
++*** that it is visible to the garbage collector even if it is |
247 |
++*** a member of some stucture or class or array or is, for any |
248 |
++*** other reason, not a local variable. Note: garbage |
249 |
++*** collection may be slowed by the presence of GCWord's! |
250 |
++*** |
251 |
++*** CWB 5/15/00 |
252 |
++***************************************************************/ |
253 |
++ |
254 |
++#ifndef _GCW_ |
255 |
++#define _GCW_ |
256 |
++ |
257 |
++ |
258 |
++extern "C" { |
259 |
++#include "saclib.h" |
260 |
++} |
261 |
++extern void gcw_register(Word *); |
262 |
++ |
263 |
++ |
264 |
++class GCWord |
265 |
++{ |
266 |
++public: |
267 |
++ Word W; |
268 |
++ |
269 |
++ //-- Constructors -------------------------------------------// |
270 |
++ GCWord() { W = 0; gcw_register(&W); } |
271 |
++ GCWord(const GCWord &X) { W = X.W; gcw_register(&W); } |
272 |
++ GCWord(const Word &X) { W = X; gcw_register(&W); } |
273 |
++ |
274 |
++ //-- Destructor ---------------------------------------------// |
275 |
++ ~GCWord() { gcw_register(&W); } |
276 |
++ |
277 |
++ //-- Assignment ---------------------------------------------// |
278 |
++ GCWord& operator=(const GCWord& X) { W = X.W; return *this; } |
279 |
++ GCWord& operator=(const Word& X) { W = X; return *this;} |
280 |
++ |
281 |
++ //-- Cast to Word -------------------------------------------// |
282 |
++ operator Word() const { return W; } |
283 |
++}; |
284 |
++ |
285 |
++#endif |
286 |
|
287 |
diff --git a/sci-libs/saclib/saclib-2.2.8.ebuild b/sci-libs/saclib/saclib-2.2.8.ebuild |
288 |
index 41c5511d1..7810ffc57 100644 |
289 |
--- a/sci-libs/saclib/saclib-2.2.8.ebuild |
290 |
+++ b/sci-libs/saclib/saclib-2.2.8.ebuild |
291 |
@@ -23,7 +23,10 @@ BDEPEND=" |
292 |
app-shells/tcsh |
293 |
" |
294 |
|
295 |
-PATCHES=( "${FILESDIR}/makefile.patch" ) |
296 |
+PATCHES=( |
297 |
+ "${FILESDIR}/qepcad-compat.patch" |
298 |
+ "${FILESDIR}/makefile.patch" |
299 |
+) |
300 |
DOCS=( doc/saclib.pdf doc/saclocal.dvi doc/desc.doc ) |
301 |
|
302 |
src_prepare() { |
303 |
@@ -35,8 +38,8 @@ src_prepare() { |
304 |
export MINMAJLIBNAME="${MAJLIBNAME}.${MINOR}" |
305 |
export FULLLIBNAME="${MINMAJLIBNAME}.${REVISION}" |
306 |
export saclib="${S}" |
307 |
- tc-export CC |
308 |
- #no main, it's a library |
309 |
+ tc-export CC CXX |
310 |
+ # no main, it's a library |
311 |
rm src/main.c || die |
312 |
default |
313 |
} |