diff --git a/scp.c b/scp.c index 58a0a5fe..1f66614d 100644 --- a/scp.c +++ b/scp.c @@ -564,7 +564,7 @@ const struct scp_error { {"TTMO", "Console Telnet connection timed out"}, {"STALL", "Console Telnet output stall"}, {"AFAIL", "Assertion failed"}, -}; + }; const size_t size_map[] = { sizeof (int8), sizeof (int8), sizeof (int16), sizeof (int32), sizeof (int32) @@ -722,12 +722,12 @@ static CTAB cmd_table[] = { "sh{ow} fea{tures} show system devices with descriptions\n" "sh{ow} m{odifiers} show modifiers for all devices\n" "sh{ow} s{how} show SHOW commands for all devices\n" - "sh{ow} n{ames} show logical names\n" - "sh{ow} q{ueue} show event queue\n" + "sh{ow} n{ames} show logical names\n" + "sh{ow} q{ueue} show event queue\n" "sh{ow} ti{me} show simulated time\n" - "sh{ow} th{rottle} show simulation rate\n" + "sh{ow} th{rottle} show simulation rate\n" "sh{ow} a{synch} show asynchronouse I/O state\n" - "sh{ow} ve{rsion} show simulator version\n" + "sh{ow} ve{rsion} show simulator version\n" "sh{ow} def{ault} show current directory\n" "sh{ow} RADIX show device display radix\n" "sh{ow} DEBUG show device debug flags\n" @@ -784,19 +784,19 @@ static CTAB cmd_table[] = { #if defined(_WIN32) || defined(__hpux) static int setenv(const char *envname, const char *envval, int overwrite) - { - char *envstr = malloc(strlen(envname)+strlen(envval)+2); - int r; +{ +char *envstr = malloc(strlen(envname)+strlen(envval)+2); +int r; - sprintf(envstr, "%s=%s", envname, envval); +sprintf(envstr, "%s=%s", envname, envval); #if defined(_WIN32) - r = _putenv(envstr); - free(envstr); +r = _putenv(envstr); +free(envstr); #else - r = putenv(envstr); +r = putenv(envstr); #endif - return r; - } +return r; +} #endif @@ -1646,7 +1646,6 @@ do { cmdp->message ((!echo && !sim_quiet) ? ocptr : NULL, stat); else if (stat >= SCPE_BASE) { /* report error if not suppressed */ - printf ("%s\n", sim_error_text (stat)); if (sim_log) fprintf (sim_log, "%s\n", sim_error_text (stat)); @@ -1874,7 +1873,7 @@ return SCPE_OK; } /* Assert command - + Syntax: ASSERT {} {} If is not specified, CPU is assumed. is expressed in the radix @@ -2196,7 +2195,7 @@ return SCPE_OK; t_stat set_cmd (int32 flag, char *cptr) { -uint32 lvl; +uint32 lvl = 0; t_stat r; char gbuf[CBUFSIZE], *cvptr, *svptr; DEVICE *dptr; @@ -2592,7 +2591,7 @@ while (*cptr != 0) { /* do all mods */ *cvptr++ = 0; for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) { if (((mptr->mask & MTAB_XTD)? /* right level? */ - (mptr->mask & lvl): (MTAB_VUN & lvl)) && + (mptr->mask & lvl): (MTAB_VUN & lvl)) && ((mptr->disp && mptr->pstring && /* named disp? */ (MATCH_CMD (gbuf, mptr->pstring) == 0)) // || @@ -2755,7 +2754,7 @@ if (cptr && (*cptr != 0)) fprintf (st, "%s simulator V%d.%d-%d", sim_name, vmaj, vmin, vpat); if (vdelt) fprintf (st, " delta %d", vdelt); -#if defined(SIM_VERSION_MODE) +#if defined (SIM_VERSION_MODE) fprintf (st, " %s", SIM_VERSION_MODE); #endif if (flag) { @@ -2774,13 +2773,25 @@ if (flag) { #if defined (SIM_ASYNCH_IO) fprintf (st, "\n\t\tAsynchronous I/O support"); #endif -#if defined(SIM_ASYNCH_MUX) +#if defined (SIM_ASYNCH_MUX) fprintf (st, "\n\t\tAsynchronous Multiplexer support"); #endif -#if defined(SIM_ASYNCH_CLOCKS) +#if defined (SIM_ASYNCH_CLOCKS) fprintf (st, "\n\t\tAsynchronous Clock support"); #endif fprintf (st, "\n\tHost Platform:"); +#if defined (__clang_version__) + fprintf (st, "\n\t\tCompiler: clang %s", __clang_version__); +#elif defined (__GNUC__) && defined (__VERSION__) + fprintf (st, "\n\t\tCompiler: GCC %s", __VERSION__); +#elif defined (_MSC_FULL_VER) && defined (_MSC_BUILD) + fprintf (st, "\n\t\tCompiler: Microsoft Visual C++ %d.%02d.%05d.%02d", _MSC_FULL_VER/10000000, (_MSC_FULL_VER/100000)%100, _MSC_FULL_VER%100000, _MSC_BUILD); +#elif defined (__DECC_VER) + fprintf (st, "\n\t\tCompiler: DEC C %c%d.%d-%03d", ("T SV")[((__DECC_VER/10000)%10)-6], __DECC_VER/10000000, (__DECC_VER/100000)%100, __DECC_VER%10000); +#endif +#if defined (__DATE__) && defined (__TIME__) + fprintf (st, "\n\t\tSimulator Compiled: %s at %s", __DATE__, __TIME__); +#endif fprintf (st, "\n\t\tMemory Access: %s Endian", sim_end ? "Little" : "Big"); fprintf (st, "\n\t\tMemory Pointer Size: %d bits", (int)sizeof(dptr)*8); fprintf (st, "\n\t\t%s", sim_toffset_64 ? "Large File (>2GB) support" : "No Large File support"); @@ -2802,6 +2813,15 @@ if (flag) { #define S_xstr(a) S_str(a) #define S_str(a) #a fprintf (st, "%sgit commit id: %8.8s", flag ? "\n " : " ", S_xstr(SIM_GIT_COMMIT_ID)); +#undef S_str +#undef S_xstr +#endif +#if defined(SIM_BUILD) +#define S_xstr(a) S_str(a) +#define S_str(a) #a +fprintf (st, "%sBuild: %s", flag ? "\n " : " ", S_xstr(SIM_BUILD)); +#undef S_str +#undef S_xstr #endif fprintf (st, "\n"); return SCPE_OK; @@ -3011,7 +3031,7 @@ DEVICE *dptr; if (cptr && (*cptr != 0)) /* now eol? */ return SCPE_2MARG; -for (i = 0; (dptr = sim_devices[i]) != NULL; i++) +for (i = 0; (dptr = sim_devices[i]) != NULL; i++) show_dev_modifiers (st, dptr, NULL, flag, cptr); for (i = 0; sim_internal_device_count && (dptr = sim_internal_devices[i]); ++i) show_dev_modifiers (st, dptr, NULL, flag, cptr); @@ -3106,7 +3126,7 @@ sim_trim_endspc(cptr); if (chdir(cptr) != 0) { printf("Unable to change to: %s\n", cptr); return SCPE_IOERR & SCPE_NOMESSAGE; -} + } return SCPE_OK; } @@ -3132,7 +3152,7 @@ t_stat r; t_addr lo, hi, max = uptr->capac - 1; int32 cnt; -if (sim_brk_types == 0) +if (sim_brk_types == 0) return SCPE_NOFNC; if ((dptr == NULL) || (uptr == NULL)) return SCPE_IERR; @@ -3166,7 +3186,7 @@ while (*cptr) { sim_brk_showall (st, sim_switches); else return SCPE_ARG; } - else { + else { for ( ; lo <= hi; lo = lo + 1) { r = ssh_break_one (st, flg, lo, cnt, aptr); if (r != SCPE_OK) @@ -3377,7 +3397,11 @@ if (sim_switches & SWMASK ('R')) { /* read only? */ else { /* normal */ uptr->fileref = sim_fopen (cptr, "rb+"); /* open r/w */ if (uptr->fileref == NULL) { /* open fail? */ +#if defined(EPERM) + if ((errno == EROFS) || (errno == EACCES) || (errno == EPERM)) {/* read only? */ +#else if ((errno == EROFS) || (errno == EACCES)) { /* read only? */ +#endif if ((uptr->flags & UNIT_ROABLE) == 0) /* allowed? */ return attach_err (uptr, SCPE_NORO); /* no error */ uptr->fileref = sim_fopen (cptr, "rb"); /* open rd only */ @@ -3807,7 +3831,7 @@ fstat (fileno (rfile), &rstat); READ_S (buf); /* [V2.5+] read version */ v35 = v32 = FALSE; if (strcmp (buf, save_vercur) == 0) /* version 3.5? */ - v35 = v32 = TRUE; + v35 = v32 = TRUE; else if (strcmp (buf, save_ver32) == 0) /* version 3.2? */ v32 = TRUE; else if (strcmp (buf, save_ver30) != 0) { /* version 3.0? */ @@ -4307,6 +4331,7 @@ return sim_cancel (&sim_step_unit); void int_handler (int sig) { stop_cpu = 1; +sim_interval = 0; /* should speed up stop detection */ return; } @@ -4362,7 +4387,7 @@ for (gptr = gbuf, reason = SCPE_OK; tdptr = sim_dfdev; /* working dptr */ if (strncmp (gptr, "STATE", strlen ("STATE")) == 0) { tptr = gptr + strlen ("STATE"); - if (*tptr && (*tptr++ != ',')) + if (*tptr && (*tptr++ != ',')) return SCPE_ARG; if ((lowr = sim_dfdev->registers) == NULL) return SCPE_NXREG; @@ -4421,7 +4446,7 @@ return reason; exdep_addr_loop examine/deposit range of addresses */ -t_stat exdep_reg_loop (FILE *ofile, SCHTAB *schptr, int32 flag, char *cptr, +t_stat exdep_reg_loop (FILE *ofile, SCHTAB *schptr, int32 flag, char *cptr, REG *lowr, REG *highr, uint32 lows, uint32 highs) { t_stat reason; @@ -4693,13 +4718,13 @@ if ((rptr->depth > 1) && (rptr->flags & REG_UNIT)) { #if defined (USE_INT64) if (sz <= sizeof (uint32)) *((uint32 *) uptr) = (*((uint32 *) uptr) & - ~(((uint32) mask) << rptr->offset)) | + ~(((uint32) mask) << rptr->offset)) | (((uint32) val) << rptr->offset); else *((t_uint64 *) uptr) = (*((t_uint64 *) uptr) & ~(mask << rptr->offset)) | (val << rptr->offset); #else *((uint32 *) uptr) = (*((uint32 *) uptr) & - ~(((uint32) mask) << rptr->offset)) | + ~(((uint32) mask) << rptr->offset)) | (((uint32) val) << rptr->offset); #endif } @@ -4887,7 +4912,7 @@ for (i = 0, j = addr; i < count; i++, j = j + dptr->aincr) { loc = j / dptr->aincr; if (uptr->flags & UNIT_BUF) { SZ_STORE (sz, sim_eval[i], uptr->filebuf, loc); - if (loc >= uptr->hwmark) + if (loc >= uptr->hwmark) uptr->hwmark = (uint32) loc + 1; } else { @@ -5526,7 +5551,7 @@ while (*cptr) { /* loop through modifier cptr = get_glyph_nc (cptr + 1, gbuf, 0); sim_ofile = sim_fopen (gbuf, "a"); /* open for append */ if (sim_ofile == NULL) { /* open failed? */ - *st = SCPE_OPENERR; + *st = SCPE_OPENERR; return NULL; } sim_opt_out |= CMD_OPT_OF; /* got output file */ @@ -6565,7 +6590,7 @@ if (sim_deb && (dptr->dctrl & dbits)) { Callers should be calling sim_debug() which is a macro defined in scp.h which evaluates the action condition before incurring call overhead. */ - + void _sim_debug (uint32 dbits, DEVICE* dptr, const char* fmt, ...) { if (sim_deb && (dptr->dctrl & dbits)) { diff --git a/sim_console.c b/sim_console.c index 0ba3ae26..72179c84 100644 --- a/sim_console.c +++ b/sim_console.c @@ -1310,7 +1310,7 @@ if ((std_input) && /* Not Background proces GetConsoleMode (std_input, &saved_mode); /* Save Mode */ return SCPE_OK; } - + static t_stat sim_os_ttrun (void) { if ((std_input) && /* If Not Background process? */ diff --git a/sim_defs.h b/sim_defs.h index e8806dca..c4256054 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -579,7 +579,7 @@ struct sim_schtab { struct sim_brktab { t_addr addr; /* address */ int32 typ; /* mask of types */ - int32 cnt; /* proceed count */ + int32 cnt; /* proceed count */ char *act; /* action string */ }; diff --git a/sim_disk.c b/sim_disk.c index 12072bc7..dab4acb0 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -534,7 +534,7 @@ t_stat sim_disk_rdsect (UNIT *uptr, t_lba lba, uint8 *buf, t_seccnt *sectsread, { t_stat r; struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; -t_seccnt sread; +t_seccnt sread = 0; sim_debug (ctx->dbit, ctx->dptr, "sim_disk_rdsect(unit=%d, lba=0x%X, sects=%d)\n", (int)(uptr-ctx->dptr->units), lba, sects); @@ -2185,10 +2185,10 @@ typedef t_int64 int64; typedef struct _VHD_Footer { /* Cookies are used to uniquely identify the original creator of the hard disk - image. The values are case-sensitive. Microsoft uses the “conectix” string + image. The values are case-sensitive. Microsoft uses the "conectix" string to identify this file as a hard disk image created by Microsoft Virtual Server, Virtual PC, and predecessor products. The cookie is stored as an - eight-character ASCII string with the “c” in the first byte, the “o” in + eight-character ASCII string with the "c" in the first byte, the "o" in the second byte, and so on. */ char Cookie[8]; @@ -2303,7 +2303,7 @@ typedef struct _VHD_Footer { uint32 DiskType; /* This field holds a basic checksum of the hard disk footer. It is just a - one’s complement of the sum of all the bytes in the footer without the + one's complement of the sum of all the bytes in the footer without the checksum field. If the checksum verification fails, the Virtual PC and Virtual Server products will instead use the header. If the checksum in the header also @@ -2342,7 +2342,7 @@ typedef struct _VHD_Footer { } VHD_Footer; /* -For dynamic and differencing disk images, the “Data Offset” field within +For dynamic and differencing disk images, the "Data Offset" field within the image footer points to a secondary structure that provides additional information about the disk image. The dynamic disk header should appear on a sector (512-byte) boundary. @@ -2389,7 +2389,7 @@ typedef struct _VHD_DynamicDiskHeader { */ uint32 BlockSize; /* - This field holds a basic checksum of the dynamic header. It is a one’s + This field holds a basic checksum of the dynamic header. It is a one's complement of the sum of all the bytes in the header without the checksum field. If the checksum verification fails the file should be assumed to be corrupt. @@ -2398,7 +2398,7 @@ typedef struct _VHD_DynamicDiskHeader { /* This field is used for differencing hard disks. A differencing hard disk stores a 128-bit UUID of the parent hard disk. For more information, see - “Creating Differencing Hard Disk Images” later in this paper. + "Creating Differencing Hard Disk Images" later in this paper. */ uint8 ParentUniqueID[16]; /* @@ -2424,8 +2424,8 @@ typedef struct _VHD_DynamicDiskHeader { /* The platform code describes which platform-specific format is used for the file locator. For Windows, a file locator is stored as a path (for example. - “c:\disksimages\ParentDisk.vhd”). On a Macintosh system, the file locator - is a binary large object (blob) that contains an “alias.” The parent locator + "c:\disksimages\ParentDisk.vhd"). On a Macintosh system, the file locator + is a binary large object (blob) that contains an "alias." The parent locator table is used to support moving hard disk images across platforms. Some current platform codes include the following: Platform Code Description diff --git a/sim_ether.c b/sim_ether.c index 09545280..d592fd62 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -2009,41 +2009,41 @@ sim_debug(dev->dbit, dev->dptr, "Determining Address Conflict for MAC address: % be affected by an address conflict were physically present on a single Ethernet cable which might have been extended by a couple of repeaters). Since that time, essentially no networks are single collision domains. - Thick and thinwire Ethernet cables don’t exist and very few networks + Thick and thinwire Ethernet cables don't exist and very few networks even have hubs. Today, essentially all LANs are deployed using one or more layers of network switches. In a switched LAN environment, the - switches on the LAN ‘learn’ which ports on the LAN source traffic from + switches on the LAN "learn" which ports on the LAN source traffic from which MAC addresses and then forward traffic destined for particular MAC address to the appropriate ports. If a particular MAC address is - already in use somewhere on the LAN, then the switches ‘know’ where + already in use somewhere on the LAN, then the switches "know" where it is. The host based test using the loopback protocol is poorly designed to detect this condition. This test is performed by the host - first changing the device’s Physical MAC address to the address which + first changing the device's Physical MAC address to the address which is to be tested, and then sending a loopback packet FROM AND TO this MAC address with a loopback reply to be sent by a system which may be currently using the MAC address. If no reply is received, then the MAC address is presumed to be unused. The sending of this packet will result in its delivery to the right system since the switch port/MAC address tables know where to deliver packets destined to this MAC - address, however the response it generates won’t be delivered to the - system performing the test since the switches on the LAN won’t know + address, however the response it generates won't be delivered to the + system performing the test since the switches on the LAN won't know about the local port being the right target for packets with this MAC address. A better test design to detect these conflicts would be for the testing system to send a loopback packet FROM the current physical MAC address (BEFORE changing it) TO the MAC address being tested with the loopback response coming to the current physical MAC address of the device. If a response is received, then the address is in use and - the attempt to change the device’s MAC address should fail. Since we - can’t change the software running in these simulators to implement this - better conflict detection approach, we can still ‘do the right thing’ - in the sim_ether layer. We’re already handling the loopback test + the attempt to change the device's MAC address should fail. Since we + can't change the software running in these simulators to implement this + better conflict detection approach, we can still "do the right thing" + in the sim_ether layer. We're already handling the loopback test packets specially since we always had to avoid receiving the packets which were being sent, but needed to allow for the incoming loopback packets to be properly dealt with. We can extend this current special - handling to change outgoing ‘loopback to self’ packets to have source - AND loopback destination addresses in the packets to be the host NIC’s + handling to change outgoing "loopback to self" packets to have source + AND loopback destination addresses in the packets to be the host NIC's physical address. The switch network will already know the correct - MAC/port relationship for the host NIC’s physical address, so loopback + MAC/port relationship for the host NIC's physical address, so loopback response packets will be delivered as needed. Code in _eth_write and _eth_callback provide the special handling to diff --git a/sim_ether.h b/sim_ether.h index c35821e3..f1103d25 100644 --- a/sim_ether.h +++ b/sim_ether.h @@ -78,7 +78,7 @@ #endif /* cygwin dowsn't have the right features to use the threaded network I/O */ -#if defined(__CYGWIN__) +#if defined(__CYGWIN__) || defined(__ZAURUS__) // psco added check for Zaurus platform #define DONT_USE_READER_THREAD #endif diff --git a/sim_timer.c b/sim_timer.c index 9d3bc6a9..eca1b741 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -180,7 +180,7 @@ return sim_os_msec() - start_time; const t_bool rtc_avail = TRUE; -uint32 sim_os_msec () +uint32 sim_os_msec (void) { uint32 quo, htod, tod[2]; int32 i; @@ -260,7 +260,7 @@ return 0; const t_bool rtc_avail = TRUE; -uint32 sim_os_msec () +uint32 sim_os_msec (void) { if (sim_idle_rate_ms) return timeGetTime (); @@ -330,7 +330,7 @@ return 0; const t_bool rtc_avail = FALSE; -uint32 sim_os_msec () +uint32 sim_os_msec (void) { return 0; } @@ -426,7 +426,7 @@ return 0; const t_bool rtc_avail = TRUE; -uint32 sim_os_msec () +uint32 sim_os_msec (void) { struct timeval cur; struct timezone foo; diff --git a/sim_tmxr.c b/sim_tmxr.c index 3a25cae5..2cdf7b95 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -2561,18 +2561,11 @@ return SCPE_OK; t_stat tmxr_attach_ex (TMXR *mp, UNIT *uptr, char *cptr, t_bool async) { -char* tptr = NULL; t_stat r; -tptr = (char *) calloc (1, 1); - -if (tptr == NULL) /* no more mem? */ - return SCPE_MEM; r = tmxr_open_master (mp, cptr); /* open master socket */ -if (r != SCPE_OK) { /* error? */ - free (tptr); /* release buf */ +if (r != SCPE_OK) /* error? */ return r; - } mp->uptr = uptr; /* save unit for polling */ uptr->filename = _mux_attach_string (uptr->filename, mp);/* save */ uptr->flags = uptr->flags | UNIT_ATT; /* no more errors */