summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorLuigi Scarso <luigi.scarso@gmail.com>2020-03-12 01:13:01 +0000
committerLuigi Scarso <luigi.scarso@gmail.com>2020-03-12 01:13:01 +0000
commit59476ba79f7d3e8beff8fb4c5a684589dc29b99f (patch)
tree579c2bec9fac6848c5e186505df263ddfd20a8c6 /Build
parent34f97da40ee8a6190275585ed040d687edd0c2f2 (diff)
sync with upstream luatex rev. 7306.
git-svn-id: svn://tug.org/texlive/trunk@54249 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rwxr-xr-xBuild/source/libs/lua53/configure24
-rw-r--r--Build/source/libs/lua53/version.ac2
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/ppheap.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utilbasexx.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.c4
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.h14
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallc.h86
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallh.h10
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.c102
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.h27
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.c90
-rw-r--r--Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.h43
-rw-r--r--Build/source/texk/web2c/luatexdir/luatex_svnversion.h2
-rw-r--r--Build/source/texk/web2c/mplibdir/ChangeLog5
-rw-r--r--Build/source/texk/web2c/mplibdir/mp.w11
15 files changed, 251 insertions, 173 deletions
diff --git a/Build/source/libs/lua53/configure b/Build/source/libs/lua53/configure
index eaddad073e5..75bf53a890d 100755
--- a/Build/source/libs/lua53/configure
+++ b/Build/source/libs/lua53/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for lua53 (TeX Live) 5.3.4.
+# Generated by GNU Autoconf 2.69 for lua53 (TeX Live) 5.3.5.
#
# Report bugs to <tex-k@tug.org>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='lua53 (TeX Live)'
PACKAGE_TARNAME='lua53--tex-live-'
-PACKAGE_VERSION='5.3.4'
-PACKAGE_STRING='lua53 (TeX Live) 5.3.4'
+PACKAGE_VERSION='5.3.5'
+PACKAGE_STRING='lua53 (TeX Live) 5.3.5'
PACKAGE_BUGREPORT='tex-k@tug.org'
PACKAGE_URL=''
@@ -1327,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures lua53 (TeX Live) 5.3.4 to adapt to many kinds of systems.
+\`configure' configures lua53 (TeX Live) 5.3.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1398,7 +1398,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of lua53 (TeX Live) 5.3.4:";;
+ short | recursive ) echo "Configuration of lua53 (TeX Live) 5.3.5:";;
esac
cat <<\_ACEOF
@@ -1515,7 +1515,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-lua53 (TeX Live) configure 5.3.4
+lua53 (TeX Live) configure 5.3.5
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1976,7 +1976,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by lua53 (TeX Live) $as_me 5.3.4, which was
+It was created by lua53 (TeX Live) $as_me 5.3.5, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3900,7 +3900,7 @@ fi
# Define the identity of the package.
PACKAGE='lua53--tex-live-'
- VERSION='5.3.4'
+ VERSION='5.3.5'
cat >>confdefs.h <<_ACEOF
@@ -5108,10 +5108,10 @@ $as_echo "no, using $LN_S" >&6; }
fi
-LUA53VERSION=5.3.4
+LUA53VERSION=5.3.5
-LUA53_LT_VERSINFO=8:4:3
+LUA53_LT_VERSINFO=8:5:3
case `pwd` in
@@ -14545,7 +14545,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by lua53 (TeX Live) $as_me 5.3.4, which was
+This file was extended by lua53 (TeX Live) $as_me 5.3.5, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -14611,7 +14611,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-lua53 (TeX Live) config.status 5.3.4
+lua53 (TeX Live) config.status 5.3.5
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/Build/source/libs/lua53/version.ac b/Build/source/libs/lua53/version.ac
index 22928054dc4..28471aa30ed 100644
--- a/Build/source/libs/lua53/version.ac
+++ b/Build/source/libs/lua53/version.ac
@@ -8,4 +8,4 @@ dnl
dnl --------------------------------------------------------
dnl
dnl m4-include this file to define the current lua53 version
-m4_define([lua53_version], [5.3.4])
+m4_define([lua53_version], [5.3.5])
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/ppheap.h b/Build/source/texk/web2c/luatexdir/luapplib/src/ppheap.h
index 1d6559d93c0..85a59ee0ab8 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/ppheap.h
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/ppheap.h
@@ -22,7 +22,7 @@
#define ppbytes_take(heap, size) _heap16_take(&(heap)->bytesheap, size)
#define ppbytes_buffer_init(heap) heap16_buffer_init(&(heap)->bytesheap, &(heap)->bytesbuffer)
-#define ppbytes_buffer(heap, atleast) heap16_buffer_some(&(heap)->bytesheap, &(heap)->bytesbuffer, atleast)
+#define ppbytes_buffer(heap, atleast) _heap16_buffer_some(&(heap)->bytesheap, &(heap)->bytesbuffer, atleast)
#define ppstruct_heap heap64
#define ppstruct_heap_init(heap, space, large, flags) (heap64_init(&(heap)->structheap, space, large, flags), heap64_head(&(heap)->structheap))
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilbasexx.c b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilbasexx.c
index 1c65b1ec399..cfe14884071 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilbasexx.c
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilbasexx.c
@@ -37,7 +37,7 @@ typedef union { basexx_state *basexxstate; runlength_state *runlengthstate; void
#define basexx_nl '\x0A'
//#define put_nl(O, line, maxline, n) ((void)((line += n) > maxline && ((line = n), iof_set(O, basexx_nl)))) // assignment in conditional warning
-#define put_nl(O, line, maxline, n) do { line += n; if (line > maxline) line = n; iof_set(O, basexx_nl); } while (0)
+#define put_nl(O, line, maxline, n) do { line += n; if (line > maxline) { line = n; iof_set(O, basexx_nl); }} while (0)
/* tail macros */
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.c b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.c
index a7141bfb682..41d6fba38f1 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.c
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.c
@@ -946,10 +946,10 @@ static size_t stderr_writer (iof *O, iof_mode mode)
}
static uint8_t iof_stdout_buffer[BUFSIZ];
-iof iof_stdout = IOF_WRITER_STRUCT(stdout_writer, NULL, iof_stdout_buffer, BUFSIZ, 0);
+iof iof_stdout = IOF_WRITER_INIT(stdout_writer, NULL, iof_stdout_buffer, BUFSIZ, 0);
static uint8_t iof_stderr_buffer[BUFSIZ];
-iof iof_stderr = IOF_WRITER_STRUCT(stderr_writer, NULL, iof_stderr_buffer, BUFSIZ, 0);
+iof iof_stderr = IOF_WRITER_INIT(stderr_writer, NULL, iof_stderr_buffer, BUFSIZ, 0);
/* read from somewhere */
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.h b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.h
index afd9c55ed88..bad43a77374 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.h
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utiliof.h
@@ -64,7 +64,7 @@ typedef size_t (*iof_handler) (iof *I, iof_mode mode);
}; \
size_t space; \
iof_handler more; \
- union { iof *next; FILE *file; iof_file *iofile; void *link; }; \
+ union { void *link; iof *next; FILE *file; iof_file *iofile; }; \
int flags; \
int refcount
@@ -135,16 +135,16 @@ is way larger the sizeof(iof)
/* initializers */
-#define IOF_READER_STRUCT(handler, file, buffer, size, flags) \
- { {{ (uint8_t *)(buffer), (uint8_t *)(buffer), (uint8_t *)(buffer) }}, size, handler, { file }, flags|IOF_READER, 0 }
+#define IOF_READER_INIT(handler, file, buffer, size, flags) \
+ { {{ (uint8_t *)(buffer), (uint8_t *)(buffer), (uint8_t *)(buffer) }}, size, handler, { file }, (flags)|IOF_READER, 0 }
-#define IOF_WRITER_STRUCT(handler, file, buffer, size, flags) \
- { {{ (uint8_t *)(buffer), (uint8_t *)(buffer), (uint8_t *)(buffer) + size }}, size, handler, { file }, flags|IOF_WRITER, 0 }
+#define IOF_WRITER_INIT(handler, file, buffer, size, flags) \
+ { {{ (uint8_t *)(buffer), (uint8_t *)(buffer), (uint8_t *)(buffer) + size }}, size, handler, { file }, (flags)|IOF_WRITER, 0 }
-#define IOF_STRING_STRUCT(buffer, size) \
+#define IOF_STRING_INIT(buffer, size) \
{ {{ (uint8_t *)(buffer), (uint8_t *)(buffer), (uint8_t *)(buffer) + size }}, size, NULL, { NULL }, 0|IOF_READER|IOF_DATA, 0 }
-#define IOF_STRING() IOF_STRING_STRUCT(0, 0)
+#define IOF_STRING() IOF_STRING_INIT(0, 0)
/* refcount */
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallc.h b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallc.h
index 57d268cf733..5471f4afb1c 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallc.h
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallc.h
@@ -114,45 +114,38 @@ is that if the chunk has already been allocated from a sole chunk, the space req
iof interface
=============
-iof is an independent interface for buffers written/read byte-by-byte. If used together with allocators, the provides a convenient
-way to write byte data to the heap or stock, without a need for intermediate buffers. The idea is to have iof buffer always ready
-for writing into the heap or stock. The buffer is setup just once, with
+iof is an independent interface for buffers written/read byte-by-byte. When used together with allocators, it provides
+a convenient way to write byte data to the heap or stock, without a need for intermediate buffers. The buffer is setup with
- iof *output = buffer_init(heap, iof) // calls some(heap, 0)
+ iof output, *O
+ O = buffer_init(heap, &output); // doesn't allocate anything
-Then one can write to iof with
+or
- iof_put(output, char);
- iof_write(output, string);
- iof_ensure(output, bytes);
- ....
+ output = BUFFER_INIT(heap); // doesn't allocate anything
+ O = &output;
-iof keeps pointers to the beginning of buffer, end of buffer, and current position. Once the position reaches the end, the iof
-internal handler updates the buffer providing more space to write. In that case, updating the buffer means settings buf/pos/end
-pointers according to a data pointer and space returned by more(). From the user perspective, this pretends a countinuous space
-for writing, without bothering about buffer boundaries.
+iof keeps pointers to the beginning of the buffer, end of buffer, and current position. Once the position reaches the end,
+the iof internal handler updates the buffer providing more space to write. When used in conjunction with heap or stock,
+the space to write is the space provided by the heap or stock. To start the buffer session:
+
+ O = buffer_some(heap, O, atleast) // ensure iof *O to have atleast bytes to be written
Once you are done with writing some chunk
- iof_flush() // calls done() and some() again
-
-updates the underlying heap or stock, and makes the iof ready for a new chunk. iof it self does not allocate a memory, so it
-doesn't need finalizer, iof_close(output) does nothing. So the cycle looks as follows:
+ buffer_done(heap, O)
- buffer_init(heap, iof)
- <write to iof> ... iof_flush(iof)
- <write to iof> ... iof_flush(iof)
- ...
+instead of buffer_done(), one may also use
-More often then not, we need to specify a minimal space for buffer each time, eg. for memcpy() or so. The actual space left
-can be checked with iof_left(iof), the space for recent chunk is iof->space.
+ iof_flush(O) // calls buffer_done() and buffer_some() again
+
+which updates the underlying heap or stock, and makes the iof ready for a new chunk. iof itself does not allocate a memory,
+so it doesn't need finalizer. iof_close(output) does nothing. To drop the buffer use:
-We can also work as follows:
+ buffer_giveup(heap, O) // restore the from before buffer_some()
- buffer_init(heap, iof)
- buffer_some(heap, iof) ... <write to iof> ... data = iof_writer_result(iof, &size)
- buffer_some(heap, iof) ... <write to iof> ... data = iof_writer_result(iof, &size)
- ...
+More often then not, we need to specify a minimal space for buffer each time, eg. for memcpy() or so. The actual space left
+can be checked with iof_left(O). The entire space of recent chunk is O->space (eq. O->end - O->buf).
Identical interface for heap and stock.
@@ -328,6 +321,17 @@ Each allocator has 4 variants for 1, 2, 4, 8 bytes alignment respectively. Eg. s
to 4 bytes, heap64_take() returns a pointer aligned to 8 bytes. You can ask for any data length, but in practise you'll always
obtain 1N, 2N, 4N or 8N. Alignment implies data padding unless the user requests for "aligned" sizes. In statistics the padding
is not considered a waste.
+
+Zeroing
+=======
+
+All heap, stock and pool may return zeroed memory chunks, depending on initial flags:
+
+ HEAP_ZERO
+ STOCK_ZERO
+ POOL_ZERO
+
+There are also take0() variants that simply return memset(take(), 0, size), regardless the flag.
*/
#ifndef UTIL_MEM_ALLC_C
@@ -346,18 +350,18 @@ Common internals for allocators suite. A selection or all of the following defin
#include <stdio.h> // printf()
#include "utilmem.h"
-//#include "utilmemallh.h"
-#if 0 // for a while
-# define ASSERT8(cond) (void)0
-# define ASSERT16(cond) (void)0
-# define ASSERT32(cond) (void)0
-# define ASSERT64(cond) (void)0
-#else
+//#if defined(DEBUG) && debug != 0
+#if 1
# define ASSERT8(cond) ((void)((cond) || (printf("8bit allocator assertion, %s:%d: %s\n", __FILE__, __LINE__, #cond), 0)))
# define ASSERT16(cond) ((void)((cond) || (printf("16bit allocator assertion, %s:%d: %s\n", __FILE__, __LINE__, #cond), 0)))
# define ASSERT32(cond) ((void)((cond) || (printf("32bit allocator assertion, %s:%d: %s\n", __FILE__, __LINE__, #cond), 0)))
# define ASSERT64(cond) ((void)((cond) || (printf("64bit allocator assertion, %s:%d: %s\n", __FILE__, __LINE__, #cond), 0)))
+#else
+# define ASSERT8(cond) (void)0
+# define ASSERT16(cond) (void)0
+# define ASSERT32(cond) (void)0
+# define ASSERT64(cond) (void)0
#endif
#if defined(UTIL_MEM_STOCK_H) || defined(UTIL_MEM_POOL_H)
@@ -474,9 +478,9 @@ otherwise it needs 4 bytes offset.
/* align requested size to keep ream->data / pyre->data always aligned. size is always size_t, no insane overflow checks */
#define align_size8(size) ((void)size)
-#define align_size16(size) ((void)((size & 1) ? (size += 1) : 0))
-#define align_size32(size) ((void)((size & 3) ? (size += 4 - (size & 3)) : 0))
-#define align_size64(size) ((void)((size & 7) ? (size += 8 - (size & 7)) : 0))
+#define align_size16(size) (size = aligned_size16(size))
+#define align_size32(size) (size = aligned_size32(size))
+#define align_size64(size) (size = aligned_size64(size))
/*
done() and pop() operations decrements block->left space by an aligned size; block->left -= alignedwritten. Lets have 8-bytes aligned
@@ -486,9 +490,9 @@ is different than for size (size_t), we cannot cross 0xff/0xffff,... bondaries.
*/
#define align_space8(space) ((void)space)
-#define align_space16(space) ((void)((space & 1) ? (space < 0xFFFF ? (space += 1) : (space -= 1)) : 0))
-#define align_space32(space) ((void)((space & 3) ? (space < 0xFFFFFFFD ? (space += 4 - (space & 3)) : (space -= (space & 3))) : 0))
-#define align_space64(space) ((void)((space & 7) ? (space < 0xFFFFFFFFFFFFFFF8ULL ? (space += 8 - (space & 7)) : (space -= (space & 7))) : 0))
+#define align_space16(space) (space = aligned_space16(space))
+#define align_space32(space) (space = aligned_space32(space))
+#define align_space64(space) (space = aligned_space64(space))
/* handling ghost structure (stock and pool) */
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallh.h b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallh.h
index de448ecd51f..a543d1acb06 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallh.h
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemallh.h
@@ -12,6 +12,16 @@ typedef struct ghost16 ghost16;
typedef struct ghost32 ghost32;
typedef struct ghost64 ghost64;
+#define aligned_size8(size) (size)
+#define aligned_size16(size) ((((size) + 1) >> 1) << 1)
+#define aligned_size32(size) ((((size) + 3) >> 2) << 2)
+#define aligned_size64(size) ((((size) + 7) >> 3) << 3)
+
+#define aligned_space8(size) (size)
+#define aligned_space16(size) (((size) & 1) ? ((size) < 0xFFFF ? ((size) + 1) : ((size) - 1)) : (size))
+#define aligned_space32(size) (((size) & 3) ? ((size) < 0xFFFFFFFD ? ((size) - ((size) & 3) + 4) : (size) - ((size) & 3)) : (size))
+#define aligned_space64(size) (((size) & 7) ? ((size) < 0xFFFFFFFFFFFFFFF8ULL ? ((size) - ((size) & 7) + 8) : (size) - ((size) & 7)) : (size))
+
/* info stub */
typedef struct {
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.c b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.c
index 9392f698aa0..cce28e0ed07 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.c
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.c
@@ -437,6 +437,26 @@ void * _heap64_take (heap64 *heap, size_t size)
return data;
}
+void * _heap8_take0 (heap8 *heap, size_t size)
+{
+ return memset(_heap8_take(heap, size), 0, size);
+}
+
+void * _heap16_take0 (heap16 *heap, size_t size)
+{
+ return memset(_heap16_take(heap, size), 0, size);
+}
+
+void * _heap32_take0 (heap32 *heap, size_t size)
+{
+ return memset(_heap32_take(heap, size), 0, size);
+}
+
+void * _heap64_take0 (heap64 *heap, size_t size)
+{
+ return memset(_heap64_take(heap, size), 0, size);
+}
+
/* pop last heap chunk */
#define taken_from_head(taken, head) (byte_data(taken) == head->data)
@@ -462,6 +482,10 @@ void heap8_pop (heap8 *heap, void *taken, size_t size)
head->prev = pyre->prev;
pyre_free(pyre);
}
+ else
+ {
+ ASSERT8(0);
+ }
}
void heap16_pop (heap16 *heap, void *taken, size_t size)
@@ -481,6 +505,10 @@ void heap16_pop (heap16 *heap, void *taken, size_t size)
head->prev = pyre->prev;
pyre_free(pyre);
}
+ else
+ {
+ ASSERT16(0);
+ }
}
void heap32_pop (heap32 *heap, void *taken, size_t size)
@@ -500,6 +528,10 @@ void heap32_pop (heap32 *heap, void *taken, size_t size)
head->prev = pyre->prev;
pyre_free(pyre);
}
+ else
+ {
+ ASSERT32(0);
+ }
}
void heap64_pop (heap64 *heap, void *taken, size_t size)
@@ -519,6 +551,10 @@ void heap64_pop (heap64 *heap, void *taken, size_t size)
head->prev = pyre->prev;
pyre_free(pyre);
}
+ else
+ {
+ ASSERT64(0);
+ }
}
/* heap buffer */
@@ -611,7 +647,7 @@ void * _heap64_some (heap64 *heap, size_t size, size_t *pspace)
return void_data(pyre->data);
}
-void * heap8_more (heap8 *heap, void *taken, size_t written, size_t size)
+void * heap8_more (heap8 *heap, void *taken, size_t written, size_t size, size_t *pspace)
{
pyre8 *pyre, *prev;
pyre = heap->head;
@@ -619,32 +655,40 @@ void * heap8_more (heap8 *heap, void *taken, size_t written, size_t size)
if (taken_from_head(taken, pyre))
{
if (size <= pyre->left)
- { // unlikely
+ {
+ *pspace = pyre->left;
}
else if (take_new_block8(heap, pyre8, pyre, size))
{
pyre = heap8_new(heap);
memcpy(pyre->data, taken, written);
+ *pspace = pyre->left;
}
else
{
pyre = heap8_sole(heap, size);
memcpy(pyre->data, taken, written);
+ *pspace = size;
}
}
else if (taken_from_sole(taken, pyre, prev))
{
pyre = heap8_sole(heap, size);
- pyre->prev = prev->prev;
memcpy(pyre->data, taken, written);
+ *pspace = size;
+ pyre->prev = prev->prev;
pyre_free(prev);
}
else
+ {
+ ASSERT8(0);
+ *pspace = 0;
return NULL;
+ }
return void_data(pyre->data);
}
-void * heap16_more (heap16 *heap, void *taken, size_t written, size_t size)
+void * heap16_more (heap16 *heap, void *taken, size_t written, size_t size, size_t *pspace)
{
pyre16 *pyre, *prev;
pyre = heap->head;
@@ -653,31 +697,39 @@ void * heap16_more (heap16 *heap, void *taken, size_t written, size_t size)
{
if (size <= pyre->left)
{
+ *pspace = pyre->left;
}
else if (take_new_block16(heap, pyre16, pyre, size))
{
pyre = heap16_new(heap);
memcpy(pyre->data, taken, written);
+ *pspace = pyre->left;
}
else
{
pyre = heap16_sole(heap, size);
memcpy(pyre->data, taken, written);
+ *pspace = size;
}
}
else if (taken_from_sole(taken, pyre, prev))
{
pyre = heap16_sole(heap, size);
- pyre->prev = prev->prev;
memcpy(pyre->data, taken, written);
+ *pspace = size;
+ pyre->prev = prev->prev;
pyre_free(prev);
}
else
+ {
+ ASSERT16(0);
+ *pspace = 0;
return NULL;
+ }
return void_data(pyre->data);
}
-void * heap32_more (heap32 *heap, void *taken, size_t written, size_t size)
+void * heap32_more (heap32 *heap, void *taken, size_t written, size_t size, size_t *pspace)
{
pyre32 *pyre, *prev;
pyre = heap->head;
@@ -686,31 +738,39 @@ void * heap32_more (heap32 *heap, void *taken, size_t written, size_t size)
{
if (size <= pyre->left)
{
+ *pspace = pyre->left;
}
else if (take_new_block32(heap, pyre32, pyre, size))
{
pyre = heap32_new(heap);
memcpy(pyre->data, taken, written);
+ *pspace = pyre->left;
}
else
{
pyre = heap32_sole(heap, size);
memcpy(pyre->data, taken, written);
+ *pspace = size;
}
}
else if (taken_from_sole(taken, pyre, prev))
{
pyre = heap32_sole(heap, size);
- pyre->prev = prev->prev;
memcpy(pyre->data, taken, written);
+ *pspace = size;
+ pyre->prev = prev->prev;
pyre_free(prev);
}
else
+ {
+ ASSERT32(0);
+ *pspace = 0;
return NULL;
+ }
return void_data(pyre->data);
}
-void * heap64_more (heap64 *heap, void *taken, size_t written, size_t size)
+void * heap64_more (heap64 *heap, void *taken, size_t written, size_t size, size_t *pspace)
{
pyre64 *pyre, *prev;
pyre = heap->head;
@@ -719,27 +779,35 @@ void * heap64_more (heap64 *heap, void *taken, size_t written, size_t size)
{
if (size <= pyre->left)
{
+ *pspace = pyre->left;
}
else if (take_new_block64(heap, pyre64, pyre, size))
{
pyre = heap64_new(heap);
memcpy(pyre->data, taken, written);
+ *pspace = pyre->left;
}
else
{
pyre = heap64_sole(heap, size);
memcpy(pyre->data, taken, written);
+ *pspace = size;
}
}
else if (taken_from_sole(taken, pyre, prev))
{
pyre = heap64_sole(heap, size);
- pyre->prev = prev->prev;
memcpy(pyre->data, taken, written);
+ *pspace = size;
+ pyre->prev = prev->prev;
pyre_free(prev);
}
else
+ {
+ ASSERT64(0);
+ *pspace = 0;
return NULL;
+ }
return void_data(pyre->data);
}
@@ -759,6 +827,10 @@ void heap8_done (heap8 *heap, void *taken, size_t written)
pyre->data += written;
pyre->chunks = 1;
}
+ else
+ {
+ ASSERT8(0);
+ }
}
void heap16_done (heap16 *heap, void *taken, size_t written)
@@ -777,6 +849,10 @@ void heap16_done (heap16 *heap, void *taken, size_t written)
pyre->data += written;
pyre->chunks = 1;
}
+ else
+ {
+ ASSERT16(0);
+ }
}
void heap32_done (heap32 *heap, void *taken, size_t written)
@@ -795,6 +871,10 @@ void heap32_done (heap32 *heap, void *taken, size_t written)
pyre->data += written;
pyre->chunks = 1;
}
+ else
+ {
+ ASSERT32(0);
+ }
}
void heap64_done (heap64 *heap, void *taken, size_t written)
@@ -813,6 +893,10 @@ void heap64_done (heap64 *heap, void *taken, size_t written)
pyre->data += written;
pyre->chunks = 1;
}
+ else
+ {
+ ASSERT64(0);
+ }
}
/* giveup */
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.h b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.h
index 08f1ce23270..8776419c284 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.h
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheap.h
@@ -93,13 +93,12 @@ struct heap64 {
};
#define HEAP_ZERO (1 << 0)
-//#define HEAP_KEEP (1 << 1)
#define HEAP_DEFAULTS 0
-#define HEAP8_INIT(space, large, flags) { NULL, space, large, flags }
-#define HEAP16_INIT(space, large, flags) { NULL, space, large, flags }
-#define HEAP32_INIT(space, large, flags) { NULL, space, large, flags }
-#define HEAP64_INIT(space, large, flags) { NULL, space, large, flags }
+#define HEAP8_INIT(space, large, flags) { NULL, aligned_space8(space), large, flags }
+#define HEAP16_INIT(space, large, flags) { NULL, aligned_space16(space), large, flags }
+#define HEAP32_INIT(space, large, flags) { NULL, aligned_space32(space), large, flags }
+#define HEAP64_INIT(space, large, flags) { NULL, aligned_space64(space), large, flags }
UTILAPI heap8 * heap8_init (heap8 *heap, uint8_t space, uint8_t large, uint8_t flags);
UTILAPI heap16 * heap16_init (heap16 *heap, uint16_t space, uint16_t large, uint8_t flags);
@@ -131,11 +130,21 @@ UTILAPI void * _heap16_take (heap16 *heap, size_t size);
UTILAPI void * _heap32_take (heap32 *heap, size_t size);
UTILAPI void * _heap64_take (heap64 *heap, size_t size);
+UTILAPI void * _heap8_take0 (heap8 *heap, size_t size);
+UTILAPI void * _heap16_take0 (heap16 *heap, size_t size);
+UTILAPI void * _heap32_take0 (heap32 *heap, size_t size);
+UTILAPI void * _heap64_take0 (heap64 *heap, size_t size);
+
#define heap8_take(heap, size) (heap8_ensure_head(heap), _heap8_take(heap, size))
#define heap16_take(heap, size) (heap16_ensure_head(heap), _heap16_take(heap, size))
#define heap32_take(heap, size) (heap32_ensure_head(heap), _heap32_take(heap, size))
#define heap64_take(heap, size) (heap64_ensure_head(heap), _heap64_take(heap, size))
+#define heap8_take0(heap, size) (heap8_ensure_head(heap), _heap8_take0(heap, size))
+#define heap16_take0(heap, size) (heap16_ensure_head(heap), _heap16_take0(heap, size))
+#define heap32_take0(heap, size) (heap32_ensure_head(heap), _heap32_take0(heap, size))
+#define heap64_take0(heap, size) (heap64_ensure_head(heap), _heap64_take0(heap, size))
+
UTILAPI void heap8_pop (heap8 *heap, void *taken, size_t size);
UTILAPI void heap16_pop (heap16 *heap, void *taken, size_t size);
UTILAPI void heap32_pop (heap32 *heap, void *taken, size_t size);
@@ -151,10 +160,10 @@ UTILAPI void * _heap64_some (heap64 *heap, size_t size, size_t *pspace);
#define heap32_some(heap, size, pspace) (heap32_ensure_head(heap), _heap32_some(heap, size, pspace))
#define heap64_some(heap, size, pspace) (heap64_ensure_head(heap), _heap64_some(heap, size, pspace))
-UTILAPI void * heap8_more (heap8 *heap, void *taken, size_t written, size_t size);
-UTILAPI void * heap16_more (heap16 *heap, void *taken, size_t written, size_t size);
-UTILAPI void * heap32_more (heap32 *heap, void *taken, size_t written, size_t size);
-UTILAPI void * heap64_more (heap64 *heap, void *taken, size_t written, size_t size);
+UTILAPI void * heap8_more (heap8 *heap, void *taken, size_t written, size_t size, size_t *pspace);
+UTILAPI void * heap16_more (heap16 *heap, void *taken, size_t written, size_t size, size_t *pspace);
+UTILAPI void * heap32_more (heap32 *heap, void *taken, size_t written, size_t size, size_t *pspace);
+UTILAPI void * heap64_more (heap64 *heap, void *taken, size_t written, size_t size, size_t *pspace);
UTILAPI void heap8_done (heap8 *heap, void *taken, size_t written);
UTILAPI void heap16_done (heap16 *heap, void *taken, size_t written);
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.c b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.c
index f459780df3e..cd9609da877 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.c
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.c
@@ -3,7 +3,7 @@
// this is identical to stock iof suite, keep in sync
-static size_t heap8_writer (iof *O, iof_mode mode)
+size_t heap8_writer (iof *O, iof_mode mode)
{
heap8 *heap;
size_t written;
@@ -11,19 +11,17 @@ static size_t heap8_writer (iof *O, iof_mode mode)
switch (mode)
{
case IOFFLUSH:
- written = (size_t)iof_size(O);
- heap8_done(heap, O->buf, written);
+ heap8_buffer_done(heap, O);
O->buf = _heap8_some(heap, 0, &O->space);
O->pos = O->buf;
O->end = O->buf + O->space;
break;
case IOFWRITE:
written = (size_t)iof_size(O);
- O->space = written << 1;
- O->buf = heap8_more(heap, O->buf, written, O->space);
+ O->buf = heap8_more(heap, O->buf, written, written << 1, &O->space);
O->pos = O->buf + written;
O->end = O->buf + O->space;
- return written; // eq (space - written)
+ return O->space - written;
case IOFCLOSE:
default:
break;
@@ -31,7 +29,7 @@ static size_t heap8_writer (iof *O, iof_mode mode)
return 0;
}
-static size_t heap16_writer (iof *O, iof_mode mode)
+size_t heap16_writer (iof *O, iof_mode mode)
{
heap16 *heap;
size_t written;
@@ -39,19 +37,17 @@ static size_t heap16_writer (iof *O, iof_mode mode)
switch (mode)
{
case IOFFLUSH:
- written = (size_t)iof_size(O);
- heap16_done(heap, O->buf, written);
+ heap16_buffer_done(heap, O);
O->buf = _heap16_some(heap, 0, &O->space);
O->pos = O->buf;
O->end = O->buf + O->space;
break;
case IOFWRITE:
written = (size_t)iof_size(O);
- O->space = written << 1;
- O->buf = heap16_more(heap, O->buf, written, O->space);
+ O->buf = heap16_more(heap, O->buf, written, written << 1, &O->space);
O->pos = O->buf + written;
O->end = O->buf + O->space;
- return written; // eq (space - written)
+ return O->space - written;
case IOFCLOSE:
default:
break;
@@ -59,7 +55,7 @@ static size_t heap16_writer (iof *O, iof_mode mode)
return 0;
}
-static size_t heap32_writer (iof *O, iof_mode mode)
+size_t heap32_writer (iof *O, iof_mode mode)
{
heap32 *heap;
size_t written;
@@ -67,19 +63,17 @@ static size_t heap32_writer (iof *O, iof_mode mode)
switch (mode)
{
case IOFFLUSH:
- written = (size_t)iof_size(O);
- heap32_done(heap, O->buf, written);
+ heap32_buffer_done(heap, O);
O->buf = _heap32_some(heap, 0, &O->space);
O->pos = O->buf;
O->end = O->buf + O->space;
break;
case IOFWRITE:
written = (size_t)iof_size(O);
- O->space = written << 1;
- O->buf = heap32_more(heap, O->buf, written, O->space);
+ O->buf = heap32_more(heap, O->buf, written, written << 1, &O->space);
O->pos = O->buf + written;
O->end = O->buf + O->space;
- return written; // eq (space - written)
+ return O->space - written;
case IOFCLOSE:
default:
break;
@@ -87,7 +81,7 @@ static size_t heap32_writer (iof *O, iof_mode mode)
return 0;
}
-static size_t heap64_writer (iof *O, iof_mode mode)
+size_t heap64_writer (iof *O, iof_mode mode)
{
heap64 *heap;
size_t written;
@@ -95,19 +89,17 @@ static size_t heap64_writer (iof *O, iof_mode mode)
switch (mode)
{
case IOFFLUSH:
- written = (size_t)iof_size(O);
- heap64_done(heap, O->buf, written);
+ heap64_buffer_done(heap, O);
O->buf = _heap64_some(heap, 0, &O->space);
O->pos = O->buf;
O->end = O->buf + O->space;
break;
case IOFWRITE:
written = (size_t)iof_size(O);
- O->space = written << 1;
- O->buf = heap64_more(heap, O->buf, written, O->space);
+ O->buf = heap64_more(heap, O->buf, written, written << 1, &O->space);
O->pos = O->buf + written;
O->end = O->buf + O->space;
- return written; // eq (space - written)
+ return O->space - written;
case IOFCLOSE:
default:
break;
@@ -115,51 +107,9 @@ static size_t heap64_writer (iof *O, iof_mode mode)
return 0;
}
-/* buffer init (made once) */
-
-iof * heap8_buffer_init (heap8 *heap, iof *O)
-{
- void *data;
- size_t space;
- data = heap8_some(heap, 0, &space);
- if (iof_writer(O, (void *)heap, heap8_writer, data, space) == NULL) // sanity
- return NULL;
- return O;
-}
-
-iof * heap16_buffer_init (heap16 *heap, iof *O)
-{
- void *data;
- size_t space;
- data = heap16_some(heap, 0, &space);
- if (iof_writer(O, (void *)heap, heap16_writer, data, space) == NULL)
- return NULL;
- return O;
-}
-
-iof * heap32_buffer_init (heap32 *heap, iof *O)
-{
- void *data;
- size_t space;
- data = heap32_some(heap, 0, &space);
- if (iof_writer(O, (void *)heap, heap32_writer, data, space) == NULL)
- return NULL;
- return O;
-}
-
-iof * heap64_buffer_init (heap64 *heap, iof *O)
-{
- void *data;
- size_t space;
- data = heap64_some(heap, 0, &space);
- if (iof_writer(O, (void *)heap, heap64_writer, data, space) == NULL)
- return NULL;
- return O;
-}
-
/* buffer for some */
-iof * heap8_buffer_some (heap8 *heap, iof *O, size_t atleast)
+iof * _heap8_buffer_some (heap8 *heap, iof *O, size_t atleast)
{
O->buf = _heap8_some(heap, atleast, &O->space);
O->pos = O->buf;
@@ -167,7 +117,7 @@ iof * heap8_buffer_some (heap8 *heap, iof *O, size_t atleast)
return O;
}
-iof * heap16_buffer_some (heap16 *heap, iof *O, size_t atleast)
+iof * _heap16_buffer_some (heap16 *heap, iof *O, size_t atleast)
{
O->buf = _heap16_some(heap, atleast, &O->space);
O->pos = O->buf;
@@ -175,7 +125,7 @@ iof * heap16_buffer_some (heap16 *heap, iof *O, size_t atleast)
return O;
}
-iof * heap32_buffer_some (heap32 *heap, iof *O, size_t atleast)
+iof * _heap32_buffer_some (heap32 *heap, iof *O, size_t atleast)
{
O->buf = _heap32_some(heap, atleast, &O->space);
O->pos = O->buf;
@@ -183,7 +133,7 @@ iof * heap32_buffer_some (heap32 *heap, iof *O, size_t atleast)
return O;
}
-iof * heap64_buffer_some (heap64 *heap, iof *O, size_t atleast)
+iof * _heap64_buffer_some (heap64 *heap, iof *O, size_t atleast)
{
O->buf = _heap64_some(heap, atleast, &O->space);
O->pos = O->buf;
diff --git a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.h b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.h
index 8384eda7aeb..1f3da7efb2f 100644
--- a/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.h
+++ b/Build/source/texk/web2c/luatexdir/luapplib/src/util/utilmemheapiof.h
@@ -5,14 +5,39 @@
#include "utilmemheap.h"
#include "utiliof.h"
-UTILAPI iof * heap8_buffer_init (heap8 *heap, iof *O);
-UTILAPI iof * heap16_buffer_init (heap16 *heap, iof *O);
-UTILAPI iof * heap32_buffer_init (heap32 *heap, iof *O);
-UTILAPI iof * heap64_buffer_init (heap64 *heap, iof *O);
-
-UTILAPI iof * heap8_buffer_some (heap8 *heap, iof *O, size_t atleast);
-UTILAPI iof * heap16_buffer_some (heap16 *heap, iof *O, size_t atleast);
-UTILAPI iof * heap32_buffer_some (heap32 *heap, iof *O, size_t atleast);
-UTILAPI iof * heap64_buffer_some (heap64 *heap, iof *O, size_t atleast);
+UTILAPI size_t heap8_writer (iof *O, iof_mode mode);
+UTILAPI size_t heap16_writer (iof *O, iof_mode mode);
+UTILAPI size_t heap32_writer (iof *O, iof_mode mode);
+UTILAPI size_t heap64_writer (iof *O, iof_mode mode);
+
+#define HEAP8_BUFFER_INIT(heap) IOF_WRITER_INIT(heap8_writer, (void *)(heap), NULL, 0, 0)
+#define HEAP16_BUFFER_INIT(heap) IOF_WRITER_INIT(heap16_writer, (void *)(heap), NULL, 0, 0)
+#define HEAP32_BUFFER_INIT(heap) IOF_WRITER_INIT(heap32_writer, (void *)(heap), NULL, 0, 0)
+#define HEAP64_BUFFER_INIT(heap) IOF_WRITER_INIT(heap64_writer, (void *)(heap), NULL, 0, 0)
+
+#define heap8_buffer_init(heap, O) iof_writer(O, (void *)(heap), heap8_writer, NULL, 0)
+#define heap16_buffer_init(heap, O) iof_writer(O, (void *)(heap), heap16_writer, NULL, 0)
+#define heap32_buffer_init(heap, O) iof_writer(O, (void *)(heap), heap32_writer, NULL, 0)
+#define heap64_buffer_init(heap, O) iof_writer(O, (void *)(heap), heap64_writer, NULL, 0)
+
+UTILAPI iof * _heap8_buffer_some (heap8 *heap, iof *O, size_t atleast);
+UTILAPI iof * _heap16_buffer_some (heap16 *heap, iof *O, size_t atleast);
+UTILAPI iof * _heap32_buffer_some (heap32 *heap, iof *O, size_t atleast);
+UTILAPI iof * _heap64_buffer_some (heap64 *heap, iof *O, size_t atleast);
+
+#define heap8_buffer_some(heap, O, atleast) (heap8_ensure_head(heap), _heap8_buffer_some(heap, O, atleast))
+#define heap16_buffer_some(heap, O, atleast) (heap16_ensure_head(heap), _heap16_buffer_some(heap, O, atleast))
+#define heap32_buffer_some(heap, O, atleast) (heap32_ensure_head(heap), _heap32_buffer_some(heap, O, atleast))
+#define heap64_buffer_some(heap, O, atleast) (heap64_ensure_head(heap), _heap64_buffer_some(heap, O, atleast))
+
+#define heap8_buffer_done(heap, O) heap8_done(heap, (O)->buf, (size_t)iof_size(O))
+#define heap16_buffer_done(heap, O) heap16_done(heap, (O)->buf, (size_t)iof_size(O))
+#define heap32_buffer_done(heap, O) heap32_done(heap, (O)->buf, (size_t)iof_size(O))
+#define heap64_buffer_done(heap, O) heap64_done(heap, (O)->buf, (size_t)iof_size(O))
+
+#define heap8_buffer_giveup(heap, O) heap8_giveup(heap, (O)->buf)
+#define heap16_buffer_giveup(heap, O) heap16_giveup(heap, (O)->buf)
+#define heap32_buffer_giveup(heap, O) heap32_giveup(heap, (O)->buf)
+#define heap64_buffer_giveup(heap, O) heap64_giveup(heap, (O)->buf)
#endif \ No newline at end of file
diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
index ec587b2cea7..3cce7d0b1be 100644
--- a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
+++ b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
@@ -1 +1 @@
-#define luatex_svn_revision 7304
+#define luatex_svn_revision 7306
diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog
index b6f1945f17a..a03ed1ac9ec 100644
--- a/Build/source/texk/web2c/mplibdir/ChangeLog
+++ b/Build/source/texk/web2c/mplibdir/ChangeLog
@@ -1,7 +1,10 @@
+2020-02-18 Luigi Scarso <luigi.scarso@gmail.com>
+ * better mp_snprintf macro
+
+
2019-03-06 Luigi Scarso <luigi.scarso@gmail.com>
* Code clean-up.
-
2019-02-06: Taco Hoekwater <taco@elvenkind.com>
* New primitive void: convert a suffix to a boolean. Work in progress.
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w
index 279739f8569..69eeb571f8b 100644
--- a/Build/source/texk/web2c/mplibdir/mp.w
+++ b/Build/source/texk/web2c/mplibdir/mp.w
@@ -2960,15 +2960,8 @@ void *mp_xmalloc (MP mp, size_t nmem, size_t size) {
}
@ @<Internal library declarations@>=
-/*int mp_snprintf_res ;*/
-/* Some compilers (i.e. gcc 8.2.0 ) complained with the old */
-/* #define mp_snprintf (void)snprintf */
-/* about truncation. For the moment we store the result. */
-/*# define mp_snprintf mp_snprintf_res=snprintf */
-/* Now gcc 10 does't like common symbols, so we switch back */
-/* to the old define. */
-#define mp_snprintf (void)snprintf
-
+/* Avoid warning on format truncation */
+#define mp_snprintf(...) (snprintf(__VA_ARGS__) < 0 ? abort() : (void)0)
@* Dynamic memory allocation.