Path: utzoo!attcan!uunet!mcvax!hp4nl!eutrc3!eutwc1!wzv!wietse From: wietse@wzv.UUCP (Wietse Venema) Newsgroups: comp.lang.c Subject: Re: How do a write portable programs? Summary: remember VOS Keywords: portable OS interface Message-ID: <141@wzv.UUCP> Date: 8 Sep 88 21:54:05 GMT References: <1056@nmtsun.nmt.edu> Reply-To: wietse@wzv.UUCP (Wietse Venema) Organization: Home (Eindhoven, NL) Lines: 29 In article <1056@nmtsun.nmt.edu> warner@hydrovax.nmt.edu (M. Warner Losh) writes: >How do I write program that are easily protable when I HAVE TO use the >system calls (be they setitimer() or lib$init_timer() or int21()...). Is >there a good and easy way that I can write my programs so that most of the >code never has to be touched when I port? What is the best way of handling >system dependent routines? Assume the whole world is UNIX and then write >UNIX system call emulation on those that aren't? Or should I write >routines that will do some functions (say turn off echo, but that is a bad >example) regardless of how that function gets done. Should I use zillions >of #ifdefs everywhere? or should there be files that contain source code >for only one system? You might take a look at `software tools' by Kernighan and Plauger. It's a little old (1978) and uses a different language (Ratfor), but provides good examples of encapsulating system-dependent code in a small collection of interface routines. I must admit that this portable interface is patterned after the standard UNIX programming interface. These ideas have been elaborated by some people (at Berkeley?) and resulted in VOS, a virtual operating system. Basically, it is a thin layer of routines that map requests to system calls of the local OS. Porting software then becomes a matter of writing an appropriate VOS implementation. Wietse -- work: wswietse@eutrc3.uucp | Eindhoven University of Technology ditto: wswietse@heitue5.bitnet | Mathematics and Computing Science home: wietse@wzv.uucp | 5600 MB Eindhoven, The Netherlands