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_REQUIRED TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type -Wno-multichar")
if(CMAKE_SYSTEM_NAME MATCHES Retro.*)

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>.
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)

View File

@ -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

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)
add_executable(ConvertObj ConvertObj.cc)

View File

@ -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<std::string>() );
vmacPath = fs::absolute( options["minivmac-path"].as<std::string>(), vmacDir );
imagePath = tempDir / "disk1.dsk";
vmacDir = fs::absolute( options["minivmac-dir"].as<std::string>() );
vmacPath = fs::absolute( options["minivmac-path"].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);
systemImage = fs::absolute(options["system-image"].as<std::string>(), vmacDir);
fs::path autoquitImage = fs::absolute(options["autoquit-image"].as<std::string>(), vmacDir);
std::vector<unsigned char> bootblock1(1024);
fs::ifstream(systemImage).read((char*) bootblock1.data(), 1024);
std::vector<unsigned char> 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<std::string>(), vmacDir );
fs::create_symlink(
romFile,
tempDir / romFile.filename() );
fs::path romFile = fs::absolute( options["minivmac-rom"].as<std::string>(), 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<char> 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<char> 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<uint8_t> 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<uint8_t> 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<char> 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<char> 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<std::string>(),"directory containing vMac.ROM")
("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")
("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")
;
desc.add_options()
("minivmac-dir", po::value<std::string>(),"directory containing vMac.ROM")
("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")
("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")
;
}
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<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:
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();

View File

@ -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();

View File

@ -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()

View File

@ -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
}

View File

@ -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)
{

View File

@ -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(); }

View File

@ -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];

View File

@ -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"

View File

@ -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<OpenTptConnectionProvider>(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

View File

@ -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);

View File

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

View File

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

View File

@ -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)

View File

@ -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})

View File

@ -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")

View File

@ -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<fixed> numbers(n);
std::vector<float> floats(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());
floats[i] = float(std::rand()) / RAND_MAX;

View File

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

View File

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

View File

@ -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)
;
}