91 Commits

Author SHA1 Message Date
Fish (David B. Trout)
d094e4f3c6 Carry over into SDL Hyperion some recent Aethra fixes:
. Fix compiler warnings on macOS.
. Fix compiler warnings on GCC 12.

. Use performance cores on Apple Silicon. (Enrico Sorichetti)

. Save maxprio/minprio in sysblk so impl() doesn't clobber them. (Tyler Mitchell)
. Handle non-GNU Linuxes properly. (Tyler Mitchell)
. getprotobyname: some Linuxes want "tcp" not "TCP". (Tyler Mitchell)
. Fix for occasional crash on exit. (Tyler Mitchell):

  In POSIX, detach_thread() is neither needed nor valid
  after a return from join_thread(). When the latter returns,
  the thread has exited and its resources are released,
  so detach_thread() not only is not needed, but references
  deallocated resources. This can be harmless, but not always.
2024-01-24 13:17:39 -08:00
Fish (David B. Trout)
7ba1ff2373 (cosmetic: remove trailing blanks) 2023-08-12 08:13:05 -07:00
Fish (David B. Trout)
87d04ed9ef Fix usleep() bug causing excessive host CPU consumption:
The root cause of the bug was in my incorrect #define of MAX_TOD_UPDATE_USECS in featall.h, which was #defined to 1000000 (one million) instead of 999999, thereby causing the TXF rubato_thread to do a usleep for 1000000 (one million) microseconds, which, being invalid, was causing it to not sleep at all and instead return immediately with an error, causing it to loop continuously without sleeping, consuming all available host CPU due to the timer threads being the highest priority thread in Hercules.

comm3705.c also had a similar bug wherein it was using "min(1000000,delay)" for one of its usleep().

In addition to fixing the previously mentioned bug, I have also introduced a new USLEEP() macro which calls a new "herc_usleep()" function that will report any usleep() error that might occur. (I purposely did not code it to fix (hide) the problem but rather to just report it so that the caller can thus be fixed to not make invalid usleep calls.)

