diff --git a/CMakeLists.txt b/CMakeLists.txt index 57374262a0..58499c2d17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_C_STANDARD 99) 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.*) diff --git a/Console/CMakeLists.txt b/Console/CMakeLists.txt index f8524c0571..1dde97ee54 100644 --- a/Console/CMakeLists.txt +++ b/Console/CMakeLists.txt @@ -16,7 +16,6 @@ # along with Retro68. If not, see . cmake_minimum_required(VERSION 2.8) -set(CMAKE_CXX_FLAGS "-std=c++11") add_library(RetroConsole Console.cc @@ -28,7 +27,13 @@ add_library(RetroConsole ) set_target_properties(retrocrt 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) diff --git a/Console/Console.cc b/Console/Console.cc index 2721efc161..4ccfac294f 100644 --- a/Console/Console.cc +++ b/Console/Console.cc @@ -19,7 +19,6 @@ #include "Console.h" #include "MacUtils.h" -#include "Events.h" #include "Fonts.h" #include "Processes.h" @@ -254,7 +253,6 @@ void Console::write(const char *p, int n) std::string Console::ReadLine() { std::string buffer; - EventRecord event; char c; do diff --git a/ConvertObj/CMakeLists.txt b/ConvertObj/CMakeLists.txt index 309f34e9de..3c9fc300b4 100644 --- a/ConvertObj/CMakeLists.txt +++ b/ConvertObj/CMakeLists.txt @@ -1,5 +1,3 @@ -set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar") - find_package(Boost COMPONENTS filesystem system REQUIRED) add_executable(ConvertObj ConvertObj.cc) diff --git a/LaunchAPPL/Client/MiniVMac.cc b/LaunchAPPL/Client/MiniVMac.cc index 2773f51382..a6e3f4d439 100644 --- a/LaunchAPPL/Client/MiniVMac.cc +++ b/LaunchAPPL/Client/MiniVMac.cc @@ -25,27 +25,28 @@ namespace fs = boost::filesystem; class MiniVMacLauncher : public Launcher { - fs::path imagePath; - fs::path systemImage; - fs::path vmacDir; - fs::path vmacPath; + fs::path imagePath; + fs::path systemImage; + fs::path vmacDir; + fs::path vmacPath; - hfsvol *sysvol; - hfsvol *vol; + hfsvol *sysvol; + hfsvol *vol; - void CopySystemFile(const std::string& fn, bool required); + void CopySystemFile(const std::string& fn, bool required); public: - MiniVMacLauncher(po::variables_map& options); - virtual ~MiniVMacLauncher(); + MiniVMacLauncher(po::variables_map& options); + virtual ~MiniVMacLauncher(); - virtual bool Go(int timeout = 0); - virtual void DumpOutput(); + virtual bool Go(int timeout = 0); + virtual void DumpOutput(); }; /* * Recursive directory copy from https://stackoverflow.com/a/39146566 */ +#ifdef __APPLE__ static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path& destinationDir) { 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}) { 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); } } +#endif MiniVMacLauncher::MiniVMacLauncher(po::variables_map &options) : Launcher(options), sysvol(NULL), vol(NULL) { - imagePath = tempDir / "disk1.dsk"; - vmacDir = fs::absolute( options["minivmac-dir"].as() ); - vmacPath = fs::absolute( options["minivmac-path"].as(), vmacDir ); + imagePath = tempDir / "disk1.dsk"; + vmacDir = fs::absolute( options["minivmac-dir"].as() ); + vmacPath = fs::absolute( options["minivmac-path"].as(), vmacDir ); - systemImage = fs::absolute(options["system-image"].as(), vmacDir); - fs::path autoquitImage = fs::absolute(options["autoquit-image"].as(), vmacDir); + systemImage = fs::absolute(options["system-image"].as(), vmacDir); + fs::path autoquitImage = fs::absolute(options["autoquit-image"].as(), vmacDir); - std::vector bootblock1(1024); - fs::ifstream(systemImage).read((char*) bootblock1.data(), 1024); + std::vector bootblock1(1024); + fs::ifstream(systemImage).read((char*) bootblock1.data(), 1024); - if(bootblock1[0] != 'L' || bootblock1[1] != 'K' || bootblock1[0xA] > 15) - throw std::runtime_error("Not a bootable Mac disk image: " + systemImage.string()); + if(bootblock1[0] != 'L' || bootblock1[1] != 'K' || bootblock1[0xA] > 15) + 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); - hfs_format(imagePath.string().c_str(), 0, 0, "SysAndApp", 0, NULL); + 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); - { - bootblock1[0x1A] = 8; - memcpy(&bootblock1[0x1B],"AutoQuit", 8); - bootblock1[0x5A] = 3; - memcpy(&bootblock1[0x5B],"App", 3); + { + bootblock1[0x1A] = 8; + memcpy(&bootblock1[0x1B],"AutoQuit", 8); + bootblock1[0x5A] = 3; + memcpy(&bootblock1[0x5B],"App", 3); - fs::fstream(imagePath, std::ios::in | std::ios::out | std::ios::binary) - .write((const char*) bootblock1.data(), 1024); - } + fs::fstream(imagePath, std::ios::in | std::ios::out | std::ios::binary) + .write((const char*) bootblock1.data(), 1024); + } - vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDWR); - assert(vol); + vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDWR); + assert(vol); - sysvol = hfs_mount(systemImage.string().c_str(),0, HFS_MODE_RDONLY); - assert(sysvol); - hfsvolent ent; - hfs_vstat(sysvol, &ent); - hfs_setcwd(sysvol, ent.blessed); + sysvol = hfs_mount(systemImage.string().c_str(),0, HFS_MODE_RDONLY); + assert(sysvol); + hfsvolent ent; + hfs_vstat(sysvol, &ent); + hfs_setcwd(sysvol, ent.blessed); - hfs_vstat(vol, &ent); - ent.blessed = hfs_getcwd(vol); - hfs_vsetattr(vol, &ent); + hfs_vstat(vol, &ent); + ent.blessed = hfs_getcwd(vol); + hfs_vsetattr(vol, &ent); - CopySystemFile(systemFileName, true); - CopySystemFile("MacsBug", false); + CopySystemFile(systemFileName, true); + CopySystemFile("MacsBug", false); - { - std::ostringstream rsrcOut; - app.resources.writeFork(rsrcOut); - std::string rsrc = rsrcOut.str(); - std::string& data = app.data; + { + std::ostringstream rsrcOut; + app.resources.writeFork(rsrcOut); + std::string rsrc = rsrcOut.str(); + std::string& data = app.data; - hfsfile *file = hfs_create(vol, "App","APPL","????"); - hfs_setfork(file, 0); - hfs_write(file, data.data(), data.size()); - hfs_setfork(file, 1); - hfs_write(file, rsrc.data(), rsrc.size()); - hfs_close(file); - } + hfsfile *file = hfs_create(vol, "App","APPL","????"); + hfs_setfork(file, 0); + hfs_write(file, data.data(), data.size()); + hfs_setfork(file, 1); + hfs_write(file, rsrc.data(), rsrc.size()); + hfs_close(file); + } - hfs_umount(sysvol); - sysvol = hfs_mount(autoquitImage.string().c_str(),0, HFS_MODE_RDONLY); - if(!sysvol) - throw std::runtime_error("Cannot open disk image: " + autoquitImage.string()); - assert(sysvol); - CopySystemFile("AutoQuit", true); + hfs_umount(sysvol); + sysvol = hfs_mount(autoquitImage.string().c_str(),0, HFS_MODE_RDONLY); + if(!sysvol) + throw std::runtime_error("Cannot open disk image: " + autoquitImage.string()); + assert(sysvol); + CopySystemFile("AutoQuit", true); - { - hfsfile *file = hfs_create(vol, "out", "TEXT", "MPS "); - hfs_close(file); - } + { + hfsfile *file = hfs_create(vol, "out", "TEXT", "MPS "); + hfs_close(file); + } - hfs_umount(sysvol); sysvol = NULL; - hfs_umount(vol); vol = NULL; + hfs_umount(sysvol); sysvol = NULL; + hfs_umount(vol); vol = NULL; - fs::path romFile = fs::absolute( options["minivmac-rom"].as(), vmacDir ); - - fs::create_symlink( - romFile, - tempDir / romFile.filename() ); + fs::path romFile = fs::absolute( options["minivmac-rom"].as(), vmacDir ); + + fs::create_symlink( + romFile, + tempDir / romFile.filename() ); - if(romFile.filename() != "vMac.ROM") - { - // If the ROM file is not named vMac.ROM, this might be for two different - // reasons. - // 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 - // ROM file MacII.ROM on purpose. - - // To be on the safe side, provide both the user-specified name and - // the standard vMac.ROM. - - fs::create_symlink( - romFile, - tempDir / romFile.filename() ); - } + if(romFile.filename() != "vMac.ROM") + { + // If the ROM file is not named vMac.ROM, this might be for two different + // reasons. + // 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 + // ROM file MacII.ROM on purpose. + + // To be on the safe side, provide both the user-specified name and + // the standard vMac.ROM. + + fs::create_symlink( + romFile, + tempDir / romFile.filename() ); + } - /* - Finally, we copy over the entire Mini vMac binary. - Mini vMac looks for ROM (vMac.ROM) and disk images (disk1.dsk) - in the directory next to its binary. - The Mac version also ignores command line arguments. - Having our own copy in our temp directory is just simpler. - It is five times smaller than System 6, so this really does not - matter. - */ + /* + Finally, we copy over the entire Mini vMac binary. + Mini vMac looks for ROM (vMac.ROM) and disk images (disk1.dsk) + in the directory next to its binary. + The Mac version also ignores command line arguments. + Having our own copy in our temp directory is just simpler. + It is five times smaller than System 6, so this really does not + matter. + */ #ifdef __APPLE__ - /* - A special case for the Mac: - We are probably dealing with an entire application bundle. - */ - if(vmacPath.extension().string() == ".app") - { - fs::path appPath = tempDir / "minivmac.app"; - - copyDirectoryRecursively( vmacPath, appPath ); - - // The following 30 lines of code should rather be written as: - // vmacPath = appPath / "Contents" / "MacOS" / Bundle(appPath).getExecutablePath(); - // But this is CoreFoundation, so it's a tiny little bit more verbose: - - CFStringRef appPathCF - = CFStringCreateWithCString( - kCFAllocatorDefault, appPath.string().c_str(), kCFStringEncodingUTF8); - CFURLRef bundleURL = CFURLCreateWithFileSystemPath( - kCFAllocatorDefault, appPathCF, kCFURLPOSIXPathStyle, true); - - CFBundleRef bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL ); - - CFURLRef executableURL = CFBundleCopyExecutableURL(bundle); - - CFStringRef executablePath = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle); - - if(const char *ptr = CFStringGetCStringPtr(executablePath, kCFURLPOSIXPathStyle)) - { - vmacPath = string(ptr); - } - else - { - vector buffer( - CFStringGetMaximumSizeForEncoding( - CFStringGetLength(executablePath), kCFStringEncodingUTF8) + 1); - CFStringGetCString(executablePath, buffer.data(), buffer.size(), kCFStringEncodingUTF8); - vmacPath = string(buffer.data()); - } - vmacPath = appPath / "Contents" / "MacOS" / vmacPath; - - CFRelease(appPathCF); - CFRelease(bundleURL); - CFRelease(bundle); - CFRelease(executableURL); - CFRelease(executablePath); - } - else + /* + A special case for the Mac: + We are probably dealing with an entire application bundle. + */ + if(vmacPath.extension().string() == ".app") + { + fs::path appPath = tempDir / "minivmac.app"; + + copyDirectoryRecursively( vmacPath, appPath ); + + // The following 30 lines of code should rather be written as: + // vmacPath = appPath / "Contents" / "MacOS" / Bundle(appPath).getExecutablePath(); + // But this is CoreFoundation, so it's a tiny little bit more verbose: + + CFStringRef appPathCF + = CFStringCreateWithCString( + kCFAllocatorDefault, appPath.string().c_str(), kCFStringEncodingUTF8); + CFURLRef bundleURL = CFURLCreateWithFileSystemPath( + kCFAllocatorDefault, appPathCF, kCFURLPOSIXPathStyle, true); + + CFBundleRef bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL ); + + CFURLRef executableURL = CFBundleCopyExecutableURL(bundle); + + CFStringRef executablePath = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle); + + if(const char *ptr = CFStringGetCStringPtr(executablePath, kCFURLPOSIXPathStyle)) + { + vmacPath = string(ptr); + } + else + { + vector buffer( + CFStringGetMaximumSizeForEncoding( + CFStringGetLength(executablePath), kCFStringEncodingUTF8) + 1); + CFStringGetCString(executablePath, buffer.data(), buffer.size(), kCFStringEncodingUTF8); + vmacPath = string(buffer.data()); + } + vmacPath = appPath / "Contents" / "MacOS" / vmacPath; + + CFRelease(appPathCF); + CFRelease(bundleURL); + CFRelease(bundle); + CFRelease(executableURL); + CFRelease(executablePath); + } + else #endif - { - fs::copy(vmacPath, tempDir / "minivmac"); - vmacPath = tempDir / "minivmac"; - } + { + fs::copy(vmacPath, tempDir / "minivmac"); + vmacPath = tempDir / "minivmac"; + } } MiniVMacLauncher::~MiniVMacLauncher() { - if(sysvol) - hfs_umount(sysvol); - if(vol) - hfs_umount(vol); + if(sysvol) + hfs_umount(sysvol); + if(vol) + hfs_umount(vol); } void MiniVMacLauncher::CopySystemFile(const std::string &fn, bool required) { - hfsdirent fileent; - if(hfs_stat(sysvol, fn.c_str(), &fileent) < 0) - { - if(required) - throw std::runtime_error(string("File ") + fn + " not found in disk image"); - else - return; - } - hfsfile *in = hfs_open(sysvol, fn.c_str()); - hfsfile *out = hfs_create(vol, fn.c_str(), fileent.u.file.type,fileent.u.file.creator); + hfsdirent fileent; + if(hfs_stat(sysvol, fn.c_str(), &fileent) < 0) + { + if(required) + throw std::runtime_error(string("File ") + fn + " not found in disk image"); + else + return; + } + hfsfile *in = hfs_open(sysvol, fn.c_str()); + hfsfile *out = hfs_create(vol, fn.c_str(), fileent.u.file.type,fileent.u.file.creator); - std::vector buffer(std::max(fileent.u.file.dsize, fileent.u.file.rsize)); - hfs_setfork(in, 0); - hfs_setfork(out, 0); - hfs_read(in, buffer.data(), fileent.u.file.dsize); - hfs_write(out, buffer.data(), fileent.u.file.dsize); - hfs_setfork(in, 1); - hfs_setfork(out, 1); - hfs_read(in, buffer.data(), fileent.u.file.rsize); - hfs_write(out, buffer.data(), fileent.u.file.rsize); - hfs_close(in); - hfs_close(out); + std::vector buffer(std::max(fileent.u.file.dsize, fileent.u.file.rsize)); + hfs_setfork(in, 0); + hfs_setfork(out, 0); + hfs_read(in, buffer.data(), fileent.u.file.dsize); + hfs_write(out, buffer.data(), fileent.u.file.dsize); + hfs_setfork(in, 1); + hfs_setfork(out, 1); + hfs_read(in, buffer.data(), fileent.u.file.rsize); + hfs_write(out, buffer.data(), fileent.u.file.rsize); + hfs_close(in); + hfs_close(out); } bool MiniVMacLauncher::Go(int timeout) { - fs::current_path(tempDir); - return ChildProcess(vmacPath.string(), {}, timeout) == 0; + fs::current_path(tempDir); + return ChildProcess(vmacPath.string(), {}, timeout) == 0; } void MiniVMacLauncher::DumpOutput() { - vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDONLY); - hfsdirent fileent; - int statres = hfs_stat(vol, "out", &fileent); - - hfsfile *out = hfs_open(vol, "out"); - if(!out) - return; - std::vector buffer(fileent.u.file.dsize); - hfs_setfork(out, 0); - hfs_read(out, buffer.data(), fileent.u.file.dsize); - hfs_close(out); - std::cout << string(buffer.begin(), buffer.end()); - hfs_umount(vol); vol = NULL; + vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDONLY); + hfsdirent fileent; + int statres = hfs_stat(vol, "out", &fileent); + if(statres) + return; + + hfsfile *out = hfs_open(vol, "out"); + if(!out) + return; + std::vector buffer(fileent.u.file.dsize); + hfs_setfork(out, 0); + hfs_read(out, buffer.data(), fileent.u.file.dsize); + hfs_close(out); + std::cout << string(buffer.begin(), buffer.end()); + hfs_umount(vol); vol = NULL; } void MiniVMac::GetOptions(options_description &desc) { - desc.add_options() - ("minivmac-dir", po::value(),"directory containing vMac.ROM") - ("minivmac-path", po::value()->default_value("./minivmac"),"relative path to minivmac") - ("minivmac-rom", po::value()->default_value("./vMac.ROM"),"minivmac ROM file") - ("system-image", po::value(),"path to disk image with system") - ("autoquit-image", po::value(),"path to autoquit disk image, available from the minivmac web site") - ; + desc.add_options() + ("minivmac-dir", po::value(),"directory containing vMac.ROM") + ("minivmac-path", po::value()->default_value("./minivmac"),"relative path to minivmac") + ("minivmac-rom", po::value()->default_value("./vMac.ROM"),"minivmac ROM file") + ("system-image", po::value(),"path to disk image with system") + ("autoquit-image", po::value(),"path to autoquit disk image, available from the minivmac web site") + ; } bool MiniVMac::CheckOptions(variables_map &options) { - return options.count("minivmac-path") != 0 - && options.count("minivmac-dir") != 0 - && options.count("minivmac-rom") != 0 - && options.count("system-image") != 0 - && options.count("autoquit-image") != 0; + return options.count("minivmac-path") != 0 + && options.count("minivmac-dir") != 0 + && options.count("minivmac-rom") != 0 + && options.count("system-image") != 0 + && options.count("autoquit-image") != 0; } std::unique_ptr MiniVMac::MakeLauncher(variables_map &options) { - return std::unique_ptr(new MiniVMacLauncher(options)); + return std::unique_ptr(new MiniVMacLauncher(options)); } diff --git a/LaunchAPPL/Client/Serial.cc b/LaunchAPPL/Client/Serial.cc index 1c2e4a4518..3a43d89479 100644 --- a/LaunchAPPL/Client/Serial.cc +++ b/LaunchAPPL/Client/Serial.cc @@ -46,7 +46,7 @@ public: private: 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; - ssize_t gotBytes = rStream.read(p, n); + size_t gotBytes = rStream.read(p, n); while(gotBytes < n) { rStream.flushWrite(); diff --git a/LaunchAPPL/Client/TCP.cc b/LaunchAPPL/Client/TCP.cc index f27e9933a7..5ad5e025bd 100644 --- a/LaunchAPPL/Client/TCP.cc +++ b/LaunchAPPL/Client/TCP.cc @@ -94,7 +94,7 @@ TCPLauncher::~TCPLauncher() ssize_t TCPLauncher::read(void *p0, size_t n) { uint8_t* p = (uint8_t*)p0; - ssize_t gotBytes = rStream.read(p, n); + size_t gotBytes = rStream.read(p, n); while(gotBytes < n) { rStream.flushWrite(); diff --git a/LaunchAPPL/Common/CMakeLists.txt b/LaunchAPPL/Common/CMakeLists.txt index e8544ef076..1e9b267e4b 100644 --- a/LaunchAPPL/Common/CMakeLists.txt +++ b/LaunchAPPL/Common/CMakeLists.txt @@ -11,6 +11,6 @@ target_include_directories(LaunchAPPLCommon PUBLIC .) add_executable(TestLaunchAPPLCommon Test.cc) target_link_libraries(TestLaunchAPPLCommon LaunchAPPLCommon) -if(CMAKE_SYSTEM_NAME MATCHES Retro68) - #target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -fno-exceptions -Os) +if(CMAKE_SYSTEM_NAME MATCHES Retro) + target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -Os) endif() diff --git a/LaunchAPPL/Common/ReliableStream.cc b/LaunchAPPL/Common/ReliableStream.cc index f1d1149571..ac07f1564e 100644 --- a/LaunchAPPL/Common/ReliableStream.cc +++ b/LaunchAPPL/Common/ReliableStream.cc @@ -95,7 +95,7 @@ void ReliableStream::gotAck(uint8_t id) if(nAcked <= sentPackets.size()) { ackedOutputPacket += nAcked; - for(int i = 0; i < nAcked; i++) + for(unsigned i = 0; i < nAcked; i++) sentPackets.pop_front(); sendPackets(); @@ -110,7 +110,7 @@ void ReliableStream::gotNack(uint8_t id) if(nAcked <= sentPackets.size()) { ackedOutputPacket += nAcked; - for(int i = 0; i < nAcked; i++) + for(unsigned i = 0; i < nAcked; i++) sentPackets.pop_front(); sentOutputPacket = ackedOutputPacket; @@ -171,8 +171,8 @@ void ReliableStream::sendOnePacket() }; int match = 0, match2 = 0; - int i; - int consumed = 0; + size_t i; + size_t consumed = 0; for(i = 0; i < n; i++) { if(p[i] == magic1[match]) @@ -390,8 +390,8 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n) case State::skipping: { - int match = 0; - int i; + unsigned match = 0; + unsigned i; for(i = 0; i < n; i++) { if(p[i] == magic1[match++]) @@ -401,7 +401,6 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n) state = State::waiting; return i-3; } - } else match = 0; @@ -412,9 +411,7 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n) case State::receiving: { - int i; - - for(i = 0; i < n; i++) + for(unsigned i = 0; i < n; i++) { incomingPacket.push_back(p[i]); @@ -461,5 +458,5 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n) } break; } - assert(false); + std::abort(); // unreachable } diff --git a/LaunchAPPL/Common/Stream.cc b/LaunchAPPL/Common/Stream.cc index eea77847b1..56eabeb581 100644 --- a/LaunchAPPL/Common/Stream.cc +++ b/LaunchAPPL/Common/Stream.cc @@ -38,7 +38,7 @@ void Stream::notifyReset() listener_->onReset(); } -long Stream::read(void *p, size_t n) +size_t Stream::read(void *p, size_t n) { if(buffer_.size() <= n) { diff --git a/LaunchAPPL/Common/Stream.h b/LaunchAPPL/Common/Stream.h index d98c182f97..4104b33941 100644 --- a/LaunchAPPL/Common/Stream.h +++ b/LaunchAPPL/Common/Stream.h @@ -25,7 +25,7 @@ public: virtual void write(const void* p, size_t n) = 0; virtual void flushWrite() {} - long read(void *p, size_t n); + size_t read(void *p, size_t n); virtual bool readyToWrite() const { return true; } bool readyToRead() const { return !buffer_.empty(); } diff --git a/LaunchAPPL/Common/Test.cc b/LaunchAPPL/Common/Test.cc index 43001715c7..d51aa996b6 100644 --- a/LaunchAPPL/Common/Test.cc +++ b/LaunchAPPL/Common/Test.cc @@ -15,7 +15,7 @@ public: virtual void write(const void* p, size_t n) { 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::endl; other->enqueueReceive(p,n); @@ -45,7 +45,7 @@ public: size_t onReceive(const uint8_t* p, size_t n) { 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) std::cout << "\\x" << std::hex << (unsigned)p[i]; diff --git a/LaunchAPPL/Server/CMakeLists.txt b/LaunchAPPL/Server/CMakeLists.txt index 4a4b88a0fa..991f157406 100644 --- a/LaunchAPPL/Server/CMakeLists.txt +++ b/LaunchAPPL/Server/CMakeLists.txt @@ -51,7 +51,7 @@ target_link_libraries(LaunchAPPLServer LaunchAPPLCommon) set_target_properties(LaunchAPPLServer PROPERTIES 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) set_target_properties(LaunchAPPLServer PROPERTIES LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/LaunchAPPLServer.segmap" diff --git a/LaunchAPPL/Server/LaunchAPPLServer.cc b/LaunchAPPL/Server/LaunchAPPLServer.cc index ac8ac38b2b..61168f259d 100644 --- a/LaunchAPPL/Server/LaunchAPPLServer.cc +++ b/LaunchAPPL/Server/LaunchAPPLServer.cc @@ -375,6 +375,9 @@ public: state = State::launch; return count; } + + default: + return 0; } } @@ -412,8 +415,10 @@ public: else { connection->suspend(); +#if TARGET_CPU_68K if(void *seg = connection->segmentToUnload()) UnloadSeg(seg); +#endif gPrefs.inSubLaunch = true; WritePrefs(); @@ -482,7 +487,7 @@ public: memset(&lpb, 0, sizeof(lpb)); lpb.reserved1 = (unsigned long) LMGetCurApName(); lpb.reserved2 = 0; - OSErr err = LaunchApplication(&lpb); + LaunchApplication(&lpb); ExitToShell(); } onReset(); @@ -552,6 +557,8 @@ void ConnectionChanged() connection = std::make_unique(statusDisplay.get());; break; #endif + default: + ; } if(connection) @@ -599,7 +606,6 @@ int main() #if TARGET_CPU_68K && !TARGET_RT_MAC_CFM short& ROM85 = *(short*) 0x028E; Boolean is128KROM = (ROM85 > 0); - Boolean hasSysEnvirons = false; Boolean hasWaitNextEvent = false; Boolean hasGestalt = false; Boolean hasAppleEvents = false; @@ -609,11 +615,9 @@ int main() if (is128KROM) { UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented); - UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons); UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent); UniversalProcPtr trapGestalt = GetOSTrapAddress(_Gestalt); - hasSysEnvirons = (trapSysEnv != trapUnimpl); hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl); hasGestalt = (trapGestalt != trapUnimpl); @@ -631,8 +635,9 @@ int main() } } #else - const Boolean hasSysEnvirons = true; +#if !TARGET_API_MAC_CARBON const Boolean hasWaitNextEvent = true; +#endif const Boolean hasGestalt = true; const Boolean hasAppleEvents = true; #endif diff --git a/LaunchAPPL/Server/MacSerialStream.cc b/LaunchAPPL/Server/MacSerialStream.cc index 5d2109d544..003533d2fb 100644 --- a/LaunchAPPL/Server/MacSerialStream.cc +++ b/LaunchAPPL/Server/MacSerialStream.cc @@ -15,25 +15,23 @@ void MacSerialStream::close() { if(inRefNum == 0) return; - SerSetBuf(inRefNum, NULL, 0); - - CloseDriver(inRefNum); - CloseDriver(outRefNum); + SerSetBuf(inRefNum, NULL, 0); + + CloseDriver(inRefNum); + CloseDriver(outRefNum); inRefNum = outRefNum = 0; } void MacSerialStream::open() { - OSErr err; - err = OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum); - err = OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum); - SerSetBuf(inRefNum, inputBuffer, kInputBufferSize); + OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum); + OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum); + SerSetBuf(inRefNum, inputBuffer, kInputBufferSize); - - SerShk shk; - memset(&shk, 0, sizeof(shk)); - shk.fCTS = true; - Control(outRefNum, kSERDHandshake, &shk); + SerShk shk; + memset(&shk, 0, sizeof(shk)); + shk.fCTS = true; + Control(outRefNum, kSERDHandshake, &shk); setBaud(curBaud); } @@ -45,18 +43,18 @@ MacSerialStream::~MacSerialStream() void MacSerialStream::write(const void* p, size_t n) { - ParamBlockRec pb; - memset(&pb, 0, sizeof(pb)); - pb.ioParam.ioRefNum = outRefNum; - pb.ioParam.ioBuffer = (Ptr)p; - pb.ioParam.ioReqCount = n; + ParamBlockRec pb; + memset(&pb, 0, sizeof(pb)); + pb.ioParam.ioRefNum = outRefNum; + pb.ioParam.ioBuffer = (Ptr)p; + pb.ioParam.ioReqCount = n; OSErr err = PBWriteSync(&pb); } void MacSerialStream::idle() { long count = 0; - SerGetBuf(inRefNum, &count); + SerGetBuf(inRefNum, &count); while(count > 0) { long count1 = count > kReadBufferSize ? kReadBufferSize : count; @@ -89,7 +87,7 @@ void MacSerialStream::setBaud(int baud) case 115200: baudval = 0; break; case 230400: baudval = 0; break; } - SerReset(outRefNum, baudval | data8 | noParity | stop10); + SerReset(outRefNum, baudval | data8 | noParity | stop10); if(baud == 115200) Control(outRefNum, kSERD115KBaud, nullptr); diff --git a/LaunchAPPL/Server/OpenTptStream.cc b/LaunchAPPL/Server/OpenTptStream.cc index a453cceae8..43d190427d 100644 --- a/LaunchAPPL/Server/OpenTptStream.cc +++ b/LaunchAPPL/Server/OpenTptStream.cc @@ -85,7 +85,6 @@ void OpenTptStream::write(const void* p, size_t n) void OpenTptStream::tryReading() { - OSStatus err; OTResult result; OTFlags flags; do diff --git a/MakeAPPL/CMakeLists.txt b/MakeAPPL/CMakeLists.txt index bf2745c948..b80caaf8a1 100644 --- a/MakeAPPL/CMakeLists.txt +++ b/MakeAPPL/CMakeLists.txt @@ -16,7 +16,6 @@ # along with Retro68. If not, see . cmake_minimum_required(VERSION 2.8) -set(CMAKE_CXX_FLAGS "--std=c++0x") add_executable(MakeAPPL main.cc) target_link_libraries(MakeAPPL ResourceFiles) diff --git a/PEFTools/CMakeLists.txt b/PEFTools/CMakeLists.txt index d628632bb6..987792f167 100644 --- a/PEFTools/CMakeLists.txt +++ b/PEFTools/CMakeLists.txt @@ -1,5 +1,3 @@ -set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar") - find_package(Boost COMPONENTS filesystem system REQUIRED) add_executable(MakePEF MakePEF.cc rs6000.h PEF.h) diff --git a/ResourceFiles/CMakeLists.txt b/ResourceFiles/CMakeLists.txt index fbae84880f..d66d170001 100644 --- a/ResourceFiles/CMakeLists.txt +++ b/ResourceFiles/CMakeLists.txt @@ -16,7 +16,6 @@ # along with Retro68. If not, see . cmake_minimum_required(VERSION 2.8) -set(CMAKE_CXX_FLAGS "--std=c++0x -Wall -Werror=return-type") find_package(Boost COMPONENTS filesystem system REQUIRED) diff --git a/Rez/CMakeLists.txt b/Rez/CMakeLists.txt index 6b33ee2de8..9121723eab 100644 --- a/Rez/CMakeLists.txt +++ b/Rez/CMakeLists.txt @@ -17,15 +17,13 @@ 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) # Look for bison. # 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 # "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) if(Boost_FOUND AND BISON_FOUND) diff --git a/Rez/Test/CMakeLists.txt b/Rez/Test/CMakeLists.txt index 487e8c3d61..a4aed2acce 100644 --- a/Rez/Test/CMakeLists.txt +++ b/Rez/Test/CMakeLists.txt @@ -1,4 +1,3 @@ -set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Wno-multichar") find_package(Boost COMPONENTS unit_test_framework) add_executable(RezUnitTests UnitTests.cc) target_link_libraries(RezUnitTests RezLib ${Boost_LIBRARIES}) diff --git a/Samples/Raytracer/CMakeLists.txt b/Samples/Raytracer/CMakeLists.txt index 7405586563..b604fa94cf 100644 --- a/Samples/Raytracer/CMakeLists.txt +++ b/Samples/Raytracer/CMakeLists.txt @@ -36,8 +36,6 @@ if(APPLE) target_link_libraries(Raytracer "-framework Carbon") target_link_libraries(Raytracer2 "-framework Carbon") else() - set(CMAKE_CXX_FLAGS "-std=c++11") - # save 200KB of code by removing unused stuff set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections") diff --git a/Samples/Raytracer/fixedbenchmark.cc b/Samples/Raytracer/fixedbenchmark.cc index 673d547ee4..9e9723c15c 100644 --- a/Samples/Raytracer/fixedbenchmark.cc +++ b/Samples/Raytracer/fixedbenchmark.cc @@ -85,12 +85,12 @@ int main(int argc, char** argv) std::cout << "Generating numbers..." << std::flush; - const int n = 1000; + const size_t n = 1000; std::vector numbers(n); std::vector floats(n); std::vector 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()); floats[i] = float(std::rand()) / RAND_MAX; diff --git a/Samples/Raytracer/raytracer2.cc b/Samples/Raytracer/raytracer2.cc index 432b348958..7922ba90bf 100644 --- a/Samples/Raytracer/raytracer2.cc +++ b/Samples/Raytracer/raytracer2.cc @@ -76,7 +76,7 @@ public: //if(l == 0) // return *this; //else - return (*this) * (T(1) / length()); + return (*this) * (T(1) / l); } #else vec3 normalize() const { diff --git a/TestApps/CMakeLists.txt b/TestApps/CMakeLists.txt index f5efd02b03..dced83c337 100644 --- a/TestApps/CMakeLists.txt +++ b/TestApps/CMakeLists.txt @@ -16,7 +16,6 @@ # along with Retro68. If not, see . cmake_minimum_required(VERSION 2.8) -set(CMAKE_CXX_FLAGS "-std=c++11") # -fomit-frame-pointer") add_application(EmptyTest EmptyTest.c) diff --git a/TestApps/InitTest.cc b/TestApps/InitTest.cc index 64e606862f..d4ed4cc664 100644 --- a/TestApps/InitTest.cc +++ b/TestApps/InitTest.cc @@ -32,7 +32,7 @@ public: { printf("Foo::~Foo() was called. (delaying 1 sec)\n"); - long start = TickCount(); + unsigned long start = TickCount(); while(TickCount() < start + 60) ; } @@ -50,7 +50,7 @@ __attribute__((destructor)) void des() { printf("des() called. (delaying 1 sec)\n"); - long start = TickCount(); + unsigned long start = TickCount(); while(TickCount() < start + 60) ; }