aboutsummaryrefslogtreecommitdiff
path: root/libgm2
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-02-25 16:28:19 +0000
committerGaius Mulley <gaiusmod2@gmail.com>2023-02-25 16:28:19 +0000
commit05652ac4e8b8685fe0c0f4ee2f75516d28bbf892 (patch)
tree37d3bf0f0a89774a4733b706ddaf3cff5447b182 /libgm2
parent461d3c84a0e5ad045ee54631901cc953d6befa20 (diff)
downloadgcc-05652ac4e8b8685fe0c0f4ee2f75516d28bbf892.zip
gcc-05652ac4e8b8685fe0c0f4ee2f75516d28bbf892.tar.gz
gcc-05652ac4e8b8685fe0c0f4ee2f75516d28bbf892.tar.bz2
modula-2 module registration process seems to fail with shared libraries [PR108261]
The commit adds pathnames to modula-2 which in turn appears in any external symbol. This is necessary to allow different dialects of libraries to coexist (different implementations of SYSTEM and Storage for example in libm2pim and libm2iso). It also makes it easier to debug as the library name forms part of the external mangled name. By default pathnames are not user facing. This commit fixes PR108261. gcc/ChangeLog: PR modula2/108261 * doc/gm2.texi (-fm2-pathname): New option documented. (-fm2-pathnameI): New option documented. (-fm2-prefix=): New option documented. (-fruntime-modules=): Update default module list. gcc/m2/ChangeLog: PR modula2/108261 * Make-lang.in (GM2-COMP-BOOT-DEFS): DynamicStringPath.def remove. DynamicPath.def add. (GM2-COMP-BOOT-MODS): DynamicStringPath.mod remove. DynamicPath.mod add. * Make-maintainer.in (BUILD-BOOT-PPG-H): New dependency. (m2/gm2-ppg-boot/$(SRC_PREFIX)%.o): $(BUILD-BOOT-PPG-H) Add dependency. (PGE-DEF): New definition. (BUILD-BOOT-PG-H): New dependency. (m2/gm2-pg-boot/$(SRC_PREFIX)%.o): $(BUILD-BOOT-PG-H) Add dependency. (BUILD-BOOT-PGE-H): New dependency. (m2/gm2-pge-boot/$(SRC_PREFIX)%.o): $(BUILD-BOOT-PGE-H) Add dependency. (GM2PATH): Add pathname entries. (m2/boot-bin/mc-devel$(exeext)): Add m2/mc-boot-ch/Gm2rtsdummy.o dependency. (m2/boot-bin/mc-opt$(exeext)): Fix -I path. * gm2-compiler/DynamicStringPath.def: Renamed module to DynamicPath. (GetUserPath): Remove. (GetSystemPath): Remove. (SetUserPath): Remove. (SetSystemPath): Remove. (DumpPath): New procedure definition. * gm2-compiler/DynamicStringPath.mod: Renamed module to DynamicPath. (GetUserPath): Remove. (GetSystemPath): Remove. (SetUserPath): Remove. (SetSystemPath): Remove. (DumpPath): Remove Debugging conditional. * gm2-compiler/M2AsmUtil.mod: Import EqualArray, NulName and GetLibName. (Debugging): New declaration. (GetFullSymName): Re-implemented to prefix (mange) libname to any extern variable/procedure which is IsExportQualified. * gm2-compiler/M2Comp.mod (qprintLibName): New procedure. * gm2-compiler/M2Graph.mod (resolveImports): Add libname. * gm2-compiler/M2Options.def (SetM2Prefix): New procedure. (GetM2Prefix): New procedure function. (SetM2PathName): New procedure. (GetM2PathName): New procedure function. * gm2-compiler/M2Options.mod: (SetM2Prefix): New procedure implemented. (GetM2Prefix): New procedure function implemented. (SetM2PathName): New procedure implemented. (GetM2PathName): New procedure function implemented. (RuntimeModuleOverride): Set to DefaultRuntimeModuleOverride. * gm2-compiler/M2Quads.mod: Import GetLibName. (SafeRequestSym) Pass result of GetLibName to RequestDependant. (callRequestDependant): Add libname as a parameter. (BuildM2InitFunction): Add libname as a parameter. (BuildM2FiniFunction): Add libname as a parameter. (BuildM2CtorFunction): Add libname as a parameter. * gm2-compiler/M2Scaffold.mod (LookupModuleSym): Set LibName if a definition source was found. * gm2-compiler/M2Search.def (FindSourceFile): Add named library parameter. (FindSourceDefFile): Add named library parameter. (FindSourceModFile): Add named library parameter. * gm2-compiler/M2Search.mod (FindSourceFile): Reimplement. (FindSourceDefFile): Add named library parameter. (FindSourceModFile): Add named library parameter. * gm2-compiler/SymbolTable.def (MakeProcedureCtorExtern): Add libname parameter. (PutLibName): New procedure. (GetLibName): New procedure function. * gm2-compiler/SymbolTable.mod (MakeProcedureCtorExtern): Add libname parameter. (GenName): Add libname parameter. (InitCtorFields): Add moduleSym as a parameter. (PutCtorExtern): Add libname parameter to GenName. * gm2-gcc/init.cc (_M2_DynamicStringPath_init): Rename function... (_M2_DynamicPath_init): ...to this. (_M2_PathName_init): Added. * gm2-gcc/m2decl.cc (m2decl_DeclareM2linkStaticInitialization): Add m2pim as the manged component of the exported symbol. (m2decl_DeclareM2linkForcedModuleInitOrder): Add m2pim mangle prefix. * gm2-gcc/m2options.h (M2Options_SetM2Prefix): New function. (M2Options_GetM2Prefix): New function. (M2Options_SetM2PathName): New function. (M2Options_GetM2PathName): New function. * gm2-lang.cc (push_back_Ipath): New function. (add_one_import_path): New function. (gm2_langhook_handle_option): Record -I component. Call SetM2PathName when -fm2-pathname= is seen. Record -fm2-pathnameI component. Call SetM2Prefix when -fm2-prefix= is seen. (gm2_langhook_post_options): Iterative over pathname entries and call SetM2PathName, SetSearchPath as appropriate. * gm2-libs-iso/M2RTS.def (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs-iso/M2RTS.mod (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs-min/M2RTS.def (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs-min/M2RTS.mod (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs/M2Dependent.def (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs/M2Dependent.mod (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs/M2RTS.def (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs/M2RTS.mod (ConstructModules): Add libname parameter. (DeconstructModules): Add libname parameter. (RegisterModule): Add libname parameter. (RequestDependant): Add libname parameter. * gm2-libs/RTint.mod (FindVector): Rename variables. (initInputVector): Rename variables. (initOutputVector): Rename variables. (InitTimeVector): Rename variables. (FindVectorNo): Rename variables. (FindPendingVector): Rename variables. (ReArmTimeVector): Rename variables. (GetTimeVector): Rename variables. (AttachVector): Rename variables. (AttachVector): Rename variables. (IncludeVector): Rename variables. (ExcludeVector): Rename variables. (AddFd): Rename variables. (AddFd): Rename variables. (DumpPendingQueue): Rename variables. (stop): Remove. (activatePending): Rename variables. (Listen): Rename variables. * gm2-libs/libc.def (snprintf): New function. * gm2-libs/sckt.def: Change all exported identifiers to be export qualified. * gm2spec.cc (push_back_Ipath): New function. (add_m2_I_path): New function. (lang_specific_driver): Skip -fm2-pathname= and remember pathname. Skip -I and record the path and current pathname. Call add_m2_I_path. * lang-specs.h: Replace %{I*} with %{fm2-pathname*}. * lang.opt (-fm2-pathname=): New entry. (-fm2-pathname): New entry. (-fm2-prefix=): New entry. * mc-boot-ch/GUnixArgs.cc (_M2_UnixArgs_dep): New function. (_M2_UnixArgs_ctor::_M2_UnixArgs_ctor): New method. * mc-boot-ch/Glibc.c (libc_snprintf): New function. * mc-boot-ch/m2rts.h (M2RTS_RequestDependant): Changed prototype. (M2RTS_RegisterModule): Changed prototype. * mc-boot/GDynamicStrings.c: Rebuild. * mc-boot/GFIO.c: Rebuild. * mc-boot/GIndexing.c: Rebuild. * mc-boot/GM2Dependent.c: Rebuild. * mc-boot/GM2Dependent.h: Rebuild. * mc-boot/GM2EXCEPTION.c: Rebuild. * mc-boot/GM2RTS.c: Rebuild. * mc-boot/GM2RTS.h: Rebuild. * mc-boot/GPushBackInput.c: Rebuild. * mc-boot/GRTExceptions.c: Rebuild. * mc-boot/GRTint.c: Rebuild. * mc-boot/GStdIO.c: Rebuild. * mc-boot/GStringConvert.c: Rebuild. * mc-boot/GSysStorage.c: Rebuild. * mc-boot/Gdecl.c: Rebuild. * mc-boot/Gkeyc.c: Rebuild. * mc-boot/Glibc.h: Rebuild. * mc-boot/GmcComment.c: Rebuild. * mc-boot/GmcComp.c: Rebuild. * mc-boot/GmcDebug.c: Rebuild. * mc-boot/GmcMetaError.c: Rebuild. * mc-boot/GmcStack.c: Rebuild. * mc-boot/GnameKey.c: Rebuild. * mc-boot/GsymbolKey.c: Rebuild. * pge-boot/GASCII.c: Rebuild. * pge-boot/GArgs.c: Rebuild. * pge-boot/GAssertion.c: Rebuild. * pge-boot/GDebug.c: Rebuild. * pge-boot/GDynamicStrings.c: Rebuild. * pge-boot/GFIO.c: Rebuild. * pge-boot/GIO.c: Rebuild. * pge-boot/GIndexing.c: Rebuild. * pge-boot/GLists.c: Rebuild. * pge-boot/GM2Dependent.c: Rebuild. * pge-boot/GM2Dependent.h: Rebuild. * pge-boot/GM2EXCEPTION.c: Rebuild. * pge-boot/GM2RTS.c: Rebuild. * pge-boot/GM2RTS.h: Rebuild. * pge-boot/GNameKey.c: Rebuild. * pge-boot/GNumberIO.c: Rebuild. * pge-boot/GOutput.c: Rebuild. * pge-boot/GPushBackInput.c: Rebuild. * pge-boot/GRTExceptions.c: Rebuild. * pge-boot/GSFIO.c: Rebuild. * pge-boot/GStdIO.c: Rebuild. * pge-boot/GStorage.c: Rebuild. * pge-boot/GStrCase.c: Rebuild. * pge-boot/GStrIO.c: Rebuild. * pge-boot/GStrLib.c: Rebuild. * pge-boot/GSymbolKey.c: Rebuild. * pge-boot/GSysExceptions.c (_M2_SysExceptions_finish): Rename this... (_M2_SysExceptions_fini): ... to this. * pge-boot/GSysStorage.c: Rebuild. (_M2_SysStorage_finish): Rename this... (_M2_SysStorage_fini): ... to this. * pge-boot/GUnixArgs.cc: New file. * pge-boot/Gbnflex.c (_M2_bnflex_finish): Rename this... (_M2_bnflex_fini): ... to this. * pge-boot/Gerrno.c (_M2_errno_finish): Rename this... (_M2_errno_fini): ... to this. * pge-boot/Glibc.c (libc_snprintf): New function. * pge-boot/Glibc.h (libc_snprintf): New prototype. * pge-boot/Gpge.c (_M2_pge_finish): Rename this... (_M2_pge_fini): ... to this. * pge-boot/Gtermios.cc (_M2_termios_finish): Rename this... (_M2_termios_fini): ... to this. * pge-boot/main.c (_M2_RTExceptions_finish): Rename this... (_M2_RTExceptions_fini): ... to this. (_M2_M2EXCEPTION_finish): Rename this... (_M2_M2EXCEPTION_fini): ... to this. (_M2_M2RTS_finish): Rename this... (_M2_M2RTS_fini): ... to this. (_M2_SysExceptions_finish): Rename this... (_M2_SysExceptions_fini): ... to this. (_M2_StrLib_finish): Rename this... (_M2_StrLib_fini): ... to this. (_M2_errno_finish): Rename this... (_M2_errno_fini): ... to this. (_M2_termios_finish): Rename this... (_M2_termios_fini): ... to this. (_M2_IO_finish): Rename this... (_M2_IO_fini): ... to this. (_M2_StdIO_finish): Rename this... (_M2_StdIO_fini): ... to this. (_M2_Debug_finish): Rename this... (_M2_Debug_fini): ... to this. (_M2_SysStorage_finish): Rename this... (_M2_SysStorage_fini): ... to this. (_M2_Storage_finish): Rename this... (_M2_Storage_fini): ... to this. (_M2_StrIO_finish): Rename this... (_M2_StrIO_fini): ... to this. (_M2_DynamicStrings_finish): Rename this... (_M2_DynamicStrings_fini): ... to this. (_M2_Assertion_finish): Rename this... (_M2_Assertion_fini): ... to this. (_M2_Indexing_finish): Rename this... (_M2_Indexing_fini): ... to this. (_M2_NameKey_finish): Rename this... (_M2_NameKey_fini): ... to this. (_M2_NumberIO_finish): Rename this... (_M2_NumberIO_fini): ... to this. (_M2_PushBackInput_finish): Rename this... (_M2_PushBackInput_fini): ... to this. (_M2_SymbolKey_finish): Rename this... (_M2_SymbolKey_fini): ... to this. (_M2_UnixArgs_finish): Rename this... (_M2_UnixArgs_fini): ... to this. (_M2_FIO_finish): Rename this... (_M2_FIO_fini): ... to this. (_M2_SFIO_finish): Rename this... (_M2_SFIO_fini): ... to this. (_M2_StrCase_finish): Rename this... (_M2_StrCase_fini): ... to this. (_M2_bnflex_finish): Rename this... (_M2_bnflex_fini): ... to this. (_M2_Lists_finish): Rename this... (_M2_Lists_fini): ... to this. (_M2_Args_finish): Rename this... (_M2_Args_fini): ... to this. (_M2_Output_finish): Rename this... (_M2_Output_fini): ... to this. (_M2_pge_finish): Rename this... (_M2_pge_fini): ... to this. * plugin/m2rte.cc (m2_runtime_error_calls): Change all runtime procedure names to their name mangled counterparts. * gm2-libs-iso/wrapsock.c: Removed. * gm2-libs-iso/wraptime.c: Removed. * mc-boot/Gpth.h: Removed. * gm2-compiler/PathName.def: New file. * gm2-compiler/PathName.mod: New file. libgm2/ChangeLog: PR modula2/108261 * libm2cor/KeyBoardLEDs.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (KeyBoardLEDs_SwitchScroll): EXPORT. (KeyBoardLEDs_SwitchNum): EXPORT. (KeyBoardLEDs_SwitchCaps): EXPORT. (KeyBoardLEDs_SwitchLeds): EXPORT. (_M2_KeyBoardLEDs_init): M2EXPORT. (_M2_KeyBoardLEDs_finish): M2EXPORT. (_M2_KeyBoardLEDs_dep): M2EXPORT. * libm2cor/Makefile.am (libm2cor_la_M2FLAGS): Define path names. * libm2cor/Makefile.in: Rebuild. * libm2iso/ErrnoCategory.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (ErrnoCategory_IsErrnoHard): EXPORT. (ErrnoCategory_IsErrnoSoft): EXPORT. (ErrnoCategory_UnAvailable): EXPORT. (ErrnoCategory_GetOpenResults): EXPORT. (_M2_ErrnoCategory_init): M2EXPORT. (_M2_ErrnoCategory_fini): M2EXPORT. (_M2_ErrnoCategory_dep): M2EXPORT. (_M2_ErrnoCategory_ctor): M2EXPORT. * libm2iso/Makefile.am (libm2iso_la_M2FLAGS): Define path names. * libm2iso/Makefile.in: Rebuild. * libm2iso/RTco.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (newSem): Add module libname prefix to HaltC. (currentThread): Remove variable and replace with a function. (never): Add module libname prefix to HaltC. (initThread): Add module libname prefix to HaltC. * libm2iso/m2rts.h (str): New define. (M2RTS_RequestDependant): Change to the mangled name equivalent. (M2RTS_RegisterModule): Change to the mangled name equivalent. (m2iso_M2RTS_RequestDependant): Add libname parameter. (m2iso_M2RTS_RegisterModule): Add libname parameter. (m2pim_M2RTS_RegisterModule): Add libname parameter. (_M2_M2RTS_init): Rename this... (m2iso_M2_M2RTS_init): ...to this. (M2RTS_ConstructModules): Change to the mangled name equivalent. (M2RTS_Terminate): Change to the mangled name equivalent. (M2RTS_DeconstructModules): Change to the mangled name equivalent. (m2iso_M2RTS_ConstructModules): Add libname parameter. (m2iso_M2RTS_Terminate): Add libname parameter. (m2iso_M2RTS_DeconstructModules): Add libname parameter. (M2RTS_HaltC): Rename this... (m2iso_M2RTS_HaltC): ...to this. * libm2iso/wrapsock.c (EXPORT): New define. (IMPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (m2iso_M2RTS_RequestDependant): Add prototype. (wrapsock_clientOpen): EXPORT. (wrapsock_clientOpenIP): EXPORT. (wrapsock_getClientPortNo): EXPORT. (wrapsock_getClientHostname): EXPORT. (wrapsock_getClientSocketFd): EXPORT. (wrapsock_getClientIP): EXPORT. (wrapsock_getPushBackChar): EXPORT. (wrapsock_setPushBackChar): EXPORT. (wrapsock_getSizeOfClientInfo): EXPORT. (_M2_wrapsock_init): M2EXPORT. (_M2_wrapsock_fini): M2EXPORT. (ctor): M2EXPORT. New function. * libm2iso/wraptime.c: Rename to... * libm2iso/wraptime.cc: ...this. (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (wraptime_InitTimeval): EXPORT. (wraptime_KillTimeval): EXPORT. (wraptime_InitTimezone): EXPORT. (wraptime_KillTimezone): EXPORT. (wraptime_InitTM): EXPORT. (wraptime_KillTM): EXPORT. (wraptime_gettimeofday): EXPORT. (wraptime_settimeofday): EXPORT. (wraptime_GetFractions): EXPORT. (wraptime_localtime_r): EXPORT. (wraptime_GetYear): EXPORT. (wraptime_GetMonth): EXPORT. (wraptime_GetDay): EXPORT. (wraptime_GetHour): EXPORT. (wraptime_GetMinute): EXPORT. (wraptime_GetSecond): EXPORT. (wraptime_GetSummerTime): EXPORT. (wraptime_GetDST): EXPORT. (wraptime_SetTimezone): EXPORT. (wraptime_SetTimeval): EXPORT. (_M2_wraptime_init): M2EXPORT. (_M2_wraptime_fini): M2EXPORT. (ctor): M2EXPORT. New function. * libm2log/Makefile.am (libm2log_la_M2FLAGS): Define path names. * libm2log/Makefile.in: * libm2min/Makefile.am (libm2min_la_M2FLAGS): Define path names. * libm2min/Makefile.in: * libm2pim/Makefile.am (libm2pim_la_M2FLAGS): Define path names. * libm2pim/Makefile.in: * libm2pim/Selective.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (Selective_Select): EXPORT. (Selective_InitTime): EXPORT. (Selective_GetTime): EXPORT. (Selective_SetTime): EXPORT. (Selective_KillTime): EXPORT. (Selective_InitSet): EXPORT. (Selective_KillSet): EXPORT. (Selective_FdZero): EXPORT. (Selective_FdSet): EXPORT. (Selective_FdClr): EXPORT. (Selective_FdIsSet): EXPORT. (Selective_GetTimeOfDay): EXPORT. (Selective_MaxFdsPlusOne): EXPORT. (Selective_WriteCharRaw): EXPORT. (Selective_ReadCharRaw): EXPORT. (_M2_Selective_init): M2EXPORT. (_M2_Selective_fini): M2EXPORT. (_M2_Selective_dep): M2EXPORT. (_M2_Selective_ctor): M2EXPORT. * libm2pim/SysExceptions.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (SysExceptions_InitExceptionHandlers): EXPORT. (_M2_SysExceptions_init): M2EXPORT. (_M2_SysExceptions_fini): M2EXPORT. (_M2_SysExceptions_dep): M2EXPORT. (_M2_SysExceptions_ctor): M2EXPORT. * libm2pim/UnixArgs.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (UnixArgs_GetArgC): EXPORT. (UnixArgs_GetArgV): EXPORT. (UnixArgs_GetEnvV): EXPORT. (_M2_UnixArgs_init): M2EXPORT. (_M2_UnixArgs_fini): M2EXPORT. (_M2_UnixArgs_dep): M2EXPORT. (_M2_UnixArgs_ctor): M2EXPORT. * libm2pim/cgetopt.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (cgetopt_getopt): EXPORT. (cgetopt_getopt_long): EXPORT. (cgetopt_getopt_long_only): EXPORT. (cgetopt_InitOptions): EXPORT. (cgetopt_KillOptions): EXPORT. (cgetopt_SetOption): EXPORT. (cgetopt_GetLongOptionArray): EXPORT. (_M2_cgetopt_init): M2EXPORT. (_M2_cgetopt_fini): M2EXPORT. (_M2_cgetopt_dep): M2EXPORT. (_M2_cgetopt_ctor): M2EXPORT. * libm2pim/dtoa.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (dtoa_strtod): EXPORT. (dtoa_calcmaxsig): EXPORT. (dtoa_calcdecimal): EXPORT. (dtoa_calcsign): EXPORT. (dtoa_dtoa): EXPORT. (_M2_dtoa_init): M2EXPORT. (_M2_dtoa_fini): M2EXPORT. (_M2_dtoa_dep): M2EXPORT. (_M2_dtoa_ctor): M2EXPORT. * libm2pim/errno.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (errno_geterrno): EXPORT. (_M2_errno_init): M2EXPORT. (_M2_errno_fini): M2EXPORT. (_M2_errno_dep): M2EXPORT. (_M2_errno_ctor): M2EXPORT. * libm2pim/ldtoa.cc (EXPORT): New define. (IMPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (dtoa_calcmaxsig): EXPORT. (dtoa_calcdecimal): EXPORT. (dtoa_calcsign): EXPORT. (ldtoa_strtold): EXPORT. (ldtoa_ldtoa): EXPORT. (_M2_ldtoa_init): M2EXPORT. (_M2_ldtoa_fini): M2EXPORT. (_M2_ldtoa_dep): M2EXPORT. (_M2_ldtoa_ctor): M2EXPORT. * libm2pim/sckt.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (tcpServerEstablishPort): EXPORT. (tcpServerEstablish): EXPORT. (tcpServerAccept): EXPORT. (tcpServerPortNo): EXPORT. (tcpServerSocketFd): EXPORT. (getLocalIP): EXPORT. (tcpServerIP): EXPORT. (tcpServerClientIP): EXPORT. (tcpServerClientPortNo): EXPORT. (tcpClientSocket): EXPORT. (tcpClientSocketIP): EXPORT. (tcpClientConnect): EXPORT. (tcpClientPortNo): EXPORT. (tcpClientSocketFd): EXPORT. (tcpClientIP): EXPORT. (_M2_sckt_init): M2EXPORT. (_M2_sckt_finish): M2EXPORT. (_M2_sckt_dep): M2EXPORT. (_M2_sckt_ctor): M2EXPORT. * libm2pim/termios.cc (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (_M2_termios_init): M2EXPORT. (_M2_termios_fini): M2EXPORT. (_M2_termios_dep): M2EXPORT. (_M2_termios_ctor): M2EXPORT. * libm2pim/wrapc.c (EXPORT): New define. (M2EXPORT): New define. (M2LIBNAME): New define. (wrapc_strtime): EXPORT. (wrapc_filesize): EXPORT. (wrapc_filemtime): EXPORT. (wrapc_fileinode): EXPORT. (wrapc_getrand): EXPORT. (wrapc_getusername): EXPORT. (wrapc_getnameuidgid): EXPORT. (wrapc_signbit): EXPORT. (wrapc_signbitl): EXPORT. (wrapc_signbitf): EXPORT. (wrapc_isfinite): EXPORT. (wrapc_isfinitel): EXPORT. (wrapc_isfinitef): EXPORT. (_M2_wrapc_init): M2EXPORT. (_M2_wrapc_fini): M2EXPORT. (_M2_wrapc_ctor): M2EXPORT. gcc/testsuite/ChangeLog: PR modula2/108261 * gm2/examples/callingC/pass/examples-callingC-pass.exp: Tidy up variable access. * gm2/examples/callingC/run/pass/examples-callingC-run-pass.exp: Tidy up variable access. * gm2/examples/cpp/pass/examples-cpp-pass.exp: Tidy up variable access. * gm2/examples/cppDef/pass/examples-cppDef-pass.exp: Tidy up variable access. * gm2/examples/hello/pass/examples-hello-pass.exp: Tidy up variable access. * gm2/examples/map/pass/examples-map-pass.exp: Tidy up variable access. * gm2/iso/check/fail/iso-check-fail.exp: Add pathname. * gm2/link/externalscaffold/pass/link-externalscaffold-pass.exp: Add pathname. * gm2/link/externalscaffold/pass/scaffold.c: Add mangled export name. * gm2/pimlib/base/run/pass/FIO.mod: Updated test code. * gm2/pimlib/base/run/pass/StrLib.mod: Updated test code. * gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp: Remove path. * gm2/projects/pim/run/pass/random/projects-pim-run-pass-random.exp: Tidy up variable access. * gm2/switches/auto-init/fail/switches-auto-init-fail.exp: Add pathname. * gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp: Add pathname. * gm2/switches/makeall/fail/switches-makeall-fail.exp: Remove -fmakeall. * gm2/switches/makeall/pass/switches-makeall-pass.exp: Remove -fmakeall. * lib/gm2-simple.exp (gm2_keep_executable): New global variable. (gm2_simple_execute): Keep executable if global is true. * lib/gm2-torture.exp: Add ; after global variable access. * lib/gm2.exp: Set up pathnames. * gm2/projects/pim/run/pass/tower/AdvCmd.def: New test. * gm2/projects/pim/run/pass/tower/AdvCmd.mod: New test. * gm2/projects/pim/run/pass/tower/AdvIntroduction.def: New test. * gm2/projects/pim/run/pass/tower/AdvIntroduction.mod: New test. * gm2/projects/pim/run/pass/tower/AdvMap.def: New test. * gm2/projects/pim/run/pass/tower/AdvMap.mod: New test. * gm2/projects/pim/run/pass/tower/AdvMath.def: New test. * gm2/projects/pim/run/pass/tower/AdvMath.mod: New test. * gm2/projects/pim/run/pass/tower/AdvParse.bnf: New test. * gm2/projects/pim/run/pass/tower/AdvParse.def: New test. * gm2/projects/pim/run/pass/tower/AdvParse.mod: New test. * gm2/projects/pim/run/pass/tower/AdvSound.def: New test. * gm2/projects/pim/run/pass/tower/AdvSound.mod: New test. * gm2/projects/pim/run/pass/tower/AdvSystem.def: New test. * gm2/projects/pim/run/pass/tower/AdvSystem.mod: New test. * gm2/projects/pim/run/pass/tower/AdvTreasure.def: New test. * gm2/projects/pim/run/pass/tower/AdvTreasure.mod: New test. * gm2/projects/pim/run/pass/tower/AdvUtil.def: New test. * gm2/projects/pim/run/pass/tower/AdvUtil.mod: New test. * gm2/projects/pim/run/pass/tower/DrawG.def: New test. * gm2/projects/pim/run/pass/tower/DrawG.mod: New test. * gm2/projects/pim/run/pass/tower/DrawL.def: New test. * gm2/projects/pim/run/pass/tower/DrawL.mod: New test. * gm2/projects/pim/run/pass/tower/Dungeon.mod: New test. * gm2/projects/pim/run/pass/tower/Lock.def: New test. * gm2/projects/pim/run/pass/tower/Lock.mod: New test. * gm2/projects/pim/run/pass/tower/ProcArgs.def: New test. * gm2/projects/pim/run/pass/tower/ProcArgs.mod: New test. * gm2/projects/pim/run/pass/tower/Screen.def: New test. * gm2/projects/pim/run/pass/tower/Screen.mod: New test. * gm2/projects/pim/run/pass/tower/SocketControl.c: New test. * gm2/projects/pim/run/pass/tower/SocketControl.def: New test. * gm2/projects/pim/run/pass/tower/Window.def: New test. * gm2/projects/pim/run/pass/tower/Window.mod: New test. * gm2/projects/pim/run/pass/tower/adv.flex: New test. * gm2/projects/pim/run/pass/tower/advflex.c: New test. * gm2/projects/pim/run/pass/tower/advflex.def: New test. * gm2/projects/pim/run/pass/tower/projects-pim-run-pass-tower.exp: New test. * gm2/projects/pim/run/pass/tower/star: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'libgm2')
-rw-r--r--libgm2/libm2cor/KeyBoardLEDs.cc42
-rw-r--r--libgm2/libm2cor/Makefile.am6
-rw-r--r--libgm2/libm2cor/Makefile.in7
-rw-r--r--libgm2/libm2iso/ErrnoCategory.cc27
-rw-r--r--libgm2/libm2iso/Makefile.am19
-rw-r--r--libgm2/libm2iso/Makefile.in33
-rw-r--r--libgm2/libm2iso/RTco.cc117
-rw-r--r--libgm2/libm2iso/m2rts.h26
-rw-r--r--libgm2/libm2iso/wrapsock.c52
-rw-r--r--libgm2/libm2iso/wraptime.cc (renamed from libgm2/libm2iso/wraptime.c)189
-rw-r--r--libgm2/libm2log/Makefile.am7
-rw-r--r--libgm2/libm2log/Makefile.in8
-rw-r--r--libgm2/libm2min/Makefile.am6
-rw-r--r--libgm2/libm2min/Makefile.in6
-rw-r--r--libgm2/libm2pim/Makefile.am7
-rw-r--r--libgm2/libm2pim/Makefile.in19
-rw-r--r--libgm2/libm2pim/Selective.cc77
-rw-r--r--libgm2/libm2pim/SysExceptions.cc22
-rw-r--r--libgm2/libm2pim/UnixArgs.cc30
-rw-r--r--libgm2/libm2pim/cgetopt.cc63
-rw-r--r--libgm2/libm2pim/dtoa.cc35
-rw-r--r--libgm2/libm2pim/errno.cc19
-rw-r--r--libgm2/libm2pim/ldtoa.cc36
-rw-r--r--libgm2/libm2pim/sckt.cc49
-rw-r--r--libgm2/libm2pim/termios.cc18
-rw-r--r--libgm2/libm2pim/wrapc.cc (renamed from libgm2/libm2pim/wrapc.c)92
26 files changed, 584 insertions, 428 deletions
diff --git a/libgm2/libm2cor/KeyBoardLEDs.cc b/libgm2/libm2cor/KeyBoardLEDs.cc
index bd0a450..e2e8198 100644
--- a/libgm2/libm2cor/KeyBoardLEDs.cc
+++ b/libgm2/libm2cor/KeyBoardLEDs.cc
@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <config.h>
#include <m2rts.h>
+#define EXPORT(FUNC) m2cor ## _KeyBoardLEDs_ ## FUNC
+#define M2EXPORT(FUNC) m2cor ## _M2_KeyBoardLEDs_ ## FUNC
+#define M2LIBNAME "m2cor"
+
#if defined(linux)
#include <sys/types.h>
@@ -50,7 +54,7 @@ static int initialized = FALSE;
extern "C" void
-KeyBoardLEDs_SwitchScroll (int scrolllock)
+EXPORT(SwitchScroll) (int scrolllock)
{
unsigned char leds;
int r = ioctl (fd, KDGETLED, &leds);
@@ -62,7 +66,7 @@ KeyBoardLEDs_SwitchScroll (int scrolllock)
}
extern "C" void
-KeyBoardLEDs_SwitchNum (int numlock)
+EXPORT(SwitchNum) (int numlock)
{
unsigned char leds;
int r = ioctl (fd, KDGETLED, &leds);
@@ -74,7 +78,7 @@ KeyBoardLEDs_SwitchNum (int numlock)
}
extern "C" void
-KeyBoardLEDs_SwitchCaps (int capslock)
+EXPORT(SwitchCaps) (int capslock)
{
unsigned char leds;
int r = ioctl (fd, KDGETLED, &leds);
@@ -86,15 +90,15 @@ KeyBoardLEDs_SwitchCaps (int capslock)
}
extern "C" void
-KeyBoardLEDs_SwitchLeds (int numlock, int capslock, int scrolllock)
+EXPORT(SwitchLeds) (int numlock, int capslock, int scrolllock)
{
- KeyBoardLEDs_SwitchScroll (scrolllock);
- KeyBoardLEDs_SwitchNum (numlock);
- KeyBoardLEDs_SwitchCaps (capslock);
+ EXPORT(SwitchScroll) (scrolllock);
+ EXPORT(SwitchNum) (numlock);
+ EXPORT(SwitchCaps) (capslock);
}
extern "C" void
-_M2_KeyBoardLEDs_init (int, char **, char **)
+M2EXPORT(init) (int, char **, char **)
{
if (! initialized)
{
@@ -110,47 +114,47 @@ _M2_KeyBoardLEDs_init (int, char **, char **)
#else
extern "C" void
-KeyBoardLEDs_SwitchLeds (int numlock, int capslock, int scrolllock)
+EXPORT(SwitchLeds) (int numlock, int capslock, int scrolllock)
{
}
extern "C" void
-KeyBoardLEDs_SwitchScroll (int scrolllock)
+EXPORT(SwitchScroll) (int scrolllock)
{
}
extern "C" void
-KeyBoardLEDs_SwitchNum (int numlock)
+EXPORT(SwitchNum) (int numlock)
{
}
extern "C" void
-KeyBoardLEDs_SwitchCaps (int capslock)
+EXPORT(SwitchCaps) (int capslock)
{
}
extern "C" void
-_M2_KeyBoardLEDs_init (int, char **, char **)
+M2EXPORT(init) (int, char **, char **)
{
}
-
#endif
/* GNU Modula-2 linking hooks. */
extern "C" void
-_M2_KeyBoardLEDs_finish (int, char **, char **)
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_KeyBoardLEDs_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
- _M2_KeyBoardLEDs_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("KeyBoardLEDs", _M2_KeyBoardLEDs_init, _M2_KeyBoardLEDs_finish,
- _M2_KeyBoardLEDs_dep);
+ m2pim_M2RTS_RegisterModule ("KeyBoardLEDs", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2cor/Makefile.am b/libgm2/libm2cor/Makefile.am
index 662a440..25a5f00 100644
--- a/libgm2/libm2cor/Makefile.am
+++ b/libgm2/libm2cor/Makefile.am
@@ -113,7 +113,11 @@ nodist_EXTRA_libm2cor_la_SOURCES = dummy.c ## forces automake to generate the L
libm2cordir = libm2cor
libm2cor_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2cor_la_SOURCES)))
libm2cor_la_CFLAGS = -I. -I.. -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -DBUILD_GM2_LIBS -I@srcdir@/../ -I@srcdir@/../libm2iso
-libm2cor_la_M2FLAGS = -I. -I$(GM2_SRC)/gm2-libs-coroutines -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -fm2-g -g -Wreturn-type -fcase
+libm2cor_la_M2FLAGS = \
+ -fm2-pathname=m2cor -I. -I$(GM2_SRC)/gm2-libs-coroutines \
+ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
+ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2cor
if TARGET_DARWIN
libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup
else
diff --git a/libgm2/libm2cor/Makefile.in b/libgm2/libm2cor/Makefile.in
index ca3ddd0..869924b 100644
--- a/libgm2/libm2cor/Makefile.in
+++ b/libgm2/libm2cor/Makefile.in
@@ -463,7 +463,12 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
@BUILD_CORLIB_TRUE@libm2cordir = libm2cor
@BUILD_CORLIB_TRUE@libm2cor_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2cor_la_SOURCES)))
@BUILD_CORLIB_TRUE@libm2cor_la_CFLAGS = -I. -I.. -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -DBUILD_GM2_LIBS -I@srcdir@/../ -I@srcdir@/../libm2iso
-@BUILD_CORLIB_TRUE@libm2cor_la_M2FLAGS = -I. -I$(GM2_SRC)/gm2-libs-coroutines -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -fm2-g -g -Wreturn-type -fcase
+@BUILD_CORLIB_TRUE@libm2cor_la_M2FLAGS = \
+@BUILD_CORLIB_TRUE@ -fm2-pathname=m2cor -I. -I$(GM2_SRC)/gm2-libs-coroutines \
+@BUILD_CORLIB_TRUE@ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
+@BUILD_CORLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+@BUILD_CORLIB_TRUE@ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2cor
+
@BUILD_CORLIB_TRUE@@TARGET_DARWIN_FALSE@libm2cor_la_link_flags =
@BUILD_CORLIB_TRUE@@TARGET_DARWIN_TRUE@libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup
@BUILD_CORLIB_TRUE@libm2cor_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2cor_la_link_flags)
diff --git a/libgm2/libm2iso/ErrnoCategory.cc b/libgm2/libm2iso/ErrnoCategory.cc
index 2db2639..55db89d 100644
--- a/libgm2/libm2iso/ErrnoCategory.cc
+++ b/libgm2/libm2iso/ErrnoCategory.cc
@@ -25,7 +25,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include "config.h"
-
#include "ChanConsts.h"
#if defined(HAVE_ERRNO_H)
@@ -38,6 +37,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "m2rts.h"
+#define EXPORT(FUNC) m2iso ## _ErrnoCategory_ ## FUNC
+#define M2EXPORT(FUNC) m2iso ## _M2_ErrnoCategory_ ## FUNC
+#define M2LIBNAME "m2iso"
+
+
#if !defined(FALSE)
#define FALSE (1 == 0)
#endif
@@ -50,7 +54,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
with a hard device error. */
extern "C" int
-ErrnoCategory_IsErrnoHard (int e)
+EXPORT(IsErrnoHard) (int e)
{
#if defined(HAVE_ERRNO_H) || defined(HAVE_SYS_ERRNO_H)
return ((e == EPERM) || (e == ENOENT) || (e == EIO) || (e == ENXIO)
@@ -65,7 +69,7 @@ ErrnoCategory_IsErrnoHard (int e)
with a soft device error. */
extern "C" int
-ErrnoCategory_IsErrnoSoft (int e)
+EXPORT(IsErrnoSoft) (int e)
{
#if defined(HAVE_ERRNO_H) || defined(HAVE_SYS_ERRNO_H)
return ((e == ESRCH) || (e == EINTR) || (e == E2BIG) || (e == ENOEXEC)
@@ -79,7 +83,7 @@ ErrnoCategory_IsErrnoSoft (int e)
}
extern "C" int
-ErrnoCategory_UnAvailable (int e)
+EXPORT(UnAvailable) (int e)
{
#if defined(HAVE_ERRNO_H) || defined(HAVE_SYS_ERRNO_H)
return ((e == ENOENT) || (e == ESRCH) || (e == ENXIO) || (e == ECHILD)
@@ -93,7 +97,7 @@ ErrnoCategory_UnAvailable (int e)
OpenResults. */
extern "C" openResults
-ErrnoCategory_GetOpenResults (int e)
+EXPORT(GetOpenResults) (int e)
{
if (e == 0)
return opened;
@@ -157,23 +161,24 @@ ErrnoCategory_GetOpenResults (int e)
/* GNU Modula-2 linking fodder. */
extern "C" void
-_M2_ErrnoCategory_init (int, char *argv[], char *env[])
+M2EXPORT(init) (int, char **, char **)
{
}
extern "C" void
-_M2_ErrnoCategory_fini (int, char *argv[], char *env[])
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_ErrnoCategory_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_ErrnoCategory_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("ErrnoCategory", _M2_ErrnoCategory_init, _M2_ErrnoCategory_fini,
- _M2_ErrnoCategory_dep);
+ m2iso_M2RTS_RegisterModule ("ErrnoCategory", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2iso/Makefile.am b/libgm2/libm2iso/Makefile.am
index cc9a477..dddced4 100644
--- a/libgm2/libm2iso/Makefile.am
+++ b/libgm2/libm2iso/Makefile.am
@@ -15,7 +15,7 @@
# along with this program; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-SUFFIXES = .c .mod .def .o .obj .lo .a .la
+SUFFIXES = .c .cc .mod .def .o .obj .lo .a .la
ACLOCAL_AMFLAGS = -I . -I .. -I ../config
@@ -178,15 +178,18 @@ M2MODS = ChanConsts.mod CharClass.mod \
toolexeclib_LTLIBRARIES = libm2iso.la
libm2iso_la_SOURCES = $(M2MODS) \
- ErrnoCategory.cc wrapsock.c \
- wraptime.c RTco.cc
+ ErrnoCategory.cc wraptime.cc RTco.cc wrapsock.c
+# wrapsock.cc
C_INCLUDES = -I.. -I$(toplevel_srcdir)/libiberty -I$(toplevel_srcdir)/include
libm2isodir = libm2iso
libm2iso_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2iso_la_SOURCES)))
libm2iso_la_CFLAGS = $(C_INCLUDES) -I. -I.. -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs -DBUILD_GM2_LIBS -I@srcdir@/../ -I../../../gcc -I$(GCC_DIR) -I$(GCC_DIR)/../include -I../../libgcc -I$(GCC_DIR)/../libgcc -I$(MULTIBUILDTOP)../../gcc/include
-libm2iso_la_M2FLAGS = -I. -Ilibm2iso -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs -fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase
+libm2iso_la_M2FLAGS = \
+ -fm2-pathname=m2iso -I. -Ilibm2iso -I$(GM2_SRC)/gm2-libs-iso \
+ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
+ -fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2iso
if TARGET_DARWIN
libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup
else
@@ -207,17 +210,15 @@ SYSTEM.def: Makefile
-I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs \
"$(GM2_FOR_TARGET)" $@
-## add these to the .mod.o rule when optimization is fixed $(CFLAGS_FOR_TARGET) $(LIBCFLAGS)
-
.mod.lo:
$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(GM2_FOR_TARGET) -c $(CFLAGS_FOR_TARGET) $(LIBCFLAGS) $(libm2iso_la_M2FLAGS) $< -o $@
-.c.lo:
- $(LIBTOOL) --tag=CC --mode=compile $(CC) -c $(CFLAGS) $(LIBCFLAGS) $(libm2iso_la_CFLAGS) $< -o $@
-
.cc.lo:
$(LIBTOOL) --tag=CXX --mode=compile $(CXX) -c -I$(srcdir) $(CXXFLAGS) $(LIBCFLAGS) $(libm2iso_la_CFLAGS) $< -o $@
+.c.lo:
+ $(LIBTOOL) --tag=CC --mode=compile $(CC) -c -I$(srcdir) $(CFLAGS) $(LIBCFLAGS) $(libm2iso_la_CFLAGS) $< -o $@
+
install-data-local: force
mkdir -p $(DESTDIR)$(inst_libdir)/$(M2LIBDIR)
for i in $(M2DEFS) $(M2MODS) ; do \
diff --git a/libgm2/libm2iso/Makefile.in b/libgm2/libm2iso/Makefile.in
index b96136a..e28e9dd 100644
--- a/libgm2/libm2iso/Makefile.in
+++ b/libgm2/libm2iso/Makefile.in
@@ -179,8 +179,8 @@ libm2iso_la_LIBADD =
@BUILD_ISOLIB_TRUE@ TextIO.lo WholeConv.lo WholeIO.lo \
@BUILD_ISOLIB_TRUE@ WholeStr.lo
@BUILD_ISOLIB_TRUE@am_libm2iso_la_OBJECTS = $(am__objects_1) \
-@BUILD_ISOLIB_TRUE@ ErrnoCategory.lo libm2iso_la-wrapsock.lo \
-@BUILD_ISOLIB_TRUE@ libm2iso_la-wraptime.lo RTco.lo
+@BUILD_ISOLIB_TRUE@ ErrnoCategory.lo wraptime.lo RTco.lo \
+@BUILD_ISOLIB_TRUE@ libm2iso_la-wrapsock.lo
libm2iso_la_OBJECTS = $(am_libm2iso_la_OBJECTS)
@BUILD_ISOLIB_TRUE@am_libm2iso_la_rpath = -rpath $(toolexeclibdir)
AM_V_P = $(am__v_P_@AM_V@)
@@ -408,7 +408,7 @@ toolexeclibdir = @toolexeclibdir@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUFFIXES = .c .mod .def .o .obj .lo .a .la
+SUFFIXES = .c .cc .mod .def .o .obj .lo .a .la
ACLOCAL_AMFLAGS = -I . -I .. -I ../config
# Multilib support.
@@ -556,14 +556,18 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
@BUILD_ISOLIB_TRUE@toolexeclib_LTLIBRARIES = libm2iso.la
@BUILD_ISOLIB_TRUE@libm2iso_la_SOURCES = $(M2MODS) \
-@BUILD_ISOLIB_TRUE@ ErrnoCategory.cc wrapsock.c \
-@BUILD_ISOLIB_TRUE@ wraptime.c RTco.cc
+@BUILD_ISOLIB_TRUE@ ErrnoCategory.cc wraptime.cc RTco.cc wrapsock.c
+# wrapsock.cc
@BUILD_ISOLIB_TRUE@C_INCLUDES = -I.. -I$(toplevel_srcdir)/libiberty -I$(toplevel_srcdir)/include
@BUILD_ISOLIB_TRUE@libm2isodir = libm2iso
@BUILD_ISOLIB_TRUE@libm2iso_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2iso_la_SOURCES)))
@BUILD_ISOLIB_TRUE@libm2iso_la_CFLAGS = $(C_INCLUDES) -I. -I.. -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs -DBUILD_GM2_LIBS -I@srcdir@/../ -I../../../gcc -I$(GCC_DIR) -I$(GCC_DIR)/../include -I../../libgcc -I$(GCC_DIR)/../libgcc -I$(MULTIBUILDTOP)../../gcc/include
-@BUILD_ISOLIB_TRUE@libm2iso_la_M2FLAGS = -I. -Ilibm2iso -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs -fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase
+@BUILD_ISOLIB_TRUE@libm2iso_la_M2FLAGS = \
+@BUILD_ISOLIB_TRUE@ -fm2-pathname=m2iso -I. -Ilibm2iso -I$(GM2_SRC)/gm2-libs-iso \
+@BUILD_ISOLIB_TRUE@ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
+@BUILD_ISOLIB_TRUE@ -fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2iso
+
@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_FALSE@libm2iso_la_link_flags =
@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup
@BUILD_ISOLIB_TRUE@libm2iso_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2iso_la_link_flags)
@@ -575,7 +579,7 @@ all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
-.SUFFIXES: .c .mod .def .o .obj .lo .a .la .cc
+.SUFFIXES: .c .cc .mod .def .o .obj .lo .a .la
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -653,7 +657,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ErrnoCategory.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RTco.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libm2iso_la-wrapsock.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libm2iso_la-wraptime.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wraptime.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -683,13 +687,6 @@ libm2iso_la-wrapsock.lo: wrapsock.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libm2iso_la_CFLAGS) $(CFLAGS) -c -o libm2iso_la-wrapsock.lo `test -f 'wrapsock.c' || echo '$(srcdir)/'`wrapsock.c
-libm2iso_la-wraptime.lo: wraptime.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libm2iso_la_CFLAGS) $(CFLAGS) -MT libm2iso_la-wraptime.lo -MD -MP -MF $(DEPDIR)/libm2iso_la-wraptime.Tpo -c -o libm2iso_la-wraptime.lo `test -f 'wraptime.c' || echo '$(srcdir)/'`wraptime.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libm2iso_la-wraptime.Tpo $(DEPDIR)/libm2iso_la-wraptime.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='wraptime.c' object='libm2iso_la-wraptime.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libm2iso_la_CFLAGS) $(CFLAGS) -c -o libm2iso_la-wraptime.lo `test -f 'wraptime.c' || echo '$(srcdir)/'`wraptime.c
-
.cc.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@@ -911,12 +908,12 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES
@BUILD_ISOLIB_TRUE@.mod.lo:
@BUILD_ISOLIB_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(GM2_FOR_TARGET) -c $(CFLAGS_FOR_TARGET) $(LIBCFLAGS) $(libm2iso_la_M2FLAGS) $< -o $@
-@BUILD_ISOLIB_TRUE@.c.lo:
-@BUILD_ISOLIB_TRUE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) -c $(CFLAGS) $(LIBCFLAGS) $(libm2iso_la_CFLAGS) $< -o $@
-
@BUILD_ISOLIB_TRUE@.cc.lo:
@BUILD_ISOLIB_TRUE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) -c -I$(srcdir) $(CXXFLAGS) $(LIBCFLAGS) $(libm2iso_la_CFLAGS) $< -o $@
+@BUILD_ISOLIB_TRUE@.c.lo:
+@BUILD_ISOLIB_TRUE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) -c -I$(srcdir) $(CFLAGS) $(LIBCFLAGS) $(libm2iso_la_CFLAGS) $< -o $@
+
@BUILD_ISOLIB_TRUE@install-data-local: force
@BUILD_ISOLIB_TRUE@ mkdir -p $(DESTDIR)$(inst_libdir)/$(M2LIBDIR)
@BUILD_ISOLIB_TRUE@ for i in $(M2DEFS) $(M2MODS) ; do \
diff --git a/libgm2/libm2iso/RTco.cc b/libgm2/libm2iso/RTco.cc
index 8b8a4dc..33da586 100644
--- a/libgm2/libm2iso/RTco.cc
+++ b/libgm2/libm2iso/RTco.cc
@@ -32,8 +32,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <m2rts.h>
#include <cstdio>
-#define EXPORT(FUNC) RTco_ ## FUNC
-#define M2EXPORT(FUNC) _M2_RTco_ ## FUNC
+#define EXPORT(FUNC) m2iso ## _RTco_ ## FUNC
+#define M2EXPORT(FUNC) m2iso ## _M2_RTco_ ## FUNC
+#define M2LIBNAME "m2iso"
/* This implementation of RTco.cc uses a single lock for mutex across
the whole module. It also forces context switching between threads
@@ -104,12 +105,9 @@ static threadSem **semArray = NULL;
static __gthread_mutex_t lock; /* This is the only mutex for
the whole module. */
static int initialized = FALSE;
-static int currentThread = 0;
-
extern "C" int EXPORT(init) (void);
-
extern "C" void
M2EXPORT(dep) (void)
{
@@ -184,8 +182,8 @@ newSem (void)
= (threadSem *)malloc (sizeof (threadSem));
nSemaphores += 1;
if (nSemaphores == SEM_POOL)
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "too many semaphores created");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "too many semaphores created");
#else
threadSem *sem
= (threadSem *)malloc (sizeof (threadSem));
@@ -233,6 +231,18 @@ EXPORT(initSemaphore) (int value)
return sid;
}
+static int
+currentThread (void)
+{
+ int tid;
+
+ for (tid = 0; tid < nThreads; tid++)
+ if (pthread_self () == threadArray[tid].p)
+ return tid;
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "failed to find currentThread");
+}
+
extern "C" int
EXPORT(currentThread) (void)
{
@@ -240,7 +250,7 @@ EXPORT(currentThread) (void)
EXPORT(init) ();
__gthread_mutex_lock (&lock);
- tid = currentThread;
+ tid = currentThread ();
tprintf ("currentThread %d\n", tid);
__gthread_mutex_unlock (&lock);
return tid;
@@ -253,9 +263,10 @@ EXPORT(currentInterruptLevel) (void)
{
EXPORT(init) ();
__gthread_mutex_lock (&lock);
+ int current = currentThread ();
tprintf ("currentInterruptLevel %d\n",
- threadArray[currentThread].interruptLevel);
- int level = threadArray[currentThread].interruptLevel;
+ threadArray[current].interruptLevel);
+ int level = threadArray[current].interruptLevel;
__gthread_mutex_unlock (&lock);
return level;
}
@@ -268,9 +279,10 @@ EXPORT(turnInterrupts) (unsigned int newLevel)
{
EXPORT(init) ();
__gthread_mutex_lock (&lock);
- unsigned int old = threadArray[currentThread].interruptLevel;
+ int current = currentThread ();
+ unsigned int old = threadArray[current].interruptLevel;
tprintf ("turnInterrupts from %d to %d\n", old, newLevel);
- threadArray[currentThread].interruptLevel = newLevel;
+ threadArray[current].interruptLevel = newLevel;
__gthread_mutex_unlock (&lock);
return old;
}
@@ -278,8 +290,8 @@ EXPORT(turnInterrupts) (unsigned int newLevel)
static void
never (void)
{
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "the main thread should never call here");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "the main thread should never call here");
}
static void *
@@ -313,10 +325,10 @@ execThread (void *t)
__gthread_mutex_unlock (&lock);
tp->proc (); /* Now execute user procedure. */
#if 0
- M2RTS_CoroutineException ( __FILE__, __LINE__, __COLUMN__, __FUNCTION__, "coroutine finishing");
+ m2iso_M2RTS_CoroutineException ( __FILE__, __LINE__, __COLUMN__, __FUNCTION__, "coroutine finishing");
#endif
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "execThread should never finish");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "execThread should never finish");
return NULL;
}
@@ -326,8 +338,8 @@ newThread (void)
#if defined(POOL)
nThreads += 1;
if (nThreads == THREAD_POOL)
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "too many threads created");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "too many threads created");
return nThreads - 1;
#else
if (nThreads == 0)
@@ -364,15 +376,15 @@ initThread (void (*proc) (void), unsigned int stackSize,
/* Set thread creation attributes. */
result = pthread_attr_init (&attr);
if (result != 0)
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "failed to create thread attribute");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "failed to create thread attribute");
if (stackSize > 0)
{
result = pthread_attr_setstacksize (&attr, stackSize);
if (result != 0)
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "failed to set stack size attribute");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "failed to set stack size attribute");
}
tprintf ("initThread [%d] function = 0x%p (arg = 0x%p)\n", tid, proc,
@@ -380,7 +392,7 @@ initThread (void (*proc) (void), unsigned int stackSize,
result = pthread_create (&threadArray[tid].p, &attr, execThread,
(void *)&threadArray[tid]);
if (result != 0)
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, "thread_create failed");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__, "thread_create failed");
tprintf (" created thread [%d] function = 0x%p 0x%p\n", tid, proc,
(void *)&threadArray[tid]);
return tid;
@@ -408,62 +420,61 @@ EXPORT(transfer) (int *p1, int p2)
{
__gthread_mutex_lock (&lock);
{
+ int current = currentThread ();
if (!initialized)
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "cannot transfer to a process before the process has been created");
- if (currentThread == p2)
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "cannot transfer to a process before the process has been created");
+ if (current == p2)
{
/* Error. */
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "attempting to transfer to ourself");
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "attempting to transfer to ourself");
}
else
{
- *p1 = currentThread;
- int old = currentThread;
- tprintf ("start, context switching from: %d to %d\n", currentThread, p2);
+ *p1 = current;
+ int old = current;
+ tprintf ("start, context switching from: %d to %d\n", current, p2);
/* Perform signal (p2 sem). Without the mutex lock as we have
already obtained it above. */
if (threadArray[p2].waiting)
{
/* p2 is blocked on the condition variable, release it. */
- tprintf ("p1 = %d cond_signal to p2 (%d)\n", currentThread, p2);
+ tprintf ("p1 = %d cond_signal to p2 (%d)\n", current, p2);
__gthread_cond_signal (&threadArray[p2].run_counter);
- tprintf ("after p1 = %d cond_signal to p2 (%d)\n", currentThread, p2);
+ tprintf ("after p1 = %d cond_signal to p2 (%d)\n", current, p2);
}
else
{
/* p2 hasn't reached the condition variable, so bump value
ready for p2 to test. */
tprintf ("no need for thread %d to cond_signal - bump %d value (pre) = %d\n",
- currentThread, p2, threadArray[p2].value);
+ current, p2, threadArray[p2].value);
threadArray[p2].value++;
}
/* Perform wait (old sem). Again without obtaining mutex as
we've already claimed it. */
if (threadArray[old].value == 0)
{
- currentThread = p2;
/* Record we are about to wait on the condition variable. */
threadArray[old].waiting = true;
__gthread_cond_wait (&threadArray[old].run_counter, &lock);
threadArray[old].waiting = false;
/* We are running again. */
- currentThread = old;
}
else
{
tprintf ("(currentThread = %d) no need for thread %d to cond_wait - taking value (pre) = %d\n",
- currentThread, old, threadArray[old].value);
+ current, old, threadArray[old].value);
/* No need to block as we have been told a signal has
effectively already been recorded. We remove the signal
notification without blocking. */
threadArray[old].value--;
}
- tprintf ("end, context back to %d\n", currentThread);
- if (currentThread != old)
- M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
- "wrong process id");
+ tprintf ("end, context back to %d\n", current);
+ if (current != old)
+ m2iso_M2RTS_HaltC (__FILE__, __LINE__, __FUNCTION__,
+ "wrong process id");
}
}
__gthread_mutex_unlock (&lock);
@@ -494,15 +505,15 @@ EXPORT(init) (void)
semArray = (threadSem **)malloc (sizeof (threadSem *) * SEM_POOL);
#endif
/* Create a thread control block for the main program (or process). */
- currentThread = newThread (); /* For the current initial thread. */
- threadArray[currentThread].p = pthread_self ();
- threadArray[currentThread].tid = currentThread;
- __GTHREAD_COND_INIT_FUNCTION (&threadArray[currentThread].run_counter);
- threadArray[currentThread].interruptLevel = 0;
+ int tid = newThread (); /* For the current initial thread. */
+ threadArray[tid].p = pthread_self ();
+ threadArray[tid].tid = tid;
+ __GTHREAD_COND_INIT_FUNCTION (&threadArray[tid].run_counter);
+ threadArray[tid].interruptLevel = 0;
/* The line below shouldn't be necessary as we are already running. */
- threadArray[currentThread].proc = never;
- threadArray[currentThread].waiting = false; /* We are running. */
- threadArray[currentThread].value = 0; /* No signal from anyone yet. */
+ threadArray[tid].proc = never;
+ threadArray[tid].waiting = false; /* We are running. */
+ threadArray[tid].value = 0; /* No signal from anyone yet. */
tprintf ("RTco initialized completed\n");
__gthread_mutex_unlock (&lock);
}
@@ -512,7 +523,7 @@ EXPORT(init) (void)
extern "C" void __attribute__((__constructor__))
M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("RTco",
- M2EXPORT(init), M2EXPORT(fini),
- M2EXPORT(dep));
+ m2iso_M2RTS_RegisterModule ("RTco", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2iso/m2rts.h b/libgm2/libm2iso/m2rts.h
index 1f3bc2d..97612c1 100644
--- a/libgm2/libm2iso/m2rts.h
+++ b/libgm2/libm2iso/m2rts.h
@@ -25,19 +25,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+#define str(X) #X
+
typedef void (*proc_con) (int, char **, char **);
typedef void (*proc_dep) (void);
-extern "C" void M2RTS_RequestDependant (const char *modulename, const char *dependancy);
-extern "C" void M2RTS_RegisterModule (const char *modulename,
+extern "C" void m2iso_M2RTS_RequestDependant (const char *modulename, const char *libname, const char *dependancy);
+extern "C" void m2iso_M2RTS_RegisterModule (const char *modulename, const char *libname,
+ proc_con init, proc_con fini, proc_dep dependencies);
+extern "C" void m2pim_M2RTS_RegisterModule (const char *modulename, const char *libname,
+ proc_con init, proc_con fini, proc_dep dependencies);
+extern "C" void M2RTS_RegisterModule (const char *modulename, const char *libname,
proc_con init, proc_con fini, proc_dep dependencies);
-extern "C" void _M2_M2RTS_init (void);
+extern "C" void m2iso_M2_M2RTS_init (void);
-extern "C" void M2RTS_ConstructModules (const char *,
- int argc, char *argv[], char *envp[]);
-extern "C" void M2RTS_Terminate (void);
-extern "C" void M2RTS_DeconstructModules (void);
+extern "C" void m2iso_M2RTS_ConstructModules (const char *modulename, const char *libname,
+ int argc, char *argv[], char *envp[]);
+extern "C" void m2iso_M2RTS_Terminate (void);
+extern "C" void m2iso_M2RTS_DeconstructModules (void);
-extern "C" void M2RTS_HaltC (const char *filename, int line,
- const char *functionname, const char *desc)
- __attribute__ ((noreturn));
+extern "C" void m2iso_M2RTS_HaltC (const char *filename, int line,
+ const char *functionname, const char *desc)
+ __attribute__ ((noreturn));
diff --git a/libgm2/libm2iso/wrapsock.c b/libgm2/libm2iso/wrapsock.c
index 79c2d89..1582f24 100644
--- a/libgm2/libm2iso/wrapsock.c
+++ b/libgm2/libm2iso/wrapsock.c
@@ -26,6 +26,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "config.h"
+#define EXPORT(FUNC) m2iso ## _wrapsock_ ## FUNC
+#define IMPORT(MODULE,FUNC) m2iso ## _ ## MODULE ## _ ## FUNC
+#define M2EXPORT(FUNC) m2iso ## _M2_wrapsock_ ## FUNC
+#define M2LIBNAME "m2iso"
+
+/* This module should be rewritten to use C++. */
+
+typedef void (*proc_con) (int, char **, char **);
+typedef void (*proc_dep) (void);
+
+extern void m2iso_M2RTS_RequestDependant (const char *modulename, const char *libname, const char *dependancy);
+extern void m2iso_M2RTS_RegisterModule (const char *modulename, const char *libname,
+ proc_con init, proc_con fini, proc_dep dependencies);
+
#if defined(HAVE_SYS_TYPES_H)
#include "sys/types.h"
#endif
@@ -106,7 +120,7 @@ static openResults clientConnect (clientInfo *c);
structure, c, will have its fields initialized. */
openResults
-wrapsock_clientOpen (clientInfo *c, char *hostname, unsigned int length,
+EXPORT(clientOpen) (clientInfo *c, char *hostname, unsigned int length,
int portNo)
{
/* remove SIGPIPE which is raised on the server if the client is killed. */
@@ -133,7 +147,7 @@ wrapsock_clientOpen (clientInfo *c, char *hostname, unsigned int length,
structure, c, will have its fields initialized. */
openResults
-wrapsock_clientOpenIP (clientInfo *c, unsigned int ip, int portNo)
+EXPORT(clientOpenIP) (clientInfo *c, unsigned int ip, int portNo)
{
/* remove SIGPIPE which is raised on the server if the client is killed. */
signal (SIGPIPE, SIG_IGN);
@@ -166,7 +180,7 @@ clientConnect (clientInfo *c)
/* getClientPortNo - returns the portNo from structure, c. */
int
-wrapsock_getClientPortNo (clientInfo *c)
+EXPORT(getClientPortNo) (clientInfo *c)
{
return c->portNo;
}
@@ -175,7 +189,7 @@ wrapsock_getClientPortNo (clientInfo *c)
which the client is connecting. */
void
-wrapsock_getClientHostname (clientInfo *c, char *hostname, unsigned int high)
+EXPORT(getClientHostname) (clientInfo *c, char *hostname, unsigned int high)
{
strncpy (hostname, c->hostname, high + 1);
}
@@ -183,7 +197,7 @@ wrapsock_getClientHostname (clientInfo *c, char *hostname, unsigned int high)
/* getClientSocketFd - returns the sockFd from structure, c. */
int
-wrapsock_getClientSocketFd (clientInfo *c)
+EXPORT(getClientSocketFd) (clientInfo *c)
{
return c->sockFd;
}
@@ -191,7 +205,7 @@ wrapsock_getClientSocketFd (clientInfo *c)
/* getClientIP - returns the sockFd from structure, s. */
unsigned int
-wrapsock_getClientIP (clientInfo *c)
+EXPORT(getClientIP) (clientInfo *c)
{
#if 0
printf("client ip = %s\n", inet_ntoa (c->sa.sin_addr.s_addr));
@@ -203,7 +217,7 @@ wrapsock_getClientIP (clientInfo *c)
available. */
unsigned int
-wrapsock_getPushBackChar (clientInfo *c, char *ch)
+EXPORT(getPushBackChar) (clientInfo *c, char *ch)
{
if (c->hasChar > 0)
{
@@ -218,7 +232,7 @@ wrapsock_getPushBackChar (clientInfo *c, char *ch)
character. */
unsigned int
-wrapsock_setPushBackChar (clientInfo *c, char ch)
+EXPORT(setPushBackChar) (clientInfo *c, char ch)
{
if (c->hasChar == MAXPBBUF)
return FALSE;
@@ -230,21 +244,35 @@ wrapsock_setPushBackChar (clientInfo *c, char ch)
/* getSizeOfClientInfo - returns the sizeof (opaque data type). */
unsigned int
-wrapsock_getSizeOfClientInfo (void)
+EXPORT(getSizeOfClientInfo) (void)
{
return sizeof (clientInfo);
}
#endif
-/* GNU Modula-2 link fodder. */
+
+/* GNU Modula-2 linking hooks. */
+
+void
+M2EXPORT(init) (int, char **, char **)
+{
+}
void
-_M2_wrapsock_init (void)
+M2EXPORT(fini) (int, char **, char **)
{
}
void
-_M2_wrapsock_fini (void)
+M2EXPORT(dep) (void)
+{
+}
+
+void __attribute__((__constructor__))
+M2EXPORT(ctor) (void)
{
+ m2iso_M2RTS_RegisterModule ("wrapsock", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2iso/wraptime.c b/libgm2/libm2iso/wraptime.cc
index 6d6929b..3cdc385 100644
--- a/libgm2/libm2iso/wraptime.c
+++ b/libgm2/libm2iso/wraptime.cc
@@ -25,6 +25,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include "config.h"
+#include <m2rts.h>
+
+#define EXPORT(FUNC) m2iso ## _wraptime_ ## FUNC
+#define M2EXPORT(FUNC) m2iso ## _M2_wraptime_ ## FUNC
+#define M2LIBNAME "m2iso"
#if defined(HAVE_SYS_TYPES_H)
#include "sys/types.h"
@@ -61,14 +66,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* InitTimeval returns a newly created opaque type. */
#if defined(HAVE_TIMEVAL) && defined(HAVE_MALLOC_H)
-struct timeval *
-wraptime_InitTimeval (void)
+extern "C" struct timeval *
+EXPORT(InitTimeval) (void)
{
return (struct timeval *)malloc (sizeof (struct timeval));
}
#else
-void *
-wraptime_InitTimeval (void)
+extern "C" void *
+EXPORT(InitTimeval) (void)
{
return NULL;
}
@@ -76,8 +81,8 @@ wraptime_InitTimeval (void)
/* KillTimeval deallocates the memory associated with an opaque type. */
-struct timeval *
-wraptime_KillTimeval (void *tv)
+extern "C" struct timeval *
+EXPORT(KillTimeval) (void *tv)
{
#if defined(HAVE_MALLOC_H)
free (tv);
@@ -88,14 +93,14 @@ wraptime_KillTimeval (void *tv)
/* InitTimezone returns a newly created opaque type. */
#if defined(HAVE_STRUCT_TIMEZONE) && defined(HAVE_MALLOC_H)
-struct timezone *
-wraptime_InitTimezone (void)
+extern "C" struct timezone *
+EXPORT(InitTimezone) (void)
{
return (struct timezone *)malloc (sizeof (struct timezone));
}
#else
-void *
-wraptime_InitTimezone (void)
+extern "C" void *
+EXPORT(InitTimezone) (void)
{
return NULL;
}
@@ -104,8 +109,8 @@ wraptime_InitTimezone (void)
/* KillTimezone - deallocates the memory associated with an opaque
type. */
-struct timezone *
-wraptime_KillTimezone (struct timezone *tv)
+extern "C" struct timezone *
+EXPORT(KillTimezone) (struct timezone *tv)
{
#if defined(HAVE_MALLOC_H)
free (tv);
@@ -116,14 +121,14 @@ wraptime_KillTimezone (struct timezone *tv)
/* InitTM - returns a newly created opaque type. */
#if defined(HAVE_STRUCT_TM) && defined(HAVE_MALLOC_H)
-struct tm *
-wraptime_InitTM (void)
+extern "C" struct tm *
+EXPORT(InitTM) (void)
{
return (struct tm *)malloc (sizeof (struct tm));
}
#else
-void *
-wraptime_InitTM (void)
+extern "C" void *
+EXPORT(InitTM) (void)
{
return NULL;
}
@@ -131,8 +136,8 @@ wraptime_InitTM (void)
/* KillTM - deallocates the memory associated with an opaque type. */
-struct tm *
-wraptime_KillTM (struct tm *tv)
+extern "C" struct tm *
+EXPORT(KillTM) (struct tm *tv)
{
#if defined(HAVE_MALLOC_H)
free (tv);
@@ -144,14 +149,14 @@ wraptime_KillTM (struct tm *tv)
and, tz. It returns 0 on success. */
#if defined(HAVE_STRUCT_TIMEZONE) && defined(HAVE_GETTIMEOFDAY)
-int
-wraptime_gettimeofday (void *tv, struct timezone *tz)
+extern "C" int
+EXPORT(gettimeofday) (void *tv, struct timezone *tz)
{
return gettimeofday (tv, tz);
}
#else
-int
-wraptime_gettimeofday (void *tv, void *tz)
+extern "C" int
+EXPORT(gettimeofday) (void *tv, void *tz)
{
return -1;
}
@@ -161,14 +166,14 @@ wraptime_gettimeofday (void *tv, void *tz)
and, tz. It returns 0 on success. */
#if defined(HAVE_STRUCT_TIMEZONE) && defined(HAVE_SETTIMEOFDAY)
-int
-wraptime_settimeofday (void *tv, struct timezone *tz)
+extern "C" int
+EXPORT(settimeofday) (void *tv, struct timezone *tz)
{
return settimeofday (tv, tz);
}
#else
-int
-wraptime_settimeofday (void *tv, void *tz)
+extern "C" int
+EXPORT(settimeofday) (void *tv, void *tz)
{
return -1;
}
@@ -178,14 +183,14 @@ wraptime_settimeofday (void *tv, void *tz)
timeval structure. */
#if defined(HAVE_TIMEVAL)
-unsigned int
-wraptime_GetFractions (struct timeval *tv)
+extern "C" unsigned int
+EXPORT(GetFractions) (struct timeval *tv)
{
return (unsigned int)tv->tv_usec;
}
#else
-unsigned int
-wraptime_GetFractions (void *tv)
+extern "C" unsigned int
+EXPORT(GetFractions) (void *tv)
{
return (unsigned int)-1;
}
@@ -197,14 +202,14 @@ wraptime_GetFractions (void *tv)
and not a time_t (as expected by the posix equivalent). */
#if defined(HAVE_TIMEVAL)
-struct tm *
-wraptime_localtime_r (struct timeval *tv, struct tm *m)
+extern "C" struct tm *
+EXPORT(localtime_r) (struct timeval *tv, struct tm *m)
{
return localtime_r (&tv->tv_sec, m);
}
#else
-struct tm *
-wraptime_localtime_r (void *tv, struct tm *m)
+extern "C" struct tm *
+EXPORT(localtime_r) (void *tv, struct tm *m)
{
return m;
}
@@ -213,14 +218,14 @@ wraptime_localtime_r (void *tv, struct tm *m)
/* wraptime_GetYear - returns the year from the structure, m. */
#if defined(HAVE_STRUCT_TM)
-unsigned int
-wraptime_GetYear (struct tm *m)
+extern "C" unsigned int
+EXPORT(GetYear) (struct tm *m)
{
return m->tm_year;
}
#else
-unsigned int
-wraptime_GetYear (void *m)
+extern "C" unsigned int
+EXPORT(GetYear) (void *m)
{
return (unsigned int)-1;
}
@@ -229,14 +234,14 @@ wraptime_GetYear (void *m)
/* wraptime_GetMonth - returns the month from the structure, m. */
#if defined(HAVE_STRUCT_TM)
-unsigned int
-wraptime_GetMonth (struct tm *m)
+extern "C" unsigned int
+EXPORT(GetMonth) (struct tm *m)
{
return m->tm_mon;
}
#else
-unsigned int
-wraptime_GetMonth (void *m)
+extern "C" unsigned int
+EXPORT(GetMonth) (void *m)
{
return (unsigned int)-1;
}
@@ -246,14 +251,14 @@ wraptime_GetMonth (void *m)
m. */
#if defined(HAVE_STRUCT_TM)
-unsigned int
-wraptime_GetDay (struct tm *m)
+extern "C" unsigned int
+EXPORT(GetDay) (struct tm *m)
{
return m->tm_mday;
}
#else
-unsigned int
-wraptime_GetDay (void *m)
+extern "C" unsigned int
+EXPORT(GetDay) (void *m)
{
return (unsigned int)-1;
}
@@ -263,14 +268,14 @@ wraptime_GetDay (void *m)
m. */
#if defined(HAVE_STRUCT_TM)
-unsigned int
-wraptime_GetHour (struct tm *m)
+extern "C" unsigned int
+EXPORT(GetHour) (struct tm *m)
{
return m->tm_hour;
}
#else
-unsigned int
-wraptime_GetHour (void *m)
+extern "C" unsigned int
+EXPORT(GetHour) (void *m)
{
return (unsigned int)-1;
}
@@ -280,14 +285,14 @@ wraptime_GetHour (void *m)
structure, m. */
#if defined(HAVE_STRUCT_TM)
-unsigned int
-wraptime_GetMinute (struct tm *m)
+extern "C" unsigned int
+EXPORT(GetMinute) (struct tm *m)
{
return m->tm_min;
}
#else
-unsigned int
-wraptime_GetMinute (void *m)
+extern "C" unsigned int
+EXPORT(GetMinute) (void *m)
{
return (unsigned int)-1;
}
@@ -298,8 +303,8 @@ wraptime_GetMinute (void *m)
A leap minute of value 60 will be truncated to 59. */
#if defined(HAVE_STRUCT_TM)
-unsigned int
-wraptime_GetSecond (struct tm *m)
+extern "C" unsigned int
+EXPORT(GetSecond) (struct tm *m)
{
if (m->tm_sec == 60)
return 59;
@@ -307,8 +312,8 @@ wraptime_GetSecond (struct tm *m)
return m->tm_sec;
}
#else
-unsigned int
-wraptime_GetSecond (void *m)
+extern "C" unsigned int
+EXPORT(GetSecond) (void *m)
{
return (unsigned int)-1;
}
@@ -317,14 +322,14 @@ wraptime_GetSecond (void *m)
/* wraptime_GetSummerTime - returns true if summer time is in effect. */
#if defined(HAVE_STRUCT_TIMEZONE)
-unsigned int
-wraptime_GetSummerTime (struct timezone *tz)
+extern "C" unsigned int
+EXPORT(GetSummerTime) (struct timezone *tz)
{
return tz->tz_dsttime != 0;
}
#else
-unsigned int
-wraptime_GetSummerTime (void *tz)
+extern "C" unsigned int
+EXPORT(GetSummerTime) (void *tz)
{
return FALSE;
}
@@ -333,14 +338,14 @@ wraptime_GetSummerTime (void *tz)
/* wraptime_GetDST - returns the number of minutes west of GMT. */
#if defined(HAVE_STRUCT_TIMEZONE)
-int
-wraptime_GetDST (struct timezone *tz)
+extern "C" int
+EXPORT(GetDST) (struct timezone *tz)
{
return tz->tz_minuteswest;
}
#else
-int
-wraptime_GetDST (void *tz)
+extern "C" int
+EXPORT(GetDST) (void *tz)
{
#if defined(INT_MIN)
return INT_MIN;
@@ -353,15 +358,15 @@ wraptime_GetDST (void *tz)
/* SetTimezone - set the timezone field inside timeval, tv. */
#if defined(HAVE_STRUCT_TIMEZONE)
-void
-wraptime_SetTimezone (struct timezone *tz, int zone, int minuteswest)
+extern "C" void
+EXPORT(SetTimezone) (struct timezone *tz, int zone, int minuteswest)
{
tz->tz_dsttime = zone;
tz->tz_minuteswest = minuteswest;
}
#else
-void
-wraptime_SetTimezone (void *tz, int zone, int minuteswest)
+extern "C" void
+EXPORT(SetTimezone) (void *tz, int zone, int minuteswest)
{
}
#endif
@@ -370,11 +375,11 @@ wraptime_SetTimezone (void *tz, int zone, int minuteswest)
day, month, year, fractions. */
#if defined(HAVE_TIMEVAL)
-void
-wraptime_SetTimeval (struct tm *t, unsigned int second, unsigned int minute,
- unsigned int hour, unsigned int day, unsigned int month,
- unsigned int year, unsigned int yday, unsigned int wday,
- unsigned int isdst)
+extern "C" void
+EXPORT(SetTimeval) (struct tm *t, unsigned int second, unsigned int minute,
+ unsigned int hour, unsigned int day, unsigned int month,
+ unsigned int year, unsigned int yday, unsigned int wday,
+ unsigned int isdst)
{
t->tm_sec = second;
t->tm_min = minute;
@@ -387,22 +392,38 @@ wraptime_SetTimeval (struct tm *t, unsigned int second, unsigned int minute,
t->tm_isdst = isdst;
}
#else
-void
-wraptime_SetTimeval (void *t, unsigned int second, unsigned int minute,
- unsigned int hour, unsigned int day, unsigned int month,
- unsigned int year, unsigned int yday, unsigned int wday,
- unsigned int isdst)
+extern "C" void
+EXPORT(SetTimeval) (void *t, unsigned int second, unsigned int minute,
+ unsigned int hour, unsigned int day, unsigned int month,
+ unsigned int year, unsigned int yday, unsigned int wday,
+ unsigned int isdst)
{
}
#endif
/* init - init/finish functions for the module */
-void
-_M2_wraptime_init ()
+/* GNU Modula-2 linking hooks. */
+
+extern "C" void
+M2EXPORT(init) (int, char **, char **)
+{
+}
+
+extern "C" void
+M2EXPORT(fini) (int, char **, char **)
{
}
-void
-_M2_wraptime_fini ()
+
+extern "C" void
+M2EXPORT(dep) (void)
+{
+}
+
+extern "C" void __attribute__((__constructor__))
+M2EXPORT(ctor) (void)
{
+ m2iso_M2RTS_RegisterModule ("wraptime", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2log/Makefile.am b/libgm2/libm2log/Makefile.am
index 450673f..c38ec3c 100644
--- a/libgm2/libm2log/Makefile.am
+++ b/libgm2/libm2log/Makefile.am
@@ -131,7 +131,12 @@ libm2log_la_SOURCES = $(M2MODS) Break.c
libm2log_la_DEPENDENCIES = ../libm2pim/SYSTEM.def $(addsuffix .lo, $(basename $(libm2log_la_SOURCES)))
libm2log_la_CFLAGS = -I. -DBUILD_GM2_LIBS -I@srcdir@/../
-libm2log_la_M2FLAGS = -I../libm2pim -I$(GM2_SRC)/gm2-libs-log -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -Wreturn-type -fcase
+libm2log_la_M2FLAGS = \
+ -fm2-pathname=m2pim -I../libm2pim \
+ -fm2-pathname=m2log -I$(GM2_SRC)/gm2-libs-log \
+ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
+ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+ -Wreturn-type -fcase -fm2-prefix=m2log
if TARGET_DARWIN
libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup
else
diff --git a/libgm2/libm2log/Makefile.in b/libgm2/libm2log/Makefile.in
index c8d36a3..ef43b0d 100644
--- a/libgm2/libm2log/Makefile.in
+++ b/libgm2/libm2log/Makefile.in
@@ -471,7 +471,13 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
@BUILD_LOGLIB_TRUE@libm2log_la_SOURCES = $(M2MODS) Break.c
@BUILD_LOGLIB_TRUE@libm2log_la_DEPENDENCIES = ../libm2pim/SYSTEM.def $(addsuffix .lo, $(basename $(libm2log_la_SOURCES)))
@BUILD_LOGLIB_TRUE@libm2log_la_CFLAGS = -I. -DBUILD_GM2_LIBS -I@srcdir@/../
-@BUILD_LOGLIB_TRUE@libm2log_la_M2FLAGS = -I../libm2pim -I$(GM2_SRC)/gm2-libs-log -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -Wreturn-type -fcase
+@BUILD_LOGLIB_TRUE@libm2log_la_M2FLAGS = \
+@BUILD_LOGLIB_TRUE@ -fm2-pathname=m2pim -I../libm2pim \
+@BUILD_LOGLIB_TRUE@ -fm2-pathname=m2log -I$(GM2_SRC)/gm2-libs-log \
+@BUILD_LOGLIB_TRUE@ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
+@BUILD_LOGLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+@BUILD_LOGLIB_TRUE@ -Wreturn-type -fcase -fm2-prefix=m2log
+
@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_FALSE@libm2log_la_link_flags =
@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup
@BUILD_LOGLIB_TRUE@libm2log_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2log_la_link_flags)
diff --git a/libgm2/libm2min/Makefile.am b/libgm2/libm2min/Makefile.am
index 6633549..4d6203a 100644
--- a/libgm2/libm2min/Makefile.am
+++ b/libgm2/libm2min/Makefile.am
@@ -104,8 +104,10 @@ toolexeclib_LTLIBRARIES = libm2min.la
libm2min_la_SOURCES = $(M2MODS) libc.c
libm2min_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2min_la_SOURCES)))
libm2min_la_CFLAGS = -I. -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs
-libm2min_la_M2FLAGS = -I. -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs -fno-exceptions \
- -fno-m2-plugin -fno-scaffold-dynamic -fno-scaffold-main
+libm2min_la_M2FLAGS = \
+ -fm2-pathname=m2min -I. -I$(GM2_SRC)/gm2-libs-min \
+ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs -fno-exceptions \
+ -fno-m2-plugin -fno-scaffold-dynamic -fno-scaffold-main -fm2-prefix=m2min
if TARGET_DARWIN
libm2min_la_link_flags = -Wl,-undefined,dynamic_lookup
else
diff --git a/libgm2/libm2min/Makefile.in b/libgm2/libm2min/Makefile.in
index 0ef7642..673d6d5 100644
--- a/libgm2/libm2min/Makefile.in
+++ b/libgm2/libm2min/Makefile.in
@@ -437,8 +437,10 @@ toolexeclib_LTLIBRARIES = libm2min.la
libm2min_la_SOURCES = $(M2MODS) libc.c
libm2min_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2min_la_SOURCES)))
libm2min_la_CFLAGS = -I. -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs
-libm2min_la_M2FLAGS = -I. -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs -fno-exceptions \
- -fno-m2-plugin -fno-scaffold-dynamic -fno-scaffold-main
+libm2min_la_M2FLAGS = \
+ -fm2-pathname=m2min -I. -I$(GM2_SRC)/gm2-libs-min \
+ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs -fno-exceptions \
+ -fno-m2-plugin -fno-scaffold-dynamic -fno-scaffold-main -fm2-prefix=m2min
@TARGET_DARWIN_FALSE@libm2min_la_link_flags =
@TARGET_DARWIN_TRUE@libm2min_la_link_flags = -Wl,-undefined,dynamic_lookup
diff --git a/libgm2/libm2pim/Makefile.am b/libgm2/libm2pim/Makefile.am
index 7bb08c0..eae14fa 100644
--- a/libgm2/libm2pim/Makefile.am
+++ b/libgm2/libm2pim/Makefile.am
@@ -161,12 +161,15 @@ libm2pim_la_SOURCES = $(M2MODS) \
errno.cc dtoa.cc \
ldtoa.cc termios.cc \
SysExceptions.cc target.c \
- wrapc.c cgetopt.cc
+ wrapc.cc cgetopt.cc
libm2pimdir = libm2pim
libm2pim_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2pim_la_SOURCES)))
libm2pim_la_CFLAGS = -I. -I.. -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -DBUILD_GM2_LIBS -I@srcdir@/../ -I@srcdir@/../libm2iso
-libm2pim_la_M2FLAGS = -I. -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -fm2-g -g -Wreturn-type -fcase
+libm2pim_la_M2FLAGS = \
+ -fm2-pathname=m2pim -I. -I$(GM2_SRC)/gm2-libs \
+ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2pim
if TARGET_DARWIN
libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup
else
diff --git a/libgm2/libm2pim/Makefile.in b/libgm2/libm2pim/Makefile.in
index 7a59893..ec81103 100644
--- a/libgm2/libm2pim/Makefile.in
+++ b/libgm2/libm2pim/Makefile.in
@@ -170,7 +170,7 @@ libm2pim_la_LIBADD =
@BUILD_PIMLIB_TRUE@ UnixArgs.lo Selective.lo sckt.lo errno.lo \
@BUILD_PIMLIB_TRUE@ dtoa.lo ldtoa.lo termios.lo \
@BUILD_PIMLIB_TRUE@ SysExceptions.lo libm2pim_la-target.lo \
-@BUILD_PIMLIB_TRUE@ libm2pim_la-wrapc.lo cgetopt.lo
+@BUILD_PIMLIB_TRUE@ wrapc.lo cgetopt.lo
libm2pim_la_OBJECTS = $(am_libm2pim_la_OBJECTS)
@BUILD_PIMLIB_TRUE@am_libm2pim_la_rpath = -rpath $(toolexeclibdir)
AM_V_P = $(am__v_P_@AM_V@)
@@ -529,12 +529,16 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
@BUILD_PIMLIB_TRUE@ errno.cc dtoa.cc \
@BUILD_PIMLIB_TRUE@ ldtoa.cc termios.cc \
@BUILD_PIMLIB_TRUE@ SysExceptions.cc target.c \
-@BUILD_PIMLIB_TRUE@ wrapc.c cgetopt.cc
+@BUILD_PIMLIB_TRUE@ wrapc.cc cgetopt.cc
@BUILD_PIMLIB_TRUE@libm2pimdir = libm2pim
@BUILD_PIMLIB_TRUE@libm2pim_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2pim_la_SOURCES)))
@BUILD_PIMLIB_TRUE@libm2pim_la_CFLAGS = -I. -I.. -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -DBUILD_GM2_LIBS -I@srcdir@/../ -I@srcdir@/../libm2iso
-@BUILD_PIMLIB_TRUE@libm2pim_la_M2FLAGS = -I. -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -fm2-g -g -Wreturn-type -fcase
+@BUILD_PIMLIB_TRUE@libm2pim_la_M2FLAGS = \
+@BUILD_PIMLIB_TRUE@ -fm2-pathname=m2pim -I. -I$(GM2_SRC)/gm2-libs \
+@BUILD_PIMLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
+@BUILD_PIMLIB_TRUE@ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2pim
+
@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_FALSE@libm2pim_la_link_flags =
@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup
@BUILD_PIMLIB_TRUE@libm2pim_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2pim_la_link_flags)
@@ -628,9 +632,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errno.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldtoa.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libm2pim_la-target.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libm2pim_la-wrapc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sckt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/termios.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrapc.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -660,13 +664,6 @@ libm2pim_la-target.lo: target.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libm2pim_la_CFLAGS) $(CFLAGS) -c -o libm2pim_la-target.lo `test -f 'target.c' || echo '$(srcdir)/'`target.c
-libm2pim_la-wrapc.lo: wrapc.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libm2pim_la_CFLAGS) $(CFLAGS) -MT libm2pim_la-wrapc.lo -MD -MP -MF $(DEPDIR)/libm2pim_la-wrapc.Tpo -c -o libm2pim_la-wrapc.lo `test -f 'wrapc.c' || echo '$(srcdir)/'`wrapc.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libm2pim_la-wrapc.Tpo $(DEPDIR)/libm2pim_la-wrapc.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='wrapc.c' object='libm2pim_la-wrapc.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libm2pim_la_CFLAGS) $(CFLAGS) -c -o libm2pim_la-wrapc.lo `test -f 'wrapc.c' || echo '$(srcdir)/'`wrapc.c
-
.cc.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
diff --git a/libgm2/libm2pim/Selective.cc b/libgm2/libm2pim/Selective.cc
index 3c6b855..09c57f2 100644
--- a/libgm2/libm2pim/Selective.cc
+++ b/libgm2/libm2pim/Selective.cc
@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <config.h>
#include <m2rts.h>
+#define EXPORT(FUNC) m2pim ## _Selective_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_Selective_ ## FUNC
+#define M2LIBNAME "m2pim"
+
#if defined(HAVE_STDDEF_H)
/* Obtain a definition for NULL. */
#include <stddef.h>
@@ -83,15 +87,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined(HAVE_STRUCT_TIMEVAL)
extern "C" int
-Selective_Select (int nooffds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
+EXPORT(Select) (int nooffds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
{
return select (nooffds, readfds, writefds, exceptfds, timeout);
}
#else
extern "C" int
-Selective_Select (int nooffds, void *readfds, void *writefds, void *exceptfds,
- void *timeout)
+EXPORT(Select) (int nooffds, void *readfds, void *writefds, void *exceptfds,
+ void *timeout)
{
return 0;
}
@@ -101,7 +105,7 @@ Selective_Select (int nooffds, void *readfds, void *writefds, void *exceptfds,
#if defined(HAVE_STRUCT_TIMEVAL)
extern "C" struct timeval *
-Selective_InitTime (unsigned int sec, unsigned int usec)
+EXPORT(InitTime) (unsigned int sec, unsigned int usec)
{
struct timeval *t = (struct timeval *)malloc (sizeof (struct timeval));
@@ -111,14 +115,14 @@ Selective_InitTime (unsigned int sec, unsigned int usec)
}
extern "C" void
-Selective_GetTime (struct timeval *t, unsigned int *sec, unsigned int *usec)
+EXPORT(GetTime) (struct timeval *t, unsigned int *sec, unsigned int *usec)
{
*sec = (unsigned int)t->tv_sec;
*usec = (unsigned int)t->tv_usec;
}
extern "C" void
-Selective_SetTime (struct timeval *t, unsigned int sec, unsigned int usec)
+EXPORT(SetTime) (struct timeval *t, unsigned int sec, unsigned int usec)
{
t->tv_sec = sec;
t->tv_usec = usec;
@@ -127,7 +131,7 @@ Selective_SetTime (struct timeval *t, unsigned int sec, unsigned int usec)
/* KillTime frees the timeval structure and returns NULL. */
extern "C" struct timeval *
-Selective_KillTime (struct timeval *t)
+EXPORT(KillTime) (struct timeval *t)
{
#if defined(HAVE_STDLIB_H)
free (t);
@@ -138,7 +142,7 @@ Selective_KillTime (struct timeval *t)
/* InitSet returns a pointer to a FD_SET. */
extern "C" FDSET_T *
-Selective_InitSet (void)
+EXPORT(InitSet) (void)
{
#if defined(HAVE_STDLIB_H)
FDSET_T *s = (FDSET_T *)malloc (sizeof (FDSET_T));
@@ -152,7 +156,7 @@ Selective_InitSet (void)
/* KillSet frees the FD_SET and returns NULL. */
extern "C" FDSET_T *
-Selective_KillSet (FDSET_T *s)
+EXPORT(KillSet) (FDSET_T *s)
{
#if defined(HAVE_STDLIB_H)
free (s);
@@ -163,7 +167,7 @@ Selective_KillSet (FDSET_T *s)
/* FdZero generate an empty set. */
extern "C" void
-Selective_FdZero (FDSET_T *s)
+EXPORT(FdZero) (FDSET_T *s)
{
FD_ZERO (s);
}
@@ -171,7 +175,7 @@ Selective_FdZero (FDSET_T *s)
/* FS_Set include an element, fd, into set, s. */
extern "C" void
-Selective_FdSet (int fd, FDSET_T *s)
+EXPORT(FdSet) (int fd, FDSET_T *s)
{
FD_SET (fd, s);
}
@@ -179,7 +183,7 @@ Selective_FdSet (int fd, FDSET_T *s)
/* FdClr exclude an element, fd, from the set, s. */
extern "C" void
-Selective_FdClr (int fd, FDSET_T *s)
+EXPORT(FdClr) (int fd, FDSET_T *s)
{
FD_CLR (fd, s);
}
@@ -187,7 +191,7 @@ Selective_FdClr (int fd, FDSET_T *s)
/* FdIsSet return TRUE if, fd, is present in set, s. */
extern "C" int
-Selective_FdIsSet (int fd, FDSET_T *s)
+EXPORT(FdIsSet) (int fd, FDSET_T *s)
{
return FD_ISSET (fd, s);
}
@@ -197,69 +201,69 @@ Selective_FdIsSet (int fd, FDSET_T *s)
It returns zero (see man 3p gettimeofday). */
extern "C" int
-Selective_GetTimeOfDay (struct timeval *t)
+EXPORT(GetTimeOfDay) (struct timeval *t)
{
return gettimeofday (t, NULL);
}
#else
extern "C" void *
-Selective_InitTime (unsigned int sec, unsigned int usec)
+EXPORT(InitTime) (unsigned int sec, unsigned int usec)
{
return NULL;
}
extern "C" void *
-Selective_KillTime (void *t)
+EXPORT(KillTime) (void *t)
{
return NULL;
}
extern "C" void
-Selective_GetTime (void *t, unsigned int *sec, unsigned int *usec)
+EXPORT(GetTime) (void *t, unsigned int *sec, unsigned int *usec)
{
}
extern "C" void
-Selective_SetTime (void *t, unsigned int sec, unsigned int usec)
+EXPORT(SetTime) (void *t, unsigned int sec, unsigned int usec)
{
}
extern "C" FDSET_T *
-Selective_InitSet (void)
+EXPORT(InitSet) (void)
{
return NULL;
}
extern "C" FDSET_T *
-Selective_KillSet (void)
+EXPORT(KillSet) (void)
{
return NULL;
}
extern "C" void
-Selective_FdZero (void *s)
+EXPORT(FdZero) (void *s)
{
}
extern "C" void
-Selective_FdSet (int fd, void *s)
+EXPORT(FdSet) (int fd, void *s)
{
}
extern "C" void
-Selective_FdClr (int fd, void *s)
+EXPORT(FdClr) (int fd, void *s)
{
}
extern "C" int
-Selective_FdIsSet (int fd, void *s)
+EXPORT(FdIsSet) (int fd, void *s)
{
return 0;
}
extern "C" int
-Selective_GetTimeOfDay (void *t)
+EXPORT(GetTimeOfDay) (void *t)
{
return -1;
}
@@ -268,7 +272,7 @@ Selective_GetTimeOfDay (void *t)
/* MaxFdsPlusOne returns max (a + 1, b + 1). */
extern "C" int
-Selective_MaxFdsPlusOne (int a, int b)
+EXPORT(MaxFdsPlusOne) (int a, int b)
{
if (a > b)
return a + 1;
@@ -279,7 +283,7 @@ Selective_MaxFdsPlusOne (int a, int b)
/* WriteCharRaw writes a single character to the file descriptor. */
extern "C" void
-Selective_WriteCharRaw (int fd, char ch)
+EXPORT(WriteCharRaw) (int fd, char ch)
{
write (fd, &ch, 1);
}
@@ -287,7 +291,7 @@ Selective_WriteCharRaw (int fd, char ch)
/* ReadCharRaw read and return a single char from file descriptor, fd. */
extern "C" char
-Selective_ReadCharRaw (int fd)
+EXPORT(ReadCharRaw) (int fd)
{
char ch;
@@ -295,24 +299,27 @@ Selective_ReadCharRaw (int fd)
return ch;
}
+/* GNU Modula-2 linking hooks. */
+
extern "C" void
-_M2_Selective_init (int argc, char *argv[], char *envp[])
+M2EXPORT(init) (int, char **, char **)
{
}
extern "C" void
-_M2_Selective_fini (int argc, char *argv[], char *envp[])
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_Selective_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_Selective_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("Selective", _M2_Selective_init, _M2_Selective_fini,
- _M2_Selective_dep);
+ m2pim_M2RTS_RegisterModule ("Selective", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2pim/SysExceptions.cc b/libgm2/libm2pim/SysExceptions.cc
index 2c37c7a..d93e79e 100644
--- a/libgm2/libm2pim/SysExceptions.cc
+++ b/libgm2/libm2pim/SysExceptions.cc
@@ -25,6 +25,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
+#include "m2rts.h"
+
+#define EXPORT(FUNC) m2pim ## _SysExceptions_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_SysExceptions_ ## FUNC
+#define M2LIBNAME "m2pim"
#if defined(HAVE_SIGNAL_H)
#include <signal.h>
@@ -172,7 +177,7 @@ sigfpeDespatcher (int signum, siginfo_t *info, void *ucontext)
}
extern "C" void
-SysExceptions_InitExceptionHandlers (
+EXPORT(InitExceptionHandlers) (
void (*indexf) (void *), void (*range) (void *), void (*casef) (void *),
void (*invalidloc) (void *), void (*function) (void *),
void (*wholevalue) (void *), void (*wholediv) (void *),
@@ -223,7 +228,7 @@ SysExceptions_InitExceptionHandlers (
#else
extern "C" void
-SysExceptions_InitExceptionHandlers (void *indexf, void *range, void *casef,
+EXPORT(InitExceptionHandlers) (void *indexf, void *range, void *casef,
void *invalidloc, void *function,
void *wholevalue, void *wholediv,
void *realvalue, void *realdiv,
@@ -236,23 +241,24 @@ SysExceptions_InitExceptionHandlers (void *indexf, void *range, void *casef,
extern "C" void
-_M2_SysExceptions_init (int, char *[], char *[])
+M2EXPORT(init) (int, char **, char **)
{
}
extern "C" void
-_M2_SysExceptions_fini (int, char *[], char *[])
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_SysExceptions_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_SysExceptions_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("SysExceptions", _M2_SysExceptions_init, _M2_SysExceptions_fini,
- _M2_SysExceptions_dep);
+ m2pim_M2RTS_RegisterModule ("SysExceptions", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2pim/UnixArgs.cc b/libgm2/libm2pim/UnixArgs.cc
index 944a3cd..803188d 100644
--- a/libgm2/libm2pim/UnixArgs.cc
+++ b/libgm2/libm2pim/UnixArgs.cc
@@ -27,10 +27,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <config.h>
#include <m2rts.h>
+#define EXPORT(FUNC) m2pim ## _UnixArgs_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_UnixArgs_ ## FUNC
+#define M2LIBNAME "m2pim"
-extern "C" int UnixArgs_GetArgC (void);
-extern "C" char **UnixArgs_GetArgV (void);
-extern "C" char **UnixArgs_GetEnvV (void);
+extern "C" int EXPORT(GetArgC) (void);
+extern "C" char **EXPORT(GetArgV) (void);
+extern "C" char **EXPORT(GetEnvV) (void);
static int UnixArgs_ArgC;
static char **UnixArgs_ArgV;
@@ -40,7 +43,7 @@ static char **UnixArgs_EnvV;
/* GetArgC returns argc. */
extern "C" int
-UnixArgs_GetArgC (void)
+EXPORT(GetArgC) (void)
{
return UnixArgs_ArgC;
}
@@ -49,7 +52,7 @@ UnixArgs_GetArgC (void)
/* GetArgV returns argv. */
extern "C" char **
-UnixArgs_GetArgV (void)
+EXPORT(GetArgV) (void)
{
return UnixArgs_ArgV;
}
@@ -58,14 +61,16 @@ UnixArgs_GetArgV (void)
/* GetEnvV returns envv. */
extern "C" char **
-UnixArgs_GetEnvV (void)
+EXPORT(GetEnvV) (void)
{
return UnixArgs_EnvV;
}
+/* GNU Modula-2 linking hooks. */
+
extern "C" void
-_M2_UnixArgs_init (int argc, char *argv[], char *envp[])
+M2EXPORT(init) (int argc, char **argv, char **envp)
{
UnixArgs_ArgC = argc;
UnixArgs_ArgV = argv;
@@ -73,18 +78,19 @@ _M2_UnixArgs_init (int argc, char *argv[], char *envp[])
}
extern "C" void
-_M2_UnixArgs_fini (int argc, char *argv[], char *envp[])
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_UnixArgs_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_UnixArgs_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("UnixArgs", _M2_UnixArgs_init, _M2_UnixArgs_fini,
- _M2_UnixArgs_dep);
+ m2pim_M2RTS_RegisterModule ("UnixArgs", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2pim/cgetopt.cc b/libgm2/libm2pim/cgetopt.cc
index 4e8ac9e..858c775 100644
--- a/libgm2/libm2pim/cgetopt.cc
+++ b/libgm2/libm2pim/cgetopt.cc
@@ -29,20 +29,24 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <getopt.h>
#include <m2rts.h>
-extern "C" {char *cgetopt_optarg;}
-extern "C" {int cgetopt_optind;}
-extern "C" {int cgetopt_opterr;}
-extern "C" {int cgetopt_optopt;}
+#define EXPORT(FUNC) m2pim ## _cgetopt_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_cgetopt_ ## FUNC
+#define M2LIBNAME "m2pim"
+
+extern "C" {char *EXPORT(optarg);}
+extern "C" {int EXPORT(optind);}
+extern "C" {int EXPORT(opterr);}
+extern "C" {int EXPORT(optopt);}
extern "C" char
-cgetopt_getopt (int argc, char *argv[], char *optstring)
+EXPORT(getopt) (int argc, char *argv[], char *optstring)
{
char r = getopt (argc, argv, optstring);
- cgetopt_optarg = optarg;
- cgetopt_optind = optind;
- cgetopt_opterr = opterr;
- cgetopt_optopt = optopt;
+ EXPORT(optarg) = optarg;
+ EXPORT(optind) = optind;
+ EXPORT(opterr) = opterr;
+ EXPORT(optopt) = optopt;
if (r == (char)-1)
return (char)0;
@@ -50,29 +54,29 @@ cgetopt_getopt (int argc, char *argv[], char *optstring)
}
extern "C" int
-cgetopt_getopt_long (int argc, char *argv[], char *optstring,
+EXPORT(getopt_long) (int argc, char *argv[], char *optstring,
const struct option *longopts, int *longindex)
{
int r = getopt_long (argc, argv, optstring, longopts, longindex);
- cgetopt_optarg = optarg;
- cgetopt_optind = optind;
- cgetopt_opterr = opterr;
- cgetopt_optopt = optopt;
+ EXPORT(optarg) = optarg;
+ EXPORT(optind) = optind;
+ EXPORT(opterr) = opterr;
+ EXPORT(optopt) = optopt;
return r;
}
extern "C" int
-cgetopt_getopt_long_only (int argc, char *argv[], char *optstring,
+EXPORT(getopt_long_only) (int argc, char *argv[], char *optstring,
const struct option *longopts, int *longindex)
{
int r = getopt_long_only (argc, argv, optstring, longopts, longindex);
- cgetopt_optarg = optarg;
- cgetopt_optind = optind;
- cgetopt_opterr = opterr;
- cgetopt_optopt = optopt;
+ EXPORT(optarg) = optarg;
+ EXPORT(optind) = optind;
+ EXPORT(opterr) = opterr;
+ EXPORT(optopt) = optopt;
return r;
}
@@ -86,7 +90,7 @@ typedef struct cgetopt_Options_s
/* InitOptions a constructor for Options. */
extern "C" cgetopt_Options *
-cgetopt_InitOptions (void)
+EXPORT(InitOptions) (void)
{
cgetopt_Options *o = (cgetopt_Options *)malloc (sizeof (cgetopt_Options));
o->cinfo = (struct option *)malloc (sizeof (struct option));
@@ -98,7 +102,7 @@ cgetopt_InitOptions (void)
up all allocated memory associated with o. */
extern "C" cgetopt_Options *
-cgetopt_KillOptions (cgetopt_Options *o)
+EXPORT(KillOptions) (cgetopt_Options *o)
{
free (o->cinfo);
free (o);
@@ -108,7 +112,7 @@ cgetopt_KillOptions (cgetopt_Options *o)
/* SetOption set option[index] with {name, has_arg, flag, val}. */
extern "C" void
-cgetopt_SetOption (cgetopt_Options *o, unsigned int index, char *name,
+EXPORT(SetOption) (cgetopt_Options *o, unsigned int index, char *name,
unsigned int has_arg, int *flag, int val)
{
if (index > o->high)
@@ -127,7 +131,7 @@ cgetopt_SetOption (cgetopt_Options *o, unsigned int index, char *name,
long options. */
extern "C" struct option *
-cgetopt_GetLongOptionArray (cgetopt_Options *o)
+EXPORT(GetLongOptionArray) (cgetopt_Options *o)
{
return o->cinfo;
}
@@ -135,23 +139,24 @@ cgetopt_GetLongOptionArray (cgetopt_Options *o)
/* GNU Modula-2 linking fodder. */
extern "C" void
-_M2_cgetopt_init (int, char *argv[], char *env[])
+M2EXPORT(init) (int, char *argv[], char *env[])
{
}
extern "C" void
-_M2_cgetopt_fini (int, char *argv[], char *env[])
+M2EXPORT(fini) (int, char *argv[], char *env[])
{
}
extern "C" void
-_M2_cgetopt_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_cgetopt_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("cgetopt", _M2_cgetopt_init, _M2_cgetopt_fini,
- _M2_cgetopt_dep);
+ m2pim_M2RTS_RegisterModule ("cgetopt", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2pim/dtoa.cc b/libgm2/libm2pim/dtoa.cc
index 95d24d4..c6b573b 100644
--- a/libgm2/libm2pim/dtoa.cc
+++ b/libgm2/libm2pim/dtoa.cc
@@ -29,6 +29,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <config.h>
#include <m2rts.h>
+#define EXPORT(FUNC) m2pim ## _dtoa_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_dtoa_ ## FUNC
+#define M2LIBNAME "m2pim"
+
#if defined(HAVE_STRINGS)
#include <strings.h>
#endif
@@ -106,7 +110,7 @@ typedef enum Mode { maxsignicant, decimaldigits } Mode;
contain ndigits past the decimal point (ndigits may be negative). */
extern "C" double
-dtoa_strtod (const char *s, int *error)
+EXPORT(strtod) (const char *s, int *error)
{
char *endp;
double d;
@@ -130,7 +134,7 @@ dtoa_strtod (const char *s, int *error)
it also removes the decimal point and exponent from string, p. */
extern "C" int
-dtoa_calcmaxsig (char *p, int ndigits)
+EXPORT(calcmaxsig) (char *p, int ndigits)
{
char *e;
char *o;
@@ -161,7 +165,7 @@ dtoa_calcmaxsig (char *p, int ndigits)
Ie ndigits is the number of digits after the '.'. */
extern "C" int
-dtoa_calcdecimal (char *p, int str_size, int ndigits)
+EXPORT(calcdecimal) (char *p, int str_size, int ndigits)
{
char *e;
char *o;
@@ -195,7 +199,7 @@ dtoa_calcdecimal (char *p, int str_size, int ndigits)
}
extern "C" int
-dtoa_calcsign (char *p, int str_size)
+EXPORT(calcsign) (char *p, int str_size)
{
if (p[0] == '-')
{
@@ -207,7 +211,7 @@ dtoa_calcsign (char *p, int str_size)
}
extern "C" char *
-dtoa_dtoa (double d, int mode, int ndigits, int *decpt, int *sign)
+EXPORT(dtoa) (double d, int mode, int ndigits, int *decpt, int *sign)
{
char format[50];
char *p;
@@ -220,15 +224,15 @@ dtoa_dtoa (double d, int mode, int ndigits, int *decpt, int *sign)
p = (char *) malloc (ndigits);
snprintf (format, 50, "%s%d%s", "%.", ndigits - 20, "E");
snprintf (p, ndigits, format, d);
- *sign = dtoa_calcsign (p, ndigits);
- *decpt = dtoa_calcmaxsig (p, ndigits);
+ *sign = EXPORT(calcsign) (p, ndigits);
+ *decpt = EXPORT(calcmaxsig) (p, ndigits);
return p;
case decimaldigits:
p = (char *) malloc (MAX_FP_DIGITS + 20);
snprintf (format, 50, "%s%d%s", "%.", MAX_FP_DIGITS, "E");
snprintf (p, MAX_FP_DIGITS + 20, format, d);
- *sign = dtoa_calcsign (p, MAX_FP_DIGITS + 20);
- *decpt = dtoa_calcdecimal (p, MAX_FP_DIGITS + 20, ndigits);
+ *sign = EXPORT(calcsign) (p, MAX_FP_DIGITS + 20);
+ *decpt = EXPORT(calcdecimal) (p, MAX_FP_DIGITS + 20, ndigits);
return p;
default:
abort ();
@@ -241,24 +245,25 @@ dtoa_dtoa (double d, int mode, int ndigits, int *decpt, int *sign)
/* GNU Modula-2 linking hooks. */
extern "C" void
-_M2_dtoa_init (int, char **, char **)
+M2EXPORT(init) (int, char **, char **)
{
}
extern "C" void
-_M2_dtoa_fini (int, char **, char **)
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_dtoa_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_dtoa_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("dtoa", _M2_dtoa_init, _M2_dtoa_fini,
- _M2_dtoa_dep);
+ m2pim_M2RTS_RegisterModule ("dtoa", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
#endif
diff --git a/libgm2/libm2pim/errno.cc b/libgm2/libm2pim/errno.cc
index 296ab0b..db8628f 100644
--- a/libgm2/libm2pim/errno.cc
+++ b/libgm2/libm2pim/errno.cc
@@ -36,8 +36,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "m2rts.h"
+#define EXPORT(FUNC) m2pim ## _errno_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_errno_ ## FUNC
+#define M2LIBNAME "m2pim"
+
extern "C" int
-errno_geterrno (void)
+EXPORT(geterrno) (void)
{
#if defined(HAVE_ERRNO_H) || defined(HAVE_SYS_ERRNO_H)
return errno;
@@ -47,23 +51,24 @@ errno_geterrno (void)
}
extern "C" void
-_M2_errno_init (int, char *[], char *[])
+M2EXPORT(init) (int, char **, char **)
{
}
extern "C" void
-_M2_errno_fini (int, char *[], char *[])
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_errno_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_errno_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("errno", _M2_errno_init, _M2_errno_fini,
- _M2_errno_dep);
+ m2pim_M2RTS_RegisterModule ("errno", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2pim/ldtoa.cc b/libgm2/libm2pim/ldtoa.cc
index 8b44983..9250ca4 100644
--- a/libgm2/libm2pim/ldtoa.cc
+++ b/libgm2/libm2pim/ldtoa.cc
@@ -29,6 +29,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <config.h>
#include <m2rts.h>
+#define EXPORT(FUNC) m2pim ## _ldtoa_ ## FUNC
+#define IMPORT(MODULE,FUNC) m2pim ## _ ## MODULE ## _ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_ldtoa_ ## FUNC
+#define M2LIBNAME "m2pim"
+
#if defined(HAVE_STRINGS)
#include <strings.h>
#endif
@@ -97,9 +102,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
typedef enum Mode { maxsignicant, decimaldigits } Mode;
-extern "C" int dtoa_calcmaxsig (char *p, int ndigits);
-extern "C" int dtoa_calcdecimal (char *p, int str_size, int ndigits);
-extern "C" int dtoa_calcsign (char *p, int str_size);
+extern "C" int IMPORT(dtoa,calcmaxsig) (char *p, int ndigits);
+extern "C" int IMPORT(dtoa,calcdecimal) (char *p, int str_size, int ndigits);
+extern "C" int IMPORT(dtoa,calcsign) (char *p, int str_size);
/* maxsignicant return a string containing max(1,ndigits) significant
digits. The return string contains the string produced by snprintf.
@@ -108,7 +113,7 @@ extern "C" int dtoa_calcsign (char *p, int str_size);
contain ndigits past the decimal point (ndigits may be negative). */
extern "C" long double
-ldtoa_strtold (const char *s, int *error)
+EXPORT(strtold) (const char *s, int *error)
{
char *endp;
long double d;
@@ -134,7 +139,7 @@ ldtoa_strtold (const char *s, int *error)
}
extern "C" char *
-ldtoa_ldtoa (long double d, int mode, int ndigits, int *decpt, int *sign)
+EXPORT(ldtoa) (long double d, int mode, int ndigits, int *decpt, int *sign)
{
char format[50];
char *p;
@@ -147,15 +152,15 @@ ldtoa_ldtoa (long double d, int mode, int ndigits, int *decpt, int *sign)
p = (char *) malloc (ndigits);
snprintf (format, 50, "%s%d%s", "%.", ndigits - 20, "LE");
snprintf (p, ndigits, format, d);
- *sign = dtoa_calcsign (p, ndigits);
- *decpt = dtoa_calcmaxsig (p, ndigits);
+ *sign = IMPORT(dtoa,calcsign) (p, ndigits);
+ *decpt = IMPORT(dtoa,calcmaxsig) (p, ndigits);
return p;
case decimaldigits:
p = (char *) malloc (MAX_FP_DIGITS + 20);
snprintf (format, 50, "%s%d%s", "%.", MAX_FP_DIGITS, "LE");
snprintf (p, MAX_FP_DIGITS + 20, format, d);
- *sign = dtoa_calcsign (p, MAX_FP_DIGITS + 20);
- *decpt = dtoa_calcdecimal (p, MAX_FP_DIGITS + 20, ndigits);
+ *sign = IMPORT(dtoa,calcsign) (p, MAX_FP_DIGITS + 20);
+ *decpt = IMPORT(dtoa,calcdecimal) (p, MAX_FP_DIGITS + 20, ndigits);
return p;
default:
abort ();
@@ -166,24 +171,25 @@ ldtoa_ldtoa (long double d, int mode, int ndigits, int *decpt, int *sign)
/* GNU Modula-2 linking hooks. */
extern "C" void
-_M2_ldtoa_init (int, char **, char **)
+M2EXPORT(init) (int, char **, char **)
{
}
extern "C" void
-_M2_ldtoa_fini (int, char **, char **)
+M2EXPORT(fini) (int, char **, char **)
{
}
extern "C" void
-_M2_ldtoa_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_ldtoa_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("ldtoa", _M2_ldtoa_init, _M2_ldtoa_fini,
- _M2_ldtoa_dep);
+ m2pim_M2RTS_RegisterModule ("ldtoa", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
}
#endif
diff --git a/libgm2/libm2pim/sckt.cc b/libgm2/libm2pim/sckt.cc
index 585ed14..ee579c2 100644
--- a/libgm2/libm2pim/sckt.cc
+++ b/libgm2/libm2pim/sckt.cc
@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <config.h>
#include <m2rts.h>
+#define EXPORT(FUNC) m2pim ## _sckt_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_sckt_ ## FUNC
+#define M2LIBNAME "m2pim"
+
#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
@@ -125,7 +129,7 @@ localExit (int i)
This method attempts to use the port specified by the parameter. */
extern "C" tcpServerState *
-tcpServerEstablishPort (int portNo)
+EXPORT(tcpServerEstablishPort) (int portNo)
{
tcpServerState *s = (tcpServerState *)malloc (sizeof (tcpServerState));
int b, p, n;
@@ -180,16 +184,16 @@ tcpServerEstablishPort (int portNo)
information about a socket declared to receive tcp connections. */
extern "C" tcpServerState *
-tcpServerEstablish (void)
+EXPORT(tcpServerEstablish) (void)
{
- return tcpServerEstablishPort (PORTSTART);
+ return EXPORT(tcpServerEstablishPort) (PORTSTART);
}
/* tcpServerAccept returns a file descriptor once a client has connected and
been accepted. */
extern "C" int
-tcpServerAccept (tcpServerState *s)
+EXPORT(tcpServerAccept) (tcpServerState *s)
{
socklen_t i = sizeof (s->isa);
int t;
@@ -204,7 +208,7 @@ tcpServerAccept (tcpServerState *s)
/* tcpServerPortNo returns the portNo from structure, s. */
extern "C" int
-tcpServerPortNo (tcpServerState *s)
+EXPORT(tcpServerPortNo) (tcpServerState *s)
{
return s->portNo;
}
@@ -212,7 +216,7 @@ tcpServerPortNo (tcpServerState *s)
/* tcpServerSocketFd returns the sockFd from structure, s. */
extern "C" int
-tcpServerSocketFd (tcpServerState *s)
+EXPORT(tcpServerSocketFd) (tcpServerState *s)
{
return s->sockFd;
}
@@ -220,7 +224,7 @@ tcpServerSocketFd (tcpServerState *s)
/* getLocalIP returns the IP address of this machine. */
extern "C" unsigned int
-getLocalIP (tcpServerState *s)
+EXPORT(getLocalIP) (tcpServerState *s)
{
char hostname[1024];
struct hostent *hp;
@@ -262,7 +266,7 @@ getLocalIP (tcpServerState *s)
/* tcpServerIP returns the IP address from structure s. */
extern "C" int
-tcpServerIP (tcpServerState *s)
+EXPORT(tcpServerIP) (tcpServerState *s)
{
return *((int *)s->hp->h_addr_list[0]);
}
@@ -271,7 +275,7 @@ tcpServerIP (tcpServerState *s)
has connected to server s. */
extern "C" unsigned int
-tcpServerClientIP (tcpServerState *s)
+EXPORT(tcpServerClientIP) (tcpServerState *s)
{
unsigned int ip;
@@ -285,7 +289,7 @@ tcpServerClientIP (tcpServerState *s)
has connected to server s. */
extern "C" unsigned int
-tcpServerClientPortNo (tcpServerState *s)
+EXPORT(tcpServerClientPortNo) (tcpServerState *s)
{
return s->isa.sin_port;
}
@@ -309,7 +313,7 @@ typedef struct
connected to, serverName:portNo. */
extern "C" tcpClientState *
-tcpClientSocket (char *serverName, int portNo)
+EXPORT(tcpClientSocket) (char *serverName, int portNo)
{
tcpClientState *s = (tcpClientState *)malloc (sizeof (tcpClientState));
@@ -342,7 +346,7 @@ tcpClientSocket (char *serverName, int portNo)
connected to, ip:portNo. */
extern "C" tcpClientState *
-tcpClientSocketIP (unsigned int ip, int portNo)
+EXPORT(tcpClientSocketIP) (unsigned int ip, int portNo)
{
tcpClientState *s = (tcpClientState *)malloc (sizeof (tcpClientState));
@@ -368,7 +372,7 @@ tcpClientSocketIP (unsigned int ip, int portNo)
once a connect has been performed. */
extern "C" int
-tcpClientConnect (tcpClientState *s)
+EXPORT(tcpClientConnect) (tcpClientState *s)
{
if (connect (s->sockFd, (struct sockaddr *)&s->sa, sizeof (s->sa)) < 0)
ERROR ("failed to connect to the TCP server");
@@ -379,7 +383,7 @@ tcpClientConnect (tcpClientState *s)
/* tcpClientPortNo returns the portNo from structure s. */
extern "C" int
-tcpClientPortNo (tcpClientState *s)
+EXPORT(tcpClientPortNo) (tcpClientState *s)
{
return s->portNo;
}
@@ -387,7 +391,7 @@ tcpClientPortNo (tcpClientState *s)
/* tcpClientSocketFd returns the sockFd from structure s. */
extern "C" int
-tcpClientSocketFd (tcpClientState *s)
+EXPORT(tcpClientSocketFd) (tcpClientState *s)
{
return s->sockFd;
}
@@ -395,7 +399,7 @@ tcpClientSocketFd (tcpClientState *s)
/* tcpClientIP returns the sockFd from structure s. */
extern "C" int
-tcpClientIP (tcpClientState *s)
+EXPORT(tcpClientIP) (tcpClientState *s)
{
#if defined(DEBUGGING)
printf ("client ip = %s\n", inet_ntoa (s->sa.sin_addr.s_addr));
@@ -407,23 +411,24 @@ tcpClientIP (tcpClientState *s)
/* GNU Modula-2 link fodder. */
extern "C" void
-_M2_sckt_init (int, char *[], char *[])
+M2EXPORT(init) (int, char *[], char *[])
{
}
extern "C" void
-_M2_sckt_finish (int, char *[], char *[])
+M2EXPORT(finish) (int, char *[], char *[])
{
}
extern "C" void
-_M2_sckt_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_sckt_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("sckt", _M2_sckt_init, _M2_sckt_finish,
- _M2_sckt_dep);
+ m2pim_M2RTS_RegisterModule ("sckt", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(finish),
+ M2EXPORT(dep));
}
diff --git a/libgm2/libm2pim/termios.cc b/libgm2/libm2pim/termios.cc
index 55818d2..5812837 100644
--- a/libgm2/libm2pim/termios.cc
+++ b/libgm2/libm2pim/termios.cc
@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <config.h>
#include <m2rts.h>
+#define EXPORT(FUNC) m2pim ## _termios_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_termios_ ## FUNC
+#define M2LIBNAME "m2pim"
+
#if defined(HAVE_STDIO_H)
#include <stdio.h>
#endif
@@ -60,8 +64,6 @@ void _M2_termios_finish (void);
#if defined(HAVE_TERMIOS_H)
-#define EXPORT(X) termios##_##X
-
typedef enum {
vintr,
vquit,
@@ -1964,23 +1966,23 @@ EXPORT (SetChar) (struct termios *t, ControlChar c, char ch)
#endif
extern "C" void
-_M2_termios_init (int, char *[], char *[])
+M2EXPORT(init) (int, char *argv[], char *env[])
{
}
extern "C" void
-_M2_termios_fini (int, char *[], char *[])
+M2EXPORT(fini) (int, char *argv[], char *env[])
{
}
extern "C" void
-_M2_termios_dep (void)
+M2EXPORT(dep) (void)
{
}
extern "C" void __attribute__((__constructor__))
-_M2_termios_ctor (void)
+M2EXPORT(ctor) (void)
{
- M2RTS_RegisterModule ("termios", _M2_termios_init, _M2_termios_fini,
- _M2_termios_dep);
+ m2pim_M2RTS_RegisterModule ("termios", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini), M2EXPORT(dep));
}
diff --git a/libgm2/libm2pim/wrapc.c b/libgm2/libm2pim/wrapc.cc
index 8e35949..0412ccc 100644
--- a/libgm2/libm2pim/wrapc.c
+++ b/libgm2/libm2pim/wrapc.cc
@@ -25,6 +25,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
+#include <m2rts.h>
+
+#define EXPORT(FUNC) m2pim ## _wrapc_ ## FUNC
+#define M2EXPORT(FUNC) m2pim ## _M2_wrapc_ ## FUNC
+#define M2LIBNAME "m2pim"
#if defined(HAVE_MATH_H)
#include <math.h>
@@ -69,11 +74,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* strtime returns the address of a string which describes the
local time. */
-char *
-wrapc_strtime (void)
+extern "C" char *
+EXPORT(strtime) (void)
{
#if defined(HAVE_CTIME)
- time_t clock = time ((void *)0);
+ time_t clock = time (NULL);
char *string = ctime (&clock);
string[24] = (char)0;
@@ -84,8 +89,8 @@ wrapc_strtime (void)
#endif
}
-int
-wrapc_filesize (int f, unsigned int *low, unsigned int *high)
+extern "C" int
+EXPORT(filesize) (int f, unsigned int *low, unsigned int *high)
{
#if defined(HAVE_SYS_STAT_H) && defined(HAVE_STRUCT_STAT)
struct stat s;
@@ -104,8 +109,8 @@ wrapc_filesize (int f, unsigned int *low, unsigned int *high)
/* filemtime returns the mtime of a file, f. */
-int
-wrapc_filemtime (int f)
+extern "C" int
+EXPORT(filemtime) (int f)
{
#if defined(HAVE_SYS_STAT_H) && defined(HAVE_STRUCT_STAT)
struct stat s;
@@ -122,8 +127,8 @@ wrapc_filemtime (int f)
/* fileinode returns the inode associated with a file, f. */
#if defined(HAVE_SYS_STAT_H) && defined(HAVE_STRUCT_STAT)
-ino_t
-wrapc_fileinode (int f, unsigned int *low, unsigned int *high)
+extern "C" ino_t
+EXPORT(fileinode) (int f, unsigned int *low, unsigned int *high)
{
struct stat s;
@@ -140,8 +145,8 @@ wrapc_fileinode (int f, unsigned int *low, unsigned int *high)
return -1;
}
#else
-int
-wrapc_fileinode (int f, unsigned int *low, unsigned int *high)
+extern "C" int
+EXPORT(fileinode) (int f, unsigned int *low, unsigned int *high)
{
*low = 0;
*high = 0;
@@ -151,8 +156,8 @@ wrapc_fileinode (int f, unsigned int *low, unsigned int *high)
/* getrand returns a random number between 0..n-1. */
-int
-wrapc_getrand (int n)
+extern "C" int
+EXPORT(getrand) (int n)
{
return rand () % n;
}
@@ -160,8 +165,8 @@ wrapc_getrand (int n)
#if defined(HAVE_PWD_H)
#include <pwd.h>
-char *
-wrapc_getusername (void)
+extern "C" char *
+EXPORT(getusername) (void)
{
return getpwuid (getuid ())->pw_gecos;
}
@@ -169,8 +174,8 @@ wrapc_getusername (void)
/* getnameuidgid fills in the, uid, and, gid, which represents
user, name. */
-void
-wrapc_getnameuidgid (char *name, int *uid, int *gid)
+extern "C" void
+EXPORT(getnameuidgid) (char *name, int *uid, int *gid)
{
struct passwd *p = getpwnam (name);
@@ -186,22 +191,22 @@ wrapc_getnameuidgid (char *name, int *uid, int *gid)
}
}
#else
-char *
-wrapc_getusername (void)
+extern "C" char *
+EXPORT(getusername) (void)
{
return "unknown";
}
-void
-wrapc_getnameuidgid (char *name, int *uid, int *gid)
+extern "C" void
+EXPORT(getnameuidgid) (char *name, int *uid, int *gid)
{
*uid = -1;
*gid = -1;
}
#endif
-int
-wrapc_signbit (double r)
+extern "C" int
+EXPORT(signbit) (double r)
{
#if defined(HAVE_SIGNBIT)
@@ -213,8 +218,8 @@ wrapc_signbit (double r)
#endif
}
-int
-wrapc_signbitl (long double r)
+extern "C" int
+EXPORT(signbitl) (long double r)
{
#if defined(HAVE_SIGNBITL)
@@ -226,8 +231,8 @@ wrapc_signbitl (long double r)
#endif
}
-int
-wrapc_signbitf (float r)
+extern "C" int
+EXPORT(signbitf) (float r)
{
#if defined(HAVE_SIGNBITF)
@@ -242,8 +247,8 @@ wrapc_signbitf (float r)
/* isfinite provide non builtin alternative to the gcc builtin
isfinite. Returns 1 if x is finite and 0 if it is not. */
-int
-wrapc_isfinite (double x)
+extern "C" int
+EXPORT(isfinite) (double x)
{
#if defined(FP_NAN) && defined(FP_INFINITE)
return (fpclassify (x) != FP_NAN && fpclassify (x) != FP_INFINITE);
@@ -255,8 +260,8 @@ wrapc_isfinite (double x)
/* isfinitel provide non builtin alternative to the gcc builtin
isfinite. Returns 1 if x is finite and 0 if it is not. */
-int
-wrapc_isfinitel (long double x)
+extern "C" int
+EXPORT(isfinitel) (long double x)
{
#if defined(FP_NAN) && defined(FP_INFINITE)
return (fpclassify (x) != FP_NAN && fpclassify (x) != FP_INFINITE);
@@ -268,8 +273,8 @@ wrapc_isfinitel (long double x)
/* isfinitef provide non builtin alternative to the gcc builtin
isfinite. Returns 1 if x is finite and 0 if it is not. */
-int
-wrapc_isfinitef (float x)
+extern "C" int
+EXPORT(isfinitef) (float x)
{
#if defined(FP_NAN) && defined(FP_INFINITE)
return (fpclassify (x) != FP_NAN && fpclassify (x) != FP_INFINITE);
@@ -278,20 +283,27 @@ wrapc_isfinitef (float x)
#endif
}
-/* init/finish are GNU Modula-2 linking fodder. */
+/* GNU Modula-2 linking hooks. */
-void
-_M2_wrapc_init ()
+extern "C" void
+M2EXPORT(init) (int, char **, char **)
{
}
-void
-_M2_wrapc_fini ()
+extern "C" void
+M2EXPORT(fini) (int, char **, char **)
{
}
-void
-_M2_wrapc_ctor ()
+extern "C" void
+M2EXPORT(dep) (void)
{
}
+extern "C" void __attribute__((__constructor__))
+M2EXPORT(ctor) (void)
+{
+ m2pim_M2RTS_RegisterModule ("wrapc", M2LIBNAME,
+ M2EXPORT(init), M2EXPORT(fini),
+ M2EXPORT(dep));
+}