Writing Portable C Code: the SAS Institute Experience

Total Page:16

File Type:pdf, Size:1020Kb

Writing Portable C Code: the SAS Institute Experience Writing Portable C Code: The SAS Institute Experience Richard D. Langston SAS Institute Inc. This paper illustrates how SAS Institute Inc. went the VM family, so the emphasis was placed on per­ about converting a large software system from PL/I formance within OS systems instead of portability. and IBM® 370 assembly language into a new ver­ Of course, the user community quickly recognized sion written almost entirely in C. The paper briefly the usefulness of the VM family and began an alle­ discusses the history of so~tware development at giance to those operating systems that precipitated the Institute, then explains the rationale behind the the Institute's need to convert the SAS System to company's decision to convert to a new language. run under VM. From there, the Institute's experience in writing portable software is discussed. In addition, the pa­ This effort was accomplished while maintaining per touches on the development process the Institute the aforementioned hybrid of languages. Very little used, including the adaptation of software coding PL/I code was added to support VM; most of the standards. system modifications were to the supervisor. There­ fore, most modifications were m_ade in assembly lan­ Let us begin by tracing the history of program­ guage. The conversion goal was to change as small ming language usage at the Institute. SAS® soft­ amount of procedure code as possible and allow the ware was originally implemented for OS-type oper­ supervisor to recognize the environment and deal ating systems (MVT, MFT, MVS, VSl). The SAS with its eccentricities, relieving the procedure writ­ System was implemented using a combination of ers to once again concentrate on their specialties. PL/I and assembly language. The assembly lan­ guage portion was known as the "supervisor" and However, certain aspects of the VM operating was implemented as such for efficiency, speed, code system certainly made their way to the procedure size, and any other characteristic for which assem­ writer's level. For example, the MVS operating sys­ bler is best suited. The PL/I portion of the system tem fills dynamically allocated memory with zeros was that of the procedures (programs written to ac­ before the application receives the pointer to the cess and create data using the supervisor through a memory. The PLjl programmers were sometimes common set of routines). PLjl was chosen here be­ unknowingly taking advantage of this fact by not cause th;: procedures were performing a higher-level initializing variables (whose initial values would be set of functions, such as statistical analysis and re­ zero nonetheless). 0 nly when their procedures were port writing. Procedure writers could spend more tested under VM did this fact arise. This was the time concentrating on the implementation of com­ first of many occurrences of recognizing the differ­ plex algorithms instead of concerning themselvses ence an operating system can make on the perfor­ with how-many base registers to have available. mance of an application that is supposed to be op­ erating system-independent. This hybrid of language served the Institute well until it was decided to transport the SAS System to The conversion for VfVl was accomplished pn­ other operating systems. Recall that at the time the marily by OS simulation"; that is, simulating OS system was first implemented, the IBM OS family of SVCs and control blocks when system calls were operating systems was much more widespread than made. However, when the Institute converted to 26 the DOS JVSE system, the system developers rec­ were available for all the systems. Third, conversion ognized the need for isolating the system-dependent woul-d not be as painful since the procedures were portions of the code so that these could be replaced already in PLjl, albeit using the PL/I Optimizing when moving to a new environment. Once again, Compiler as a base language_ very little of the procedure code had to be changed to function under DOSjVSE. The programming staff quickly discovered that each vendor's implementation of the PLjllanguage The SAS System remained an IBM mainstay was different. As the staff gained experience with through the 82.4 release of the product. The sys­ the compilers, a set of coding standards was adapted tem did not function on any other computers other to ensure that the code would compile on any of the than those within the 370 family (using the oper­ machines. Some of the simpler decisions made were ating systems VSjl, MVS, VMjCMS, DOSjVSE). that such characters as '#' and '@' could not be However, just as the Institute recognized a grow­ used in the names of variables because the ANSI ing force in the user community for the VM family, Standard did not include them. The use of # and @ there was acceptance of the fact that even more in variables was a common practice among the de­ operating systems seemed likely candidates for con­ velopers using the more amiable Optimizing Com­ version. The user community had been asking for piler. Another common practice was incrementing minicomputer support, primarily on Digital Equip­ pointers by overlaying an integer on the pointer and ment Corp.'s VMS® Data General's AOSjVS, and incrementing the integer. This became verboten in Prime's PRIMOS® operating systems. the portable implementation due to pointer sizes on some machines. These are but two of many eXam­ But converting to those operating systems would ples of differences that were dealt with. Striving be much different than converting from MVS to for portability across operating systems became a VMjCMS. After all, the IBM operating systems all common goal among all developers, and this virtue use a common assembly language and PL/I com­ carried on throughout the minicomputer implemen­ piler (not a completely. true statement but relatively tation and is still apparent in the latest design effort speaking, close enough)_ The three minicomputer using the C language. operating systems all had their own assembly lan­ guages and different Pljl compilers (all different The minicomputer and mainframe implementa­ implementations of the ANSI standard), and they tions merged with the advent of the Version 5 SAS were architecturally far removed from the IBM 370 System. The procedure code implemented for the family. A totally new implementation of the SAS minicomputers was also functional on the mainframe System would be needed. And, to simplify this im­ system_ Only the supervisor was different between plementation, the largest possible subset of the sys­ the two systems. The supervisor on all three mini­ tem needed to be implemented in a portable lan­ computer systems was the same, with the exception guage so that the same code would function on all of small amounts of host-dependent code, necessary three minicomputers_ to perform the low-level tasks demanded of a com­ plex system. The final outcome of the design was that the su­ pervisor for the system was wriiten in PLjl. This lan­ As the Version 5 SAS System made its way into guage was chosen for several reasons_ First, almost the user community, the IBM PC was quickly evolv­ all of the Institute programming staff was familiar ing into a viable environment for a system as com­ with it, having written procedures in this language_ plex and expansive as the SAS System. An experi­ Second, the intention was to once again have the mental project began on this microcomputer, using procedures be as portable as possible across oper­ C as the implementation language. C was chosen ating systems (IBM mainframes and the minicom­ because there was not a fully acceptable PLjl com­ puters). At the time, PLjl was the language with piler available for the machine_ C has many charac­ the most power and flexibility for which compilers teristics of Pl/l, so its choice was not an unreason- 27 able one. And its functionality on a microcomputer tion's NOS IVE. The Institute also realized that was well recognized. many other operating systems had C compilers, and if a new implementation would function success­ Once again, the Institute was faced with needs fully on all of the systems currently available to the of the user community that would require massive Institute, new operating systems could be added changes to system implementation. Was it better expediently and with much less "pain" than with to develop a system written in ( solely for the P( VM/(MS, DOS/VSE, or the minicomputers using' environment, similar to the Version 5 PLjl system PL/L written for the minicomputers? It was decided that the best approach was to rewrite the entire system Most developers accepted the ( language quite tn C in such a way that it would be portable across readily. As stated earlier, there are' similarities be­ all operating systems, so that minimal reimplemen­ tween PL/I and C. The most obvious are the use tat ion would be necessary when stili more computer of semicolons as statement ddimiters and j* * j as systems became viable as environments for the SAS comment delimiters. My own experience with learn­ System. ing C was that it was initially a "step down" from PL/I; the string-handling capabilities of ( are min­ The biggest problem with this decision was com­ imal, and it has the feel of a low-level language, piler availability. All of the minicomputers on which unlike PL/I. However, as more developers began to . the SAS System ran had good ( compilers, anq convert to the new language, more subroutines and there were several available on the IBM Pc. How­ macros were created and C began to have the look ever, such was not the case for the IBM mainframe.
Recommended publications
  • C Programmer's Manual
    C PROGRAMMER'S MANUAL CGC 7900 SERIES COLOR GRAPHICS COMPUTERS Whitesmiths, Ltd. C PROGRAMMERS' MANUAL Release: 2.1 Date: Ma rch 1982 The C language was developed at Bell Laboratories by Dennis Ritchie; Whitesmiths, Ltd. has endeavored to remain as faithful as possible to his language specification. The external specifications of the Idris operating system, and of most of its utilities, are based heavily on those of UNIX, which was also developed at Bell Labora­ tories by Dennis Ritchie" and Ken Thompson. Whi tesmi ths, Ltd. grate­ fully acknowledges the parentage of many of the concepts we have commercialized, and we thank Western Electric Co. for waiving patent licensing fees for use of the UNIX protection mechanism. The successful implementation of Whi tesmi ths r compilers, operating systems, and utilities, however, is entirely the work of our pro­ gramming staff and allied consultants. For the record, UNIX is a trademark of Bell Laboratories; lAS, PDP-11, RSTS/E, RSX-11M, RT-11, VAX, VMS, and nearly every other term with an 11 in it all are trademarks of Digital Equipment Cor­ poration; CP/M is a trademark of Digital Research Co.; MC68000 and VERSAdos are trademarks of Motorola Inc.; ISIS is a trademark of In­ tel Corporation; A-Natural and Idris are trademarks of Whitesmiths, Ltd. C is not. Copyright (c) 1978, 1979, 1980, 1981 by Whitesmiths, Ltd. C PROGRAMMERS' MANUAL SECTIONS I. The C Languag-e II. Portable C Runtime Library III. C System Interface Library IV. C Machine Interface Library SCOPE This manual describes the C programming language, as implemented by Whitesmiths, Ltd., and the various library routines that make up the machine independent C environment.
    [Show full text]
  • COSMIC C Cross Compiler for Motorola 68HC11 Family
    COSMIC C Cross Compiler for Motorola 68HC11 Family COSMIC’s C cross compiler, cx6811 for the Motorola 68HC11 family of microcontrollers, incorporates over twenty years of innovative design and development effort. In the field since 1986 and previously sold under the Whitesmiths brand name, cx6811 is reliable, field-tested and incorporates many features to help ensure your embedded 68HC11 design meets and exceeds performance specifications. The C Compiler package for Windows includes: COSMIC integrated development environment (IDEA), optimizing C cross compiler, macro assembler, linker, librarian, object inspector, hex file generator, object format converters, debugging support utilities, run-time libraries and a compiler command driver. The PC compiler package runs under Windows 95/98/ME/NT4/2000 and XP. Complexity of a more generic compiler. You also get header Key Features file support for many of the popular 68HC11 peripherals, so Supports All 68HC11 Family Microcontrollers you can access their memory mapped objects by name either ANSI C Implementation at the C or assembly language levels. Extensions to ANSI for Embedded Systems ANSI / ISO Standard C Global and Processor-Specific Optimizations This implementation conforms with the ANSI and ISO Optimized Function Calling Standard C specifications which helps you protect your C support for Internal EEPROM software investment by aiding code portability and reliability. C support for Direct Page Data C Runtime Support C support for Code Bank Switching C runtime support consists of a subset of the standard ANSI C support for Interrupt Handlers library, and is provided in C source form with the binary Three In-Line Assembly Methods package so you are free to modify library routines to match User-defined Code/Data Program Sections your needs.
    [Show full text]
  • The User's Column, December 1980, BYTE Magazine
    BASIC, Computer Languages, and Computer Adventures Jerry Pournelle c/ o BYTE Publications 70 Main St Peterborough NH 03458 It's a typical Sunday afternoon here at Chaos Manor. new users become familiar with the way computers In one room a dozen kids are playing games on the Radio think, became studded with features. Every time you Shack TRS-80, while here in the office I've been playing turned around there was a new BASIC interpreter, each about with the C programming language after adding a one larger than the last, and almost none of them com­ check-writer to my accounting programs. My wife, the patible with each other. Whatever portability BASIC had only practical member of the family, gently reminds me enjoyed vanished in a myriad of disk operations, func­ of my deadlines: galley proofs of a new novel, King tions, WHILE statements, new input formats, etc, etc, David's Spaceship (Simon and Schuster); two chapters of and, at the same time, the "free" memory left over after the latest Niven/ Pournelie collaboration, Oath of Fealty loading BASIC got so small that you couldn't handle (Simon and Schuster, Real Soon Now); plus three col­ much data. umns; a speech to a librarians' convention; and inputs for The logical end of that process is Microsoft's newest a NASA study on America's fifty-year space plan. Some BASIC-BO. Understand, it's an excellent BASIC. It has business people worry about cash flow; for authors it's features that, not long ago, the most advanced languages work flow-work comes in bunches, like bananas, and didn't have.
    [Show full text]
  • Comparing UNIX with Other Systems
    Comparing UNIX with other systems Timothy DO' Chase Corporate Computer systems, Inc. 33 West Main Street Holmdel, New Jersey he original concept behind this article was to make a grand comparison between UNIX Tand several other well known systems. This was to beall encompassing and packed with vital information summarized in neat charts, tables and graphs. As the work began, the realization settled in that this was not only difficult to do, but would result in a work so boring as to beincomprehensible. The reader, faced with such awealth ofinformation would be lost at best. Conclusions would be difficult to draw and, in short, the result would be worthless. Mtertearfully filling my waste basket with the initial efforts, I regrouped and began by as­ king myself why would anyone be interested in comparing UNIX with another operating system? There appears to be only two answers. First, one might hope to learn something about UNIX by analogy. IfI understand the file system on MPEN and someone tells me that UNIX is like that except for such and so, then I might be more quickly able to under­ stand UNIX. This I felt was an unlikely motivation. After all, there are much simpler ways to learn UNIX. Instead, the motivation for comparing UNIX to other systems must come from a need to evaluate UNIX. Ifwe are aware of the features or short comings ofother systems, then we can benefit by evaluating UNIX relative to those systems. Choosing an operating system or computer is a major decision which we can benefit from or be stuck with for a long time.
    [Show full text]
  • Why Pascal Is Not My Favorite Programming Language
    AT&T Bell Laboratories Murray Hill, New Jersey 07974 Computing Science Technical Report No. 100 Why Pascal is Not My Favorite Programming Language Brian W. Kernighan April 2, 1981 Why Pascal is Not My Favorite Programming Language Brian W. Kernighan AT&T Bell Laboratories Murray Hill, New Jersey 07974 ABSTRACT The programming language Pascal has become the dominant language of instruction in computer science education. It has also strongly influenced lan- guages developed subsequently, in particular Ada. Pascal was originally intended primarily as a teaching language, but it has been more and more often recommended as a language for serious programming as well, for example, for system programming tasks and even operating systems. Pascal, at least in its standard form, is just plain not suitable for serious pro- gramming. This paper discusses my personal discovery of some of the reasons why. April 2, 1981 Why Pascal is Not My Favorite Programming Language Brian W. Kernighan AT&T Bell Laboratories Murray Hill, New Jersey 07974 1. Genesis This paper has its origins in two events — a spate of papers that compare C and Pas- cal1, 2, 3, 4 and a personal attempt to rewrite Software Tools5 in Pascal. Comparing C and Pascal is rather like comparing a Learjet to a Piper Cub — one is meant for getting something done while the other is meant for learning — so such comparisons tend to be somewhat farfetched. But the revision of Software Tools seems a more relevant comparison. The programs therein were originally written in Ratfor, a ‘‘structured’’ dialect of Fortran imple- mented by a preprocessor.
    [Show full text]
  • FOREWORD the Attached Paper Appeared As Part of a Workshop Session of Tutorial Lectures Held at the PRO- TEXT I Conference in Late 1984
    FOREWORD The attached paper appeared as part of a Workshop session of tutorial lectures held at the PRO- TEXT I Conference in late 1984. The lecture was an informal presentation telling the story of how the University of Nottingham equipped itself — just prior to the era of PostScript and “desk- top publishing” — to typeset all of its examination papers ‘in house’. On a personal level, my vol- unteering to lead this project triggered an interest in computerised typesetting which later devel- oped into a new direction in my computer science research interests. This ‘new direction’ has now lasted for more than 20 years and has grown to encompass almost all aspects of a subject now called ‘document engineering’. The paper is of some historical interest, if only to note that the equipment we used cost us the staggering sum of £80,000 in 1982. Nowadays comparable quality, and much greater speed, could be obtained from a computer and laser-printer combination costing about one twentieth of that amount. The key factors in the success of our project, in those very early days, were the willingness of the University not only to buy the necessary typesetters and computers but also to purchase a source code licence for the device-independent version of troff. This latter item, at £4000, was not cheap but it has done sterling service and is still in use, some 20 years later, in the School of Computer Science. Above all, the device independent troff, (unlike the original version of troff which was for the second-generation GSI CAT typesetter only) proved to be readily adaptable to a variety of typesetters and laser-printers.
    [Show full text]
  • LIFE with UNIX a Guide for Everyone
    LIFE WITH UNIX LIFE WITH UNIX A Guide For Everyone Don Libes & Sandy Ressler PRENTICE HALL, Englewood Cliffs, New Jersey 07632 Library of Congress Cataloging in Publication Data Life with UNIX, A Guide For Everyone UNIX is a registered trademark of AT&T. Production: Sophie Papanikolaou Cover production: Eloise Starkweather Cover design: Lundgren Graphics, Ltd. Cover artwork: Sandy Ressler Marketing: Mary Franz Life With UNIX was edited and composed with Frame Maker on a Sun Microsystems work- station running UNIX. Camera-ready copy was prepared on a Linotronic 100P by Profession- al Fast-Print Corporation using PostScript files generated by Frame Maker. 1989 by Prentice-Hall, Inc. A division of Simon & Schuster Englewood Cliffs, New Jersey 07632 All rights reserved. No part of this book may be reproduced, in any form or by any means, without written permission from the publisher. Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 Prentice-Hall International (UK) Limited, London Prentice-Hall of Australia Pty. Limited, Sydney Prentice-Hall Canada Inc., Toronto Prentice-Hall Hispanoamericana, S.A., Mexico Prentice-Hall of India Priviate Limited, New Delhi Prentice-Hall of Japan, Inc., Tokyo Simon & Schuster Asia Pte. Ltd., Singapore Editora Prentice-Hall do Brasil, Ltda., Rio de Janeiro To our loving families Contents Preface .................................................................................................................. xiii How To Read This Book ......................................................................................xvii
    [Show full text]
  • Apply Principles of Creating Computer Software by Developing a Complete Programme to Meet Given Business Specifications 115392
    APPLY PRINCIPLES OF CREATING COMPUTER SOFTWARE BY DEVELOPING A COMPLETE PROGRAMME TO MEET GIVEN BUSINESS SPECIFICATIONS 115392 PURPOSE OF THE UNIT STANDARD This unit standard is intended: To provide a expert knowledge of the areas covered For those working in, or entering the workplace in the area of Systems Development To demonstrate an understanding of how to create (in the computer language of choice) a complete computer program that will solve a given business problem, showing all the steps involved in creating computer software People credited with this unit standard are able to: Interpret a given specification to plan a computer program solution Design a computer program to meet a business requirement Create a computer program that implements the design Test a computer program against the business requirements Implement the program to meet business requirements Document the program according to industry standards The performance of all elements is to a standard that allows for further learning in this area. LEARNING ASSUMED TO BE IN PLACE AND RECOGNITION OF PRIOR LEARNING The credit value of this unit is based on a person having the prior knowledge and skills to: Apply the principles of Computer Programming Design, develop and test computer program segments to given specifications UNIT STANDARD RANGE N/A INDEX NC: IT: SYSTEMS DEVELOPMENT AUTHOR: LEARNER MANUAL REL DATE: 27/01/2020 REV DATE: 01/01/2023 DOC REF: 48872 LM MOD 3 V-1 PAGE 260 Competence Requirements Page Unit Standard 115392 alignment index Here you will find the different outcomes explained which you need to be proved 261 competent in, in order to complete the Unit Standard 115392.
    [Show full text]
  • The History of Solaris
    32 2593 AppC 9/19/01 12:55 PM Page 895 APPENDIX C The History of Solaris UNIX is plural. It is not one operating system but, HOW IT ALL BEGAN many implementations of an idea that originated in 1965. As a system administrator, you need to under- It all began at Bell Labs, the research lab of AT&T, one stand the history of the UNIX operating system— of the largest and most powerful companies of our where it came from, how it was built, and where it is time. Ironically, AT&T was not interested in develop- now. Understanding the various versions of UNIX and ing and selling computers or operating systems. In fact, its origins makes it clear why UNIX became known as the U.S. Department of Justice did not allow AT&T to a somewhat hostile operating system. For example, sell software. However, AT&T’s existing systems, made UNIX was not developed by a single company with a up of people and paper, were in danger of being over- large marketing organization driving the user interface. whelmed in the boom of the 1960s. By the 1970s, the (In other words, it did not follow the development phone business was in jeopardy. Out of desperation path of, say, Microsoft Windows.) On the other hand, and need, Ken Thompson of AT&T set out to develop UNIX was not invented by hackers who were fooling what no computer company was ready to provide—a around; it grew out of strong academic roots. The pri- multiuser, multiprocessing operating system to be used mary contributors to UNIX were highly educated in-house for its own information processing depart- mathematicians and computer scientists employed by ment.
    [Show full text]
  • Rationale for International Standard - Programming Language - C
    Rationale for International Standard - Programming Language - C UNIX is a trademark of X/Open Co., Ltd.. DEC and PDP-11 are trademarks of Digital Equipment Corporation. POSIX is a trademark of IEEE. CONTENTS 0. Introduction..........................................................................................................................1 0.1 Organization of the document .........................................................................................5 1. Scope ...................................................................................................................................6 2. Normative References...........................................................................................................6 3. Terms and definitions............................................................................................................6 4. Conformance........................................................................................................................7 5. Environment.........................................................................................................................8 5.1 Conceptual models..........................................................................................................8 5.1.1 Translation environment...........................................................................................9 5.1.2 Execution environments .........................................................................................10 5.2 Environmental considerations........................................................................................12
    [Show full text]
  • Rationale for International Standard— Programming Languages— C
    Rationale for International Standard— Programming Languages— C Revision 5.10 April-2003 UNIX is a trademark of The Open Group. POSIX is a trademark of IEEE. Contents 0. Introduction ............................................................................................................................1 0.1 Organization of the document ......................................................................................5 1. Scope ......................................................................................................................................7 2. Normative References............................................................................................................9 5 3. Terms and definitions...........................................................................................................11 4. Conformance ........................................................................................................................13 5. Environment.........................................................................................................................15 5.1 Conceptual models......................................................................................................15 5.1.1 Translation environment.................................................................................15 10 5.1.2 Execution environments .................................................................................17 5.2 Environmental considerations....................................................................................19
    [Show full text]
  • C Style Long Method Declaration
    C Style Long Method Declaration Phanerogamic Darwin recharged very heftily while Manfred remains pedate and autoradiograph. Is Darrin crined enough,or crocodilian is Dennis after hypoplastic?ergodic Dario beguiles so yea? When Kalle prologuized his bullets surmise not amicably There is likely to c declaration In an extended slice, TORT OR from, white spaces and white lines. Pascal comments in style documentation explicitly relying on. If none of a local to. All methods are stored as they are. Python as long standing usage as an item in style looks like void or resources if this type of styles have one or whether it too. Spacing in a function signature. The method declaration style. As with you closure in Groovy, whereas you evaluate always head the result of a reinterpret_cast back to extinguish original country before using it can ensure portability. Programming style is about practice you organize and document your code. The tendency is to law all variables at home beginning till the method body, union, outlook the arguments can be evaluated by the compiler in grand order. This variant allows null code points. Go on its logical units for your answer. As programs become more complicated, etc. If the description extends over multiple lines, not the waist one. Details should only generally useful universal class names in some machines where content posted every java. Object file name may break introduced inside parenthesis and used for sharing your design an output. Grab a possibly go programs written using angle brackets and declarations, send a save users. This is done by value, when planning based on a single blank line as its contents.
    [Show full text]