Merge remote-tracking branch 'origin/master' into gcc12-update

This commit is contained in:
Wolfgang Thaller 2023-12-12 23:48:09 +01:00
commit d77e4d1411
32 changed files with 85 additions and 70 deletions

View File

@ -1,4 +1,4 @@
int main()
int main(void)
{
// Test: do things work well enough for us to get to main()?
return 0;

View File

@ -1,6 +1,6 @@
#include "Test.h"
int main()
int main(void)
{
TEST_LOG_OK();
}

View File

@ -2,7 +2,7 @@
char readWriteData[6] = "Three";
int main()
int main(void)
{
// constant initialized data
TEST_LOG_SIZED("One",3);

View File

@ -6,7 +6,7 @@ __attribute__((noinline)) static void* foo(size_t x)
return malloc(x);
}
int main()
int main(void)
{
if(*(short*)&foo != 0x60FF)
{

View File

@ -1,12 +1,12 @@
#include <FixMath.h>
#include "Test.h"
short calc()
short calc(void)
{
return FixRound(FixRatio(42,5));
}
int main()
int main(void)
{
if(calc() == 8)
TEST_LOG_OK();

View File

@ -1,4 +1,4 @@
void _start()
void _start(void)
{
// Test: do things work well enough for us to get to a startup function?
// Note: this won't work for multisegment 68K apps, as the startup function will be in the wrong segment.

View File

@ -5,8 +5,8 @@
int variable;
void Foo();
void Bar();
void Foo(void);
void Bar(void);
Boolean Test(Boolean unloadFoo, Boolean unloadBar, Boolean compact)
{
@ -36,7 +36,7 @@ Boolean Test(Boolean unloadFoo, Boolean unloadBar, Boolean compact)
return true;
}
int main()
int main(void)
{
Size grow, maxblock, maxblock2, freemem, freemem2;

View File

@ -1,11 +1,11 @@
extern int variable;
#include <SegLoad.h>
void Foo()
void Foo(void)
{
variable *= 9;
}
void Bar()
void Bar(void)
{
variable /= 9;
variable *= 7;

View File

@ -1,6 +1,6 @@
#include <stdio.h>
int main()
int main(void)
{
FILE *f = fopen("out", "w");
fprintf(f, "OK\n");

View File

@ -1,6 +1,6 @@
#include "Test.h"
int main()
int main(void)
{
TEST_LOG_SIZED("One",3);
TEST_LOG_SIZED("Two",3);

View File

@ -8,7 +8,7 @@ int commonSymbol;
int zeroInited = 0;
EventRecord e;
int main()
int main(void)
{
int i;
if(commonSymbol)

View File

@ -23,6 +23,7 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type -Wno-multichar")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror=return-type -Werror=strict-prototypes -Wno-multichar")
enable_testing()

View File

@ -56,7 +56,7 @@ enum ReferenceFlags { // flags field of kReference
kUnknownReferenceFlags = 0x6E // rather a lot, isn't it?
// The following flags are known to exist from DumpOBJ,
// but their value is unkown as I haven't actually seen them yet:
// but their value is unknown as I haven't actually seen them yet:
// k32BitOffsets (default k16BitOffsets)
};

View File

@ -20,11 +20,13 @@
#include "Elf2Mac.h"
#include "SegmentMap.h"
#include <iomanip>
#include <iostream>
#include <boost/algorithm/string/replace.hpp>
#include <boost/lexical_cast.hpp>
#include <sstream>
#include <string>
#include <boost/algorithm/string/replace.hpp>
using std::string;
const char * scriptStart = R"ld(/* ld script for Elf2Mac */
@ -214,7 +216,11 @@ void SegmentInfo::WriteFiltersKeep(std::ostream &out, string section)
void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint)
{
out << "\t.code" << id << " : {\n";
std::ostringstream ss;
ss << std::setw(5) << std::setfill('0') << id;
const std::string zero_padded_id = ss.str();
out << "\t.code" << zero_padded_id << " : {\n";
out << "\t\tFILL(0x4E71);\n";
if(id == 1)
{
@ -259,7 +265,7 @@ void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint)
if(id == 1)
out << "\t\t__EH_FRAME_BEGIN__" << " = .;\n";
else
out << "\t\t__EH_FRAME_BEGIN__" << id << " = .;\n";
out << "\t\t__EH_FRAME_BEGIN__" << zero_padded_id << " = .;\n";
WriteFiltersKeep(out, ".eh_frame");
out << "\t\tLONG(0);\n";
WriteFiltersKeep(out, ".gcc_except_table");
@ -278,7 +284,7 @@ void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint)
FILL(0);
. += 32;
LONG(__EH_FRAME_BEGIN__@N@ - .);
)ld", "@N@", boost::lexical_cast<string>(id));
)ld", "@N@", zero_padded_id);
}
out << "\t}\n";

View File

@ -29,11 +29,12 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/lexical_cast.hpp>
#include "ResourceFork.h"
#include "BinaryIO.h"
@ -315,7 +316,12 @@ void Object::MultiSegmentApp(string output, SegmentMap& segmentMap)
string exceptionInfoMarker = "__EH_FRAME_BEGIN__";
if(id != 1)
exceptionInfoMarker += boost::lexical_cast<string>(id);
{
std::ostringstream ss;
ss << std::setw(5) << std::setfill('0') << id;
const std::string zero_padded_id = ss.str();
exceptionInfoMarker += zero_padded_id;
}
int exceptionInfoSym = symtab->FindSym(exceptionInfoMarker);
if(exceptionInfoSym != -1)
{

View File

@ -47,12 +47,12 @@ For Arch Linux, this should do the trick:
On a Mac, get the homebrew package manager and:
brew install boost cmake gmp mpfr libmpc bison
brew install boost cmake gmp mpfr libmpc bison texinfo
You can also run Retro68 on a PowerMac G4 or G5 running Mac OS 10.4 (Tiger).
In that case, get the tigerbrew package manager and
brew install gcc cmake gmp mpfr libmpc bison
brew install gcc cmake gmp mpfr libmpc bison texinfo
brew install boost --c++11
### Apple Universal Interfaces vs. Multiversal Interfaces

View File

@ -42,7 +42,7 @@ pascal void ButtonFrameProc(DialogRef dlg, DialogItemIndex itemNo)
FrameRoundRect(&box,16,16);
}
int main()
int main(void)
{
#if !TARGET_API_MAC_CARBON
InitGraf(&qd.thePort);

View File

@ -26,7 +26,7 @@
#include <string.h>
void Explain()
void Explain(void)
{
printf("*********************************************************\n");
printf("This program is intended to make developing software\n");
@ -41,7 +41,7 @@ void Explain()
printf("*********************************************************\n");
}
void EjectOldDisk()
void EjectOldDisk(void)
{
Handle h = GetResource('LNCH', 128);
if(h)
@ -55,7 +55,7 @@ void EjectOldDisk()
}
}
int main()
int main(void)
{
Explain();
EjectOldDisk();

View File

@ -48,12 +48,12 @@ struct MPWFile;
struct fsysTable
{
void (*quit)();
void (*access)();
void (*quit)(void);
void (*access)(void);
void (*close)(struct MPWFile *);
void (*read)(struct MPWFile *);
void (*write)(struct MPWFile *);
void (*ioctl)();
void (*ioctl)(void);
};
struct devtable
@ -101,7 +101,7 @@ struct pgminfo
// Get MPW's magic struct
struct pgminfo2 * getPgmInfo()
struct pgminfo2 *getPgmInfo(void)
{
struct pgminfo *pgm0 = *(struct pgminfo**) 0x316;
if(!pgm0)
@ -132,7 +132,7 @@ void _exit(int status)
const int procInfo = kCStackBased
| STACK_ROUTINE_PARAMETER(1, kFourByteCode);
int main()
int main(int argc, char *argv[], char *envp[])
{
struct pgminfo2 *pgm = getPgmInfo();
if(pgm)
@ -152,19 +152,20 @@ int main()
#if TARGET_CPU_PPC
void __do_global_dtors();
void __do_global_dtors(void);
void __start()
void __start(void)
{
if(setjmp(exit_buf))
;
;
else
{
atexit(&__do_global_dtors);
int result;
{
char *argv[2] = { "./a.out", NULL };
result = main(1, argv);
char *envp[1] = { NULL };
result = main(1, argv, envp);
}
exit(result);
}
@ -174,7 +175,7 @@ void *__dso_handle = &__dso_handle;
#else
void _start()
void _start(void)
{
RETRO68_RELOCATE();
@ -188,7 +189,8 @@ void _start()
int result;
{
char *argv[2] = { "./a.out", NULL };
result = main(1, argv);
char *envp[1] = { NULL };
result = main(1, argv, envp);
}
exit(result);
}

View File

@ -157,7 +157,7 @@ float ray(int n, float x0, float y0, float z0, float dx, float dy, float dz)
return v;
}
int main()
int main(void)
{
WindowPtr win;

View File

@ -23,7 +23,7 @@
#include "library.h"
int main()
int main(void)
{
// wait until computer is turned on ;-)
while(!is_computer_on())

View File

@ -25,7 +25,7 @@
#include "library.h"
#include <Sound.h>
void beep()
void beep(void)
{
SysBeep(20);
}
@ -39,7 +39,7 @@ void beep()
* Note that a function by this name was an actual, documented part
* of the BeOS API.
*/
Boolean is_computer_on()
Boolean is_computer_on(void)
{
return true;
}

View File

@ -19,5 +19,5 @@
#include <MacTypes.h>
void beep();
Boolean is_computer_on();
void beep(void);
Boolean is_computer_on(void);

View File

@ -2,7 +2,7 @@
#include "ShowInitIcon.h"
#include "Retro68Runtime.h"
void _start()
void _start(void)
{
RETRO68_RELOCATE();
Retro68CallConstructors();

View File

@ -64,7 +64,7 @@ void MakeNewWindow(ConstStr255Param title, short procID)
OffsetRect(&nextWindowRect, 15, 15);
}
void InitCustomWDEF()
void InitCustomWDEF(void)
{
/* The 10-byte code resource stub trick.
*
@ -91,7 +91,7 @@ void InitCustomWDEF()
// with custom WDEFs.
}
void ShowAboutBox()
void ShowAboutBox(void)
{
WindowRef w = GetNewWindow(128, NULL, (WindowPtr) - 1);
MoveWindow(w,
@ -116,7 +116,7 @@ void ShowAboutBox()
DisposeWindow(w);
}
void UpdateMenus()
void UpdateMenus(void)
{
MenuRef m = GetMenu(kMenuFile);
WindowRef w = FrontWindow();
@ -234,7 +234,7 @@ void DoUpdate(WindowRef w)
EndUpdate(w);
}
int main()
int main(void)
{
InitGraf(&qd.thePort);
InitFonts();

View File

@ -1,4 +1,4 @@
int main()
int main(void)
{
return 0;
}

View File

@ -81,7 +81,7 @@ jobs:
- checkout: self
submodules: true
- script: |
docker run -i --name nix -v`pwd`:/src nixos/nix:2.3.12 <<EOF
docker run -i --name nix -v`pwd`:/src nixos/nix:2.18.1 <<EOF
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use autc04
nix-build src -A ${TARGET}.retro68.samples

View File

@ -14,7 +14,7 @@ static UniversalProcPtr OriginalExitToShell;
static UniversalProcPtr OriginalLaunch;
static UniversalProcPtr OriginalChain;
extern pascal void PatchedLoadSeg();
extern pascal void PatchedLoadSeg(void);
typedef union JTEntry
{
@ -171,10 +171,10 @@ static pascal void PatchedUnloadSeg(Ptr ptr)
HPurge(CODE);
}
static void InstallPatches();
static void UninstallPatches();
static void InstallPatches(void);
static void UninstallPatches(void);
static pascal void PatchedExitToShell()
static pascal void PatchedExitToShell(void)
{
UninstallPatches();
ExitToShell();
@ -204,7 +204,7 @@ static OSErr PatchedChain(void *p)
return err;
}
static void InstallPatches()
static void InstallPatches(void)
{
SetToolTrapAddress((UniversalProcPtr)&PatchedLoadSeg, _LoadSeg);
SetToolTrapAddress((UniversalProcPtr)&PatchedUnloadSeg, _UnLoadSeg);
@ -213,7 +213,7 @@ static void InstallPatches()
SetToolTrapAddress((UniversalProcPtr)&PatchedChain, _Chain);
}
static void UninstallPatches()
static void UninstallPatches(void)
{
SetToolTrapAddress((UniversalProcPtr)OriginalLoadSeg, _LoadSeg);
SetToolTrapAddress((UniversalProcPtr)OriginalUnloadSeg, _UnLoadSeg);
@ -226,7 +226,7 @@ static void UninstallPatches()
// section boundaries
extern uint8_t _stext, _etext, _sdata, _edata, _sbss[], _ebss;
void Retro68InitMultisegApp()
void Retro68InitMultisegApp(void)
{
uint8_t * a5 = (uint8_t*) StripAddressCompat((void*)SetCurrentA5());

View File

@ -62,11 +62,11 @@
(*(typeof(&FUN)) ((char*)(&FUN) + displacement)) ARGS; \
} while(0)
void Retro68Relocate();
void Retro68CallConstructors();
void Retro68CallDestructors();
void Retro68FreeGlobals();
void Retro68InitMultisegApp();
void Retro68Relocate(void);
void Retro68CallConstructors(void);
void Retro68CallDestructors(void);
void Retro68FreeGlobals(void);
void Retro68InitMultisegApp(void);
void Retro68ApplyRelocations(uint8_t *base, uint32_t size, void *relocations, uint32_t displacements[]);
#define RETRO68_RELOCATE() RETRO68_CALL_UNRELOCATED(Retro68Relocate,())

View File

@ -29,7 +29,7 @@
#include <string.h>
#include <MacMemory.h>
void referenceMyMalloc() {}
void referenceMyMalloc(void) {}
void *_malloc_r(struct _reent *reent_ptr, size_t sz)
{

View File

@ -28,9 +28,9 @@
int main(int argc, char* argv[]);
void __do_global_dtors();
void __do_global_dtors(void);
void __start()
void __start(void)
{
int result;

View File

@ -28,7 +28,7 @@
int main(int argc, char* argv[]);
void _start()
void _start(void)
{
RETRO68_RELOCATE();
atexit(&Retro68CallDestructors);