Matt Birkholz [Tue, 21 Dec 2010 17:28:03 +0000 (10:28 -0700)]
FFI support for 64bit architectures.
* src/ffi/generator.scm: Declare long callback IDs, large enough to
avoid truncation warnings when the toolkit type is also large. Use
%ld instead of %d for sizeof and member offsets, and cast them to
long. On x86_64, these have types ulong and long respectively.
* src/microcode/: pruxffi.c, pruxffi.h: (callback_run_kernel)
(callback_run_handler): Declare long callback_id params. Use %ld.
* src/runtime/ffi.scm (radix): Parameterize alien operations to
support 64bit or 32bit addresses.
Fix datime.scm's time formats to accept up to 61 seconds in a minute.
Minutes in any UTC-based time system, which covers every system of
which representations are parsed in datime.scm, can have 59, 60, or
61 seconds; previously we refused to parse representations of the
61st second.
Unfortunately, our notion of `universal time' is still essentially
Common Lisp's ill-specified notion of universal time, and implemented
by POSIX's mind-bogglingly brain-damaged notion of `number of seconds
since the Epoch' which actually means `number of seconds since the
Epoch, minus the number of them that were leap seconds in UTC'.
Replace `masking exceptions' by `trapping exceptions'.
Reversing the sense makes it clearer -- `trap on division by zero' is
a positive request, versus `mask division by zero traps', i.e. `don't
trap on division by zero'. This better reflects the IEEE 754 notion
of actions to take on exceptions. Also, the sense of `mask' is often
confusing (Scheme's `interrupt mask' is not the interrupts that are
masked, but the bit mask of interrupts that are *enabled*; the BSD
fpgetmask and fpsetmask library routines control the bit mask of
floating-point exceptions for which trapping is enabled; but, on the
other hand, a POSIX process's `signal mask' is the set of signals
that are disabled).
Implement a complete set of integer division operator pairs.
Given a numerator n and a denominator d, each operator pair computes
an integral quotient q and the induced remainder r = n - d q such
that |r| < |d|. There are five pairs: ceiling, euclidean, floor,
round, and truncate. Ceiling, floor, round, and truncate compute the
rounded quotient as their names suggest. Euclidean division is floor
division for positive denominators, and ceiling division for negative
denominators, so that it exhibits the stronger property 0 <= r < |d|.
Matt Birkholz [Fri, 12 Nov 2010 21:16:11 +0000 (14:16 -0700)]
Fixed src/README.txt. Portable C Installation instructions.
* doc/user-manual/user.texinfo: Added node "Portable C Installation".
Added "Type and range checking" describing the no-type-checks and
no-range-checks declarations.
* src/README.txt: Added a preface for the newbie that runs across this
file in a binary distribution. Removed "CVS". Added "portable C
distribution" and "MIT_SCHEME_EXE". Removed mention of "bin/" in
binary distributions, and "SCHEME_LARGE" and "SCHEME_COMPILER"
variables in build scripts; these are no longer used. Replaced
"system" with "program" or "build tree" or whatnot, reserving "system"
for the thing that runs the "operating system". Punted sections
"Building from source... ```The Hard Way''" and "... Tabula Rasa''",
which were mostly about re-compiling / re-linking the microcode. The
solution to such problems is now automated by the compile-microcode
step in the Unix installation instructions.
Matt Birkholz [Sun, 31 Oct 2010 00:05:05 +0000 (17:05 -0700)]
Added c-cast, struct member peeks, param syntax checking.
* src/ffi/cdecls.scm (valid-param): Check that the param name does not
contain `-', nor any other non-C identifier chars. These names go
into the generated .c files.
* src/ffi/syntax.scm (expand-peek): Allow peeks at struct members to
create or set an alien, just as peeking an array member does already.
* src/ffi/ffi.scm (c-cast): New. Basically set-%alien/ctype! with a
convenient return value.
(alien/address, copy-alien-address!, alien-null?, alien-null!, alien=?):
Declare these as integrable operators, not via define-integrable.
Their arguments are referenced multiple times.
* src/runtime/runtime.pkg (runtime ffi): Export c-cast to ().
This causes problems in the cold load, and doesn't enhance the safety
of the relevant code. It only marginally increases the debuggability
of the mistake it catches.
Make #@n always read as a quotation of the nth hashed object.
Previously, #@n sometimes read as the nth hashed object, and
sometimes read as a quotation of it. The advantage of the old
behaviour is that non-scode objects could be mentioned inside
quotations with #@n. Personally, most of the time I referred to
non-scode objects inside quotations with #@n was as '#@n to work
around the problems this fixes:
New operations on the two's-complement representation of integers.
These include the SRFI 33 operations, as well as some other useful
operations.
Although these are implemented as primitives with native definitions
for bignums, the primitives are not yet open-coded for the fixnum
case. Eventually they should be open-coded, so that you don't need
to make a choice between safe code using the integer operations and
fast code using FIX:AND, FIX:LSH, &c. Some operations are easy to
open-code for the fixnum case, such as all the bitwise operations.
Others are not so easy, such as SHIFT-LEFT, and it would be better to
open-code common aggregate operations such as EXTRACT-BIT-FIELD for
the fixnum case. In any case, at least we now have names for the
safe operations.
Simplify and fix X-DISPLAY-PROCESS-EVENTS primitive.
This primitive no longer supports options for blocking vs
non-blocking or selecting vs not selecting; these are now the
responsibility of the caller.
The cached event trick previously used the value of the
uninitialized variable `event', rather than the event that was
cached. Now it correctly uses the event that was cached.
Implement user-defined unparser methods for entities.
New DEFINE-STRUCTURE option PRINT-ENTITY-PROCEDURE is like
PRINT-PROCEDURE, except that the second argument to the procedure
is not a structure instance itself but an entity whose extra is a
structure instance.
New procedure SET-RECORD-TYPE-ENTITY-UNPARSER-METHOD! is like
SET-RECORD-TYPE-UNPARSER-METHOD! with the same difference.
New optional argument to MAKE-RECORD-TYPE specifies an entity
unparser method.
Existing code should be unaffected by the changes, including
existing compiled code that used DEFINE-STRUCTURE.
Screen coordinates are signed, and not always nonnegative; project
negative ones onto the border. Widths and heights are technically
signed too, according to my Xlib.h, but I haven't observed negative
values, and negative values can't possibly make sense, whereas I have
observed negative coordinates in the wild (button down in-window,
button up out-of-window).
Refuse to signal a subprocess that has terminated.
Once Scheme has called wait*(2) on a process that has terminated, its
pid may be recycled, so attempting to send a signal to it may cause a
signal to be sent to some random process!
New tests for subprocess support include a regression test for this.
Add hook in dynamically loaded modules for unloading actions.
Dynamically loaded modules can't use reload cleanups, because they
may be unloaded by pruxdld's reload cleanup before their reload
cleanups get to run, causing DISK-RESTORE to attempt to execute
unmapped code. Instead, pruxdld will now call dload_finalize_file
if it is defined in the file.
Use this mechanism in prx11. Fixes DISK-RESTORE after launching
and exiting Edwin. (Does not fix DISK-RESTORE of an image that was
saved while Edwin was running. That is much harder.)
Cache parsed date, subject, author, and recipient in memory in IMAIL.
This is not really the right thing, but it substantially speeds up
sorting, and slightly speeds up summarization, without requiring the
memory overhead of keeping whole headers strongly in memory.
What IMAIL should really do is
(1) store headers (and bodies and body structures and so on) strongly
in memory, and use a secondary GC daemon to discard them when space is
short; and
(2) use a generic, compact, on-disk cache, for every folder, of the
important information for each message: date, subject, author,
recipient, message-id, thread-id.
Conditionalized compilation of the flonum casting primitives.
The primitives `cast-ieee754-double-to-integer' and
`cast-integer-to-ieee754-double' are omitted when the type
<uint64_t> is not available.
Added <AC_INT64_T> and <AC_UINT64_T> to "configure.ac". The latter is
now required by "flonum.c" because of the new primitives I added, and
CPH asked me to include the former, too.
Make the GC cleverer about reallocating the ephemeron array, in order
to avoid potentially quadratic-time behaviour in MAKE-EPHEMERON and
fasloading files with ephemerons in them.
Now fasls and bands with ephemerons in them should really work, this
time with feeling...
In the process, complete the transition to the STACK_END fasl format.
In the EPHEMERON fasl format, the fasl header has an extra field for
the number of ephemerons stored in the fasl, for which the fasloader
reserves space in ephemeron_array.
The fasdumper chooses between the C_CODE, STACK_END, or EPHEMERON
fasl format for maximum compatibility:
- If there are any ephemerons in the fasl, the fasdumper chooses the
EPHEMERON format. Older microcodes don't know about ephemerons and
thus can't handle such fasls anyway.
- If dumping a band, the fasdumper chooses the STACK_END format,
since the only differences between the C_CODE format and the
STACK_END format matter only for bands. Support for reading the
STACK_END format was added in version 15 of the microcode; any
newly created bands are not likely to be used in older microcodes
than that anyway.
- Otherwise, the fasdumper chooses the C_CODE format, like before.
Removed NaN tests because they cause traps on Linux. (It turns out
that they are supposed to on OS X, too, but a bug prevents that).
Taylor is considering adding support for controlling the
floating-point exception mask and flags, in which case we'll be able
to manipulate NaN values and I can add these tests back.
* Renamed `cast-flonum-to-integer' to `cast-ieee754-double-to-integer'.
* Renamed `cast-integer-to-flonum' to `cast-integer-to-ieee754-double'.
* Changed both to use <uint64_t> instead of <unsigned long> for
conversion. That way, they should work on 32-bit systems. (Thanks to
Taylor for pointing out that bug.)
* Added `cast-ieee754-single-to-integer' and `cast-integer-to-ieee754-single'.
* Updated existing tests.
* Added tests for casts to and from single-precision floating-point numbers.
Removed the divisions by zero that I had used to create floating-point
infinities since those are supposed to trap, not actually return
infinities. On OS X, the trap doesn't happen, but I shouldn't depend
on a bug.
Since this is used only to initialize trampolines, the starting
instruction is irrelevant, and will be garbage anyway because the
trampoline blocks are always freshly allocated.
In FLO:VECTOR-LENGTH, coerce length to fixnum before OBJECT->FIXNUM.
The previous open-coding worked whenever OBJECT->FIXNUM merely
shifted left by the tag width, ignoring whatever tag was there
before. The SVM does not do this, however.
Omit continuation code words after interpreter cache references.
The RTL already arranges their continuations to follow them; putting
an extra continuation code word causes the machine to try to execute
the real one as if it were an instruction.