PR modula2/116181 remove ODR warnings from library interface files

This patch removes the warnings generated by -Wodr from the library
interface between modula-2 and C.

gcc/m2/ChangeLog:

	PR modula2/116181
	* Make-lang.in (MC_SRC_FLAGS): New macro.
	(m2/mc-boot/$(SRC_PREFIX)%.o): Use MC_SRC_FLAGS.
	(m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto.
	(m2/gm2-libs-boot/M2RTS.o): Ditto.
	(m2/gm2-libs-boot/%.o): Ditto.
	(GM2-LIBS-BOOT-H): New macro.
	(m2/gm2-libs-boot/RTcodummy.o): Use MC_SRC_FLAGS.
	Remove gm2-libs-host.h from the dependancy.
	(m2/gm2-libs-boot/wrapc.o): Use MC_SRC_FLAGS.
	Add dependancy GM2-LIBS-BOOT-H.
	(m2/gm2-libs-boot/UnixArgs.o): Ditto.
	(m2/gm2-libs-boot/choosetemp.o): Ditto.
	(m2/gm2-libs-boot/errno.o): Ditto.
	(m2/gm2-libs-boot/dtoa.o): Ditto.
	(m2/gm2-libs-boot/ldtoa.o): Ditto.
	(m2/gm2-libs-boot/termios.o): Ditto.
	(m2/gm2-libs-boot/SysExceptions.o): Ditto.
	(m2/gm2-compiler-boot/M2GCCDeclare.o): Add gm2-libs-ch to the
	search path.
	(m2/gm2-compiler-boot/M2Error.o): Ditto.
	(m2/gm2-compiler-boot/%.o): Ditto.
	(m2/pge-boot/%.o): Ditto.
	* gm2-gcc/m2color.cc (m2color_colorize_start): Replace parameter
	type char to void and recast to char * when calling colorize_start.
	* gm2-gcc/m2color.h (m2color_colorize_start): Replace parameter
	type char to void.
	* gm2-gcc/m2type.h: Remove #if 0 block.
	* gm2-libs-ch/SysExceptions.c (DECL_PROC_T): Provide alternative
	defines for MC an gm2.
	(PROC_FUNC): Ditto.
	(EXTERN): Force undefine and redefine.
	(SysExceptions_InitExceptionHandlers): Rewrite function
	declaration using defined macros.
	(_M2_SysExceptions_init): Use EXTERN.
	(_M2_SysExceptions_finish): Replace with ...
	(_M2_SysExceptions_fini): ... this and add parameters.
	* gm2-libs-ch/UnixArgs.cc (gm2-libs-host.h): Include.
	(GUnixArgs.h): Include.
	(GM2RTS.h): Include.
	(UnixArgs_GetArgV): Change return type to void *.
	(UnixArgs_GetEnvV): Ditto.
	* gm2-libs-ch/m2rts.h (M2RTS_RegisterModule_Cstr): Add new
	conditional macro.
	(M2RTS_RequestDependant): Remove.
	(M2RTS_RegisterModule): Ditto.
	(M2RTS_Terminate): Ditto.
	(M2RTS_DeconstructModules): Ditto.
	(M2RTS_Halt): Ditto.
	(_M2_M2RTS_init): Ditto.
	(M2RTS_ConstructModules): Ditto.
	* gm2-libs-ch/termios.c (_termios_C): Define.
	(EXTERN): Add conditional definition.
	(doSetUnset): New function.
	(_M2_termios_init): Add correct parameters.
	(_M2_termios_finish): Ditto.
	(_M2_termios_fini): Ditto.
	* mc-boot-ch/GSysExceptions.c (DECL_PROC_T): New define.
	(PROC_FUNC): Ditto.
	(EXTERN): Force undef.
	(SysExceptions_InitExceptionHandlers): Rewrite.
	* mc-boot-ch/Glibc.c (libc_open): Rename parameter
	oflag to flags.
	* mc-boot-ch/Gtermios.cc (_termios_C): New define.
	(KillTermios): Change parameter type from
	struct termios * to termios_TERMIOS.
	(tcsnow): Rewrite.
	(tcsnow): Rewrite.
	(tcsdrain): Rewrite.
	(tcsflush): Rewrite.
	(cfgetospeed): Rewrite.
	(cfgetispeed): Rewrite.
	(cfsetospeed): Rewrite.
	(cfsetispeed): Rewrite.
	(cfsetspeed): Rewrite.
	(cfsetspeed): Rewrite.
	(tcgetattr): Rewrite.
	(tcsetattr): Rewrite.
	(cfmakeraw): Rewrite.
	(tcsendbreak): Rewrite.
	(tcdrain): Rewrite.
	(tcflushi): Rewrite.
	(tcflusho): Rewrite.
	(tcflushio): Rewrite.
	(tcflowoni): Rewrite.
	(tcflowoffi): Rewrite.
	(tcflowono): Rewrite.
	(tcflowoffo): Rewrite.
	(GetFlag): Rewrite.
	(SetFlag): Rewrite.
	(GetChar): Rewrite.
	(SetChar): Rewrite.
	(InitTermios): Rewrite.
	* pge-boot/GM2RTS.cc: Regenerate.
	* pge-boot/GSysExceptions.cc: Ditto.
	* pge-boot/Gtermios.cc: Ditto.
	* pge-boot/m2rts.h: Rewrite.
	* mc-boot-ch/GSYSTEM.h: New file.
	* mc-boot-ch/GSysExceptions.h: New file.
	* mc-boot-ch/Gtermios.h: New file.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
Gaius Mulley 2024-08-28 22:51:11 +01:00
parent 3c89c41991
commit b8ef805e4d
18 changed files with 1659 additions and 1134 deletions

View File

@ -512,6 +512,8 @@ MC=m2/boot-bin/mc$(exeext) $(MC_ARGS)
MC_LIBS=m2/mc-boot-ch/Glibc.o m2/mc-boot-ch/Gmcrts.o
MC_SRC_FLAGS=-DMC_M2
M2LINK=m2/boot-bin/mklink$(exeext)
GM2_O=-O0
GM2_O_S3=-O
@ -1434,17 +1436,17 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \
m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
$(POSTCOMPILE)
m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
$(POSTCOMPILE)
m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
@ -1464,80 +1466,82 @@ mcflex.c: $(srcdir)/m2/mc/mc.flex
m2/gm2-libs-boot/M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(MC) --suppress-noreturn -o=m2/gm2-libs-boot/M2RTS.c $(srcdir)/m2/gm2-libs/M2RTS.mod
$(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@
$(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -I$(srcdir)/m2/gm2-libs-ch $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs-boot/$*.mod
$(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@
$(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) $(MCINCLUDES) -I$(srcdir)/m2/gm2-libs-ch m2/gm2-libs-boot/$*.c -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs/$*.mod
$(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@
$(COMPILER) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -I$(srcdir)/m2/gm2-libs-ch $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
-test -d $(@D) || $(mkinstalldirs) $(@D)
$(MC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def
m2/gm2-libs-boot/RTcodummy.o: $(srcdir)/m2/gm2-libs-ch/RTcodummy.c m2/gm2-libs/gm2-libs-host.h
GM2-LIBS-BOOT-H=m2/gm2-libs/gm2-libs-host.h m2/gm2-libs-boot/GM2RTS.h m2/gm2-libs-boot/GSYSTEM.h
m2/gm2-libs-boot/RTcodummy.o: $(srcdir)/m2/gm2-libs-ch/RTcodummy.c
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/RTintdummy.o: $(srcdir)/m2/gm2-libs-ch/RTintdummy.c m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/RTintdummy.o: $(srcdir)/m2/gm2-libs-ch/RTintdummy.c
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c -DHAVE_CONFIG_H $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c -DHAVE_CONFIG_H $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c m2/gm2-libs-boot/$(SRC_PREFIX)errno.h m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c m2/gm2-libs-boot/$(SRC_PREFIX)errno.h $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs-boot -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs-boot -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c $(BUILD-LIBS-BOOT-H) m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c $(BUILD-LIBS-BOOT-H) $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \
m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h m2/gm2-libs/gm2-libs-host.h
m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h $(GM2-LIBS-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(CXX) $(CM2DEP) -c $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
$(POSTCOMPILE)
m2/gm2-libs-boot/SysStorage.o: $(srcdir)/m2/gm2-libs/SysStorage.mod $(MCDEPS) $(BUILD-BOOT-H)
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(MC) -o=m2/gm2-libs-boot/SysStorage.c $(srcdir)/m2/gm2-libs/SysStorage.mod
$(COMPILER) $(CM2DEP) -DIN_GCC -c $(CFLAGS) $(GM2_PICFLAGS) \
$(COMPILER) $(CM2DEP) -DIN_GCC -c $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) \
-I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) \
m2/gm2-libs-boot/SysStorage.c -o m2/gm2-libs-boot/SysStorage.o
$(POSTCOMPILE)
@ -1547,7 +1551,7 @@ m2/gm2-compiler-boot/M2GCCDeclare.o: $(srcdir)/m2/gm2-compiler/M2GCCDeclare.mod
$(MC) $(MC_EXTENDED_OPAQUE) -o=m2/gm2-compiler-boot/M2GCCDeclare.c $<
$(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
-I. -I$(srcdir)/../include -I$(srcdir) \
-I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \
-I. -Im2/gm2-libs-boot -I$(srcdir)/m2/gm2-libs-ch -Im2/gm2-compiler-boot \
-I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2GCCDeclare.c -o $@
$(POSTCOMPILE)
@ -1556,7 +1560,7 @@ m2/gm2-compiler-boot/M2Error.o: $(srcdir)/m2/gm2-compiler/M2Error.mod $(MCDEPS)
$(MC) $(MC_EXTENDED_OPAQUE) -o=m2/gm2-compiler-boot/M2Error.c $<
$(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
-I. -I$(srcdir)/../include -I$(srcdir) \
-I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \
-I. -Im2/gm2-libs-boot -I$(srcdir)/m2/gm2-libs-ch -Im2/gm2-compiler-boot \
-I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2Error.c -o $@
$(POSTCOMPILE)
@ -1565,7 +1569,7 @@ m2/gm2-compiler-boot/%.o: $(srcdir)/m2/gm2-compiler/%.mod $(BUILD-BOOT-H) $(MCDE
$(MC) -o=m2/gm2-compiler-boot/$*.c $(srcdir)/m2/gm2-compiler/$*.mod
$(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
-I. -I$(srcdir)/../include -I$(srcdir) \
-I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -Im2/gm2-libiberty \
-I. -Im2/gm2-libs-boot -I$(srcdir)/m2/gm2-libs-ch -Im2/gm2-compiler-boot -Im2/gm2-libiberty \
-I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@
$(POSTCOMPILE)
@ -1575,6 +1579,7 @@ m2/gm2-compiler-boot/%.o: m2/gm2-compiler-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
$(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
-I. -I$(srcdir)/../include -I$(srcdir) \
-I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \
-I$(srcdir)/m2/gm2-libs-ch \
-I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@
$(POSTCOMPILE)
@ -1837,12 +1842,12 @@ include m2/Make-maintainer
else
m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) $(CFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
$(CXX) $(CM2DEP) $(CFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
$(POSTCOMPILE)
m2/pge-boot/%.o: m2/pge-boot/%.cc m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
-test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
$(CXX) $(CM2DEP) $(CXXFLAGS) $(GM2_PICFLAGS) $(MC_SRC_FLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
$(POSTCOMPILE)
$(PGE): $(BUILD-PGE-O)

View File

@ -27,9 +27,11 @@ along with GNU Modula-2; see the file COPYING3. If not see
char *
m2color_colorize_start (bool show_color, char *name, unsigned int _name_high)
m2color_colorize_start (bool show_color, void *name, unsigned int _name_high)
{
return const_cast<char*> (colorize_start (show_color, name, _name_high));
return const_cast<char*> (colorize_start (show_color,
reinterpret_cast <char *> (name),
_name_high));
}

View File

@ -37,7 +37,7 @@ along with GNU Modula-2; see the file COPYING3. If not see
EXTERN char *
m2color_colorize_start (bool show_color, char *name, unsigned int name_len);
m2color_colorize_start (bool show_color, void *name, unsigned int name_len);
EXTERN char *m2color_colorize_stop (bool show_color);

View File

@ -87,13 +87,6 @@ EXTERN tree m2type_BuildArrayStringConstructor (location_t location,
tree arrayType, tree str,
tree length);
#if 0
EXTERN tree m2type_GetPointerOne (void);
EXTERN tree m2type_GetPointerZero (void);
EXTERN tree m2type_GetWordOne (void);
EXTERN tree m2type_GetWordZero (void);
#endif
EXTERN tree m2type_GetM2CharType (void);
EXTERN tree m2type_GetM2IntegerType (void);
EXTERN tree m2type_GetM2ShortRealType (void);

View File

@ -26,15 +26,23 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "config.h"
#include "system.h"
#include "ansidecl.h"
#include "gm2-libs-host.h"
#if defined(HAVE_SIGNAL_H)
#include <signal.h>
#ifdef MC_M2
#include "GSysExceptions.h"
#define DECL_PROC_T(X) SysExceptions_PROCEXCEPTION X
#define PROC_FUNC(X) X.proc
#else
#define DECL_PROC_T(X) void (*X) (void *)
#define PROC_FUNC(X) X
#endif
#ifdef __cplusplus
extern "C" {
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
#else
#define EXTERN
#endif
#if 0
@ -75,16 +83,14 @@ extern "C" {
#define SIGSYS 31 /* Bad system call. */
#define SIGUNUSED 31
(indexException, rangeException, caseSelectException, invalidLocation,
functionException, wholeValueException, wholeDivException, realValueException,
realDivException, complexValueException, complexDivException, protException,
sysException, coException, exException
);
#endif
/* note wholeDivException and realDivException are caught by SIGFPE
/* wholeDivException and realDivException are caught by SIGFPE
and depatched to the appropriate Modula-2 runtime routine upon
testing FPE_INTDIV or FPE_FLTDIV. realValueException is also
caught by SIGFPE and dispatched by testing FFE_FLTOVF or
@ -113,6 +119,7 @@ static void (*systemProc) (void *);
static void (*coroutineProc) (void *);
static void (*exceptionProc) (void *);
static void
sigbusDespatcher (int signum, siginfo_t *info, void *ucontext)
{
@ -164,33 +171,41 @@ sigfpeDespatcher (int signum, siginfo_t *info, void *ucontext)
}
}
EXTERN
void
SysExceptions_InitExceptionHandlers (
void (*indexf) (void *), void (*range) (void *), void (*casef) (void *),
void (*invalidloc) (void *), void (*function) (void *),
void (*wholevalue) (void *), void (*wholediv) (void *),
void (*realvalue) (void *), void (*realdiv) (void *),
void (*complexvalue) (void *), void (*complexdiv) (void *),
void (*protection) (void *), void (*systemf) (void *),
void (*coroutine) (void *), void (*exception) (void *))
SysExceptions_InitExceptionHandlers (DECL_PROC_T(indexf),
DECL_PROC_T(range),
DECL_PROC_T(casef),
DECL_PROC_T(invalidloc),
DECL_PROC_T(function),
DECL_PROC_T(wholevalue),
DECL_PROC_T(wholediv),
DECL_PROC_T(realvalue),
DECL_PROC_T(realdiv),
DECL_PROC_T(complexvalue),
DECL_PROC_T(complexdiv),
DECL_PROC_T(protection),
DECL_PROC_T(systemf),
DECL_PROC_T(coroutine),
DECL_PROC_T(exception))
{
struct sigaction old;
indexProc = indexf;
rangeProc = range;
caseProc = casef;
invalidlocProc = invalidloc;
functionProc = function;
wholevalueProc = wholevalue;
wholedivProc = wholediv;
realvalueProc = realvalue;
realdivProc = realdiv;
complexvalueProc = complexvalue;
complexdivProc = complexdiv;
protectionProc = protection;
systemProc = systemf;
coroutineProc = coroutine;
exceptionProc = exception;
indexProc = PROC_FUNC (indexf);
rangeProc = PROC_FUNC (range);
caseProc = PROC_FUNC (casef);
invalidlocProc = PROC_FUNC (invalidloc);
functionProc = PROC_FUNC (function);
wholevalueProc = PROC_FUNC (wholevalue);
wholedivProc = PROC_FUNC (wholediv);
realvalueProc = PROC_FUNC (realvalue);
realdivProc = PROC_FUNC (realdiv);
complexvalueProc = PROC_FUNC (complexvalue);
complexdivProc = PROC_FUNC (complexdiv);
protectionProc = PROC_FUNC (protection);
systemProc = PROC_FUNC (systemf);
coroutineProc = PROC_FUNC (coroutine);
exceptionProc = PROC_FUNC (exception);
sigbus.sa_sigaction = sigbusDespatcher;
sigbus.sa_flags = (SA_SIGINFO);
@ -215,29 +230,37 @@ SysExceptions_InitExceptionHandlers (
}
#else
EXTERN
void
SysExceptions_InitExceptionHandlers (void *indexf, void *range, void *casef,
void *invalidloc, void *function,
void *wholevalue, void *wholediv,
void *realvalue, void *realdiv,
void *complexvalue, void *complexdiv,
void *protection, void *systemf,
void *coroutine, void *exception)
SysExceptions_InitExceptionHandlers (DECL_PROC_T(indexf),
DECL_PROC_T(range),
DECL_PROC_T(casef),
DECL_PROC_T(invalidloc),
DECL_PROC_T(function),
DECL_PROC_T(wholevalue),
DECL_PROC_T(wholediv),
DECL_PROC_T(realvalue),
DECL_PROC_T(realdiv),
DECL_PROC_T(complexvalue),
DECL_PROC_T(complexdiv),
DECL_PROC_T(protection),
DECL_PROC_T(systemf),
DECL_PROC_T(coroutine),
DECL_PROC_T(exception))
{
}
#endif
/* GNU Modula-2 linking fodder. */
EXTERN
void
_M2_SysExceptions_init (int argc, char *argv[], char *envp[])
{
}
EXTERN
void
_M2_SysExceptions_finish (void)
_M2_SysExceptions_fini (int argc, char *argv[], char *envp[])
{
}
#ifdef __cplusplus
}
#endif

View File

@ -29,9 +29,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define LIBNAME "m2pim"
extern "C" int UnixArgs_GetArgC (void);
extern "C" char **UnixArgs_GetArgV (void);
extern "C" char **UnixArgs_GetEnvV (void);
#include "gm2-libs-host.h"
#include "GUnixArgs.h"
#include "GM2RTS.h"
static int UnixArgs_ArgC;
static char **UnixArgs_ArgV;
@ -49,7 +50,7 @@ UnixArgs_GetArgC (void)
/* GetArgV returns argv. */
extern "C" char **
extern "C" void *
UnixArgs_GetArgV (void)
{
return UnixArgs_ArgV;
@ -58,7 +59,7 @@ UnixArgs_GetArgV (void)
/* GetEnvV returns envv. */
extern "C" char **
extern "C" void *
UnixArgs_GetEnvV (void)
{
return UnixArgs_EnvV;

View File

@ -24,23 +24,15 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include "GM2RTS.h"
typedef void (*proc_con) (int, char **, char **);
typedef void (*proc_dep) (void);
#ifdef MC_M2
/* mc sources do not register their init fini functions as they are
initialized by a static scaffold (called by main). */
#define M2RTS_RegisterModule_Cstr(MODNAME,LIBNAME,init,fini,dep)
#else
#define M2RTS_RegisterModule_Cstr(MODNAME,LIBNAME,init,fini,dep) \
M2RTS_RegisterModule (reinterpret_cast <void *> (const_cast <char *> (MODNAME)), \
reinterpret_cast <void *> (const_cast <char *> (LIBNAME)), \
init, fini, dep)
extern "C" void M2RTS_RequestDependant (const void *modulename, const void *dependancy);
extern "C" void M2RTS_RegisterModule (void *modulename, void *libname,
proc_con init, proc_con fini, proc_dep dependencies);
extern "C" void _M2_M2RTS_init (void);
extern "C" void M2RTS_ConstructModules (const void *,
int argc, char *argv[], char *envp[]);
extern "C" void M2RTS_Terminate (void);
extern "C" void M2RTS_DeconstructModules (void);
extern "C" void M2RTS_Halt (const char *, const char *, const char *, int) __attribute__ ((noreturn));
#endif

View File

@ -26,24 +26,28 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "config.h"
#include "system.h"
#include "ansidecl.h"
#include "gm2-libs-host.h"
#define _termios_C
#include "Gtermios.h"
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#endif
#ifdef TERMIOS_NEEDS_XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#if defined(HAVE_TERMIOS_H)
#include <termios.h>
#if defined(__cplusplus)
#define EXTERN extern "C"
#else
#define EXTERN
#endif
#define EXPORT(X) termios##_##X
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
vintr,
vquit,
@ -168,40 +172,25 @@ typedef enum {
liexten
} Flag;
/* prototypes. */
void *EXPORT (InitTermios) (void);
void *EXPORT (KillTermios) (struct termios *p);
int EXPORT (cfgetospeed) (struct termios *t);
int EXPORT (cfgetispeed) (struct termios *t);
int EXPORT (cfsetospeed) (struct termios *t, unsigned int b);
int EXPORT (cfsetispeed) (struct termios *t, unsigned int b);
int EXPORT (cfsetspeed) (struct termios *t, unsigned int b);
int EXPORT (tcgetattr) (int fd, struct termios *t);
int EXPORT (tcsetattr) (int fd, int option, struct termios *t);
void EXPORT (cfmakeraw) (struct termios *t);
int EXPORT (tcsendbreak) (int fd, int duration);
int EXPORT (tcdrain) (int fd);
int EXPORT (tcflushi) (int fd);
int EXPORT (tcflusho) (int fd);
int EXPORT (tcflushio) (int fd);
int EXPORT (tcflowoni) (int fd);
int EXPORT (tcflowoffi) (int fd);
int EXPORT (tcflowono) (int fd);
int EXPORT (tcflowoffo) (int fd);
bool EXPORT (GetFlag) (struct termios *t, Flag f, bool *b);
bool EXPORT (SetFlag) (struct termios *t, Flag f, bool b);
bool EXPORT (GetChar) (struct termios *t, ControlChar c, char *ch);
bool EXPORT (SetChar) (struct termios *t, ControlChar c, char ch);
int EXPORT (tcsnow) (void);
int EXPORT (tcsflush) (void);
int EXPORT (tcsdrain) (void);
bool doSetUnset (tcflag_t *bitset, unsigned int mask, bool value);
void _M2_termios_init (void);
void _M2_termios_finish (void);
int
doSetUnset (tcflag_t *bitset, unsigned int mask, int value)
{
if (value)
(*bitset) |= mask;
else
(*bitset) &= (~mask);
return 1;
}
#ifdef __cplusplus
extern "C" {
#endif
/* InitTermios - new data structure. */
void *EXPORT (InitTermios) (void)
void *
EXPORT (InitTermios) (void)
{
struct termios *p = (struct termios *)malloc (sizeof (struct termios));
@ -211,50 +200,79 @@ void *EXPORT (InitTermios) (void)
/* KillTermios - delete data structure. */
void *EXPORT (KillTermios) (struct termios *p)
void *
EXPORT (KillTermios) (termios_TERMIOS p)
{
free (p);
return NULL;
}
/* tcsnow - return the value of TCSANOW. */
/* tcsnow return the value of TCSANOW. */
int EXPORT (tcsnow) (void) { return TCSANOW; }
/* tcsdrain - return the value of TCSADRAIN. */
int EXPORT (tcsdrain) (void) { return TCSADRAIN; }
/* tcsflush - return the value of TCSAFLUSH. */
int EXPORT (tcsflush) (void) { return TCSAFLUSH; }
/* cfgetospeed - return output baud rate. */
int EXPORT (cfgetospeed) (struct termios *t) { return cfgetospeed (t); }
/* cfgetispeed - return input baud rate. */
int EXPORT (cfgetispeed) (struct termios *t) { return cfgetispeed (t); }
/* cfsetospeed - set output baud rate. */
int EXPORT (cfsetospeed) (struct termios *t, unsigned int b)
int
EXPORT (tcsnow) (void)
{
return TCSANOW;
}
/* tcsdrain return the value of TCSADRAIN. */
int
EXPORT (tcsdrain) (void)
{
return TCSADRAIN;
}
/* tcsflush return the value of TCSAFLUSH. */
int
EXPORT (tcsflush) (void)
{
return TCSAFLUSH;
}
/* cfgetospeed return output baud rate. */
int
EXPORT (cfgetospeed) (termios_TERMIOS _t)
{
struct termios *t = (termios *)_t;
return cfgetospeed (t);
}
/* cfgetispeed return input baud rate. */
int
EXPORT (cfgetispeed) (termios_TERMIOS _t)
{
struct termios *t = (termios *)_t;
return cfgetispeed (t);
}
/* cfsetospeed set output baud rate. */
int
EXPORT (cfsetospeed) (termios_TERMIOS _t, unsigned int b)
{
struct termios *t = (termios *)_t;
return cfsetospeed (t, b);
}
/* cfsetispeed - set input baud rate. */
/* cfsetispeed set input baud rate. */
int EXPORT (cfsetispeed) (struct termios *t, unsigned int b)
int
EXPORT (cfsetispeed) (termios_TERMIOS _t, unsigned int b)
{
struct termios *t = (termios *)_t;
return cfsetispeed (t, b);
}
/* cfsetspeed - set input and output baud rate. */
/* cfsetspeed set input and output baud rate. */
int EXPORT (cfsetspeed) (struct termios *t, unsigned int b)
int
EXPORT (cfsetspeed) (termios_TERMIOS _t, unsigned int b)
{
struct termios *t = (termios *)_t;
int val = cfsetispeed (t, b);
if (val == 0)
return cfsetospeed (t, b);
@ -262,43 +280,55 @@ int EXPORT (cfsetspeed) (struct termios *t, unsigned int b)
return val;
}
/* tcgetattr - get state of, fd, into, t. */
/* tcgetattr get state of fd into t. */
int EXPORT (tcgetattr) (int fd, struct termios *t)
int
EXPORT (tcgetattr) (int fd, termios_TERMIOS _t)
{
struct termios *t = (termios *)_t;
return tcgetattr (fd, t);
}
/* tcsetattr - set state of, fd, to, t, using option. */
/* tcsetattr set state of fd to t using option. */
int EXPORT (tcsetattr) (int fd, int option, struct termios *t)
int
EXPORT (tcsetattr) (int fd, int option, termios_TERMIOS _t)
{
struct termios *t = (termios *)_t;
return tcsetattr (fd, option, t);
}
/* cfmakeraw - sets the terminal to raw mode. */
/* cfmakeraw sets the terminal to raw mode. */
void EXPORT (cfmakeraw) (struct termios *t)
void
EXPORT (cfmakeraw) (termios_TERMIOS _t)
{
#if defined(HAVE_CFMAKERAW)
struct termios *t = (termios *)_t;
cfmakeraw (t);
#endif
}
/* tcsendbreak - send zero bits for duration. */
/* tcsendbreak send zero bits for duration. */
int EXPORT (tcsendbreak) (int fd, int duration)
int
EXPORT (tcsendbreak) (int fd, int duration)
{
return tcsendbreak (fd, duration);
}
/* tcdrain - waits for pending output to be written on, fd. */
/* tcdrain waits for pending output to be written on fd. */
int EXPORT (tcdrain) (int fd) { return tcdrain (fd); }
int
EXPORT (tcdrain) (int fd)
{
return tcdrain (fd);
}
/* tcflushi - flush input. */
/* tcflushi flush input. */
int EXPORT (tcflushi) (int fd)
int
EXPORT (tcflushi) (int fd)
{
#if defined(TCIFLUSH)
return tcflush (fd, TCIFLUSH);
@ -307,9 +337,10 @@ int EXPORT (tcflushi) (int fd)
#endif
}
/* tcflusho - flush output. */
/* tcflusho flush output. */
int EXPORT (tcflusho) (int fd)
int
EXPORT (tcflusho) (int fd)
{
#if defined(TCOFLUSH)
return tcflush (fd, TCOFLUSH);
@ -318,9 +349,10 @@ int EXPORT (tcflusho) (int fd)
#endif
}
/* tcflushio - flush input and output. */
/* tcflushio flush input and output. */
int EXPORT (tcflushio) (int fd)
int
EXPORT (tcflushio) (int fd)
{
#if defined(TCIOFLUSH)
return tcflush (fd, TCIOFLUSH);
@ -329,9 +361,10 @@ int EXPORT (tcflushio) (int fd)
#endif
}
/* tcflowoni - restart input on, fd. */
/* tcflowoni restart input on fd. */
int EXPORT (tcflowoni) (int fd)
int
EXPORT (tcflowoni) (int fd)
{
#if defined(TCION)
return tcflow (fd, TCION);
@ -340,9 +373,10 @@ int EXPORT (tcflowoni) (int fd)
#endif
}
/* tcflowoffi - stop input on, fd. */
/* tcflowoffi stop input on fd. */
int EXPORT (tcflowoffi) (int fd)
int
EXPORT (tcflowoffi) (int fd)
{
#if defined(TCIOFF)
return tcflow (fd, TCIOFF);
@ -351,9 +385,10 @@ int EXPORT (tcflowoffi) (int fd)
#endif
}
/* tcflowono - restart output on, fd. */
/* tcflowono restart output on fd. */
int EXPORT (tcflowono) (int fd)
int
EXPORT (tcflowono) (int fd)
{
#if defined(TCOON)
return tcflow (fd, TCOON);
@ -362,9 +397,10 @@ int EXPORT (tcflowono) (int fd)
#endif
}
/* tcflowoffo - stop output on, fd. */
/* tcflowoffo stop output on fd. */
int EXPORT (tcflowoffo) (int fd)
int
EXPORT (tcflowoffo) (int fd)
{
#if defined(TCOOFF)
return tcflow (fd, TCOOFF);
@ -373,23 +409,14 @@ int EXPORT (tcflowoffo) (int fd)
#endif
}
/* doSetUnset applies mask or undoes mask depending upon value and returns true. */
/* GetFlag sets a flag value from t in b and returns TRUE if
t supports f. */
bool
doSetUnset (tcflag_t *bitset, unsigned int mask, bool value)
{
if (value)
(*bitset) |= mask;
else
(*bitset) &= (~mask);
return true;
}
/* GetFlag sets a flag value from t in b and returns true if t supports f. */
bool
EXPORT (GetFlag) (struct termios *t, Flag f, bool *b)
EXPORT (GetFlag) (termios_TERMIOS _t, termios_Flag _f, bool *b)
{
Flag f = (Flag) _f;
struct termios *t = (termios *)_t;
switch (f)
{
@ -1069,15 +1096,17 @@ EXPORT (GetFlag) (struct termios *t, Flag f, bool *b)
return false;
}
/* SetFlag - sets a flag value in, t, to, b, and returns TRUE if this
/* SetFlag sets a flag value in t to b and returns TRUE if this
flag value is supported. */
bool
EXPORT (SetFlag) (struct termios *t, Flag f, bool b)
EXPORT (SetFlag) (termios_TERMIOS _t, termios_Flag _f, bool b)
{
struct termios *t = (struct termios *) _t;
Flag f = (Flag) _f;
switch (f)
{
case ignbrk:
#if defined(IGNBRK)
return doSetUnset (&t->c_iflag, IGNBRK, b);
@ -1658,12 +1687,14 @@ EXPORT (SetFlag) (struct termios *t, Flag f, bool b)
return false;
}
/* GetChar sets a CHAR ch value from t and returns true if this
/* GetChar sets a CHAR ch value from t and returns true/false if this
value is supported. */
bool
EXPORT (GetChar) (struct termios *t, ControlChar c, char *ch)
EXPORT (GetChar) (termios_TERMIOS _t, termios_ControlChar _c, char *ch)
{
ControlChar c = (ControlChar) _c;
struct termios *t = (termios *)_t;
switch (c)
{
@ -1791,11 +1822,14 @@ EXPORT (GetChar) (struct termios *t, ControlChar c, char *ch)
}
}
/* SetChar sets a CHAR value in t and returns true if c is supported. */
/* SetChar sets a CHAR value in t and returns true/false if c is
supported. */
bool
EXPORT (SetChar) (struct termios *t, ControlChar c, char ch)
EXPORT (SetChar) (termios_TERMIOS _t, termios_ControlChar _c, char ch)
{
ControlChar c = (ControlChar) _c;
struct termios *t = (termios *)_t;
switch (c)
{
@ -1924,12 +1958,12 @@ EXPORT (SetChar) (struct termios *t, ControlChar c, char ch)
}
void
_M2_termios_init (void)
_M2_termios_init (int argc, char *argv[], char *envp[])
{
}
void
_M2_termios_finish (void)
_M2_termios_fini (int argc, char *argv[], char *envp[])
{
}

113
gcc/m2/mc-boot-ch/GSYSTEM.h Normal file
View File

@ -0,0 +1,113 @@
/* do not edit automatically generated by mc from SYSTEM. */
/* SYSTEM.def provides access to the SYSTEM dependent module.
Copyright (C) 2001-2024 Free Software Foundation, Inc.
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
This file is part of GNU Modula-2.
GNU Modula-2 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Modula-2 is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined (_SYSTEM_H)
# define _SYSTEM_H
#include "config.h"
#include "system.h"
# ifdef __cplusplus
extern "C" {
# endif
#include <stdbool.h>
# if !defined (PROC_D)
# define PROC_D
typedef void (*PROC_t) (void);
typedef struct { PROC_t proc; } PROC;
# endif
# if defined (_SYSTEM_C)
# define EXTERN
# else
# define EXTERN extern
# endif
# define SYSTEM_BITSPERBYTE 8
# define SYSTEM_BYTESPERWORD 4
/*
ShiftVal - is a runtime procedure whose job is to implement
the SHIFT procedure of ISO SYSTEM. GNU Modula-2 will
inline a SHIFT of a single WORD sized set and will only
call this routine for larger sets.
*/
EXTERN void SYSTEM_ShiftVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int ShiftCount);
/*
ShiftLeft - performs the shift left for a multi word set.
This procedure might be called by the back end of
GNU Modula-2 depending whether amount is known at
compile time.
*/
EXTERN void SYSTEM_ShiftLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount);
/*
ShiftRight - performs the shift left for a multi word set.
This procedure might be called by the back end of
GNU Modula-2 depending whether amount is known at
compile time.
*/
EXTERN void SYSTEM_ShiftRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount);
/*
RotateVal - is a runtime procedure whose job is to implement
the ROTATE procedure of ISO SYSTEM. GNU Modula-2 will
inline a ROTATE of a single WORD (or less)
sized set and will only call this routine for larger
sets.
*/
EXTERN void SYSTEM_RotateVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int RotateCount);
/*
RotateLeft - performs the rotate left for a multi word set.
This procedure might be called by the back end of
GNU Modula-2 depending whether amount is known at
compile time.
*/
EXTERN void SYSTEM_RotateLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount);
/*
RotateRight - performs the rotate right for a multi word set.
This procedure might be called by the back end of
GNU Modula-2 depending whether amount is known at
compile time.
*/
EXTERN void SYSTEM_RotateRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount);
# ifdef __cplusplus
}
# endif
# undef EXTERN
#endif

View File

@ -24,6 +24,16 @@ along with GNU Modula-2; see the file COPYING3. If not see
#include "gm2-libs-host.h"
#ifdef MC_M2
#include "GSysExceptions.h"
#define DECL_PROC_T(X) SysExceptions_PROCEXCEPTION X
#define PROC_FUNC(X) X.proc
#else
#define DECL_PROC_T(X) void (*X) (void *)
#define PROC_FUNC(X) X
#endif
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
#else
@ -68,13 +78,11 @@ along with GNU Modula-2; see the file COPYING3. If not see
#define SIGSYS 31 /* Bad system call. */
#define SIGUNUSED 31
(indexException, rangeException, caseSelectException, invalidLocation,
functionException, wholeValueException, wholeDivException, realValueException,
realDivException, complexValueException, complexDivException, protException,
sysException, coException, exException
);
#endif
/* wholeDivException and realDivException are caught by SIGFPE
@ -106,6 +114,7 @@ static void (*systemProc) (void *);
static void (*coroutineProc) (void *);
static void (*exceptionProc) (void *);
static void
sigbusDespatcher (int signum, siginfo_t *info, void *ucontext)
{
@ -159,32 +168,39 @@ sigfpeDespatcher (int signum, siginfo_t *info, void *ucontext)
EXTERN
void
SysExceptions_InitExceptionHandlers (
void (*indexf) (void *), void (*range) (void *), void (*casef) (void *),
void (*invalidloc) (void *), void (*function) (void *),
void (*wholevalue) (void *), void (*wholediv) (void *),
void (*realvalue) (void *), void (*realdiv) (void *),
void (*complexvalue) (void *), void (*complexdiv) (void *),
void (*protection) (void *), void (*systemf) (void *),
void (*coroutine) (void *), void (*exception) (void *))
SysExceptions_InitExceptionHandlers (DECL_PROC_T(indexf),
DECL_PROC_T(range),
DECL_PROC_T(casef),
DECL_PROC_T(invalidloc),
DECL_PROC_T(function),
DECL_PROC_T(wholevalue),
DECL_PROC_T(wholediv),
DECL_PROC_T(realvalue),
DECL_PROC_T(realdiv),
DECL_PROC_T(complexvalue),
DECL_PROC_T(complexdiv),
DECL_PROC_T(protection),
DECL_PROC_T(systemf),
DECL_PROC_T(coroutine),
DECL_PROC_T(exception))
{
struct sigaction old;
indexProc = indexf;
rangeProc = range;
caseProc = casef;
invalidlocProc = invalidloc;
functionProc = function;
wholevalueProc = wholevalue;
wholedivProc = wholediv;
realvalueProc = realvalue;
realdivProc = realdiv;
complexvalueProc = complexvalue;
complexdivProc = complexdiv;
protectionProc = protection;
systemProc = systemf;
coroutineProc = coroutine;
exceptionProc = exception;
indexProc = PROC_FUNC (indexf);
rangeProc = PROC_FUNC (range);
caseProc = PROC_FUNC (casef);
invalidlocProc = PROC_FUNC (invalidloc);
functionProc = PROC_FUNC (function);
wholevalueProc = PROC_FUNC (wholevalue);
wholedivProc = PROC_FUNC (wholediv);
realvalueProc = PROC_FUNC (realvalue);
realdivProc = PROC_FUNC (realdiv);
complexvalueProc = PROC_FUNC (complexvalue);
complexdivProc = PROC_FUNC (complexdiv);
protectionProc = PROC_FUNC (protection);
systemProc = PROC_FUNC (systemf);
coroutineProc = PROC_FUNC (coroutine);
exceptionProc = PROC_FUNC (exception);
sigbus.sa_sigaction = sigbusDespatcher;
sigbus.sa_flags = (SA_SIGINFO);
@ -211,13 +227,21 @@ SysExceptions_InitExceptionHandlers (
#else
EXTERN
void
SysExceptions_InitExceptionHandlers (void *indexf, void *range, void *casef,
void *invalidloc, void *function,
void *wholevalue, void *wholediv,
void *realvalue, void *realdiv,
void *complexvalue, void *complexdiv,
void *protection, void *systemf,
void *coroutine, void *exception)
SysExceptions_InitExceptionHandlers (DECL_PROC_T(indexf),
DECL_PROC_T(range),
DECL_PROC_T(casef),
DECL_PROC_T(invalidloc),
DECL_PROC_T(function),
DECL_PROC_T(wholevalue),
DECL_PROC_T(wholediv),
DECL_PROC_T(realvalue),
DECL_PROC_T(realdiv),
DECL_PROC_T(complexvalue),
DECL_PROC_T(complexdiv),
DECL_PROC_T(protection),
DECL_PROC_T(systemf),
DECL_PROC_T(coroutine),
DECL_PROC_T(exception))
{
}
#endif

View File

@ -0,0 +1,63 @@
/* do not edit automatically generated by mc from SysExceptions. */
/* SysExceptions.def provides a mechanism for the underlying libraries to.
Copyright (C) 2009-2024 Free Software Foundation, Inc.
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
This file is part of GNU Modula-2.
GNU Modula-2 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Modula-2 is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined (_SysExceptions_H)
# define _SysExceptions_H
#include "config.h"
#include "system.h"
# ifdef __cplusplus
extern "C" {
# endif
#include <stdbool.h>
# if !defined (PROC_D)
# define PROC_D
typedef void (*PROC_t) (void);
typedef struct { PROC_t proc; } PROC;
# endif
# include "GSYSTEM.h"
# if defined (_SysExceptions_C)
# define EXTERN
# else
# define EXTERN extern
# endif
typedef struct SysExceptions_PROCEXCEPTION_p SysExceptions_PROCEXCEPTION;
typedef void (*SysExceptions_PROCEXCEPTION_t) (void *);
struct SysExceptions_PROCEXCEPTION_p { SysExceptions_PROCEXCEPTION_t proc; };
EXTERN void SysExceptions_InitExceptionHandlers (SysExceptions_PROCEXCEPTION indexf, SysExceptions_PROCEXCEPTION range, SysExceptions_PROCEXCEPTION casef, SysExceptions_PROCEXCEPTION invalidloc, SysExceptions_PROCEXCEPTION function, SysExceptions_PROCEXCEPTION wholevalue, SysExceptions_PROCEXCEPTION wholediv, SysExceptions_PROCEXCEPTION realvalue, SysExceptions_PROCEXCEPTION realdiv, SysExceptions_PROCEXCEPTION complexvalue, SysExceptions_PROCEXCEPTION complexdiv, SysExceptions_PROCEXCEPTION protection, SysExceptions_PROCEXCEPTION systemf, SysExceptions_PROCEXCEPTION coroutine, SysExceptions_PROCEXCEPTION exception);
# ifdef __cplusplus
}
# endif
# undef EXTERN
#endif

View File

@ -343,10 +343,10 @@ libc_creat (char *p, mode_t mode)
EXTERN
int
libc_open (void *p, int oflag, int mode)
libc_open (void *p, int flags, int mode)
{
tracedb_open (p, oflag, mode);
int result = open (reinterpret_cast <char *> (p), oflag, mode);
tracedb_open (p, flags, mode);
int result = open (reinterpret_cast <char *> (p), flags, mode);
tracedb_result (result);
return result;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,208 @@
/* do not edit automatically generated by mc from termios. */
/* termios.def provides a procedural interface to termios.
Copyright (C) 2005-2024 Free Software Foundation, Inc.
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
This file is part of GNU Modula-2.
GNU Modula-2 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Modula-2 is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined (_termios_H)
# define _termios_H
#include "config.h"
#include "system.h"
# ifdef __cplusplus
extern "C" {
# endif
#include <stdbool.h>
# if !defined (PROC_D)
# define PROC_D
typedef void (*PROC_t) (void);
typedef struct { PROC_t proc; } PROC;
# endif
# include "GSYSTEM.h"
# if defined (_termios_C)
# define EXTERN
# else
# define EXTERN extern
# endif
typedef void *termios_TERMIOS;
typedef enum {termios_vintr, termios_vquit, termios_verase, termios_vkill, termios_veof, termios_vtime, termios_vmin, termios_vswtc, termios_vstart, termios_vstop, termios_vsusp, termios_veol, termios_vreprint, termios_vdiscard, termios_vwerase, termios_vlnext, termios_veol2} termios_ControlChar;
typedef enum {termios_ignbrk, termios_ibrkint, termios_ignpar, termios_iparmrk, termios_inpck, termios_istrip, termios_inlcr, termios_igncr, termios_icrnl, termios_iuclc, termios_ixon, termios_ixany, termios_ixoff, termios_imaxbel, termios_opost, termios_olcuc, termios_onlcr, termios_ocrnl, termios_onocr, termios_onlret, termios_ofill, termios_ofdel, termios_onl0, termios_onl1, termios_ocr0, termios_ocr1, termios_ocr2, termios_ocr3, termios_otab0, termios_otab1, termios_otab2, termios_otab3, termios_obs0, termios_obs1, termios_off0, termios_off1, termios_ovt0, termios_ovt1, termios_b0, termios_b50, termios_b75, termios_b110, termios_b135, termios_b150, termios_b200, termios_b300, termios_b600, termios_b1200, termios_b1800, termios_b2400, termios_b4800, termios_b9600, termios_b19200, termios_b38400, termios_b57600, termios_b115200, termios_b240400, termios_b460800, termios_b500000, termios_b576000, termios_b921600, termios_b1000000, termios_b1152000, termios_b1500000, termios_b2000000, termios_b2500000, termios_b3000000, termios_b3500000, termios_b4000000, termios_maxbaud, termios_crtscts, termios_cs5, termios_cs6, termios_cs7, termios_cs8, termios_cstopb, termios_cread, termios_parenb, termios_parodd, termios_hupcl, termios_clocal, termios_lisig, termios_licanon, termios_lxcase, termios_lecho, termios_lechoe, termios_lechok, termios_lechonl, termios_lnoflsh, termios_ltopstop, termios_lechoctl, termios_lechoprt, termios_lechoke, termios_lflusho, termios_lpendin, termios_liexten} termios_Flag;
/*
InitTermios - new data structure.
*/
EXTERN termios_TERMIOS termios_InitTermios (void);
/*
KillTermios - delete data structure.
*/
EXTERN termios_TERMIOS termios_KillTermios (termios_TERMIOS t);
/*
cfgetospeed - return output baud rate.
*/
EXTERN int termios_cfgetospeed (termios_TERMIOS t);
/*
cfgetispeed - return input baud rate.
*/
EXTERN int termios_cfgetispeed (termios_TERMIOS t);
/*
cfsetospeed - set output baud rate.
*/
EXTERN int termios_cfsetospeed (termios_TERMIOS t, unsigned int b);
/*
cfsetispeed - set input baud rate.
*/
EXTERN int termios_cfsetispeed (termios_TERMIOS t, unsigned int b);
/*
cfsetspeed - set input and output baud rate.
*/
EXTERN int termios_cfsetspeed (termios_TERMIOS t, unsigned int b);
/*
tcgetattr - get state of, fd, into, t.
*/
EXTERN int termios_tcgetattr (int fd, termios_TERMIOS t);
EXTERN int termios_tcsnow (void);
EXTERN int termios_tcsdrain (void);
EXTERN int termios_tcsflush (void);
/*
tcsetattr - set state of, fd, to, t, using option.
*/
EXTERN int termios_tcsetattr (int fd, int option, termios_TERMIOS t);
/*
cfmakeraw - sets, t, to raw mode.
*/
EXTERN void termios_cfmakeraw (termios_TERMIOS t);
/*
tcsendbreak - send zero bits for duration.
*/
EXTERN int termios_tcsendbreak (int fd, int duration);
/*
tcdrain - waits for pending output to be written on, fd.
*/
EXTERN int termios_tcdrain (int fd);
/*
tcflushi - flush input.
*/
EXTERN int termios_tcflushi (int fd);
/*
tcflusho - flush output.
*/
EXTERN int termios_tcflusho (int fd);
/*
tcflushio - flush input and output.
*/
EXTERN int termios_tcflushio (int fd);
/*
tcflowoni - restart input on, fd.
*/
EXTERN int termios_tcflowoni (int fd);
/*
tcflowoffi - stop input on, fd.
*/
EXTERN int termios_tcflowoffi (int fd);
/*
tcflowono - restart output on, fd.
*/
EXTERN int termios_tcflowono (int fd);
/*
tcflowoffo - stop output on, fd.
*/
EXTERN int termios_tcflowoffo (int fd);
/*
GetFlag - sets a flag value from, t, in, b, and returns TRUE
if, t, supports, f.
*/
EXTERN bool termios_GetFlag (termios_TERMIOS t, termios_Flag f, bool *b);
/*
SetFlag - sets a flag value in, t, to, b, and returns TRUE if
this flag value is supported.
*/
EXTERN bool termios_SetFlag (termios_TERMIOS t, termios_Flag f, bool b);
/*
GetChar - sets a CHAR, ch, value from, t, and returns TRUE if
this value is supported.
*/
EXTERN bool termios_GetChar (termios_TERMIOS t, termios_ControlChar c, char *ch);
/*
SetChar - sets a CHAR value in, t, and returns TRUE if, c,
is supported.
*/
EXTERN bool termios_SetChar (termios_TERMIOS t, termios_ControlChar c, char ch);
# ifdef __cplusplus
}
# endif
# undef EXTERN
#endif

View File

@ -25,6 +25,8 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include <stdbool.h>
# if !defined (PROC_D)
# define PROC_D
@ -40,13 +42,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# define FALSE (1==0)
# endif
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#define _M2RTS_H
#define _M2RTS_C
#include "GM2RTS.h"
# include "Glibc.h"
# include "GNumberIO.h"
# include "GStrLib.h"
@ -62,9 +60,6 @@ typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP;
# define stderrFd 2
typedef char *M2RTS_PtrToChar;
typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *);
struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; };
static int ExitValue;
static bool isHalting;
static bool CallExit;
@ -138,7 +133,7 @@ extern "C" void M2RTS_ExecuteTerminationProcedures (void);
not call ExecuteTerminationProcedures.
*/
extern "C" void M2RTS_Terminate (void);
extern "C" void M2RTS_Terminate (void) __attribute__ ((noreturn));
/*
HALT - terminate the current program. The procedure
@ -151,7 +146,7 @@ extern "C" void M2RTS_Terminate (void);
then calling HALT with no parameter.
*/
extern "C" void M2RTS_HALT (int exitcode);
extern "C" void M2RTS_HALT (int exitcode) __attribute__ ((noreturn));
/*
Halt - provides a more user friendly version of HALT, which takes
@ -159,7 +154,7 @@ extern "C" void M2RTS_HALT (int exitcode);
to stderr and calls exit (1).
*/
extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_high, const char *filename_, unsigned int _filename_high, const char *function_, unsigned int _function_high, unsigned int line);
extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_high, const char *filename_, unsigned int _filename_high, const char *function_, unsigned int _function_high, unsigned int line) __attribute__ ((noreturn));
/*
HaltC - provides a more user friendly version of HALT, which takes
@ -167,7 +162,7 @@ extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_
to stderr and calls exit (1).
*/
extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line);
extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line) __attribute__ ((noreturn));
/*
ExitOnHalt - if HALT is executed then call exit with the exit code, e.
@ -179,7 +174,7 @@ extern "C" void M2RTS_ExitOnHalt (int e);
ErrorMessage - emits an error message to stderr and then calls exit (1).
*/
extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high);
extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn));
/*
Length - returns the length of a string, a. This is called whenever
@ -188,30 +183,30 @@ extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_
*/
extern "C" unsigned int M2RTS_Length (const char *a_, unsigned int _a_high);
extern "C" void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_IncException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_DecException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_InclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_ExclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_ShiftException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_RotateException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_StaticArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_DynamicArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_ForLoopBeginException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_ForLoopToException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_ForLoopEndException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_PointerNilException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_NoReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_CaseException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_WholeNonPosDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_WholeNonPosModException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_WholeZeroDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_WholeZeroRemException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_WholeValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
extern "C" void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_IncException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_DecException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_InclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_ExclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_ShiftException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_RotateException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_StaticArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_DynamicArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_ForLoopBeginException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_ForLoopToException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_ForLoopEndException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_PointerNilException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_NoReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_CaseException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_WholeNonPosDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_WholeNonPosModException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_WholeZeroDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_WholeZeroRemException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_WholeValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
/*
ErrorString - writes a string to stderr.
@ -229,7 +224,7 @@ static void ErrorStringC (void * str);
ErrorMessageC - emits an error message to stderr and then calls exit (1).
*/
static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function);
static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function) __attribute__ ((noreturn));
/*
Init - initialize the initial, terminate procedure lists and booleans.
@ -259,7 +254,7 @@ static void ErrorString (const char *a_, unsigned int _a_high)
/* make a local copy of each unbounded array. */
memcpy (a, a_, _a_high+1);
n = static_cast<int> (libc_write (stderrFd, &a, static_cast<size_t> (StrLib_StrLen ((const char *) a, _a_high))));
n = static_cast<int> (libc_write (stderrFd, const_cast<void*> (static_cast<const void*>(a)), static_cast<size_t> (StrLib_StrLen ((const char *) a, _a_high))));
}
@ -714,11 +709,11 @@ extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned
RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), filename, line, column, scope, message);
}
extern "C" void _M2_M2RTS_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
extern "C" void _M2_M2RTS_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
{
CheckInitialized ();
}
extern "C" void _M2_M2RTS_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
extern "C" void _M2_M2RTS_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
{
}

