mirror of
https://github.com/ksherlock/mpw.git
synced 2025-04-16 17:37:25 +00:00
commit
ac4506b52e
@ -2,6 +2,7 @@
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#include <toolbox/os.h>
|
||||
@ -239,4 +240,4 @@ namespace Debug {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "intern.h"
|
||||
#include <unordered_map>
|
||||
#include <cstring>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <deque>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "debugger.h"
|
||||
@ -368,7 +369,7 @@ bool ParseLine(const char *iter, Command *command)
|
||||
//ParseTrace(stdout, "--> ");
|
||||
command->action = cmdNull;
|
||||
|
||||
int length = strlen(iter);
|
||||
int length = std::strlen(iter);
|
||||
const char *p = iter;
|
||||
const char *pe = iter + length;
|
||||
const char *eof = pe;
|
||||
@ -431,4 +432,4 @@ bool ParseLine(const char *iter, Command *command)
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -28,6 +28,86 @@
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
|
||||
namespace _loadtrap_rl {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
|
||||
#define _GETDELIM_MINLEN 4 /* minimum line buffer size */
|
||||
|
||||
ssize_t getdelim(char ** lineptr, size_t * n, int delimiter, FILE * stream) {
|
||||
char *buf, *pos;
|
||||
int c;
|
||||
ssize_t bytes;
|
||||
|
||||
if (lineptr == NULL || n == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (stream == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* resize (or allocate) the line buffer if necessary */
|
||||
buf = *lineptr;
|
||||
if (buf == NULL || *n < _GETDELIM_MINLEN) {
|
||||
buf = (char*)realloc(*lineptr, _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n = _GETDELIM_GROWBY;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
/* read characters until delimiter is found, end of file is reached, or an
|
||||
error occurs. */
|
||||
bytes = 0;
|
||||
pos = buf;
|
||||
while ((c = getc(stream)) != EOF) {
|
||||
if (bytes + 1 >= SSIZE_MAX) {
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
bytes++;
|
||||
if (bytes >= *n - 1) {
|
||||
buf = (char*)realloc(*lineptr, *n + _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n += _GETDELIM_GROWBY;
|
||||
pos = buf + bytes - 1;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
*pos++ = (char) c;
|
||||
if (c == delimiter) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stream) || (feof(stream) && (bytes == 0))) {
|
||||
/* EOF, or an error from getc(). */
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pos = '\0';
|
||||
return bytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ssize_t getline(char ** lineptr, size_t * n, FILE * stream) {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
return getdelim(lineptr, n, '\n', stream);
|
||||
#else
|
||||
return ::getline(lineptr, n, stream);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
namespace {
|
||||
// private...
|
||||
%%{
|
||||
@ -155,7 +235,7 @@ namespace Debug {
|
||||
char *line;
|
||||
ssize_t length;
|
||||
|
||||
length = getline(&lineBuffer, &lineSize, fp);
|
||||
length = _loadtrap_rl::getline(&lineBuffer, &lineSize, fp);
|
||||
if (!length) continue; //?
|
||||
if (length < 0) break; // eof or error.
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include "debugger.h"
|
||||
|
||||
#include <toolbox/MM.h>
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "debugger_internal.h"
|
||||
#include "loader.h" // Flags.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <toolbox/toolbox.h>
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
@ -251,4 +252,4 @@ bool LoadTemplateFile(const std::string &filename, std::unordered_map<std::strin
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "template.h"
|
||||
|
||||
|
@ -246,20 +246,24 @@ void cpuSetModel(ULO major, ULO minor)
|
||||
if (makeOpcodeTable) cpuMakeOpcodeTableForModel();
|
||||
}
|
||||
|
||||
#if defined(__BIG_ENDIAN__)
|
||||
void cpuSetDRegWord(ULO regno, UWO val) {*((WOR*)&cpu_regs[0][regno]+1) = val;}
|
||||
void cpuSetDRegByte(ULO regno, UBY val) {*((UBY*)&cpu_regs[0][regno]+3) = val;}
|
||||
#else
|
||||
void cpuSetDRegWord(ULO regno, UWO val) {*((WOR*)&cpu_regs[0][regno]) = val;}
|
||||
void cpuSetDRegByte(ULO regno, UBY val) {*((UBY*)&cpu_regs[0][regno]) = val;}
|
||||
#endif
|
||||
UWO cpuGetRegWord(ULO i, ULO regno) {return (UWO)cpu_regs[i][regno];}
|
||||
|
||||
UWO cpuGetDRegWord(ULO regno) {return (UWO)cpu_regs[0][regno];}
|
||||
UBY cpuGetDRegByte(ULO regno) {return (UBY)cpu_regs[0][regno];}
|
||||
|
||||
UWO cpuGetARegWord(ULO regno) {return (UWO)cpu_regs[1][regno];}
|
||||
UBY cpuGetARegByte(ULO regno) {return (UBY)cpu_regs[1][regno];}
|
||||
ULO cpuGetDRegWordSignExtLong(ULO regno) {return cpuSignExtWordToLong(cpuGetDRegWord(regno));}
|
||||
UWO cpuGetDRegByteSignExtWord(ULO regno) {return cpuSignExtByteToWord(cpuGetDRegByte(regno));}
|
||||
ULO cpuGetDRegByteSignExtLong(ULO regno) {return cpuSignExtByteToLong(cpuGetDRegByte(regno));}
|
||||
|
||||
UWO cpuGetARegWord(ULO regno) {return (UWO)cpu_regs[1][regno];}
|
||||
UBY cpuGetARegByte(ULO regno) {return (UBY)cpu_regs[1][regno];}
|
||||
|
||||
typedef UWO (*cpuGetWordFunc)(void);
|
||||
typedef ULO (*cpuGetLongFunc)(void);
|
||||
|
||||
|
@ -29,6 +29,86 @@
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
|
||||
namespace _env_rl {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
|
||||
#define _GETDELIM_MINLEN 4 /* minimum line buffer size */
|
||||
|
||||
ssize_t getdelim(char ** lineptr, size_t * n, int delimiter, FILE * stream) {
|
||||
char *buf, *pos;
|
||||
int c;
|
||||
ssize_t bytes;
|
||||
|
||||
if (lineptr == NULL || n == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (stream == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* resize (or allocate) the line buffer if necessary */
|
||||
buf = *lineptr;
|
||||
if (buf == NULL || *n < _GETDELIM_MINLEN) {
|
||||
buf = (char*)realloc(*lineptr, _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n = _GETDELIM_GROWBY;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
/* read characters until delimiter is found, end of file is reached, or an
|
||||
error occurs. */
|
||||
bytes = 0;
|
||||
pos = buf;
|
||||
while ((c = getc(stream)) != EOF) {
|
||||
if (bytes + 1 >= SSIZE_MAX) {
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
bytes++;
|
||||
if (bytes >= *n - 1) {
|
||||
buf = (char*)realloc(*lineptr, *n + _GETDELIM_GROWBY);
|
||||
if (buf == NULL) {
|
||||
/* ENOMEM */
|
||||
return -1;
|
||||
}
|
||||
*n += _GETDELIM_GROWBY;
|
||||
pos = buf + bytes - 1;
|
||||
*lineptr = buf;
|
||||
}
|
||||
|
||||
*pos++ = (char) c;
|
||||
if (c == delimiter) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stream) || (feof(stream) && (bytes == 0))) {
|
||||
/* EOF, or an error from getc(). */
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pos = '\0';
|
||||
return bytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ssize_t getline(char ** lineptr, size_t * n, FILE * stream) {
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
return getdelim(lineptr, n, '\n', stream);
|
||||
#else
|
||||
return ::getline(lineptr, n, stream);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace MPW
|
||||
{
|
||||
@ -308,7 +388,7 @@ namespace MPW {
|
||||
char *line;
|
||||
ssize_t length;
|
||||
|
||||
length = getline(&lineBuffer, &lineSize, fp);
|
||||
length = _env_rl::getline(&lineBuffer, &lineSize, fp);
|
||||
if (!length) continue; //?
|
||||
if (length < 0) break; // eof or error.
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
@ -552,4 +553,4 @@ namespace Loader {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <cpu/fmem.h>
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
@ -59,7 +59,9 @@ using ToolBox::Log;
|
||||
|
||||
using MacOS::macos_error_from_errno;
|
||||
|
||||
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define st_birthtime st_mtime
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
@ -348,4 +350,4 @@ namespace OS {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,14 @@
|
||||
*/
|
||||
|
||||
#include <cerrno>
|
||||
#include <cassert>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include <sys/xattr.h>
|
||||
#include <sys/stat.h>
|
||||
@ -54,6 +55,10 @@
|
||||
#include "stackframe.h"
|
||||
#include "fs_spec.h"
|
||||
|
||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||
#define st_birthtime st_mtime
|
||||
#endif
|
||||
|
||||
using ToolBox::Log;
|
||||
|
||||
using MacOS::macos_error_from_errno;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include <sys/xattr.h>
|
||||
#include <sys/stat.h>
|
||||
@ -40,6 +41,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
|
@ -32,6 +32,9 @@
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@ -115,7 +118,7 @@ namespace OS { namespace Internal {
|
||||
if (rv1 == 1 && rv2 == 2)
|
||||
{
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
ftype = (ftype >> 8) | (ftype << 8)
|
||||
ftype = (ftype >> 8) | (ftype << 8);
|
||||
#endif
|
||||
|
||||
char tmp[8] = {
|
||||
@ -187,7 +190,7 @@ namespace OS { namespace Internal {
|
||||
|
||||
|
||||
// convert pdos types...
|
||||
if (::memcmp(buffer + 4, "pdos", 4) == 0)
|
||||
if (std::memcmp(buffer + 4, "pdos", 4) == 0)
|
||||
{
|
||||
// mpw expects 'xx ' where
|
||||
// xx are the ascii-encode hex value of the file type.
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace OS { namespace Internal {
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
static char sccsid[] = "@(#)realpath.c 8.1 (Berkeley) 2/16/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
//#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
|
@ -25,10 +25,13 @@
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
#include "rm.h"
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
#include "stackframe.h"
|
||||
@ -133,13 +134,13 @@ using std::to_string;
|
||||
|
||||
complex &operator=(long double ld)
|
||||
{
|
||||
switch(fpclassify(ld))
|
||||
switch(std::fpclassify(ld))
|
||||
{
|
||||
case FP_NAN:
|
||||
_data = NaN;
|
||||
break;
|
||||
case FP_INFINITE:
|
||||
if (signbit(ld))
|
||||
if (std::signbit(ld))
|
||||
{
|
||||
_data = -INT64_MAX;
|
||||
}
|
||||
@ -159,13 +160,13 @@ using std::to_string;
|
||||
|
||||
complex &operator=(double d)
|
||||
{
|
||||
switch(fpclassify(d))
|
||||
switch(std::fpclassify(d))
|
||||
{
|
||||
case FP_NAN:
|
||||
_data = NaN;
|
||||
break;
|
||||
case FP_INFINITE:
|
||||
if (signbit(d))
|
||||
if (std::signbit(d))
|
||||
{
|
||||
_data = -INT64_MAX;
|
||||
}
|
||||
@ -720,18 +721,18 @@ using std::to_string;
|
||||
}
|
||||
|
||||
|
||||
inline int classify(float x) { return fpclassify(x); }
|
||||
inline int classify(double x) { return fpclassify(x); }
|
||||
inline int classify(extended x) { return fpclassify(x); }
|
||||
inline int classify(float x) { return std::fpclassify(x); }
|
||||
inline int classify(double x) { return std::fpclassify(x); }
|
||||
inline int classify(extended x) { return std::fpclassify(x); }
|
||||
inline int classify(complex c) {
|
||||
if (c.isnan()) return FP_NAN;
|
||||
if ((uint64_t)c == (uint64_t)0) return FP_ZERO;
|
||||
return FP_NORMAL;
|
||||
}
|
||||
|
||||
inline int sign(float x) { return signbit(x); }
|
||||
inline int sign(double x) { return signbit(x); }
|
||||
inline int sign(extended x) { return signbit(x); }
|
||||
inline int sign(float x) { return std::signbit(x); }
|
||||
inline int sign(double x) { return std::signbit(x); }
|
||||
inline int sign(extended x) { return std::signbit(x); }
|
||||
inline int sign(complex c) {
|
||||
if (c.isnan()) return 0;
|
||||
return ((int64_t)c < (int64_t)0) ? 1 : 0;
|
||||
@ -1161,4 +1162,4 @@ struct decimal {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user