mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-11 05:34:28 +08:00
05652ac4e8
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>
1989 lines
35 KiB
C++
1989 lines
35 KiB
C++
/* termios.cc provide access to the terminal.
|
|
|
|
Copyright (C) 2010-2022 Free Software Foundation, Inc.
|
|
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
|
|
|
|
This file is part of GNU Modula-2.
|
|
|
|
GNU Modula-2 is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
any later version.
|
|
|
|
GNU Modula-2 is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#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
|
|
#if defined(HAVE_STDARG_H)
|
|
#include <stdarg.h>
|
|
#endif
|
|
#if defined(HAVE_STDLIB_H)
|
|
#include <stdlib.h>
|
|
#endif
|
|
#if defined(HAVE_STRING_H)
|
|
#include <string.h>
|
|
#endif
|
|
#if defined(HAVE_STRINGS_H)
|
|
#include <strings.h>
|
|
#endif
|
|
|
|
#ifdef TERMIOS_NEEDS_XOPEN_SOURCE
|
|
#define _XOPEN_SOURCE
|
|
#endif
|
|
|
|
#if defined(HAVE_SYS_TYPES_H)
|
|
#include <sys/types.h>
|
|
#endif
|
|
|
|
#if defined(HAVE_TERMIOS_H)
|
|
#include <termios.h>
|
|
#endif
|
|
|
|
void _M2_termios_init (void);
|
|
void _M2_termios_finish (void);
|
|
|
|
#if defined(HAVE_TERMIOS_H)
|
|
|
|
typedef enum {
|
|
vintr,
|
|
vquit,
|
|
verase,
|
|
vkill,
|
|
veof,
|
|
vtime,
|
|
vmin,
|
|
vswtc,
|
|
vstart,
|
|
vstop,
|
|
vsusp,
|
|
veol,
|
|
vreprint,
|
|
vdiscard,
|
|
vwerase,
|
|
vlnext,
|
|
veol2
|
|
} ControlChar;
|
|
|
|
typedef enum {
|
|
/* Input flag bits. */
|
|
ignbrk,
|
|
ibrkint,
|
|
ignpar,
|
|
iparmrk,
|
|
inpck,
|
|
istrip,
|
|
inlcr,
|
|
igncr,
|
|
icrnl,
|
|
iuclc,
|
|
ixon,
|
|
ixany,
|
|
ixoff,
|
|
imaxbel,
|
|
/* Output flag bits. */
|
|
opost,
|
|
olcuc,
|
|
onlcr,
|
|
ocrnl,
|
|
onocr,
|
|
onlret,
|
|
ofill,
|
|
ofdel,
|
|
onl0,
|
|
onl1,
|
|
ocr0,
|
|
ocr1,
|
|
ocr2,
|
|
ocr3,
|
|
otab0,
|
|
otab1,
|
|
otab2,
|
|
otab3,
|
|
obs0,
|
|
obs1,
|
|
off0,
|
|
off1,
|
|
ovt0,
|
|
ovt1,
|
|
/* Baud rate. */
|
|
b0,
|
|
b50,
|
|
b75,
|
|
b110,
|
|
b135,
|
|
b150,
|
|
b200,
|
|
b300,
|
|
b600,
|
|
b1200,
|
|
b1800,
|
|
b2400,
|
|
b4800,
|
|
b9600,
|
|
b19200,
|
|
b38400,
|
|
b57600,
|
|
b115200,
|
|
b240400,
|
|
b460800,
|
|
b500000,
|
|
b576000,
|
|
b921600,
|
|
b1000000,
|
|
b1152000,
|
|
b1500000,
|
|
b2000000,
|
|
b2500000,
|
|
b3000000,
|
|
b3500000,
|
|
b4000000,
|
|
maxbaud,
|
|
crtscts,
|
|
/* Character size. */
|
|
cs5,
|
|
cs6,
|
|
cs7,
|
|
cs8,
|
|
cstopb,
|
|
cread,
|
|
parenb,
|
|
parodd,
|
|
hupcl,
|
|
clocal,
|
|
/* Local flags. */
|
|
lisig,
|
|
licanon,
|
|
lxcase,
|
|
lecho,
|
|
lechoe,
|
|
lechok,
|
|
lechonl,
|
|
lnoflsh,
|
|
ltopstop,
|
|
lechoctl,
|
|
lechoprt,
|
|
lechoke,
|
|
lflusho,
|
|
lpendin,
|
|
liexten
|
|
} Flag;
|
|
|
|
/* Prototypes. */
|
|
extern "C" void *EXPORT (InitTermios) (void);
|
|
extern "C" void *EXPORT (KillTermios) (struct termios *p);
|
|
extern "C" int EXPORT (cfgetospeed) (struct termios *t);
|
|
extern "C" int EXPORT (cfgetispeed) (struct termios *t);
|
|
extern "C" int EXPORT (cfsetospeed) (struct termios *t, unsigned int b);
|
|
extern "C" int EXPORT (cfsetispeed) (struct termios *t, unsigned int b);
|
|
extern "C" int EXPORT (cfsetspeed) (struct termios *t, unsigned int b);
|
|
extern "C" int EXPORT (tcgetattr) (int fd, struct termios *t);
|
|
extern "C" int EXPORT (tcsetattr) (int fd, int option, struct termios *t);
|
|
extern "C" void EXPORT (cfmakeraw) (struct termios *t);
|
|
extern "C" int EXPORT (tcsendbreak) (int fd, int duration);
|
|
extern "C" int EXPORT (tcdrain) (int fd);
|
|
extern "C" int EXPORT (tcflushi) (int fd);
|
|
extern "C" int EXPORT (tcflusho) (int fd);
|
|
extern "C" int EXPORT (tcflushio) (int fd);
|
|
extern "C" int EXPORT (tcflowoni) (int fd);
|
|
extern "C" int EXPORT (tcflowoffi) (int fd);
|
|
extern "C" int EXPORT (tcflowono) (int fd);
|
|
extern "C" int EXPORT (tcflowoffo) (int fd);
|
|
extern "C" int EXPORT (GetFlag) (struct termios *t, Flag f, int *b);
|
|
extern "C" int EXPORT (SetFlag) (struct termios *t, Flag f, int b);
|
|
extern "C" int EXPORT (GetChar) (struct termios *t, ControlChar c, char *ch);
|
|
extern "C" int EXPORT (SetChar) (struct termios *t, ControlChar c, char ch);
|
|
extern "C" int EXPORT (tcsnow) (void);
|
|
extern "C" int EXPORT (tcsflush) (void);
|
|
extern "C" int EXPORT (tcsdrain) (void);
|
|
extern "C" int doSetUnset (tcflag_t *bitset, unsigned int mask, int value);
|
|
|
|
/* InitTermios new data structure. */
|
|
|
|
extern "C" void
|
|
*EXPORT (InitTermios) (void)
|
|
{
|
|
struct termios *p = (struct termios *)malloc (sizeof (struct termios));
|
|
|
|
memset (p, 0, sizeof (struct termios));
|
|
return p;
|
|
}
|
|
|
|
/* KillTermios delete data structure. */
|
|
|
|
extern "C" void*
|
|
EXPORT (KillTermios) (struct termios *p)
|
|
{
|
|
free (p);
|
|
return NULL;
|
|
}
|
|
|
|
/* tcsnow return the value of TCSANOW. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcsnow) (void) { return TCSANOW; }
|
|
|
|
/* tcsdrain return the value of TCSADRAIN. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcsdrain) (void) { return TCSADRAIN; }
|
|
|
|
/* tcsflush return the value of TCSAFLUSH. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcsflush) (void) { return TCSAFLUSH; }
|
|
|
|
/* cfgetospeed return output baud rate. */
|
|
|
|
extern "C" int
|
|
EXPORT (cfgetospeed) (struct termios *t) { return cfgetospeed (t); }
|
|
|
|
/* cfgetispeed return input baud rate. */
|
|
|
|
extern "C" int
|
|
EXPORT (cfgetispeed) (struct termios *t) { return cfgetispeed (t); }
|
|
|
|
/* cfsetospeed set output baud rate. */
|
|
|
|
extern "C" int
|
|
EXPORT (cfsetospeed) (struct termios *t, unsigned int b)
|
|
{
|
|
return cfsetospeed (t, b);
|
|
}
|
|
|
|
/* cfsetispeed set input baud rate. */
|
|
|
|
extern "C" int
|
|
EXPORT (cfsetispeed) (struct termios *t, unsigned int b)
|
|
{
|
|
return cfsetispeed (t, b);
|
|
}
|
|
|
|
/* cfsetspeed set input and output baud rate. */
|
|
|
|
extern "C" int
|
|
EXPORT (cfsetspeed) (struct termios *t, unsigned int b)
|
|
{
|
|
int val = cfsetispeed (t, b);
|
|
if (val == 0)
|
|
return cfsetospeed (t, b);
|
|
cfsetospeed (t, b);
|
|
return val;
|
|
}
|
|
|
|
/* tcgetattr get state of, fd, into, t. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcgetattr) (int fd, struct termios *t)
|
|
{
|
|
return tcgetattr (fd, t);
|
|
}
|
|
|
|
/* tcsetattr set state of, fd, to, t, using option. */
|
|
|
|
int EXPORT (tcsetattr) (int fd, int option, struct termios *t)
|
|
{
|
|
return tcsetattr (fd, option, t);
|
|
}
|
|
|
|
/* cfmakeraw sets the terminal to raw mode. */
|
|
|
|
extern "C" void
|
|
EXPORT (cfmakeraw) (struct termios *t)
|
|
{
|
|
#if defined(HAVE_CFMAKERAW)
|
|
return cfmakeraw (t);
|
|
#endif
|
|
}
|
|
|
|
/* tcsendbreak send zero bits for duration. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcsendbreak) (int fd, int duration)
|
|
{
|
|
return tcsendbreak (fd, duration);
|
|
}
|
|
|
|
/* tcdrain waits for pending output to be written on, fd. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcdrain) (int fd) { return tcdrain (fd); }
|
|
|
|
/* tcflushi flush input. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcflushi) (int fd)
|
|
{
|
|
#if defined(TCIFLUSH)
|
|
return tcflush (fd, TCIFLUSH);
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/* tcflusho flush output. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcflusho) (int fd)
|
|
{
|
|
#if defined(TCOFLUSH)
|
|
return tcflush (fd, TCOFLUSH);
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/* tcflushio flush input and output. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcflushio) (int fd)
|
|
{
|
|
#if defined(TCIOFLUSH)
|
|
return tcflush (fd, TCIOFLUSH);
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/* tcflowoni restart input on, fd. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcflowoni) (int fd)
|
|
{
|
|
#if defined(TCION)
|
|
return tcflow (fd, TCION);
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/* tcflowoffi stop input on, fd. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcflowoffi) (int fd)
|
|
{
|
|
#if defined(TCIOFF)
|
|
return tcflow (fd, TCIOFF);
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/* tcflowono restart output on, fd. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcflowono) (int fd)
|
|
{
|
|
#if defined(TCOON)
|
|
return tcflow (fd, TCOON);
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/* tcflowoffo stop output on, fd. */
|
|
|
|
extern "C" int
|
|
EXPORT (tcflowoffo) (int fd)
|
|
{
|
|
#if defined(TCOOFF)
|
|
return tcflow (fd, TCOOFF);
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}
|
|
|
|
/* doSetUnset applies mask or undoes mask depending upon value. */
|
|
|
|
extern "C" int
|
|
doSetUnset (tcflag_t *bitset, unsigned int mask, int value)
|
|
{
|
|
if (value)
|
|
(*bitset) |= mask;
|
|
else
|
|
(*bitset) &= (~mask);
|
|
return 1;
|
|
}
|
|
|
|
/* GetFlag sets a flag value from, t, in, b, and returns TRUE
|
|
if, t, supports, f. */
|
|
|
|
extern "C" int
|
|
EXPORT (GetFlag) (struct termios *t, Flag f, int *b)
|
|
{
|
|
switch (f)
|
|
{
|
|
|
|
case ignbrk:
|
|
#if defined(IGNBRK)
|
|
*b = ((t->c_iflag & IGNBRK) == IGNBRK);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ibrkint:
|
|
#if defined(BRKINT)
|
|
*b = ((t->c_iflag & BRKINT) == BRKINT);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ignpar:
|
|
#if defined(IGNPAR)
|
|
*b = ((t->c_iflag & IGNPAR) == IGNPAR);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case iparmrk:
|
|
#if defined(PARMRK)
|
|
*b = ((t->c_iflag & PARMRK) == PARMRK);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case inpck:
|
|
#if defined(INPCK)
|
|
*b = ((t->c_iflag & INPCK) == INPCK);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case istrip:
|
|
#if defined(ISTRIP)
|
|
*b = ((t->c_iflag & ISTRIP) == ISTRIP);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case inlcr:
|
|
#if defined(INLCR)
|
|
*b = ((t->c_iflag & INLCR) == INLCR);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case igncr:
|
|
#if defined(IGNCR)
|
|
*b = ((t->c_iflag & IGNCR) == IGNCR);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case icrnl:
|
|
#if defined(ICRNL)
|
|
*b = ((t->c_iflag & ICRNL) == ICRNL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case iuclc:
|
|
#if defined(IUCLC)
|
|
*b = ((t->c_iflag & IUCLC) == IUCLC);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ixon:
|
|
#if defined(IXON)
|
|
*b = ((t->c_iflag & IXON) == IXON);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ixany:
|
|
#if defined(IXANY)
|
|
*b = ((t->c_iflag & IXANY) == IXANY);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ixoff:
|
|
#if defined(IXOFF)
|
|
*b = ((t->c_iflag & IXOFF) == IXOFF);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case imaxbel:
|
|
#if defined(IMAXBEL)
|
|
*b = ((t->c_iflag & IMAXBEL) == IMAXBEL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case opost:
|
|
#if defined(OPOST)
|
|
*b = ((t->c_oflag & OPOST) == OPOST);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case olcuc:
|
|
#if defined(OLCUC)
|
|
*b = ((t->c_oflag & OLCUC) == OLCUC);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onlcr:
|
|
#if defined(ONLCR)
|
|
*b = ((t->c_oflag & ONLCR) == ONLCR);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocrnl:
|
|
#if defined(OCRNL)
|
|
*b = ((t->c_oflag & OCRNL) == OCRNL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onocr:
|
|
#if defined(ONOCR)
|
|
*b = ((t->c_oflag & ONOCR) == ONOCR);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onlret:
|
|
#if defined(ONLRET)
|
|
*b = ((t->c_oflag & ONLRET) == ONLRET);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ofill:
|
|
#if defined(OFILL)
|
|
*b = ((t->c_oflag & OFILL) == OFILL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ofdel:
|
|
#if defined(OFDEL)
|
|
*b = ((t->c_oflag & OFDEL) == OFDEL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onl0:
|
|
#if defined(NL0)
|
|
*b = ((t->c_oflag & NL0) == NL0);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onl1:
|
|
#if defined(NL1)
|
|
*b = ((t->c_oflag & NL1) == NL1);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr0:
|
|
#if defined(CR0)
|
|
*b = ((t->c_oflag & CR0) == CR0);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr1:
|
|
#if defined(CR1)
|
|
*b = ((t->c_oflag & CR1) == CR1);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr2:
|
|
#if defined(CR2)
|
|
*b = ((t->c_oflag & CR2) == CR2);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr3:
|
|
#if defined(CR3)
|
|
*b = ((t->c_oflag & CR3) == CR3);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab0:
|
|
#if defined(TAB0)
|
|
*b = ((t->c_oflag & TAB0) == TAB0);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab1:
|
|
#if defined(TAB1)
|
|
*b = ((t->c_oflag & TAB1) == TAB1);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab2:
|
|
#if defined(TAB2)
|
|
*b = ((t->c_oflag & TAB2) == TAB2);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab3:
|
|
#if defined(TAB3)
|
|
*b = ((t->c_oflag & TAB3) == TAB3);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case obs0:
|
|
#if defined(BS0)
|
|
*b = ((t->c_oflag & BS0) == BS0);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case obs1:
|
|
#if defined(BS1)
|
|
*b = ((t->c_oflag & BS1) == BS1);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case off0:
|
|
#if defined(FF0)
|
|
*b = ((t->c_oflag & FF0) == FF0);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case off1:
|
|
#if defined(FF1)
|
|
*b = ((t->c_oflag & FF1) == FF1);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ovt0:
|
|
#if defined(VT0)
|
|
*b = ((t->c_oflag & VT0) == VT0);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ovt1:
|
|
#if defined(VT1)
|
|
*b = ((t->c_oflag & VT1) == VT1);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b0:
|
|
#if defined(B0)
|
|
*b = ((t->c_cflag & B0) == B0);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b50:
|
|
#if defined(B50)
|
|
*b = ((t->c_cflag & B50) == B50);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b75:
|
|
#if defined(B75)
|
|
*b = ((t->c_cflag & B75) == B75);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b110:
|
|
#if defined(B110)
|
|
*b = ((t->c_cflag & B110) == B110);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b135:
|
|
#if defined(B134)
|
|
*b = ((t->c_cflag & B134) == B134);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b150:
|
|
#if defined(B150)
|
|
*b = ((t->c_cflag & B150) == B150);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b200:
|
|
#if defined(B200)
|
|
*b = ((t->c_cflag & B200) == B200);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b300:
|
|
#if defined(B300)
|
|
*b = ((t->c_cflag & B300) == B300);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b600:
|
|
#if defined(B600)
|
|
*b = ((t->c_cflag & B600) == B600);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1200:
|
|
#if defined(B1200)
|
|
*b = ((t->c_cflag & B1200) == B1200);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1800:
|
|
#if defined(B1800)
|
|
*b = ((t->c_cflag & B1800) == B1800);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b2400:
|
|
#if defined(B2400)
|
|
*b = ((t->c_cflag & B2400) == B2400);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b4800:
|
|
#if defined(B4800)
|
|
*b = ((t->c_cflag & B4800) == B4800);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b9600:
|
|
#if defined(B9600)
|
|
*b = ((t->c_cflag & B9600) == B9600);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b19200:
|
|
#if defined(B19200)
|
|
*b = ((t->c_cflag & B19200) == B19200);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b38400:
|
|
#if defined(B38400)
|
|
*b = ((t->c_cflag & B38400) == B38400);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b57600:
|
|
#if defined(B57600)
|
|
*b = ((t->c_cflag & B57600) == B57600);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b115200:
|
|
#if defined(B115200)
|
|
*b = ((t->c_cflag & B115200) == B115200);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b240400:
|
|
#if defined(B230400)
|
|
*b = ((t->c_cflag & B230400) == B230400);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b460800:
|
|
#if defined(B460800)
|
|
*b = ((t->c_cflag & B460800) == B460800);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b500000:
|
|
#if defined(B500000)
|
|
*b = ((t->c_cflag & B500000) == B500000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b576000:
|
|
#if defined(B576000)
|
|
*b = ((t->c_cflag & B576000) == B576000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b921600:
|
|
#if defined(B921600)
|
|
*b = ((t->c_cflag & B921600) == B921600);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1000000:
|
|
#if defined(B1000000)
|
|
*b = ((t->c_cflag & B1000000) == B1000000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1152000:
|
|
#if defined(B1152000)
|
|
*b = ((t->c_cflag & B1152000) == B1152000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1500000:
|
|
#if defined(B1500000)
|
|
*b = ((t->c_cflag & B1500000) == B1500000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b2000000:
|
|
#if defined(B2000000)
|
|
*b = ((t->c_cflag & B2000000) == B2000000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b2500000:
|
|
#if defined(B2500000)
|
|
*b = ((t->c_cflag & B2500000) == B2500000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b3000000:
|
|
#if defined(B3000000)
|
|
*b = ((t->c_cflag & B3000000) == B3000000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b3500000:
|
|
#if defined(B3500000)
|
|
*b = ((t->c_cflag & B3500000) == B3500000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b4000000:
|
|
#if defined(B4000000)
|
|
*b = ((t->c_cflag & B4000000) == B4000000);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case maxbaud:
|
|
#if defined(MAX)
|
|
*b = ((t->c_cflag & __MAX_BAUD) == __MAX_BAUD);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case crtscts:
|
|
#if defined(CRTSCTS)
|
|
*b = ((t->c_cflag & CRTSCTS) == CRTSCTS);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs5:
|
|
#if defined(CS5)
|
|
*b = ((t->c_cflag & CS5) == CS5);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs6:
|
|
#if defined(CS6)
|
|
*b = ((t->c_cflag & CS6) == CS6);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs7:
|
|
#if defined(CS7)
|
|
*b = ((t->c_cflag & CS7) == CS7);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs8:
|
|
#if defined(CS8)
|
|
*b = ((t->c_cflag & CS8) == CS8);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cstopb:
|
|
#if defined(CSTOPB)
|
|
*b = ((t->c_cflag & CSTOPB) == CSTOPB);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cread:
|
|
#if defined(CREAD)
|
|
*b = ((t->c_cflag & CREAD) == CREAD);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case parenb:
|
|
#if defined(PARENB)
|
|
*b = ((t->c_cflag & PARENB) == PARENB);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case parodd:
|
|
#if defined(PARODD)
|
|
*b = ((t->c_cflag & PARODD) == PARODD);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case hupcl:
|
|
#if defined(HUPCL)
|
|
*b = ((t->c_cflag & HUPCL) == HUPCL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case clocal:
|
|
#if defined(CLOCAL)
|
|
*b = ((t->c_cflag & CLOCAL) == CLOCAL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lisig:
|
|
#if defined(ISIG)
|
|
*b = ((t->c_lflag & ISIG) == ISIG);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case licanon:
|
|
#if defined(ICANON)
|
|
*b = ((t->c_lflag & ICANON) == ICANON);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lxcase:
|
|
#if defined(XCASE)
|
|
*b = ((t->c_lflag & XCASE) == XCASE);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lecho:
|
|
#if defined(ECHO)
|
|
*b = ((t->c_lflag & ECHO) == ECHO);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoe:
|
|
#if defined(ECHOE)
|
|
*b = ((t->c_lflag & ECHOE) == ECHOE);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechok:
|
|
#if defined(ECHOK)
|
|
*b = ((t->c_lflag & ECHOK) == ECHOK);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechonl:
|
|
#if defined(ECHONL)
|
|
*b = ((t->c_lflag & ECHONL) == ECHONL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lnoflsh:
|
|
#if defined(NOFLSH)
|
|
*b = ((t->c_lflag & NOFLSH) == NOFLSH);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ltopstop:
|
|
#if defined(TOSTOP)
|
|
*b = ((t->c_lflag & TOSTOP) == TOSTOP);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoctl:
|
|
#if defined(ECHOCTL)
|
|
*b = ((t->c_lflag & ECHOCTL) == ECHOCTL);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoprt:
|
|
#if defined(ECHOPRT)
|
|
*b = ((t->c_lflag & ECHOPRT) == ECHOPRT);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoke:
|
|
#if defined(ECHOKE)
|
|
*b = ((t->c_lflag & ECHOKE) == ECHOKE);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lflusho:
|
|
#if defined(FLUSHO)
|
|
*b = ((t->c_lflag & FLUSHO) == FLUSHO);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lpendin:
|
|
#if defined(PENDIN)
|
|
*b = ((t->c_lflag & PENDIN) == PENDIN);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case liexten:
|
|
#if defined(IEXTEN)
|
|
*b = ((t->c_lflag & IEXTEN) == IEXTEN);
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* SetFlag sets a flag value in, t, to, b, and returns TRUE if
|
|
this flag value is supported. */
|
|
|
|
extern "C" int
|
|
EXPORT (SetFlag) (struct termios *t, Flag f, int b)
|
|
{
|
|
switch (f)
|
|
{
|
|
|
|
case ignbrk:
|
|
#if defined(IGNBRK)
|
|
return doSetUnset (&t->c_iflag, IGNBRK, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ibrkint:
|
|
#if defined(BRKINT)
|
|
return doSetUnset (&t->c_iflag, BRKINT, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ignpar:
|
|
#if defined(IGNPAR)
|
|
return doSetUnset (&t->c_iflag, IGNPAR, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case iparmrk:
|
|
#if defined(PARMRK)
|
|
return doSetUnset (&t->c_iflag, PARMRK, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case inpck:
|
|
#if defined(INPCK)
|
|
return doSetUnset (&t->c_iflag, INPCK, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case istrip:
|
|
#if defined(ISTRIP)
|
|
return doSetUnset (&t->c_iflag, ISTRIP, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case inlcr:
|
|
#if defined(INLCR)
|
|
return doSetUnset (&t->c_iflag, INLCR, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case igncr:
|
|
#if defined(IGNCR)
|
|
return doSetUnset (&t->c_iflag, IGNCR, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case icrnl:
|
|
#if defined(ICRNL)
|
|
return doSetUnset (&t->c_iflag, ICRNL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case iuclc:
|
|
#if defined(IUCLC)
|
|
return doSetUnset (&t->c_iflag, IUCLC, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ixon:
|
|
#if defined(IXON)
|
|
return doSetUnset (&t->c_iflag, IXON, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ixany:
|
|
#if defined(IXANY)
|
|
return doSetUnset (&t->c_iflag, IXANY, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ixoff:
|
|
#if defined(IXOFF)
|
|
return doSetUnset (&t->c_iflag, IXOFF, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case imaxbel:
|
|
#if defined(IMAXBEL)
|
|
return doSetUnset (&t->c_iflag, IMAXBEL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case opost:
|
|
#if defined(OPOST)
|
|
return doSetUnset (&t->c_oflag, OPOST, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case olcuc:
|
|
#if defined(OLCUC)
|
|
return doSetUnset (&t->c_oflag, OLCUC, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onlcr:
|
|
#if defined(ONLCR)
|
|
return doSetUnset (&t->c_oflag, ONLCR, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocrnl:
|
|
#if defined(OCRNL)
|
|
return doSetUnset (&t->c_oflag, OCRNL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onocr:
|
|
#if defined(ONOCR)
|
|
return doSetUnset (&t->c_oflag, ONOCR, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onlret:
|
|
#if defined(ONLRET)
|
|
return doSetUnset (&t->c_oflag, ONLRET, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ofill:
|
|
#if defined(OFILL)
|
|
return doSetUnset (&t->c_oflag, OFILL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ofdel:
|
|
#if defined(OFDEL)
|
|
return doSetUnset (&t->c_oflag, OFDEL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onl0:
|
|
#if defined(NL0)
|
|
return doSetUnset (&t->c_oflag, NL0, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case onl1:
|
|
#if defined(NL1)
|
|
return doSetUnset (&t->c_oflag, NL1, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr0:
|
|
#if defined(CR0)
|
|
return doSetUnset (&t->c_oflag, CR0, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr1:
|
|
#if defined(CR1)
|
|
return doSetUnset (&t->c_oflag, CR1, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr2:
|
|
#if defined(CR2)
|
|
return doSetUnset (&t->c_oflag, CR2, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ocr3:
|
|
#if defined(CR3)
|
|
return doSetUnset (&t->c_oflag, CR3, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab0:
|
|
#if defined(TAB0)
|
|
return doSetUnset (&t->c_oflag, TAB0, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab1:
|
|
#if defined(TAB1)
|
|
return doSetUnset (&t->c_oflag, TAB1, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab2:
|
|
#if defined(TAB2)
|
|
return doSetUnset (&t->c_oflag, TAB2, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case otab3:
|
|
#if defined(TAB3)
|
|
return doSetUnset (&t->c_oflag, TAB3, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case obs0:
|
|
#if defined(BS0)
|
|
return doSetUnset (&t->c_oflag, BS0, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case obs1:
|
|
#if defined(BS1)
|
|
return doSetUnset (&t->c_oflag, BS1, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case off0:
|
|
#if defined(FF0)
|
|
return doSetUnset (&t->c_oflag, FF0, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case off1:
|
|
#if defined(FF1)
|
|
return doSetUnset (&t->c_oflag, FF1, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ovt0:
|
|
#if defined(VT0)
|
|
return doSetUnset (&t->c_oflag, VT0, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ovt1:
|
|
#if defined(VT1)
|
|
return doSetUnset (&t->c_oflag, VT1, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b0:
|
|
#if defined(B0)
|
|
return doSetUnset (&t->c_cflag, B0, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b50:
|
|
#if defined(B50)
|
|
return doSetUnset (&t->c_cflag, B50, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b75:
|
|
#if defined(B75)
|
|
return doSetUnset (&t->c_cflag, B75, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b110:
|
|
#if defined(B110)
|
|
return doSetUnset (&t->c_cflag, B110, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b135:
|
|
#if defined(B134)
|
|
return doSetUnset (&t->c_cflag, B134, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b150:
|
|
#if defined(B150)
|
|
return doSetUnset (&t->c_cflag, B150, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b200:
|
|
#if defined(B200)
|
|
return doSetUnset (&t->c_cflag, B200, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b300:
|
|
#if defined(B300)
|
|
return doSetUnset (&t->c_cflag, B300, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b600:
|
|
#if defined(B600)
|
|
return doSetUnset (&t->c_cflag, B600, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1200:
|
|
#if defined(B1200)
|
|
return doSetUnset (&t->c_cflag, B1200, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1800:
|
|
#if defined(B1800)
|
|
return doSetUnset (&t->c_cflag, B1800, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b2400:
|
|
#if defined(B2400)
|
|
return doSetUnset (&t->c_cflag, B2400, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b4800:
|
|
#if defined(B4800)
|
|
return doSetUnset (&t->c_cflag, B4800, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b9600:
|
|
#if defined(B9600)
|
|
return doSetUnset (&t->c_cflag, B9600, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b19200:
|
|
#if defined(B19200)
|
|
return doSetUnset (&t->c_cflag, B19200, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b38400:
|
|
#if defined(B38400)
|
|
return doSetUnset (&t->c_cflag, B38400, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b57600:
|
|
#if defined(B57600)
|
|
return doSetUnset (&t->c_cflag, B57600, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b115200:
|
|
#if defined(B115200)
|
|
return doSetUnset (&t->c_cflag, B115200, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b240400:
|
|
#if defined(B230400)
|
|
return doSetUnset (&t->c_cflag, B230400, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b460800:
|
|
#if defined(B460800)
|
|
return doSetUnset (&t->c_cflag, B460800, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b500000:
|
|
#if defined(B500000)
|
|
return doSetUnset (&t->c_cflag, B500000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b576000:
|
|
#if defined(B576000)
|
|
return doSetUnset (&t->c_cflag, B576000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b921600:
|
|
#if defined(B921600)
|
|
return doSetUnset (&t->c_cflag, B921600, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1000000:
|
|
#if defined(B1000000)
|
|
return doSetUnset (&t->c_cflag, B1000000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1152000:
|
|
#if defined(B1152000)
|
|
return doSetUnset (&t->c_cflag, B1152000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b1500000:
|
|
#if defined(B1500000)
|
|
return doSetUnset (&t->c_cflag, B1500000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b2000000:
|
|
#if defined(B2000000)
|
|
return doSetUnset (&t->c_cflag, B2000000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b2500000:
|
|
#if defined(B2500000)
|
|
return doSetUnset (&t->c_cflag, B2500000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b3000000:
|
|
#if defined(B3000000)
|
|
return doSetUnset (&t->c_cflag, B3000000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b3500000:
|
|
#if defined(B3500000)
|
|
return doSetUnset (&t->c_cflag, B3500000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case b4000000:
|
|
#if defined(B4000000)
|
|
return doSetUnset (&t->c_cflag, B4000000, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case maxbaud:
|
|
#if defined(__MAX_BAUD)
|
|
return doSetUnset (&t->c_cflag, __MAX_BAUD, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case crtscts:
|
|
#if defined(CRTSCTS)
|
|
return doSetUnset (&t->c_cflag, CRTSCTS, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs5:
|
|
#if defined(CS5)
|
|
return doSetUnset (&t->c_cflag, CS5, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs6:
|
|
#if defined(CS6)
|
|
return doSetUnset (&t->c_cflag, CS6, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs7:
|
|
#if defined(CS7)
|
|
return doSetUnset (&t->c_cflag, CS7, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cs8:
|
|
#if defined(CS8)
|
|
return doSetUnset (&t->c_cflag, CS8, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cstopb:
|
|
#if defined(CSTOPB)
|
|
return doSetUnset (&t->c_cflag, CSTOPB, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case cread:
|
|
#if defined(CREAD)
|
|
return doSetUnset (&t->c_cflag, CREAD, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case parenb:
|
|
#if defined(PARENB)
|
|
return doSetUnset (&t->c_cflag, PARENB, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case parodd:
|
|
#if defined(PARODD)
|
|
return doSetUnset (&t->c_cflag, PARODD, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case hupcl:
|
|
#if defined(HUPCL)
|
|
return doSetUnset (&t->c_cflag, HUPCL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case clocal:
|
|
#if defined(CLOCAL)
|
|
return doSetUnset (&t->c_cflag, CLOCAL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lisig:
|
|
#if defined(ISIG)
|
|
return doSetUnset (&t->c_lflag, ISIG, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case licanon:
|
|
#if defined(ICANON)
|
|
return doSetUnset (&t->c_lflag, ICANON, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lxcase:
|
|
#if defined(XCASE)
|
|
return doSetUnset (&t->c_lflag, XCASE, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lecho:
|
|
#if defined(ECHO)
|
|
return doSetUnset (&t->c_lflag, ECHO, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoe:
|
|
#if defined(ECHOE)
|
|
return doSetUnset (&t->c_lflag, ECHOE, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechok:
|
|
#if defined(ECHOK)
|
|
return doSetUnset (&t->c_lflag, ECHOK, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechonl:
|
|
#if defined(ECHONL)
|
|
return doSetUnset (&t->c_lflag, ECHONL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lnoflsh:
|
|
#if defined(NOFLSH)
|
|
return doSetUnset (&t->c_lflag, NOFLSH, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case ltopstop:
|
|
#if defined(TOSTOP)
|
|
return doSetUnset (&t->c_lflag, TOSTOP, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoctl:
|
|
#if defined(ECHOCTL)
|
|
return doSetUnset (&t->c_lflag, ECHOCTL, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoprt:
|
|
#if defined(ECHOPRT)
|
|
return doSetUnset (&t->c_lflag, ECHOPRT, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lechoke:
|
|
#if defined(ECHOKE)
|
|
return doSetUnset (&t->c_lflag, ECHOKE, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lflusho:
|
|
#if defined(FLUSHO)
|
|
return doSetUnset (&t->c_lflag, FLUSHO, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case lpendin:
|
|
#if defined(PENDIN)
|
|
return doSetUnset (&t->c_lflag, PENDIN, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case liexten:
|
|
#if defined(IEXTEN)
|
|
return doSetUnset (&t->c_lflag, IEXTEN, b);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* GetChar sets a CHAR, ch, value from, t, and returns TRUE if
|
|
this value is supported. */
|
|
|
|
extern "C" int
|
|
EXPORT (GetChar) (struct termios *t, ControlChar c, char *ch)
|
|
{
|
|
switch (c)
|
|
{
|
|
|
|
case vintr:
|
|
#if defined(VINTR)
|
|
*ch = t->c_cc[VINTR];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vquit:
|
|
#if defined(VQUIT)
|
|
*ch = t->c_cc[VQUIT];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case verase:
|
|
#if defined(VERASE)
|
|
*ch = t->c_cc[VERASE];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vkill:
|
|
#if defined(VKILL)
|
|
*ch = t->c_cc[VKILL];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case veof:
|
|
#if defined(VEOF)
|
|
*ch = t->c_cc[VEOF];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vtime:
|
|
#if defined(VTIME)
|
|
*ch = t->c_cc[VTIME];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vmin:
|
|
#if defined(VMIN)
|
|
*ch = t->c_cc[VMIN];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vswtc:
|
|
#if defined(VSWTC)
|
|
*ch = t->c_cc[VSWTC];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vstart:
|
|
#if defined(VSTART)
|
|
*ch = t->c_cc[VSTART];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vstop:
|
|
#if defined(VSTOP)
|
|
*ch = t->c_cc[VSTOP];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vsusp:
|
|
#if defined(VSUSP)
|
|
*ch = t->c_cc[VSUSP];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case veol:
|
|
#if defined(VEOL)
|
|
*ch = t->c_cc[VEOL];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vreprint:
|
|
#if defined(VREPRINT)
|
|
*ch = t->c_cc[VREPRINT];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vdiscard:
|
|
#if defined(VDISCARD)
|
|
*ch = t->c_cc[VDISCARD];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vwerase:
|
|
#if defined(VWERASE)
|
|
*ch = t->c_cc[VWERASE];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vlnext:
|
|
#if defined(VLNEXT)
|
|
*ch = t->c_cc[VLNEXT];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case veol2:
|
|
#if defined(VEOL2)
|
|
*ch = t->c_cc[VEOL2];
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/* SetChar sets a CHAR value in, t, and returns TRUE if, c,
|
|
is supported. */
|
|
|
|
extern "C" int
|
|
EXPORT (SetChar) (struct termios *t, ControlChar c, char ch)
|
|
{
|
|
switch (c)
|
|
{
|
|
|
|
case vintr:
|
|
#if defined(VINTR)
|
|
t->c_cc[VINTR] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vquit:
|
|
#if defined(VQUIT)
|
|
t->c_cc[VQUIT] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case verase:
|
|
#if defined(VERASE)
|
|
t->c_cc[VERASE] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vkill:
|
|
#if defined(VKILL)
|
|
t->c_cc[VKILL] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case veof:
|
|
#if defined(VEOF)
|
|
t->c_cc[VEOF] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vtime:
|
|
#if defined(VTIME)
|
|
t->c_cc[VTIME] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vmin:
|
|
#if defined(VMIN)
|
|
t->c_cc[VMIN] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vswtc:
|
|
#if defined(VSWTC)
|
|
t->c_cc[VSWTC] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vstart:
|
|
#if defined(VSTART)
|
|
t->c_cc[VSTART] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vstop:
|
|
#if defined(VSTOP)
|
|
t->c_cc[VSTOP] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vsusp:
|
|
#if defined(VSUSP)
|
|
t->c_cc[VSUSP] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case veol:
|
|
#if defined(VEOL)
|
|
t->c_cc[VEOL] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vreprint:
|
|
#if defined(VREPRINT)
|
|
t->c_cc[VREPRINT] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vdiscard:
|
|
#if defined(VDISCARD)
|
|
t->c_cc[VDISCARD] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vwerase:
|
|
#if defined(VWERASE)
|
|
t->c_cc[VWERASE] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case vlnext:
|
|
#if defined(VLNEXT)
|
|
t->c_cc[VLNEXT] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
case veol2:
|
|
#if defined(VEOL2)
|
|
t->c_cc[VEOL2] = ch;
|
|
return 1;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
extern "C" void
|
|
M2EXPORT(init) (int, char *argv[], char *env[])
|
|
{
|
|
}
|
|
|
|
extern "C" void
|
|
M2EXPORT(fini) (int, char *argv[], char *env[])
|
|
{
|
|
}
|
|
|
|
extern "C" void
|
|
M2EXPORT(dep) (void)
|
|
{
|
|
}
|
|
|
|
extern "C" void __attribute__((__constructor__))
|
|
M2EXPORT(ctor) (void)
|
|
{
|
|
m2pim_M2RTS_RegisterModule ("termios", M2LIBNAME,
|
|
M2EXPORT(init), M2EXPORT(fini), M2EXPORT(dep));
|
|
}
|