1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-14 07:30:21 +00:00

218 Commits

Author SHA1 Message Date
Nick Briggs
c7fd28a438 Removed unused (and unimplemented) stackcheck() and stackoverflow() routines
These routines were stubs that did nothing and were not called from anywhere
so lack value in even providing a template or hook for a fuller implementation.
Also note that "stackcheck" conflicts with a predefined symbol in some runtime
libraries.  Should these be implemented in the future they should use a
maiko-specific name.
2021-12-09 14:57:45 -08:00
Nick Briggs
e1efc860c4 Prefer typedef over #define where it can be used for type definitions 2021-12-09 14:48:52 -08:00
Nick Briggs
212a0fa9c6
Add some support for cross-compilation to MC68000 AmigaOS (#412)
Add m68k to recognized CPUs (machinetype)
Add amigaos to recognized operating systems (osversion)
Add ability to override "config.guess" output w/ LDEARCH= to osversion
Add platform.h clauses to recognize AmigaOS 3 using gcc to cross-compile
2021-12-08 12:03:04 -08:00
Nick Briggs
65bbcb7d9d
Remove makepathname() (#410)
makepathname() is only ever called with one of two constant string
arguments, in one case (DOS) such that it only does a strncpy(...),
and the other case (non-DOS) expanding "~" to the current user's home
directory. Additional code duplicates realpath() functionality but is
never used.
2021-11-26 19:53:26 -08:00
Nick Briggs
987cf4c7c6
Correct error for missing byteswap macros in tosfns.h EVAL implementation (#407)
Commit c46fcce307018df6554805050ceb634d72e737c9 fixed a warning for
incompatible pointers to nnewframe() but did not consider that the
order of the DLwords is swapped depending on the endianness of the
system it is running on.  Add the necessary GETBASEWORD() macros to
access the items when constructing the pointer.
2021-11-06 18:36:25 -07:00
Nick Briggs
c46fcce307
Fix "warning: incompatible pointer types" in EVAL implementation (#406)
nnewframe() as called from the EVAL implementation expects to be passed
the address of an array of two DLwords.  Do that, and compose the 32-bit
result correctly rather than passing the address of a (32-bit) LispPTR
and then having to swapx() that result to get the expected value.
2021-11-04 20:18:27 -07:00
Nick Briggs
de5ea2110f
Correct integer type warnings (#405)
* Correct warning: cast to smaller integer type -- X_init/lispbitmap

* Fixes to INTRSAFE, INTRSAFE0 and ensure TIMEOUT, TIMEOUT0 used appropriately

INTRSAFE and INTRSAFE0 must clear errno before executing the library or system
call because not all library calls set errno on success.
Avoid casting pointers or larger integer values down to smaller ints before
comparing to 0 or -1, and use NULL (a pointer) rather than 0.

Fix cases where the result of the library call is a pointer rather than an int
to use TIMEOUT0 instead of TIMEOUT, testing for NULL rather than -1
on timeout (errno == EINTR)

* Remove useless validity check of LASTVMEMFILEPAGE_word pointer

* Convert pointer arithmetic type in drawline from int to ptrdiff_t

* Add NOTE warning about a 32-bit vs 64-bit issue affecting currently unused GET_NATIVE_ADDR_FROM_LISP_PTR
2021-11-04 09:08:55 -07:00
Nick Briggs
c39b751f42
Rework make_atom() to allow removal of parse_number() (#404)
No calls to make_atom() depend on the ability to parse the atom's
pname as a number.  Additionally, the parse_number() implementation
used here was non-functional.

We remove parse_number() and adjust the parameter list of make_atom()
to remove the non_numericp flag.
2021-10-29 09:51:32 -07:00
Nick Briggs
75c668f1cd
The pointers Atomspace, Spospspace, Snegspace, Arrayspace can be removed (#402)
These pointers are neither initialized nor referenced anywhere in the code.
2021-10-10 16:55:33 -07:00
Nick Briggs
533c935e72
Fix various bugprone warnings (#397)
* Fix some warnings in main.c

main.c:678: narrowing conversion from 'unsigned long' to signed type 'int' is implementation-defined
main.c:493: The return value from the call to 'seteuid' is not checked.

* Fix some warnings in array operations

Instead of extracting typenumbers to an 'int', use the unsigned typenumber directly

array3.c:49: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined
array4.c:61: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined
array5.c:63: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined
array6.c:50: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined

* Resolve type mismatches for version numbers and propp flag

dir.c:1849: narrowing conversion from 'unsigned int' to signed type 'int'
dir.c:1850: narrowing conversion from 'unsigned int' to signed type 'int'
dir.c:2114: narrowing conversion from 'unsigned long' to signed type 'int'
dir.c:2207: narrowing conversion from 'unsigned int' to signed type 'int'

* Resolve type mismatches for version numbers and strlen result type

dsk.c:1072: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1108: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1549: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1712: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:1751: narrowing conversion from 'unsigned long' to signed type 'int'
dsk.c:3426: narrowing conversion from 'unsigned int' to signed type 'int'

* Resolve type mismatches for strlen result type

ufs.c:213: narrowing conversion from 'unsigned long' to signed type 'int'
ufs.c:404: narrowing conversion from 'unsigned long' to signed type 'int'

* Resolve type error

uutils.c:117: 'signed char' to 'int' conversion [bugprone-signed-char-misuse,cert-str34-c]
2021-09-16 17:24:25 -07:00
Nick Briggs
6fedd97d21
add yield subr (#398)
* Add experimental SUBR to call nanosleep() for experiments in reducing CPU load

This adds a SUBR, sb_YIELD, value (octal) 0322 which takes a single number
0..999999999 which is the number of nanoseconds to pass to nanosleep().

The return value is T if the call to nanosleep() was executed or NIL
if it was not (argument out-of-range, or other error in getting the
number from the argument).

To use this experimental SUBR in a sysout you should:

   (SETQ \INITSUBRS (CONS '(YIELD #o322) \INITSUBRS))

then you can define functions that use that SUBR:

   (DEFINEQ (BACKGROUND-YIELD () (SUBRCALL YIELD 833333)))
   (COMPILE 'BACKGROUND-YIELD)
   (SETQ BACKGROUNDFNS (CONS 'BACKGROUND-YIELD BACKGROUNDFNS))

* Update to use subrs.h newly generated from LLSUBRS

The subrs.h include file is generated by WRITECALLSUBRS based on the \INITSUBRS
list.  This update provides for the new YIELD subr in the generated file,
and makes some necessary updates to the C code implementations for some subr
names which have changed.
2021-09-15 10:30:04 -07:00
Nick Briggs
4f79f55c20
Replace uses of atoi() with strtol() or stroul() as appropriate (#394)
As a side-effect of this change, we also resolve a a problem with
signed file version numbers, so that instead of version 2147483647
wrapping to -2147483648 we can go as far as 4294967296 before we
have issues.  Various sprintf() formats get changed from %d to %u.
The DOS version code is left behind as int versions.
2021-09-08 09:58:01 -07:00
Nick Briggs
377a6f3f47
Rewrite keyboard and async I/O handling to improve performance and reduce dependency on async I/O signals (#392)
* Rewrite keyboard and async I/O handling to improve performance and reduce dependency on async I/O signals

Replaces the SIGIO handler, which used to process X events in the interrupt context, with
a stub routine that sets a flag to signal processing is required.
Actual event processing is moved to the main dispatch loop where Lisp periodic interrupts
are handled.

Removes the X connection file descriptor from the set of fds contributing to SIGIO events
and moves the processing of X events to where the Lisp periodic interrupt is handled in
the main dispatch loop.  This code is already guarded by a check for XPending() so can
be called regardless of whether any file descriptors are known to be ready.

Actual processing of async I/O events and X events are handled by procedures
process_io_events() and process_Xevents() respectively.  For the most part these are
a renaming of getsignaldata() and getXsignaldata().

The Lisp periodic timer (VTALRM) was set to operate with a 25000 us period (40 Hz),
but on modern hardware it is possible to run this timer with a period of 10000 us (100 Hz)

Incidentally, a bug was noted (and fixed) in the X event handling code for motion events:
Mouse motion without any keyboard activity should not add an entry to the keyboard event
ring buffer as these events do not represent a key state change.
Since the ring buffer is of limited size, when it is filled new events are ignored
until the buffered events are processed.  This resulted in the loss of a key/mouse button
transition (up or down) if the mouse was moved about "too much" between keyboard events.

A few incidental cleanups were also made:
  - KBDEventFlg initialization fixed (wrong semantic type)
  - Event_Req renamed to IO_Signalled (more appropriate name)
  - int_io_open() sets up process (self) to handle SIGIO generated by O_ASYNC operations
  - LOCK_X_EVENTS turned off since X library calls can no longer happen in an interrupt context

* Use of O_ASYNC must depend on the symbol being defined (looking at you, Cygwin)

* Add SA_RESTART flag to sigaction for SIGVTALRM periodic interrupt

* LOCK_X_UPDATE is no longer needed and should not be defined by default for Solaris in version.h
2021-09-02 12:42:51 -07:00
Nick Briggs
934a86fbb5 Remove Create_N_Set_Cell() which is unused since native code is not supported. 2021-08-24 12:05:17 -07:00
Nick Briggs
6cad51735f
Fix errors preventing the use of -DDTDDEBUG for mkcell.c (#389) 2021-08-11 11:37:15 -07:00
Nick Briggs
c33386ef44
Remove code for unsupported Sun display configurations (#388)
* Remove code for unsupported Sun display configurations

Initial cleanup removing all code that was #ifdef'd for SUNDISPLAY.
Other SunWindows dependent code may also be removeable

* prropstyle will never be defined with no SunWindows support and therefore no pixrect code

* Remove code that is ifndef NOPIXRECT, since pixrects are part of the obsolete Sun windows code.

There are still traces of pixrect dependent code that could be removed.
2021-08-10 16:31:59 -07:00
Nick Briggs
9e179e66f2 Call getXsignaldata() with XLocked set
getXsignaldata() can call additional Xlib procedures which could generate an I/O
interrupt.  To avoid deadlocks in Xlib, ensure that XLocked is set when
getXsignaldata() is called.
2021-07-08 15:18:41 -07:00
Nick Briggs
9ed46e6b69 Integer variables referenced from a signal handler (XLocked, XNeedSignal) should be type sig_atomic_t 2021-07-05 14:19:23 -07:00
Nick Briggs
ef6a6554ac
Remove SIGPOLL usage (#385)
* Remove unnecessary calls to XLOCK/XUNLOCK

The X methods called by flush_display_region() and flush_display_lineregion() handle the
locking/unlocking, therefore it is unnecessary to invoke the locking here.

* Remove explict signals when doing XUNLOCK()

Call getXsignaldata() directly if a signal happened while X code
was locked, instead of generating a signal and then handling it.

Some macros and functions needed to pass the DspInterface instead of
extracting the X display and window and passing those so that the
correct structure was available for the XUNLOCK() call.
2021-06-27 19:02:02 -07:00
Nick Briggs
1c47bf5df0
Fix the FastRetCALL macro to use do {} while (0) style (#384) 2021-06-17 13:21:00 -07:00
Nick Briggs
2122f095e8
Simplify OPFN/OPFNX macros by removing hand expansion of 1, 2, N bindings (#383)
The OPFN and OPFNX macros had been coded with a hand expansion of a loop
pushing values on the stack to separately handle the cases of 1, 2, and
more values.  This actually lead to larger, likely slower, and certainly
less obvious code.
2021-05-18 16:35:21 -07:00
Nick Briggs
c4873d0ff8
Improvements to package/atom access in the sysout from maiko C code (#372)
* Display atom name in error message if get_package_atom() fails

* Various fixes to package/atom handling in testtool.c

Remove S_TOPVAL and S_MAKEATOM which only existed to deal with an old issue
with dbx where you supposedly couldn't enter a string with "\" in it.

Remove countchar(), which is functionally identical to  strlen(), and adjust
code that used it.

Adjust return type of MAKEATOM() to be the LispPTR that it should be, instead of int.

Limit find_package_from_name() to examining only the number of entries that are
present in the *PACKAGE-FROM-INDEX* array, instead of walking off the end.

MakeAtom68k() now drops into uraid() if asked to look up an atom that does not exist
(Make... is a misnomer, it will never *make* the atom, only lookup an existing
one)
2021-03-29 14:01:10 -07:00
Nick Briggs
36ccd9a5f5
warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses] (#374)
Except where the expansion would be syntactically invalid,
for example "goto macroarg;" detection of which is a bug in clang-tidy,
so warn it off with a NOLINT...(bugprone-macro-parentheses)
2021-03-20 16:31:23 -07:00
Bruce Mitchener
0129b50127
tidy: xrdopt. (#364)
* Remove unused `print_lispusage()`.
* Make some globals into function locals.
* Make the options table into a `static`. It can't be `const`
  because `XrmParseCommand` wants a mutable pointer.
* Remove unused `homeDB`.
* Stop using `caddr_t`, use `XPointer`. `caddr_t` is not POSIX
  and never made it past old obsolete BSD code.
2021-02-22 09:44:43 -08:00
Bruce Mitchener
ddb1c9f717 tidy: FindAvailablePty.
* Remove unused `Master` argument.
* Update documentation.
* Remove unused `MasterFD` variable in caller.
* Remove `slot` variable in caller and use `Master` in each case.
* Make `FindAvailablePty` a static function.
2021-02-22 11:54:51 +07:00
Nick Briggs
1043a80d1f
Remove unnecessary (re)definitions of TRUE/FALSE (#356) 2021-02-14 16:47:04 -08:00
Nick Briggs
c60b522012
Files should explicitly include the definitions they directly depend on (#355)
... start by fixing the include files and the fallout in C source from
removing includes not directly needed by headers that previously included
them.
2021-02-13 21:41:31 -08:00
Bruce Mitchener
694d9b08c6
Update more header include guards. (#348)
Some of these didn't have include guards, some  used old names
for them. Now they follow the current convention.
2021-02-11 10:42:07 -08:00
Nick Briggs
1fc0d28167
Fix extra semicolon warnings (#345)
"warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning" [-Wextra-semi-stmt]
occurred 254 times in xc.c when warnings were turned up.

Review this commit with "git diff -w ..." to make it easier to see changes other than indentation caused by
the addition of do { ... } while (0) around many macro definition bodies.
2021-02-10 20:33:54 -08:00
Nick Briggs
7274e16b24
Reformat (with clang-format 10.0) some header files (#344)
...in preparation for editing macro definitions to wrap in do {} while (0)
or other adjustment to make them complete statements without unnecessary
semicolons.

This programmatic reformatting should not introduce any functional changes.
2021-02-10 16:44:37 -08:00
Bruce Mitchener
b21aeecf4c
Remove cdrom&cdaudio support code. (#339)
This is not used in Medley (the MISCN-TABLE-LIST doesn't include
the required constants), nor does anything use or reference this
code. It also won't compile as it needs some routines that are
missing from our code.
2021-02-09 20:38:08 -08:00
Bruce Mitchener
78943073c3
Favor C99 inline over __inline__. (#337) 2021-02-08 19:11:31 -08:00
Bruce Mitchener
c19b184820
Remove GetNumber. (#338)
This isn't used and if it were, it wouldn't compile. It calls
`ufn`, which doesn't get compiled in either (unless `C_ONLY`
is defined, which it isn't, and if it were, that wouldn't
compile either due to a missing `StkLim0`).

A subsequent PR will remove `ufn` and related code.
2021-02-09 03:10:38 +00:00
Nick Briggs
2aacca596b
Fix the unixfork/unixcomm code to deal with pid over 65535 (#333)
* ForkUnixShell() can be a static procedure

* Restructure SAFEREAD() to be a little clearer

* Convert unixjob type field defines to an enum and fix related unhandled switch cases.

* Use local declaration of loop variables in for-loop, removing register attributes

* Restructure SAFEREAD() to be a little clearer

* Send and receive 2 additional bytes for pid.

* Prefer standard C99 "inline" over "__inline__" for SAFEREAD
2021-02-08 18:26:56 -08:00
Nick Briggs
d482cc461c
Address older versions of C compiler which don't have __BYTE_ORDER__ (#335)
* Address older versions of C compiler which don't have __BYTE_ORDER__

* Checking for __GNUC__ is not sufficient to determine if builtins are available.

* Add makefile fragment for 32-bit PowerPC on Mac OSX build, and ignore the build directories.

* Add comment describing use of __BIG/LITTLE_ENDIAN__ definition
2021-02-06 20:51:42 -08:00
Nick Briggs
9957f5c305
Cleanup EVAL macro definition (#334)
Reformat and make use of PTRMASK & swapx() as appropriate.
It's likely that nnewframe() could be reworked to avoid needing
to unconditionally swapx() the result and, like native_newframe()
return the appropriate value as the result.
2021-02-05 00:20:26 +00:00
Nick Briggs
261069f131
Detect byte order from preprocessor definition (#330)
Rather than having to specify or omit -DBYTESWAP in the Makefile
fragment for each system we can detect whether the system requires
byte swapping  based on the __BYTE_ORDER__ C preprocessor definition.

Update CMakeLists.txt to account for this as well.
2021-01-31 16:56:35 -08:00
Bruce Mitchener
70db63449c
Remove support for the Sun386i. (#329)
This was a machine running SunOS 4, which we no longer support.

It had an odd display controller and a compiler with issues that
required workarounds. Those compiler issues aren't an issue in
today's world, so we don't need to keep the workarounds present
for reference.

It had a bit of inline assembly, but that is still present in
other files for other platforms.
2021-01-31 04:02:40 +00:00
Nick Briggs
1f17665741
Fix off-by-one error in clipping_Xbitblt (#327)
The LowerRightX and LowerRightY were calculated as the X and Y coordinates of the
pixel to the right and below the last visible pixel, but are compared with the
last actually visible pixel in the source. They need an extra -1 offset to correct.

Add comments to explain what's going on.  Fix the signature of the function to reflect
that the "dummy" passed for the display region is a pointer not an integer.
2021-01-30 19:03:17 -08:00
Bruce Mitchener
4788031c15
Add an opcodes enum with names for each opcode. (#321)
This is based on the info in `medley/sources/LLCODE`.
2021-01-30 17:24:28 -08:00
Bruce Mitchener
b09663b3e9
Inline swapx and byte_swap_word. (#323)
This lets us remove `SWAP_WORDS` and some bits of assembly.
2021-01-29 23:18:09 -08:00
Bruce Mitchener
40aa5d392d
Remove SwitchDisplay and colordsp. (#317) 2021-01-29 19:56:07 -08:00
Nick Briggs
f7113d53ee
Remove provision for offline assembler peephole optimizations on SunOS3/4 (#304)
We no longer need to run a separate peephole optimization pass over the
compiler generated or hand-coded assembler for SunOS3 and SunOS4 on 68K or SPARC

We remove the preprocessor symbols and code controlled by them
	SUN4_OS4_IL
	SUN3_OS3_IL
	SUN3_OS4_IL
and	SUN3_OS3_OR_OS4_IL
2021-01-26 16:44:40 -08:00
Bruce Mitchener
eba664771a
Fix tty.c to compile. (#180)
This removes a bit of the debug info printing, but other than
that, is pretty close to what it was before.

We also now build it in both the make and cmake build systems.
2021-01-26 17:42:17 +00:00
Bruce Mitchener
8cb1c53e3f
Remove Xbitblt.h (#302)
This unused file contained older, header-only versions of the
code in `xbbt.c`.
2021-01-25 21:55:02 -08:00
Bruce Mitchener
4a722565ab
Sprinkle some const on char * params. (#298)
This is enough to let us move `il_string` in `loopsops.c`
into read-only storage.
2021-01-25 21:04:36 -08:00
Nick Briggs
364420db88
Fix lispcmp bytecmp (#211)
* Correct signedness of 2nd parameter of lispcmp().

* Be clear that comparison of characters in bytecmp is unsigned since GETBYTE returns unsigned char.

* Make bytecmp() and lispcmp() helper functions static and removed from mkatomdefs.h.

* If no BYTESWAP we need to include <string.h> for memcmp()

* Use (uint8_t) rather than (unsigned char) in bytecmp when comparing to GETBYTE()
2021-01-25 09:57:55 -08:00
Bruce Mitchener
07aed60cc7
Remove bbtsub.h, duplicate of bbtsubdefs.h. (#294)
`bbtsubdefs.h` and `bbtsub.h` were close to the same. We only
need one.
2021-01-24 23:22:28 -08:00
Bruce Mitchener
0bcc8718de
Fix typo. (#292) 2021-01-25 07:02:47 +00:00
Nick Briggs
b151790c40
Cleanup for ERROR_EXIT/TIMER_EXIT/WARN style, remove unused typedef (#283)
Convert ERROR_EXIT, TIMER_EXIT, and WARN to "do {} while (0)" style and
  fix a few usage points that were missing trailing semi-colons.
Remove unused typedef for CFuncPtr.
2021-01-24 17:59:31 -08:00