cleanup CMAKE_CXX_FLAGS and fix various warnings

This commit is contained in:
Wolfgang Thaller 2019-01-04 03:35:32 +01:00
parent bade105326
commit 380fef0114
26 changed files with 268 additions and 272 deletions

View File

@ -22,6 +22,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE) set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type -Wno-multichar")
if(CMAKE_SYSTEM_NAME MATCHES Retro.*) if(CMAKE_SYSTEM_NAME MATCHES Retro.*)

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "-std=c++11")
add_library(RetroConsole add_library(RetroConsole
Console.cc Console.cc
@ -28,7 +27,13 @@ add_library(RetroConsole
) )
set_target_properties(retrocrt set_target_properties(retrocrt
PROPERTIES PROPERTIES
COMPILE_OPTIONS -ffunction-sections) COMPILE_OPTIONS -ffunction-sections)
# different library name for Carbon
# (Carbon shares the powerpc-apple-macos/ directory with Classic PPC)
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
set_target_properties(RetroConsole PROPERTIES OUTPUT_NAME RetroConsoleCarbon)
endif()
install(TARGETS RetroConsole DESTINATION lib) install(TARGETS RetroConsole DESTINATION lib)

View File

@ -19,7 +19,6 @@
#include "Console.h" #include "Console.h"
#include "MacUtils.h" #include "MacUtils.h"
#include "Events.h"
#include "Fonts.h" #include "Fonts.h"
#include "Processes.h" #include "Processes.h"
@ -254,7 +253,6 @@ void Console::write(const char *p, int n)
std::string Console::ReadLine() std::string Console::ReadLine()
{ {
std::string buffer; std::string buffer;
EventRecord event;
char c; char c;
do do

View File

@ -1,5 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar")
find_package(Boost COMPONENTS filesystem system REQUIRED) find_package(Boost COMPONENTS filesystem system REQUIRED)
add_executable(ConvertObj ConvertObj.cc) add_executable(ConvertObj ConvertObj.cc)

View File

@ -25,27 +25,28 @@ namespace fs = boost::filesystem;
class MiniVMacLauncher : public Launcher class MiniVMacLauncher : public Launcher
{ {
fs::path imagePath; fs::path imagePath;
fs::path systemImage; fs::path systemImage;
fs::path vmacDir; fs::path vmacDir;
fs::path vmacPath; fs::path vmacPath;
hfsvol *sysvol; hfsvol *sysvol;
hfsvol *vol; hfsvol *vol;
void CopySystemFile(const std::string& fn, bool required); void CopySystemFile(const std::string& fn, bool required);
public: public:
MiniVMacLauncher(po::variables_map& options); MiniVMacLauncher(po::variables_map& options);
virtual ~MiniVMacLauncher(); virtual ~MiniVMacLauncher();
virtual bool Go(int timeout = 0); virtual bool Go(int timeout = 0);
virtual void DumpOutput(); virtual void DumpOutput();
}; };
/* /*
* Recursive directory copy from https://stackoverflow.com/a/39146566 * Recursive directory copy from https://stackoverflow.com/a/39146566
*/ */
#ifdef __APPLE__
static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path& destinationDir) static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path& destinationDir)
{ {
if (!fs::exists(sourceDir) || !fs::is_directory(sourceDir)) if (!fs::exists(sourceDir) || !fs::is_directory(sourceDir))
@ -64,262 +65,265 @@ static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path&
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir}) for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
{ {
const auto& path = dirEnt.path(); const auto& path = dirEnt.path();
auto relativePathStr = path.string().substr(sourceDir.string().size()); auto relativePathStr = path.string().substr(sourceDir.string().size());
fs::copy(path, destinationDir / relativePathStr); fs::copy(path, destinationDir / relativePathStr);
} }
} }
#endif
MiniVMacLauncher::MiniVMacLauncher(po::variables_map &options) MiniVMacLauncher::MiniVMacLauncher(po::variables_map &options)
: Launcher(options), : Launcher(options),
sysvol(NULL), vol(NULL) sysvol(NULL), vol(NULL)
{ {
imagePath = tempDir / "disk1.dsk"; imagePath = tempDir / "disk1.dsk";
vmacDir = fs::absolute( options["minivmac-dir"].as<std::string>() ); vmacDir = fs::absolute( options["minivmac-dir"].as<std::string>() );
vmacPath = fs::absolute( options["minivmac-path"].as<std::string>(), vmacDir ); vmacPath = fs::absolute( options["minivmac-path"].as<std::string>(), vmacDir );
systemImage = fs::absolute(options["system-image"].as<std::string>(), vmacDir); systemImage = fs::absolute(options["system-image"].as<std::string>(), vmacDir);
fs::path autoquitImage = fs::absolute(options["autoquit-image"].as<std::string>(), vmacDir); fs::path autoquitImage = fs::absolute(options["autoquit-image"].as<std::string>(), vmacDir);
std::vector<unsigned char> bootblock1(1024); std::vector<unsigned char> bootblock1(1024);
fs::ifstream(systemImage).read((char*) bootblock1.data(), 1024); fs::ifstream(systemImage).read((char*) bootblock1.data(), 1024);
if(bootblock1[0] != 'L' || bootblock1[1] != 'K' || bootblock1[0xA] > 15) if(bootblock1[0] != 'L' || bootblock1[1] != 'K' || bootblock1[0xA] > 15)
throw std::runtime_error("Not a bootable Mac disk image: " + systemImage.string()); throw std::runtime_error("Not a bootable Mac disk image: " + systemImage.string());
string systemFileName(bootblock1.begin() + 0xB, bootblock1.begin() + 0xB + bootblock1[0xA]); string systemFileName(bootblock1.begin() + 0xB, bootblock1.begin() + 0xB + bootblock1[0xA]);
int size = 5000*1024; int size = 5000*1024;
fs::ofstream(imagePath, std::ios::binary | std::ios::trunc).seekp(size-1).put(0); fs::ofstream(imagePath, std::ios::binary | std::ios::trunc).seekp(size-1).put(0);
hfs_format(imagePath.string().c_str(), 0, 0, "SysAndApp", 0, NULL); hfs_format(imagePath.string().c_str(), 0, 0, "SysAndApp", 0, NULL);
{ {
bootblock1[0x1A] = 8; bootblock1[0x1A] = 8;
memcpy(&bootblock1[0x1B],"AutoQuit", 8); memcpy(&bootblock1[0x1B],"AutoQuit", 8);
bootblock1[0x5A] = 3; bootblock1[0x5A] = 3;
memcpy(&bootblock1[0x5B],"App", 3); memcpy(&bootblock1[0x5B],"App", 3);
fs::fstream(imagePath, std::ios::in | std::ios::out | std::ios::binary) fs::fstream(imagePath, std::ios::in | std::ios::out | std::ios::binary)
.write((const char*) bootblock1.data(), 1024); .write((const char*) bootblock1.data(), 1024);
} }
vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDWR); vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDWR);
assert(vol); assert(vol);
sysvol = hfs_mount(systemImage.string().c_str(),0, HFS_MODE_RDONLY); sysvol = hfs_mount(systemImage.string().c_str(),0, HFS_MODE_RDONLY);
assert(sysvol); assert(sysvol);
hfsvolent ent; hfsvolent ent;
hfs_vstat(sysvol, &ent); hfs_vstat(sysvol, &ent);
hfs_setcwd(sysvol, ent.blessed); hfs_setcwd(sysvol, ent.blessed);
hfs_vstat(vol, &ent); hfs_vstat(vol, &ent);
ent.blessed = hfs_getcwd(vol); ent.blessed = hfs_getcwd(vol);
hfs_vsetattr(vol, &ent); hfs_vsetattr(vol, &ent);
CopySystemFile(systemFileName, true); CopySystemFile(systemFileName, true);
CopySystemFile("MacsBug", false); CopySystemFile("MacsBug", false);
{ {
std::ostringstream rsrcOut; std::ostringstream rsrcOut;
app.resources.writeFork(rsrcOut); app.resources.writeFork(rsrcOut);
std::string rsrc = rsrcOut.str(); std::string rsrc = rsrcOut.str();
std::string& data = app.data; std::string& data = app.data;
hfsfile *file = hfs_create(vol, "App","APPL","????"); hfsfile *file = hfs_create(vol, "App","APPL","????");
hfs_setfork(file, 0); hfs_setfork(file, 0);
hfs_write(file, data.data(), data.size()); hfs_write(file, data.data(), data.size());
hfs_setfork(file, 1); hfs_setfork(file, 1);
hfs_write(file, rsrc.data(), rsrc.size()); hfs_write(file, rsrc.data(), rsrc.size());
hfs_close(file); hfs_close(file);
} }
hfs_umount(sysvol); hfs_umount(sysvol);
sysvol = hfs_mount(autoquitImage.string().c_str(),0, HFS_MODE_RDONLY); sysvol = hfs_mount(autoquitImage.string().c_str(),0, HFS_MODE_RDONLY);
if(!sysvol) if(!sysvol)
throw std::runtime_error("Cannot open disk image: " + autoquitImage.string()); throw std::runtime_error("Cannot open disk image: " + autoquitImage.string());
assert(sysvol); assert(sysvol);
CopySystemFile("AutoQuit", true); CopySystemFile("AutoQuit", true);
{ {
hfsfile *file = hfs_create(vol, "out", "TEXT", "MPS "); hfsfile *file = hfs_create(vol, "out", "TEXT", "MPS ");
hfs_close(file); hfs_close(file);
} }
hfs_umount(sysvol); sysvol = NULL; hfs_umount(sysvol); sysvol = NULL;
hfs_umount(vol); vol = NULL; hfs_umount(vol); vol = NULL;
fs::path romFile = fs::absolute( options["minivmac-rom"].as<std::string>(), vmacDir ); fs::path romFile = fs::absolute( options["minivmac-rom"].as<std::string>(), vmacDir );
fs::create_symlink( fs::create_symlink(
romFile, romFile,
tempDir / romFile.filename() ); tempDir / romFile.filename() );
if(romFile.filename() != "vMac.ROM") if(romFile.filename() != "vMac.ROM")
{ {
// If the ROM file is not named vMac.ROM, this might be for two different // If the ROM file is not named vMac.ROM, this might be for two different
// reasons. // reasons.
// 1. The user didn't bother to rename it to the correct "vMac.ROM" // 1. The user didn't bother to rename it to the correct "vMac.ROM"
// 2. The user is using a MacII version of Mini vMac and has named the // 2. The user is using a MacII version of Mini vMac and has named the
// ROM file MacII.ROM on purpose. // ROM file MacII.ROM on purpose.
// To be on the safe side, provide both the user-specified name and // To be on the safe side, provide both the user-specified name and
// the standard vMac.ROM. // the standard vMac.ROM.
fs::create_symlink( fs::create_symlink(
romFile, romFile,
tempDir / romFile.filename() ); tempDir / romFile.filename() );
} }
/* /*
Finally, we copy over the entire Mini vMac binary. Finally, we copy over the entire Mini vMac binary.
Mini vMac looks for ROM (vMac.ROM) and disk images (disk1.dsk) Mini vMac looks for ROM (vMac.ROM) and disk images (disk1.dsk)
in the directory next to its binary. in the directory next to its binary.
The Mac version also ignores command line arguments. The Mac version also ignores command line arguments.
Having our own copy in our temp directory is just simpler. Having our own copy in our temp directory is just simpler.
It is five times smaller than System 6, so this really does not It is five times smaller than System 6, so this really does not
matter. matter.
*/ */
#ifdef __APPLE__ #ifdef __APPLE__
/* /*
A special case for the Mac: A special case for the Mac:
We are probably dealing with an entire application bundle. We are probably dealing with an entire application bundle.
*/ */
if(vmacPath.extension().string() == ".app") if(vmacPath.extension().string() == ".app")
{ {
fs::path appPath = tempDir / "minivmac.app"; fs::path appPath = tempDir / "minivmac.app";
copyDirectoryRecursively( vmacPath, appPath ); copyDirectoryRecursively( vmacPath, appPath );
// The following 30 lines of code should rather be written as: // The following 30 lines of code should rather be written as:
// vmacPath = appPath / "Contents" / "MacOS" / Bundle(appPath).getExecutablePath(); // vmacPath = appPath / "Contents" / "MacOS" / Bundle(appPath).getExecutablePath();
// But this is CoreFoundation, so it's a tiny little bit more verbose: // But this is CoreFoundation, so it's a tiny little bit more verbose:
CFStringRef appPathCF CFStringRef appPathCF
= CFStringCreateWithCString( = CFStringCreateWithCString(
kCFAllocatorDefault, appPath.string().c_str(), kCFStringEncodingUTF8); kCFAllocatorDefault, appPath.string().c_str(), kCFStringEncodingUTF8);
CFURLRef bundleURL = CFURLCreateWithFileSystemPath( CFURLRef bundleURL = CFURLCreateWithFileSystemPath(
kCFAllocatorDefault, appPathCF, kCFURLPOSIXPathStyle, true); kCFAllocatorDefault, appPathCF, kCFURLPOSIXPathStyle, true);
CFBundleRef bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL ); CFBundleRef bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL );
CFURLRef executableURL = CFBundleCopyExecutableURL(bundle); CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
CFStringRef executablePath = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle); CFStringRef executablePath = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle);
if(const char *ptr = CFStringGetCStringPtr(executablePath, kCFURLPOSIXPathStyle)) if(const char *ptr = CFStringGetCStringPtr(executablePath, kCFURLPOSIXPathStyle))
{ {
vmacPath = string(ptr); vmacPath = string(ptr);
} }
else else
{ {
vector<char> buffer( vector<char> buffer(
CFStringGetMaximumSizeForEncoding( CFStringGetMaximumSizeForEncoding(
CFStringGetLength(executablePath), kCFStringEncodingUTF8) + 1); CFStringGetLength(executablePath), kCFStringEncodingUTF8) + 1);
CFStringGetCString(executablePath, buffer.data(), buffer.size(), kCFStringEncodingUTF8); CFStringGetCString(executablePath, buffer.data(), buffer.size(), kCFStringEncodingUTF8);
vmacPath = string(buffer.data()); vmacPath = string(buffer.data());
} }
vmacPath = appPath / "Contents" / "MacOS" / vmacPath; vmacPath = appPath / "Contents" / "MacOS" / vmacPath;
CFRelease(appPathCF); CFRelease(appPathCF);
CFRelease(bundleURL); CFRelease(bundleURL);
CFRelease(bundle); CFRelease(bundle);
CFRelease(executableURL); CFRelease(executableURL);
CFRelease(executablePath); CFRelease(executablePath);
} }
else else
#endif #endif
{ {
fs::copy(vmacPath, tempDir / "minivmac"); fs::copy(vmacPath, tempDir / "minivmac");
vmacPath = tempDir / "minivmac"; vmacPath = tempDir / "minivmac";
} }
} }
MiniVMacLauncher::~MiniVMacLauncher() MiniVMacLauncher::~MiniVMacLauncher()
{ {
if(sysvol) if(sysvol)
hfs_umount(sysvol); hfs_umount(sysvol);
if(vol) if(vol)
hfs_umount(vol); hfs_umount(vol);
} }
void MiniVMacLauncher::CopySystemFile(const std::string &fn, bool required) void MiniVMacLauncher::CopySystemFile(const std::string &fn, bool required)
{ {
hfsdirent fileent; hfsdirent fileent;
if(hfs_stat(sysvol, fn.c_str(), &fileent) < 0) if(hfs_stat(sysvol, fn.c_str(), &fileent) < 0)
{ {
if(required) if(required)
throw std::runtime_error(string("File ") + fn + " not found in disk image"); throw std::runtime_error(string("File ") + fn + " not found in disk image");
else else
return; return;
} }
hfsfile *in = hfs_open(sysvol, fn.c_str()); hfsfile *in = hfs_open(sysvol, fn.c_str());
hfsfile *out = hfs_create(vol, fn.c_str(), fileent.u.file.type,fileent.u.file.creator); hfsfile *out = hfs_create(vol, fn.c_str(), fileent.u.file.type,fileent.u.file.creator);
std::vector<uint8_t> buffer(std::max(fileent.u.file.dsize, fileent.u.file.rsize)); std::vector<uint8_t> buffer(std::max(fileent.u.file.dsize, fileent.u.file.rsize));
hfs_setfork(in, 0); hfs_setfork(in, 0);
hfs_setfork(out, 0); hfs_setfork(out, 0);
hfs_read(in, buffer.data(), fileent.u.file.dsize); hfs_read(in, buffer.data(), fileent.u.file.dsize);
hfs_write(out, buffer.data(), fileent.u.file.dsize); hfs_write(out, buffer.data(), fileent.u.file.dsize);
hfs_setfork(in, 1); hfs_setfork(in, 1);
hfs_setfork(out, 1); hfs_setfork(out, 1);
hfs_read(in, buffer.data(), fileent.u.file.rsize); hfs_read(in, buffer.data(), fileent.u.file.rsize);
hfs_write(out, buffer.data(), fileent.u.file.rsize); hfs_write(out, buffer.data(), fileent.u.file.rsize);
hfs_close(in); hfs_close(in);
hfs_close(out); hfs_close(out);
} }
bool MiniVMacLauncher::Go(int timeout) bool MiniVMacLauncher::Go(int timeout)
{ {
fs::current_path(tempDir); fs::current_path(tempDir);
return ChildProcess(vmacPath.string(), {}, timeout) == 0; return ChildProcess(vmacPath.string(), {}, timeout) == 0;
} }
void MiniVMacLauncher::DumpOutput() void MiniVMacLauncher::DumpOutput()
{ {
vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDONLY); vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDONLY);
hfsdirent fileent; hfsdirent fileent;
int statres = hfs_stat(vol, "out", &fileent); int statres = hfs_stat(vol, "out", &fileent);
if(statres)
hfsfile *out = hfs_open(vol, "out"); return;
if(!out)
return; hfsfile *out = hfs_open(vol, "out");
std::vector<char> buffer(fileent.u.file.dsize); if(!out)
hfs_setfork(out, 0); return;
hfs_read(out, buffer.data(), fileent.u.file.dsize); std::vector<char> buffer(fileent.u.file.dsize);
hfs_close(out); hfs_setfork(out, 0);
std::cout << string(buffer.begin(), buffer.end()); hfs_read(out, buffer.data(), fileent.u.file.dsize);
hfs_umount(vol); vol = NULL; hfs_close(out);
std::cout << string(buffer.begin(), buffer.end());
hfs_umount(vol); vol = NULL;
} }
void MiniVMac::GetOptions(options_description &desc) void MiniVMac::GetOptions(options_description &desc)
{ {
desc.add_options() desc.add_options()
("minivmac-dir", po::value<std::string>(),"directory containing vMac.ROM") ("minivmac-dir", po::value<std::string>(),"directory containing vMac.ROM")
("minivmac-path", po::value<std::string>()->default_value("./minivmac"),"relative path to minivmac") ("minivmac-path", po::value<std::string>()->default_value("./minivmac"),"relative path to minivmac")
("minivmac-rom", po::value<std::string>()->default_value("./vMac.ROM"),"minivmac ROM file") ("minivmac-rom", po::value<std::string>()->default_value("./vMac.ROM"),"minivmac ROM file")
("system-image", po::value<std::string>(),"path to disk image with system") ("system-image", po::value<std::string>(),"path to disk image with system")
("autoquit-image", po::value<std::string>(),"path to autoquit disk image, available from the minivmac web site") ("autoquit-image", po::value<std::string>(),"path to autoquit disk image, available from the minivmac web site")
; ;
} }
bool MiniVMac::CheckOptions(variables_map &options) bool MiniVMac::CheckOptions(variables_map &options)
{ {
return options.count("minivmac-path") != 0 return options.count("minivmac-path") != 0
&& options.count("minivmac-dir") != 0 && options.count("minivmac-dir") != 0
&& options.count("minivmac-rom") != 0 && options.count("minivmac-rom") != 0
&& options.count("system-image") != 0 && options.count("system-image") != 0
&& options.count("autoquit-image") != 0; && options.count("autoquit-image") != 0;
} }
std::unique_ptr<Launcher> MiniVMac::MakeLauncher(variables_map &options) std::unique_ptr<Launcher> MiniVMac::MakeLauncher(variables_map &options)
{ {
return std::unique_ptr<Launcher>(new MiniVMacLauncher(options)); return std::unique_ptr<Launcher>(new MiniVMacLauncher(options));
} }

