Porting M2C Across Different Operating Systems and Platforms
For the porting effort to Plan9 and RISC OS, the M2C project has now obtained a Raspberry Pi embedded computer, pictured below.
Designed for Portability
M2C is designed to be highly portable across different operating systems.
All OS dependent code is provided by two portability libraries
A third platform dependent module will be added for creating a subprocess to invoke the host system's resident C compiler and linker.
The portable fileutils library provides wrappers for file system functions:
- test if a file exists
- test if a file is a directory
- test if a file is a regular file
- obtain a file's size
- obtain a file's last modification time
- obtain the path of the current working directory
The portable pathnames library provides functions to validate, split and compose pathnames:
- validate a pathname
- validate a filename
- split a pathname into its directory path and filename components
- split a filename into its basename and suffix components
- test if a filename's suffix is a Modula-2 source file suffix
- compose a pathname from directory path, basename and suffix
By porting these libraries to a new target OS, M2C will compile and run on that OS.
At present, implementations of these modules exist for AmigaOS, POSIX, OpenVMS and Windows. The POSIX version covers BSD, Linux, MacOS X, Minix, Solaris and other Unix like operating systems. The Windows version should also cover MS-DOS and OS/2.
Support for further host platforms is desirable, some work is under way (see further below).
To facilitate platform testing, the two portability libraries are available for download in the download area. Links are given below:
- fileutils library source code (zip archive, 10 KB)
- pathnames library source code (zip archive, 35 KB)
OSes Supported Thus Far
Thus far, M2C has been built and tested on AmigaOS, BSD, Linux, Mac OS X, OpenVMS and Windows. The Windows port should in principle also work with MS-DOS and OS/2 but this has not been tested.
AmigaOS is the name of an operating system family that runs on modern PowerPC based desktop computers and goes all the way back to the original Commodore Amiga computer. M2C has been ported to AmigaOS with the help of Tom Breeden who is also the author of Aglet Modula-2, a native ISO Modula-2 compiler for AmigaOS.
The modern BSD family of operating systems, most notably FreeBSD, NetBSD and OpenBSD are descendants of the original BSD operating system by Berkeley University. M2C has been built and tested on the BSDs without modification, using the POSIX implementation of the platform dependent libraries.
Cygwin is a Unix user and development environment for the Windows operating system. It provides portability of software written for Unix operating systems to build and run on Windows. The resulting executables require the Cygwin environment to run. Thanks to Martin Brown, M2C has been built and tested under Cygwin without modification, using the POSIX implementation of the platform dependent M2C libraries.
Linux, also referred to as GNU/Linux, is a Unix like operating system based on the Linux kernel by Linus Torvalds and the GNU user environment by the Free Software Foundation. M2C has been built and tested on Ubuntu and Red Hat Linux without modification, using the POSIX implementation of the platform dependent libraries. Furthermore, we will be testing M2C on our Raspberry Pi under Raspbian Linux.
✔ Mac OS X
Max OS X is the operating system for the Macintosh computer family by Apple Inc. It is based on a hybrid kernel consisting of a Mach core and parts from FreeBSD along with a FreeBSD user environment and Apple proprietary GUI and APIs. Most of M2C is being written and tested first on Mac OS X. It has been built with both the GCC and Clang C compilers.
OpenVMS is a family of commercial operating systems that runs on Intel Itanium CPU based servers but goes all the way back to the legendary VAX by Digital Equipment Corporation. The OS is now owned by HPE and it is being ported to the AMD/Intel x86-64 architecture. Thanks to a free shell account from Decuserve.org, a remainder of the former DEC Users Society (DECUS), M2C has been ported to OpenVMS and tested under OpenVMS/Alpha V.8.3.
Windows is the world's most commonly used desktop computer operating system by Microsoft Corp. M2C has been ported to Windows with the help of Frank Schonjans, who is the author of the ISO Modula-2 based MedCalc software. The C compiler of Visual Studio 2015 was used for this port. For the Windows port using GCC, see Cygwin.
Work In Progress
Work on support for Plan9 and RISC OS is now under way.
✰ Plan9 (from Bell Labs)
Plan9 is the next generation of Unix from the original designers of Unix at Bell Labs. The OS is based on a distributed architecture and its GUI was inspired by Niklaus Wirth's Oberon system. It runs on off-the-shelf Intel PC hardware and even more interestingly, there is a ready made install image for the Raspberry Pi single-board computer. We will be doing the porting of M2C on a Raspberry Pi.
✰ RISC OS
RISC OS is the original operating system for the ARM CPU, developed by the designers of ARM. It was used for the British Acorn RISC PCs in the 1980s and 1990s and has since been used in embedded applications. It features its own GUI and development can be done directly under RISC OS. We will be doing the porting of M2C on a Raspberry Pi.
OSes on Our TO DO List
We will further ensure portability for Minix and QNX.
Minix is a Unix like operating system by Andrew Tannenbaum at the University of Amsterdam. Originally designed as an OS for teaching operating system design at the university, its latest incarnation is a fault-tolerant and secure operating system kernel whose development was commissioned by the EU with a NetBSD user environment. M2C is likely to build and run out of the box using the POSIX implementation of its OS dependent libraries but this has not been tested yet.
QNX is a commercial Real-Time OS for embedded devices, used in industrial applications, medical devices, cars and other critical equipment. Unlike many other RTOS, QNX also features a fully operational GUI and development can be done directly under QNX. We have been granted a non-commercial license and will start porting M2C to QNX once we have obtained a suitable embedded development board.
OSes on Our Wish List
Further OSes we would like M2C to build and run on are FreeMint, Haiku, LynxOS, NSK and zOS.
✘ FreeMint (AtariTOS)
FreeMint is a modern open source implementation of the original Atari TOS for Atari desktop computers of the 1980s and 1990s. Since it requires custom hardware which is difficult to come by, we will rely on a volunteer from the FreeMint community to come forward and do the porting work, or at least the testing.
✘ Haiku (BeOS)
Haiku is a modern open source implementation of the original BeOS operating system from the 1990s. Although it does run on off-the-shelf Intel PC hardware, we will rely on a volunteer from the Haiku community to come forward and do the porting work, or at least the testing.
LynxOS is a commercial Real-Time OS for embedded devices, used in industrial, defence and aerospace applications. It is POSIX compliant and widely compatible with Linux. M2C should therefore build and run without modifications but we will require a non-commercial license for a test environment.
✘ NSK (NonStop Kernel)
NSK, short for NonStop Kernel is the operating system that runs on the world's most reliable computer system, the Tandem Architecture, now owned by HPE. It is a massive parallel architecture where everything is hot-swappable: CPUs, RAM, storage and power supplies. Repairs and operating system upgrades are carried out while the system is running. It is truly non-stop. Unfortunately, only large corporations can afford one and we will therefore rely on a corporate sponsor for system access in order to port M2C.
zOS is IBM's mainframe operating system widely used in commerce by large corporations. As with NSK, we will rely on a corporate sponsor for system access in order to port M2C.
For those who would like to build and run M2C under legacy systems such as CP/M, classic MacOS, MPE, OS-9, RSTS, RSX-11, RT-11 and VAX/VMS the challenge will be the lack of a modern C compiler. Although it is in princple possible to modify M2C such that it would compile under ANSI-C and generate ANSI-C, the lack of a modern C compiler serves as a litmus test: If there is no community to whom the system is important enough to maintain a C compiler, then it is doubtful that the system is important enough to justify the effort porting M2C to it. Consequently, we do not consider these systems important enough to become an official work item.
The project is looking for ...
● testers for testing the Windows version of the libs on MS-DOS and OS/2.
● corporate sponsors willing to provide system access to NSK and/or zOS.
● developers willing to help porting the two OS dependent libraries of M2C to FreeMint and/or Haiku.
If you would like to contribute, please get in touch via the M2C project's home page at savannah
or via the M2C project's IRC channel #sgos at Freenode
or via email to the developer or the maintainer
trijezdci (gmail) or sinuhe (gnu.org)