mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-26 09:46:09 +00:00
math/reduce: unbreak with clang 8 on i386
PR: 236326 Submitted by: pfg (maintainer) Obtained from: upstream
This commit is contained in:
parent
8d89342c41
commit
c59f01e8a8
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=495584
218
math/reduce/files/patch-svn-r4935
Normal file
218
math/reduce/files/patch-svn-r4935
Normal file
@ -0,0 +1,218 @@
|
||||
https://sourceforge.net/p/reduce-algebra/code/4935/
|
||||
|
||||
--- csl/cslbase/allocate.cpp.orig 2018-09-16 11:16:17 UTC
|
||||
+++ csl/cslbase/allocate.cpp
|
||||
@@ -2284,15 +2284,13 @@ void init_heap_segments(double store_size)
|
||||
set_next_active_page();
|
||||
|
||||
// There are other bits of memory that I will grab manually for now...
|
||||
- nilsegment = (LispObject *)malloc(NIL_SEGMENT_SIZE+16);
|
||||
+ nilsegment = (LispObject *)aligned_malloc(NIL_SEGMENT_SIZE+16);
|
||||
#ifdef COMMON
|
||||
- nil = (LispObject)(doubleword_align_up((uintptr_t)nilsegment) +
|
||||
- TAG_CONS + 8);
|
||||
+ nil = (LispObject)((uintptr_t)nilsegment + TAG_CONS + 8);
|
||||
#else
|
||||
- nil = (LispObject)(doubleword_align_up((uintptr_t)nilsegment) +
|
||||
- TAG_SYMBOL);
|
||||
+ nil = (LispObject)((uintptr_t)nilsegment + TAG_SYMBOL);
|
||||
#endif
|
||||
- stacksegment = (LispObject *)malloc(CSL_PAGE_SIZE);
|
||||
+ stacksegment = (LispObject *)alligned_malloc(CSL_PAGE_SIZE);
|
||||
if (stacksegment == NULL) fatal_error(err_no_store);
|
||||
stackbase = (LispObject *)stacksegment;
|
||||
}
|
||||
@@ -2310,8 +2308,8 @@ void drop_heap_segments(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
- free(nilsegment);
|
||||
- free(stacksegment);
|
||||
+ aligned_free(nilsegment);
|
||||
+ aligned_free(stacksegment);
|
||||
}
|
||||
|
||||
// This allocates another page of memory if that is allowed and if it is
|
||||
@@ -3270,11 +3268,9 @@ uintptr_t *C_stackbase;
|
||||
/*@*/ pool = pool + NIL_SEGMENT_SIZE;
|
||||
#ifdef COMMON
|
||||
/*@*/// NB here that NIL is tagged as a CONS not as a symbol
|
||||
-/*@*/ nil = (LispObject)(
|
||||
-/*@*/ doubleword_align_up((uintptr_t)nilsegment) + TAG_CONS + 8);
|
||||
+/*@*/ nil = (LispObject)((uintptr_t)nilsegment + TAG_CONS + 8);
|
||||
#else
|
||||
-/*@*/ nil = (LispObject)(
|
||||
-/*@*/ doubleword_align_up((uintptr_t)nilsegment) + TAG_SYMBOL);
|
||||
+/*@*/ nil = (LispObject)((uintptr_t)nilsegment + TAG_SYMBOL);
|
||||
#endif
|
||||
/*@*/// If at the end of the run I am going to free some space I had better not
|
||||
/*@*/// free these pages. When I free the nilsegment they all get discarded at
|
||||
@@ -3298,7 +3294,7 @@ uintptr_t *C_stackbase;
|
||||
/*@*/ if (nilsegment != NULL && pages_count > 0)
|
||||
/*@*/ { if (stack_segsize != 1)
|
||||
/*@*/ { stacksegment =
|
||||
-/*@*/ (LispObject *)malloc(stack_segsize*CSL_PAGE_SIZE);
|
||||
+/*@*/ (LispObject *)aligned_malloc(stack_segsize*CSL_PAGE_SIZE);
|
||||
/*@*/ if (stacksegment == NULL) fatal_error(err_no_store);
|
||||
/*@*/ }
|
||||
/*@*/ else stacksegment = (LispObject *)pages[--pages_count];
|
||||
@@ -3326,7 +3322,7 @@ uintptr_t *C_stackbase;
|
||||
/*@*/// all be recycled in one go when the whole chunk is freed. Note that
|
||||
/*@*/// the whole of the "big chunk" tends to get allocated as part of the
|
||||
/*@*/// segment that contans nil.
|
||||
-/*@*/ if (w != NULL && !is_in_big_chunk(w)) free(w);
|
||||
+/*@*/ if (w != NULL && !is_in_big_chunk(w)) aligned_free(w);
|
||||
/*@*/ }
|
||||
/*@*/}
|
||||
/*@*/
|
||||
@@ -3334,8 +3330,8 @@ uintptr_t *C_stackbase;
|
||||
/*@*/{ abandon(pages, pages_count);
|
||||
/*@*/ abandon(heap_pages, heap_pages_count);
|
||||
/*@*/ abandon(vheap_pages, vheap_pages_count);
|
||||
-/*@*/ if (!is_in_big_chunk(stacksegment)) free(stacksegment);
|
||||
-/*@*/ free(nilsegment);
|
||||
+/*@*/ if (!is_in_big_chunk(stacksegment)) aligned_free(stacksegment);
|
||||
+/*@*/ aligned_free(nilsegment);
|
||||
/*@*/}
|
||||
/*@*/
|
||||
/*@*/// This allocates another page of memory if that is allowed and if it is
|
||||
--- csl/cslbase/configure.ac.orig 2018-09-25 20:26:06 UTC
|
||||
+++ csl/cslbase/configure.ac
|
||||
@@ -803,6 +803,12 @@ else
|
||||
AC_DEFINE([NORETURN], [[/* noreturn */]], [C++-11 attributes available?])
|
||||
fi
|
||||
|
||||
+# The sad news is that some 32-bit systems only set maxalign to 4, so for
|
||||
+# instance even double precision floats can be aligned only that well. A
|
||||
+# consequence is that they are entitles to let malloc() return an address
|
||||
+# that is not 8-byte aligned, and that hurts my tagging scheme. I need to
|
||||
+# review uses of malloc() and do alignment for myself where it is needed.
|
||||
+
|
||||
AC_COMPUTE_INT(maxalign, alignof(std::max_align_t), [#include <cstddef>],
|
||||
maxalign="0")
|
||||
if test "$maxalign" = "0"
|
||||
@@ -818,11 +824,11 @@ fi
|
||||
# it to be 16 on most if not all 64-bit systems. The test here is in case
|
||||
# somebody tries a build on a system where everything can be placed at
|
||||
# arbitrary byte boundaries and hence where malloc (and friends) feel
|
||||
-# entitles to return values that are not aligned at all.
|
||||
+# entitled to return values that are not aligned at all.
|
||||
|
||||
if test $maxalign -lt 8
|
||||
then
|
||||
- AC_MSG_ERROR([max_align_t must be at least 8 for CSL to work])
|
||||
+ AC_DEFINE([MAXALIGN4], [1], [alignof(max_align_t)==4])
|
||||
fi
|
||||
|
||||
# I have alternative ways of doing things on Windows and Macintosh, but
|
||||
--- csl/cslbase/csl.cpp.orig 2018-07-01 08:32:38 UTC
|
||||
+++ csl/cslbase/csl.cpp
|
||||
@@ -2629,7 +2629,7 @@ void cslstart(int argc, const char *argv[], character_
|
||||
// nil-segment and cons().
|
||||
//
|
||||
|
||||
- nilsegment = (LispObject *)malloc(NIL_SEGMENT_SIZE);
|
||||
+ nilsegment = (LispObject *)aligned_malloc(NIL_SEGMENT_SIZE);
|
||||
if (nilsegment == NULL) abort();
|
||||
#ifdef COMMON
|
||||
nil = (LispObject)nilsegment + TAG_CONS + 8;
|
||||
@@ -2637,7 +2637,7 @@ void cslstart(int argc, const char *argv[], character_
|
||||
nil = (LispObject)nilsegment + TAG_SYMBOL;
|
||||
#endif
|
||||
pages_count = heap_pages_count = vheap_pages_count = 0;
|
||||
- stacksegment = (LispObject *)malloc(CSL_PAGE_SIZE);
|
||||
+ stacksegment = (LispObject *)aligned_malloc(CSL_PAGE_SIZE);
|
||||
if (stacksegment == NULL) abort();
|
||||
heaplimit = (LispObject)stacksegment;
|
||||
heaplimit = (LispObject)stacksegment;
|
||||
--- csl/cslbase/machine.h.orig 2018-05-05 12:06:25 UTC
|
||||
+++ csl/cslbase/machine.h
|
||||
@@ -333,6 +333,46 @@ typedef __int128 int128_t;
|
||||
// With luck that will have regularised the situation with regard to
|
||||
// integer types!
|
||||
|
||||
+#ifdef MAXALING4
|
||||
+
|
||||
+// In the horrid case where malloc might return a fairly unaligned block
|
||||
+// of memory I will allocate a block that is 32-bytes larger than will be
|
||||
+// required. If I round that address up to be a multiple of 16 I can then
|
||||
+// guarantee to leave 16 bytes that are both free and aligned at a 16 byte
|
||||
+// boundary. I put a "void *" value in there (it will very probably not use
|
||||
+// up all the space, but I do not mind) pointing at the original start of
|
||||
+// the block.
|
||||
+
|
||||
+inline void *aligned_malloc(size_t n)
|
||||
+{ void *p = (void *)malloc(n + 32);
|
||||
+ if (p == NULL) return p;
|
||||
+ void *r = (void *)((((uintptr_t)p + 15) & -(uint64_t)16) + 16);
|
||||
+ (void *)((uintptr_t)r - 16) = p;
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
+// To free something I need to retrieve the pointer to the genuine block
|
||||
+// start and hand that to free().
|
||||
+
|
||||
+inline void aligned_free(void *p)
|
||||
+{ if (p == NULL) return;
|
||||
+ free(*(void *)((uintptr_t)p - 16));
|
||||
+}
|
||||
+#else // MAXALING4
|
||||
+
|
||||
+// IN the hugely more common case where malloc does align things to at least
|
||||
+// 8 byte boundaries I can use malloc() and free() directly.
|
||||
+
|
||||
+inline void *aligned_malloc(size_t n)
|
||||
+{ return (void *)malloc(n);
|
||||
+}
|
||||
+
|
||||
+inline void aligned_free(void *p)
|
||||
+{ free(p);
|
||||
+}
|
||||
+
|
||||
+#endif // MAXALING4
|
||||
+
|
||||
#endif // header_machine_h
|
||||
|
||||
// end machine.h
|
||||
--- csl/cslbase/restart.cpp.orig 2018-07-01 08:32:38 UTC
|
||||
+++ csl/cslbase/restart.cpp
|
||||
@@ -2528,7 +2528,7 @@ void setup(int restart_flag, double store_size)
|
||||
{ int32_t more = heap_pages_count + vheap_pages_count;
|
||||
more = 3 *more - pages_count;
|
||||
while (more-- > 0)
|
||||
- { void *page = (void *)malloc((size_t)CSL_PAGE_SIZE);
|
||||
+ { void *page = (void *)aligned_malloc((size_t)CSL_PAGE_SIZE);
|
||||
if (page == NULL)
|
||||
{ init_flags &= ~INIT_EXPANDABLE;
|
||||
break;
|
||||
--- csl/cslbase/showmathdemo.cpp.orig 2017-02-05 19:17:16 UTC
|
||||
+++ csl/cslbase/showmathdemo.cpp
|
||||
@@ -73,16 +73,25 @@ extern int main(int argc,char *argv[]);
|
||||
|
||||
#ifdef HAVE_LIBXFT
|
||||
|
||||
+namespace FX
|
||||
+{
|
||||
+extern XftDraw *ftDraw;
|
||||
+extern XftColor ftBlack;
|
||||
+extern XftFont *ftFont;
|
||||
+}
|
||||
+
|
||||
extern Display *dpy;
|
||||
extern int screen;
|
||||
-extern XftDraw *ftDraw;
|
||||
+extern XftDraw *FX::ftDraw;
|
||||
extern Visual *ftVisual;
|
||||
extern Colormap ftColormap;
|
||||
-extern XftColor ftBlack;
|
||||
+extern XftColor FX::ftBlack;
|
||||
extern FcConfig *config;
|
||||
-extern XftFont *ftFont;
|
||||
+extern XftFont *FX::ftFont;
|
||||
|
||||
#endif
|
||||
+
|
||||
+using namespace FX;
|
||||
|
||||
// At least for testing purposes I will extract the LaTeX-like stuff
|
||||
// from a string...
|
Loading…
Reference in New Issue
Block a user