View File

@ -24,6 +24,16 @@ along with GNU Modula-2; see the file COPYING3. If not see
#include "gm2-libs-host.h"
#ifdef MC_M2
#include "GSysExceptions.h"
#define DECL_PROC_T(X) SysExceptions_PROCEXCEPTION X
#define PROC_FUNC(X) X.proc
#else
#define DECL_PROC_T(X) void (*X) (void *)
#define PROC_FUNC(X) X
#endif
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
#else
@ -68,13 +78,11 @@ along with GNU Modula-2; see the file COPYING3. If not see
#define SIGSYS 31 /* Bad system call. */
#define SIGUNUSED 31
(indexException, rangeException, caseSelectException, invalidLocation,
functionException, wholeValueException, wholeDivException, realValueException,
realDivException, complexValueException, complexDivException, protException,
sysException, coException, exException
);
#endif
/* wholeDivException and realDivException are caught by SIGFPE
@ -106,6 +114,7 @@ static void (*systemProc) (void *);
static void (*coroutineProc) (void *);
static void (*exceptionProc) (void *);
static void
sigbusDespatcher (int signum, siginfo_t *info, void *ucontext)
{
@ -159,32 +168,39 @@ sigfpeDespatcher (int signum, siginfo_t *info, void *ucontext)
EXTERN
void
SysExceptions_InitExceptionHandlers (
void (*indexf) (void *), void (*range) (void *), void (*casef) (void *),
void (*invalidloc) (void *), void (*function) (void *),
void (*wholevalue) (void *), void (*wholediv) (void *),
void (*realvalue) (void *), void (*realdiv) (void *),
void (*complexvalue) (void *), void (*complexdiv) (void *),
void (*protection) (void *), void (*systemf) (void *),
void (*coroutine) (void *), void (*exception) (void *))
SysExceptions_InitExceptionHandlers (DECL_PROC_T(indexf),
DECL_PROC_T(range),
DECL_PROC_T(casef),
DECL_PROC_T(invalidloc),
DECL_PROC_T(function),
DECL_PROC_T(wholevalue),
DECL_PROC_T(wholediv),
DECL_PROC_T(realvalue),
DECL_PROC_T(realdiv),
DECL_PROC_T(complexvalue),
DECL_PROC_T(complexdiv),
DECL_PROC_T(protection),
DECL_PROC_T(systemf),
DECL_PROC_T(coroutine),
DECL_PROC_T(exception))
{
struct sigaction old;
indexProc = indexf;
rangeProc = range;
caseProc = casef;
invalidlocProc = invalidloc;
functionProc = function;
wholevalueProc = wholevalue;
wholedivProc = wholediv;
realvalueProc = realvalue;
realdivProc = realdiv;
complexvalueProc = complexvalue;
complexdivProc = complexdiv;
protectionProc = protection;
systemProc = systemf;
coroutineProc = coroutine;
exceptionProc = exception;
indexProc = PROC_FUNC (indexf);
rangeProc = PROC_FUNC (range);
caseProc = PROC_FUNC (casef);
invalidlocProc = PROC_FUNC (invalidloc);
functionProc = PROC_FUNC (function);
wholevalueProc = PROC_FUNC (wholevalue);
wholedivProc = PROC_FUNC (wholediv);
realvalueProc = PROC_FUNC (realvalue);
realdivProc = PROC_FUNC (realdiv);
complexvalueProc = PROC_FUNC (complexvalue);
complexdivProc = PROC_FUNC (complexdiv);
protectionProc = PROC_FUNC (protection);
systemProc = PROC_FUNC (systemf);
coroutineProc = PROC_FUNC (coroutine);
exceptionProc = PROC_FUNC (exception);
sigbus.sa_sigaction = sigbusDespatcher;
sigbus.sa_flags = (SA_SIGINFO);
@ -211,13 +227,21 @@ SysExceptions_InitExceptionHandlers (
#else
EXTERN
void
SysExceptions_InitExceptionHandlers (void *indexf, void *range, void *casef,
void *invalidloc, void *function,
void *wholevalue, void *wholediv,
void *realvalue, void *realdiv,
void *complexvalue, void *complexdiv,
void *protection, void *systemf,
void *coroutine, void *exception)
SysExceptions_InitExceptionHandlers (DECL_PROC_T(indexf),
DECL_PROC_T(range),
DECL_PROC_T(casef),
DECL_PROC_T(invalidloc),
DECL_PROC_T(function),
DECL_PROC_T(wholevalue),
DECL_PROC_T(wholediv),
DECL_PROC_T(realvalue),
DECL_PROC_T(realdiv),
DECL_PROC_T(complexvalue),
DECL_PROC_T(complexdiv),
DECL_PROC_T(protection),
DECL_PROC_T(systemf),
DECL_PROC_T(coroutine),
DECL_PROC_T(exception))
{
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -24,23 +24,31 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
typedef void (*proc_con) (int, char **, char **);
typedef void (*proc_dep) (void);
#ifdef M2_MC
/* These type definitions match those used by mc, they are defined differently
to satisfy -Wodr when building from the mc translated versions of m2
source. */
#include "GM2RTS.h"
#else
/* These type definitions match those used by cc1gm2, they will be the same
sizeof as those above (and also for all their dependants). */
typedef void (*M2RTS_ArgCVEnvP) (int, char **, char **);
typedef void (*PROC) (void);
#endif
#define M2RTS_RegisterModule_Cstr(MODNAME,LIBNAME,init,fini,dep) \
M2RTS_RegisterModule (reinterpret_cast <void *> (const_cast <char *> (MODNAME)), \
reinterpret_cast <void *> (const_cast <char *> (LIBNAME)), \
init, fini, dep)
extern "C" void M2RTS_RequestDependant (const char *modulename, const char *dependancy);
extern "C" void M2RTS_RequestDependant (const void *modulename, const void *dependancy);
extern "C" void M2RTS_RegisterModule (void *modulename, void *libname,
proc_con init, proc_con fini, proc_dep dependencies);
M2RTS_ArgCVEnvP init, M2RTS_ArgCVEnvP fini, PROC dependencies);
extern "C" void _M2_M2RTS_init (void);
extern "C" void M2RTS_ConstructModules (const char *,
extern "C" void M2RTS_ConstructModules (const void *,
int argc, char *argv[], char *envp[]);
extern "C" void M2RTS_Terminate (void);
extern "C" void M2RTS_DeconstructModules (void);
extern "C" void M2RTS_Halt (const char *, int, const char *, const char *) __attribute__ ((noreturn));
extern "C" void M2RTS_Halt (const char *, const char *, const char *, int) __attribute__ ((noreturn));