View File

@ -46,7 +46,7 @@ public:
private: private:
void write(const void *p, size_t n); void write(const void *p, size_t n);
ssize_t read(void * p, size_t n); size_t read(void * p, size_t n);
}; };
@ -140,10 +140,10 @@ SerialLauncher::~SerialLauncher()
{ {
} }
ssize_t SerialLauncher::read(void *p0, size_t n) size_t SerialLauncher::read(void *p0, size_t n)
{ {
uint8_t* p = (uint8_t*)p0; uint8_t* p = (uint8_t*)p0;
ssize_t gotBytes = rStream.read(p, n); size_t gotBytes = rStream.read(p, n);
while(gotBytes < n) while(gotBytes < n)
{ {
rStream.flushWrite(); rStream.flushWrite();

View File

@ -94,7 +94,7 @@ TCPLauncher::~TCPLauncher()
ssize_t TCPLauncher::read(void *p0, size_t n) ssize_t TCPLauncher::read(void *p0, size_t n)
{ {
uint8_t* p = (uint8_t*)p0; uint8_t* p = (uint8_t*)p0;
ssize_t gotBytes = rStream.read(p, n); size_t gotBytes = rStream.read(p, n);
while(gotBytes < n) while(gotBytes < n)
{ {
rStream.flushWrite(); rStream.flushWrite();

View File

@ -11,6 +11,6 @@ target_include_directories(LaunchAPPLCommon PUBLIC .)
add_executable(TestLaunchAPPLCommon Test.cc) add_executable(TestLaunchAPPLCommon Test.cc)
target_link_libraries(TestLaunchAPPLCommon LaunchAPPLCommon) target_link_libraries(TestLaunchAPPLCommon LaunchAPPLCommon)
if(CMAKE_SYSTEM_NAME MATCHES Retro68) if(CMAKE_SYSTEM_NAME MATCHES Retro)
#target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -fno-exceptions -Os) target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -Os)
endif() endif()

View File

@ -95,7 +95,7 @@ void ReliableStream::gotAck(uint8_t id)
if(nAcked <= sentPackets.size()) if(nAcked <= sentPackets.size())
{ {
ackedOutputPacket += nAcked; ackedOutputPacket += nAcked;
for(int i = 0; i < nAcked; i++) for(unsigned i = 0; i < nAcked; i++)
sentPackets.pop_front(); sentPackets.pop_front();
sendPackets(); sendPackets();
@ -110,7 +110,7 @@ void ReliableStream::gotNack(uint8_t id)
if(nAcked <= sentPackets.size()) if(nAcked <= sentPackets.size())
{ {
ackedOutputPacket += nAcked; ackedOutputPacket += nAcked;
for(int i = 0; i < nAcked; i++) for(unsigned i = 0; i < nAcked; i++)
sentPackets.pop_front(); sentPackets.pop_front();
sentOutputPacket = ackedOutputPacket; sentOutputPacket = ackedOutputPacket;
@ -171,8 +171,8 @@ void ReliableStream::sendOnePacket()
}; };
int match = 0, match2 = 0; int match = 0, match2 = 0;
int i; size_t i;
int consumed = 0; size_t consumed = 0;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
if(p[i] == magic1[match]) if(p[i] == magic1[match])
@ -390,8 +390,8 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
case State::skipping: case State::skipping:
{ {
int match = 0; unsigned match = 0;
int i; unsigned i;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
if(p[i] == magic1[match++]) if(p[i] == magic1[match++])
@ -401,7 +401,6 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
state = State::waiting; state = State::waiting;
return i-3; return i-3;
} }
} }
else else
match = 0; match = 0;
@ -412,9 +411,7 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
case State::receiving: case State::receiving:
{ {
int i; for(unsigned i = 0; i < n; i++)
for(i = 0; i < n; i++)
{ {
incomingPacket.push_back(p[i]); incomingPacket.push_back(p[i]);
@ -461,5 +458,5 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
} }
break; break;
} }
assert(false); std::abort(); // unreachable
} }

View File

@ -38,7 +38,7 @@ void Stream::notifyReset()
listener_->onReset(); listener_->onReset();
} }
long Stream::read(void *p, size_t n) size_t Stream::read(void *p, size_t n)
{ {
if(buffer_.size() <= n) if(buffer_.size() <= n)
{ {

View File

@ -25,7 +25,7 @@ public:
virtual void write(const void* p, size_t n) = 0; virtual void write(const void* p, size_t n) = 0;
virtual void flushWrite() {} virtual void flushWrite() {}
long read(void *p, size_t n); size_t read(void *p, size_t n);
virtual bool readyToWrite() const { return true; } virtual bool readyToWrite() const { return true; }
bool readyToRead() const { return !buffer_.empty(); } bool readyToRead() const { return !buffer_.empty(); }

View File

@ -15,7 +15,7 @@ public:
virtual void write(const void* p, size_t n) virtual void write(const void* p, size_t n)
{ {
std::cout << prefix << ": "; std::cout << prefix << ": ";
for(int i = 0; i < n; i++) for(size_t i = 0; i < n; i++)
std::cout << std::hex << std::setfill('0') << std::setw(2) << (int) ((uint8_t*)p)[i] << " "; std::cout << std::hex << std::setfill('0') << std::setw(2) << (int) ((uint8_t*)p)[i] << " ";
std::cout << std::endl; std::cout << std::endl;
other->enqueueReceive(p,n); other->enqueueReceive(p,n);
@ -45,7 +45,7 @@ public:
size_t onReceive(const uint8_t* p, size_t n) size_t onReceive(const uint8_t* p, size_t n)
{ {
std::cout << prefix; std::cout << prefix;
for(int i = 0; i < n; i++) for(size_t i = 0; i < n; i++)
{ {
if(p[i] >= 128 || p[i] < 32) if(p[i] >= 128 || p[i] < 32)
std::cout << "\\x" << std::hex << (unsigned)p[i]; std::cout << "\\x" << std::hex << (unsigned)p[i];

View File

@ -51,7 +51,7 @@ target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
set_target_properties(LaunchAPPLServer PROPERTIES set_target_properties(LaunchAPPLServer PROPERTIES
CXX_STANDARD 17 CXX_STANDARD 17
) )
target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -Os) # -fno-exceptions target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -Os)
if(CMAKE_SYSTEM_NAME MATCHES Retro68) if(CMAKE_SYSTEM_NAME MATCHES Retro68)
set_target_properties(LaunchAPPLServer PROPERTIES set_target_properties(LaunchAPPLServer PROPERTIES
LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/LaunchAPPLServer.segmap" LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/LaunchAPPLServer.segmap"

View File

@ -375,6 +375,9 @@ public:
state = State::launch; state = State::launch;
return count; return count;
} }
default:
return 0;
} }
} }
@ -412,8 +415,10 @@ public:
else else
{ {
connection->suspend(); connection->suspend();
#if TARGET_CPU_68K
if(void *seg = connection->segmentToUnload()) if(void *seg = connection->segmentToUnload())
UnloadSeg(seg); UnloadSeg(seg);
#endif
gPrefs.inSubLaunch = true; gPrefs.inSubLaunch = true;
WritePrefs(); WritePrefs();
@ -482,7 +487,7 @@ public:
memset(&lpb, 0, sizeof(lpb)); memset(&lpb, 0, sizeof(lpb));
lpb.reserved1 = (unsigned long) LMGetCurApName(); lpb.reserved1 = (unsigned long) LMGetCurApName();
lpb.reserved2 = 0; lpb.reserved2 = 0;
OSErr err = LaunchApplication(&lpb); LaunchApplication(&lpb);
ExitToShell(); ExitToShell();
} }
onReset(); onReset();
@ -552,6 +557,8 @@ void ConnectionChanged()
connection = std::make_unique<OpenTptConnectionProvider>(statusDisplay.get());; connection = std::make_unique<OpenTptConnectionProvider>(statusDisplay.get());;
break; break;
#endif #endif
default:
;
} }
if(connection) if(connection)
@ -599,7 +606,6 @@ int main()
#if TARGET_CPU_68K && !TARGET_RT_MAC_CFM #if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
short& ROM85 = *(short*) 0x028E; short& ROM85 = *(short*) 0x028E;
Boolean is128KROM = (ROM85 > 0); Boolean is128KROM = (ROM85 > 0);
Boolean hasSysEnvirons = false;
Boolean hasWaitNextEvent = false; Boolean hasWaitNextEvent = false;
Boolean hasGestalt = false; Boolean hasGestalt = false;
Boolean hasAppleEvents = false; Boolean hasAppleEvents = false;
@ -609,11 +615,9 @@ int main()
if (is128KROM) if (is128KROM)
{ {
UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented); UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented);
UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons);
UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent); UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent);
UniversalProcPtr trapGestalt = GetOSTrapAddress(_Gestalt); UniversalProcPtr trapGestalt = GetOSTrapAddress(_Gestalt);
hasSysEnvirons = (trapSysEnv != trapUnimpl);
hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl); hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl);
hasGestalt = (trapGestalt != trapUnimpl); hasGestalt = (trapGestalt != trapUnimpl);
@ -631,8 +635,9 @@ int main()
} }
} }
#else #else
const Boolean hasSysEnvirons = true; #if !TARGET_API_MAC_CARBON
const Boolean hasWaitNextEvent = true; const Boolean hasWaitNextEvent = true;
#endif
const Boolean hasGestalt = true; const Boolean hasGestalt = true;
const Boolean hasAppleEvents = true; const Boolean hasAppleEvents = true;
#endif #endif

