From owner-svn-ports-all@freebsd.org Wed Mar 13 15:41:30 2019 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 967E9153727B; Wed, 13 Mar 2019 15:41:30 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2B96184B89; Wed, 13 Mar 2019 15:41:30 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5DE5DC89A; Wed, 13 Mar 2019 15:41:26 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DFfQM1077336; Wed, 13 Mar 2019 15:41:26 GMT (envelope-from jbeich@FreeBSD.org) Received: (from jbeich@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DFfQSY077327; Wed, 13 Mar 2019 15:41:26 GMT (envelope-from jbeich@FreeBSD.org) Message-Id: <201903131541.x2DFfQSY077327@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jbeich set sender to jbeich@FreeBSD.org using -f From: Jan Beich Date: Wed, 13 Mar 2019 15:41:26 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r495584 - head/math/reduce/files X-SVN-Group: ports-head X-SVN-Commit-Author: jbeich X-SVN-Commit-Paths: head/math/reduce/files X-SVN-Commit-Revision: 495584 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2B96184B89 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 15:41:30 -0000 Author: jbeich Date: Wed Mar 13 15:41:25 2019 New Revision: 495584 URL: https://svnweb.freebsd.org/changeset/ports/495584 Log: math/reduce: unbreak with clang 8 on i386 PR: 236326 Submitted by: pfg (maintainer) Obtained from: upstream Added: head/math/reduce/files/patch-svn-r4935 (contents, props changed) Added: head/math/reduce/files/patch-svn-r4935 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/math/reduce/files/patch-svn-r4935 Wed Mar 13 15:41:25 2019 (r495584) @@ -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 ], + 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...