1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-15 15:57:13 +00:00

474 Commits

Author SHA1 Message Date
Nick Briggs
740f012254 Eliminate URaid access to uninitialized pointer when saving post-crash VM image
Old code attempted to save the display region through an uninitialized pointer
which occurs nowhere else in the system.  Removed the save.
2021-09-02 15:14:32 -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
c07618f55c Do not attempt to use ether_fd as valid fd if it is -1. Closes medley #450 2021-09-02 10:35:10 -07:00
Nick Briggs
e957e331c4
Lock X updates for all systems and lock around X cleanup at exit (#391)
* Lock X updates for all systems and lock around X cleanup at exit

All systems which could generate I/O interrupts on the X file descriptor need
to have locking enabled, or there is a high probability that the X library
will deadlock. This requirement may be removed in the future with restructuring
of the way that the interrupt driven I/O is handled.

Ensure that the appropriate XLOCK/XUNLOCK is done around the X window
closing code.

* Also lock X updates when building with CMake.
2021-08-26 16:29:10 -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
28ea238807 Check for flags in argv[1..n] not argv[0..n] 2021-08-23 21:15:23 -07:00
Nick Briggs
81c36341ef Fully initialize XImage ScreenBitmap with XInitImage() before using it. 2021-08-22 18:23:41 -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
c56cbb2a91 Add missing include of <time.h> to initsout.c 2021-08-09 12:30:34 -07:00
Nick Briggs
40e18e6da0 Remove unnecessary XLOCK/XUNLOCK around calls to bitblt_to_screen/clipping_Xbitblt in getXsignaldata() 2021-07-06 20:15:35 -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
934b15b63b Correct declaration mismatch for Event_Req between xc.c and other (correct) sites 2021-07-05 14:10:38 -07:00
Nick Briggs
2de44247b5 Include byteswapdefs.h for swapx() and byte_swap_code_block() 2021-07-05 14:03:02 -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
f42671022f
Remove outdated hand-optimized assembler support for gcc on 386 (#379) 2021-05-29 17:32:32 -07:00
Nick Briggs
a5410ef93d
Cleanup USE_DPLI usage (#378)
Until now, the only differentiation between using DLPI and using NIT for
the ethernet interface was expressed as a function of USE_DLPI.

This commit makes explicit when code is for the DLPI interface or the NIT
interface, with USE_DLPI and USE_NIT.  This is setup for using the BPF
interface to the ethernet as an alternative.
2021-04-07 20:51:28 -07:00
Abe Jellinek
5ce292ed32
Command line: fix potential buffer overruns in argument/env variable handling (#375)
* Fix buffer overrun vulnerability: use strncpy

read_Xoption uses a char buffer defined in main.c with length
MAXPATHLEN, aka PATH_MAX in POSIX. Unfortunately it was using strcpy to
copy from the command-line arguments (via argv) and the environment (via
getenv) without any bounds checking whatsoever. This could very easily
cause an overflow.

It's unlikely that a user will want to provide a path longer than
PATH_MAX-1 (a generous 1023 bytes on my machine). If they try, we should
stop them from causing any damage.

* Use strlcpy instead of strncpy

Thanks to Nick Briggs for the suggestion. It would be best to use
sizeof(sysout_name) instead of hardcoding a reference to the PATH_MAX
constant, but unfortunately sysout_name is an extern in xrdopt.c and so
the compiler doesn't know its size. I don't want to mess with that
coupling in this commit, because I assume there was a reason for doing
it that way rather than putting sysout_name in a header; I'll keep the
scope of the changes here small.

* Revert "Use strlcpy instead of strncpy"

Ah. This is not great. Turns out strlcpy is a nonstandard BSD extension
with its own set of problems
[https://en.wikibooks.org/wiki/C_Programming/C_Reference/nonstandard/strlcpy]
that we may be best served by avoiding. On Linux, it's only accessible
through libbsd, and we have no other reason (as far as I can tell) to
require that. Unless we want to provide our own strlcpy implementation,
we should stick with strncpy. It's far safer than what was there before
and doesn't present any edge cases in this scenario that are apparent to
me.
2021-04-05 14:43:37 -07:00
Nick Briggs
081e2288ff
Enable X mouse buttons 6 and 7 for horizontal scrolling. (#367) 2021-03-29 14:03:14 -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
01a8948a7d
Rename _curXXX structures to curXXX to avoid leading underscore (#376) 2021-03-29 12:34:32 -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
Nick Briggs
be4d4c771e
Fix printf format warnings in testtool.c (#369)
Conversion of PC output from octal to hexadecimal will be handled separately as there are multiple places that this change needs to take place.
2021-03-18 15:40:02 -07:00
Nick Briggs
c6a74b2516
XrmParseCommand and XrmMergeDatabases depend on destination database being initialized. (#366) 2021-02-23 01:45:43 +00:00
Bruce Mitchener
d8e063bf02
tidy: Remove last caddr_t. (#365)
This cast isn't needed here and `caddr_t` is obsolete / not POSIX.
2021-02-22 09:45:07 -08: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
a64a06466c
tidy: initdsp: Remove some unused globals. (#363) 2021-02-22 09:44:21 -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
31927cd255
Clean up missing include file when compiling for INIT (#359)
* Compiling for INIT requires an extra include file vs normal.

* Compiling for INIT often includes tracing which also requires additional includes
2021-02-17 11:35:33 -08: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
Nick Briggs
f019d3ddc2
Compiling with ethernet support requires etherdefs.h in certain places (#354) 2021-02-13 17:22:27 -08:00
Bruce Mitchener
64957b508d
Fix some unused variable warnings. (#352)
Also removes a prototype that wasn't needed.
2021-02-13 09:14:12 -08:00
Nick Briggs
1116ee7b60
Fix missing includes in ldeether.c (#351) 2021-02-13 09:07:21 -08:00
Nick Briggs
3a55f1d132
Missing include of sys/select.h in tty.c (closes Interlisp/medley#186) (#353)
(fix confirmed by original issue reporter)
2021-02-13 16:41:20 +00:00
Nick Briggs
f2ac050e8e
Prevent duplicate printing of info lines in response to -info option (#349)
The X options parser printed the info lines as well as the main options handler.
Add mention of the -info option in the -help usage information.

Fixes Interlisp/medley#41
2021-02-12 08:06:43 -08:00
Nick Briggs
0d7dcc24bd Minor formatting revisions. 2021-02-11 23:35:38 -08:00
Nick Briggs
2a71f330b5 Allocate fptovp table from heap and release it when done 2021-02-11 23:24:25 -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
c9a0d441c4
Cleanup timer leftovers (#341)
* Remove unnecessary variables and calls during itimer setup.

* Variable referenced from signal handler should be volatile and sig_atomic_t
2021-02-10 13:58:40 -08:00
Bruce Mitchener
015972c05c
Remove Cldeetr.c. (#340)
This was like `ldeether`, but for SunOS4 with a color display. It
isn't needed any longer as on Solaris, we have `ldeether`, no color
display, and that code already works, unlike this one.
2021-02-09 23:14:51 -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
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
Bruce Mitchener
f0a53302ce
Fix compilation with MAIKO_HANDLE_CONSOLE_MESSAGES. (#332)
* Switch from sgtty over to termios. All of the various
  separate values that were copied individually before
  can now be done at once.
* Fix compilation error with missing `&`.
* Fix compilation error with missing return value.

I haven't tested that this works as I don't know how to do that,
but at least it compiles now.
2021-02-01 06:42:39 +00:00
Bruce Mitchener
275c5b9c13
Clean up MAIKO_HANDLE_CONSOLE_MESSAGES some. (#331)
* `LOGINT` is only useful when `MAIKO_HANDLE_CONSOLE_MESSAGES`
  is set.
* Only define some variables if `MAIKO_HANDLE_CONSOLE_MESSAGES`
  is set. Flag them as static.
* Remove setting `LOGINT` from the build system as it isn't
  needed because we aren't handling console messages.
2021-01-31 21:22:13 -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
Nick Briggs
3764acda85
The MISC7 (FBITMAPBIT) opcode should flush the correct bits to the display (#328)
The MISC7 opcode was not accounting for the offset from the base when
calculating which (16-bit) word should be flushed to the actual display.
2021-01-30 18:42:47 -08:00