This should close GitHub Issue #589 "Auxiliary threads eating up CPU time" as well as the long running "CPU utilization on Raspberry Pi" thread that took place in the main Hercules group recently.
2023-08-04 22:04:53 -07:00
Rhialto The M
8175ad07bc Fix UB when calling ctype functions. (#570)
Compiling Hercules with gcc 10 produces many warnings like this one:
```
  CC       hao.lo
In file included from /usr/include/ctype.h:97,
                 from hstdinc.h:117,
                 from hao.c:17:
hao.c: In function 'hao_message':
hao.c:812:37: warning: array subscript has type 'char' [-Wchar-subscripts]
  812 |                         if (isdigit(p[2]))
      |                             ^
```
Gcc should really present these as compile time errors, since each and every
one represents a potential case of Undefined Behaviour.
I changed (almost) all of these calls, except a few where the parameter was an
int that just came from a getc()-type function.
2023-06-12 11:43:50 -07:00
Fish (David B. Trout)
97a397673e Various misc. tweaks:
Mostly related to messages and the moving of several misc. utility/helper functions to hscutil.c where they belong.
2022-11-23 01:01:32 -08:00
Fish (David B. Trout)
5198616db6 Fix runtest script timeout parsing and error handling 2022-11-15 00:18:00 -08:00
Ivan Warren
f095637632 Back out chnages introduced by 56a5cb10c3 2020-12-09 22:50:50 +01:00
Ivan Warren
56a5cb10c3 fix: Fix (attempt) for race condition in runtest (make check) 2020-12-07 15:52:54 +01:00
Fish (David B. Trout)
cba56356fc Fix most Mac print format warnings regarding thread id 2019-04-09 23:24:32 -07:00
Fish (David B. Trout)
971a864592 Use hercules.rc in current directory if appropriate:
Fix regression caused by commit 79a0a17354: use the .rc file specified by the '-r' command line argument first (if given), or defined by the HERCULES_RC environment variable if the '-r' command line argument was not specified, but then default to using the "hercules.rc" file in the current directory (if it exists) if neither was specified.

Closes #179: "Presence of hercules.rc not honored, need -r option".
2019-02-02 05:49:27 -08:00
Fish (David B. Trout)
652e952fac Move parse_args to hutil so e.g. utilities can use it too. 2019-01-28 19:52:00 -08:00
Fish (David B. Trout)
f6923d8302 Replace 'getenv' calls with 'get_symbol' calls instead #3:
Closes #178 "File Set Via HERCULES_RC Environment Variable No Longer Found".
2019-01-26 18:15:33 -08:00
Fish (David B. Trout)
fd239c34a0 Make ENABLE_SYSTEM_SYMBOLS et al. permanent:
The ENABLE_CONFIG_INCLUDE, ENABLE_SYSTEM_SYMBOLS, ENABLE_BUILTIN_SYMBOLS build options are no longer optional build options. This reduces #if defined() tests and makes the code clearer and easier to maintain. (I doubt anyone actually builds special builds of Hercules without these build options defined anyway.)
2019-01-19 23:16:01 -08:00
Fish (David B. Trout)
6c3d42e269 Thread name constants 2018-07-24 05:56:40 -07:00
Fish (David B. Trout)
3d02efac2b simplify get/set_thread_priority macro use 2018-07-08 12:46:27 -07:00
Fish (David B. Trout)
544ee1e09d HDL cleanup part 1 continued:
define typedefs for HDL function pointers and use them in hsys.c and hexterns.h
2018-03-08 13:27:42 -08:00
Fish (David B. Trout)
4f1b20b622 Make DYNAMIC_LOAD, BUILD_SHARED, EXTERNALGUI permanent. 2018-03-08 13:27:42 -08:00
Fish (David B. Trout)
771dccae92 standard beginning of all source files ...
... according to comments in impexp.h.
2018-03-08 13:27:41 -08:00
Fish (David B. Trout)
a22e26e108 Use capital (C) in Copyright message 2018-03-08 13:27:34 -08:00
Stephen Orso
b737f04b5b Fix runtest issues identified by Steve Orso:
1. Due to variable internal delay starting a CPU depending on host load, runtest4's expected test duration should be increased to prevent sporadic failures on non-idle hosts.

2. Doing a "sysclear" to reset the system when a test fails makes it impossible to examine storage to determine why it failed.  Change to "stopall" and "sysreset" instead, which doesn't clear storage, making for easier forensic post-mortem analysis.
2018-03-08 13:25:55 -08:00
Fish (David B. Trout)
c80e60a2ce LARGE Cosmetic: many renames and added comments:
_ARCHMODE1/2/3    ==>  _ARCH_NUM_0/1/2
ARCH_370/390/900  ==>  ARCH_370/390/900_IDX
GEN_ARCHCOUNT     ==>  NUM_GEN_ARCHS
GEN_MAXARCH       ==>  NUM_INSTR_TAB_PTRS
zz_func           ==>  instr_func
2018-03-08 13:25:44 -08:00
Fish (David B. Trout)
6b5e721065 strlcpy/strlcat ==> STRLCPY/STRLCAT 2017-05-14 23:52:31 -07:00
Fish (David B. Trout)
8ded95b890 ENABLE_xxx..._REXX ==> HAVE_xxx..._REXX 2017-05-14 11:45:00 -07:00
Fish (David B. Trout)
cdc014ad14 Miscellaneous tweaks:
reverse_bits, tkcount, STRLCPY, RTRIM et al.
Improved w32_basename, w32_dirname.
dlerror() ==> strerror(GetLastError())
arraysize ==> _countof
script runtest timeout duration
BFR_VSNPRINTF: identical for Window/Linux
hdl_setpath: MSVC 'stat' fix
HTML web page consistency
2017-05-14 10:51:48 -07:00
Fish (David B. Trout)
800aac0ff2 Fix warning 2016-05-17 06:59:30 -07:00
John P. Hartmann
7f8d738b62 Enhcance the runtest script command to load the restart new PSW
from one of the five other old PSWs.

This is specified by the interrupt name in the first operand, e.g.,
to continue after an expected program check:

runtest program

The psa member of REGS is made a union to support accessing it
without having to cast the z architecture PSA.
2016-05-15 16:59:52 +02:00
Fish (David B. Trout)
63a47cc322 Fix runtest breakage caused by 2c03ad1ad9 item 2. 2015-12-17 13:56:06 -08:00
Fish (David B. Trout)
638e145e33 Fix incorrect .HET handling of BSF to Load Point:
Problem originally reported by Steve Orso <stephen.orso@yahoo.com> as "Backspace File CCW does not reposition HET tapes under certain circumstances" in Hercules-390 group (as well as in the "Re: DOS Samples" thread of the H390-DOSVS group).
2015-12-14 20:22:04 -08:00
John P. Hartmann
b49b566561 Support -r - to specify reading the .rc file from standard input.
In daemon mode, treat standard input as a .rc file.
2015-11-27 13:44:31 +01:00
John P. Hartmann
79a0a17354 Fix impl.c to process arguments early so that flags are set correctly.
This implements daemon mode as it should be.

Still a number of problems (sigsevs), but it is unclear which are due
to this fix and what if due to my environment, so we stash this for now.
2015-11-24 13:34:35 +01:00
John P. Hartmann
e2168b293b Remove unix semaphore code.
Update testing engine to support comparing multiple messages and
if/then/else for 32 bit vs 64 bit systems.

The code to run the .rc script is called only when the .rc file
must exist (specified as -r or environmentor hercules.rc does
exist).
2015-11-22 13:40:14 +01:00
John P. Hartmann
798b79e60a Remove some debugging messages.
Sorry.  They should have been gone in the commit.
2015-11-14 11:49:43 +01:00
Fish (David B. Trout)
17b243c102 JPHTEST 2015-11-13 09:42:34 -08:00
John P. Hartmann
0e8b4cf3ec Add 'testpath' predefined variable when using RUNTEST
Any script commands should reference this variable.  Fish should
presumably define this variable as '.' on windows.
2015-11-13 17:03:23 +01:00
John P. Hartmann
ce26653a1b Fix script.c to issue a message when a script command cannot be resolved
Problem was that any scripts embedded in a .rc script failed without a message.

The aggregate command from a script file is computed incorrectly when
any return code is negative.

tests/README has been gently wordsmithed.
2015-11-13 15:49:48 +01:00
Fish (David B. Trout)
2c03ad1ad9 Windows 'runtest' tweaks:
1. Add support for runtest script command arguments.
2. Tweak end of test detection in cpu.c and script.c
3. Split runtest.tst test into runtest0.tst and runtest4.tst
4. Add tests recently added by previous commits to makefile.am and vcproj.
5. Document runtest test script command in readme.
2015-11-12 17:24:58 -08:00
John P. Hartmann
0b3dc9319f Change sigp test to do runtest start after it has sigp'ed stop
Add -t flag to runtest command

Add comments to cpu.c and remove unused variable from impl.c
2015-11-12 19:41:11 +01:00
John P. Hartmann
8dd13939a0 Add test cases for timeout and multicpu disabled wait.
Also gag automatic maxrates.

For the moment, the bitmaps of configured, starting, and waiting CPUs
are displayed on Linux when the last CPU goes into the stopped state
and when a test case times out.
2015-11-12 13:09:49 +01:00
John P. Hartmann
7fb7093dc7 Merge branch 'devel'
Conflicts:
	cpu.c
	impl.c
	tests/agf.assemble
	tests/agf.listing
	tests/agf.tst
	tests/logicimm.assemble
	tests/logicimm.listing
	tests/logicimm.tst
	tests/sske.assemble
	tests/sske.listing
	tests/sske.tst
2015-11-11 20:54:11 +01:00
John P. Hartmann
027535909d Linux semaphore implementation runs. 2015-11-11 19:32:17 +01:00
Fish (David B. Trout)
7890543f79 Fix runtest to detect stopped CPUs too:
This should resolve the sigp.tst problem that previous commits 5b9b82fb18 and 5b9b82fb18 attempted to resolve but actually didn't.

Note that this also reverts commit db0959cf0a too, which was the beginning of a different attempt to resolve the same problem.
2015-11-10 12:50:34 -08:00
Fish (David B. Trout)
4b247eff7a Backout bad commit 5b9b82fb18 2015-11-09 20:23:05 -08:00
Fish (David B. Trout)
5b9b82fb18 Fix is_test_done to prevent deadlock w/cpu thread. 2015-11-09 18:00:33 -08:00
Fish (David B. Trout)
fa24e4e317 Hercules 'runtest' testing harness rework:
1. New -t command line switch to activate test mode (see hercinst.html).
2. New 'runtest' test script command to replace existing 'wait' command that issues the 'restart' to start the test and then waits for it to complete.
3. Tweak 'is_test_done' function and cpu.c code to address new 'sigp' test needs.
4. Change most existing tests to use new 'runtest' test script command.
5. Enhance Windows "runtest.cmd" batch file to support '/r' repeat option and '-t' test timeout factor value, as well as resetting the system state (specifically, numcpu) between each test. (Needs more work)
6. Tweak redtest.rexx reduction script to work properly with timestamped logfile messages.
2015-11-09 15:31:56 -08:00
Fish (David B. Trout)
59697f18da Test harness script 'wait' command:
A new script-only command called "wait" is introduced that waits for all processors to load a disabled wait PSW before continuing.

Its syntax is identical to the "pause" statement.  You specify on your "wait" statement the maximum number of seconds you are willing to wait for all CPUs to enter disabled wait.  If the time limit is exceeded the script issues a warning and continues anyway.  Otherwise it will continue immediately as soon as all CPUs have entered a disabled wait state.  A new 'wait.tst' test verifies proper functionality.

Both the "pause" statement as well as the new "wait" statement are now handled virtually identically by the new logic which also resolves (eliminates) the previous poorly designed 'polling" technique.  Canceling a script via the "cscript" command now occurs immediately.

The bug in the the *nix 'runtest' script introduced by commit 87b551b77f is also fixed.
2015-11-01 12:57:27 -08:00
Fish (David B. Trout)
65e34ab264 Revert most of 9c26648e1a
(under discussion)
2015-10-24 11:05:35 -07:00
John P. Hartmann
9c26648e1a Add suspend script command. Silence some warnings. Make some test cases use suspend.
The suspend command, when semaphore.h is available, uses sem_wait to wait for
sem_post when the last active CPU goes into a disabled wait.

When semaphore.h is not available or the semaphore is not initialised,
suspend behaves exactly like pause.  Thus, you should specify a wait time.
2015-10-24 14:34:40 +02:00
Fish (David B. Trout)
dd9de618cc Resolve symbols before echoing command 2015-10-16 14:59:15 -07:00
Fish (David B. Trout)
04cbb443da Fix MSVC build error C4702: unreachable code 2015-01-25 16:38:56 -08:00
Enrico Sorichetti
93005fb28b symbols cleanup
renamed some flags for consistency
	obey casing rules for symbol names ( case sensitive for unix like )
	deleted the setenv code
	proper stacking of symbols values
	some non symbols related mods ( cosmetics ??? )
	tested on ...
	Yosemite(CLANG), Centos-6(GCC), Centos-7 (CLANG and GCC)
	( reinstalling windows XP under VMware takes longer than planned )
2014-11-30 17:29:41 +01:00