View File

@ -15,25 +15,23 @@ void MacSerialStream::close()
{ {
if(inRefNum == 0) if(inRefNum == 0)
return; return;
SerSetBuf(inRefNum, NULL, 0); SerSetBuf(inRefNum, NULL, 0);
CloseDriver(inRefNum); CloseDriver(inRefNum);
CloseDriver(outRefNum); CloseDriver(outRefNum);
inRefNum = outRefNum = 0; inRefNum = outRefNum = 0;
} }
void MacSerialStream::open() void MacSerialStream::open()
{ {
OSErr err; OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum);
err = OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum); OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum);
err = OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum); SerSetBuf(inRefNum, inputBuffer, kInputBufferSize);
SerSetBuf(inRefNum, inputBuffer, kInputBufferSize);
SerShk shk;
SerShk shk; memset(&shk, 0, sizeof(shk));
memset(&shk, 0, sizeof(shk)); shk.fCTS = true;
shk.fCTS = true; Control(outRefNum, kSERDHandshake, &shk);
Control(outRefNum, kSERDHandshake, &shk);
setBaud(curBaud); setBaud(curBaud);
} }
@ -45,18 +43,18 @@ MacSerialStream::~MacSerialStream()
void MacSerialStream::write(const void* p, size_t n) void MacSerialStream::write(const void* p, size_t n)
{ {
ParamBlockRec pb; ParamBlockRec pb;
memset(&pb, 0, sizeof(pb)); memset(&pb, 0, sizeof(pb));
pb.ioParam.ioRefNum = outRefNum; pb.ioParam.ioRefNum = outRefNum;
pb.ioParam.ioBuffer = (Ptr)p; pb.ioParam.ioBuffer = (Ptr)p;
pb.ioParam.ioReqCount = n; pb.ioParam.ioReqCount = n;
OSErr err = PBWriteSync(&pb); OSErr err = PBWriteSync(&pb);
} }
void MacSerialStream::idle() void MacSerialStream::idle()
{ {
long count = 0; long count = 0;
SerGetBuf(inRefNum, &count); SerGetBuf(inRefNum, &count);
while(count > 0) while(count > 0)
{ {
long count1 = count > kReadBufferSize ? kReadBufferSize : count; long count1 = count > kReadBufferSize ? kReadBufferSize : count;
@ -89,7 +87,7 @@ void MacSerialStream::setBaud(int baud)
case 115200: baudval = 0; break; case 115200: baudval = 0; break;
case 230400: baudval = 0; break; case 230400: baudval = 0; break;
} }
SerReset(outRefNum, baudval | data8 | noParity | stop10); SerReset(outRefNum, baudval | data8 | noParity | stop10);
if(baud == 115200) if(baud == 115200)
Control(outRefNum, kSERD115KBaud, nullptr); Control(outRefNum, kSERD115KBaud, nullptr);

View File

@ -85,7 +85,6 @@ void OpenTptStream::write(const void* p, size_t n)
void OpenTptStream::tryReading() void OpenTptStream::tryReading()
{ {
OSStatus err;
OTResult result; OTResult result;
OTFlags flags; OTFlags flags;
do do

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++0x")
add_executable(MakeAPPL main.cc) add_executable(MakeAPPL main.cc)
target_link_libraries(MakeAPPL ResourceFiles) target_link_libraries(MakeAPPL ResourceFiles)

View File

@ -1,5 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar")
find_package(Boost COMPONENTS filesystem system REQUIRED) find_package(Boost COMPONENTS filesystem system REQUIRED)
add_executable(MakePEF MakePEF.cc rs6000.h PEF.h) add_executable(MakePEF MakePEF.cc rs6000.h PEF.h)

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++0x -Wall -Werror=return-type")
find_package(Boost COMPONENTS filesystem system REQUIRED) find_package(Boost COMPONENTS filesystem system REQUIRED)

View File

@ -17,15 +17,13 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall")
find_package(Boost COMPONENTS wave filesystem system thread regex program_options) find_package(Boost COMPONENTS wave filesystem system thread regex program_options)
# Look for bison. # Look for bison.
# We need Version 3, and Mac OS X still comes with an outdated version (2.3). # We need Version 3, and Mac OS X still comes with an outdated version (2.3).
# So we just add the path where the homebrew package manager installs its # So we just add the path where the homebrew package manager installs its
# "keg-only" version. Shouldn't hurt on Linux. # "keg-only" version. Shouldn't hurt on Linux.
set(CMAKE_PROGRAM_PATH $CMAKE_PROGRAM_PATH "/usr/local/opt/bison/bin") set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} "/usr/local/opt/bison/bin")
find_package(BISON 3.0.2) find_package(BISON 3.0.2)
if(Boost_FOUND AND BISON_FOUND) if(Boost_FOUND AND BISON_FOUND)

View File

@ -1,4 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Wno-multichar")
find_package(Boost COMPONENTS unit_test_framework) find_package(Boost COMPONENTS unit_test_framework)
add_executable(RezUnitTests UnitTests.cc) add_executable(RezUnitTests UnitTests.cc)
target_link_libraries(RezUnitTests RezLib ${Boost_LIBRARIES}) target_link_libraries(RezUnitTests RezLib ${Boost_LIBRARIES})

View File

@ -36,8 +36,6 @@ if(APPLE)
target_link_libraries(Raytracer "-framework Carbon") target_link_libraries(Raytracer "-framework Carbon")
target_link_libraries(Raytracer2 "-framework Carbon") target_link_libraries(Raytracer2 "-framework Carbon")
else() else()
set(CMAKE_CXX_FLAGS "-std=c++11")
# save 200KB of code by removing unused stuff # save 200KB of code by removing unused stuff
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections") set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections")

View File

@ -85,12 +85,12 @@ int main(int argc, char** argv)
std::cout << "Generating numbers..." << std::flush; std::cout << "Generating numbers..." << std::flush;
const int n = 1000; const size_t n = 1000;
std::vector<fixed> numbers(n); std::vector<fixed> numbers(n);
std::vector<float> floats(n); std::vector<float> floats(n);
std::vector<double> doubles(n); std::vector<double> doubles(n);
for(int i = 0; i < numbers.size(); i++) for(size_t i = 0; i < numbers.size(); i++)
{ {
numbers[i] = fixed(std::rand(), fixed::raw()); numbers[i] = fixed(std::rand(), fixed::raw());
floats[i] = float(std::rand()) / RAND_MAX; floats[i] = float(std::rand()) / RAND_MAX;

View File

@ -76,7 +76,7 @@ public:
//if(l == 0) //if(l == 0)
// return *this; // return *this;
//else //else
return (*this) * (T(1) / length()); return (*this) * (T(1) / l);
} }
#else #else
vec3<T> normalize() const { vec3<T> normalize() const {

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>. # along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "-std=c++11") # -fomit-frame-pointer")
add_application(EmptyTest EmptyTest.c) add_application(EmptyTest EmptyTest.c)

View File

@ -32,7 +32,7 @@ public:
{ {
printf("Foo::~Foo() was called. (delaying 1 sec)\n"); printf("Foo::~Foo() was called. (delaying 1 sec)\n");
long start = TickCount(); unsigned long start = TickCount();
while(TickCount() < start + 60) while(TickCount() < start + 60)
; ;
} }
@ -50,7 +50,7 @@ __attribute__((destructor))
void des() void des()
{ {
printf("des() called. (delaying 1 sec)\n"); printf("des() called. (delaying 1 sec)\n");
long start = TickCount(); unsigned long start = TickCount();
while(TickCount() < start + 60) while(TickCount() < start + 60)
; ;
} }