Skip to content

Page 1

The C Programming Language

ND 211149 ND C for ND-500/ND-5000

[Photo: Person using a vintage computer]

    _____  ______
   |  ND  |      |  
   |______| Data | 
          |______|

Scanned by Jonny Oddene for Sintran Data © 2010


Page 2

The C Programming Language

Introduction

C is one of today's most popular programming languages supporting many types of applications on a variety of different computers. Originally, the language was designed by Brian W. Kernighan and Dennis M. Ritchie as a programming language for the UNIX* operating system. C has proven equally well suited for commercial, technical, and scientific applications. The concept for modular programming, efficient language constructs, and an extensive runtime system support are the keys to its success.

In order to provide a high degree of compatibility with other systems, the C language implemented by Norsk Data conforms to the specification described in 'The C Programming Language' by Kernighan and Ritchie, which is generally regarded as C 'Standard'. The implementation of Norsk Data offers useful language extensions and library support for many UNIX system functions, as well as a good integration into the SINTRAN environment (symbolic debug and interfaces to SIBAS, ISAM, FOCUS, and monitor calls).

Features and Benefits

This C implementation is now a standard Norsk Data product, i.e., further development, maintenance, and tuning are done by ND’s R & D department.

The most important goal is to provide a very high degree of compatibility with C implementations on other systems, while allowing the direct use of ND’s standard subsystems. C supports mixing with other languages like FORTRAN, PASCAL, and PLANC, and provides a convenient interface to SIBAS, FOCUS, ISAM, and Monitor-Calls.

C uses the same (CAT) code generator as PASCAL, which has already proven to be highly reliable and efficient. The following points sum up the major features and benefits:

  • High degree of compatibility with other C implementations
  • Full integration with ND’s standard libraries:
    ISAM (indexed sequential access method)
    the SIBAS database system,
    the FOCUS screen-handling system, and
    the monitor-call library
  • PASCAL, FORTRAN, PLANC, and assembler routines may be called
  • A great number of UNIX functions are supported
  • Symbolic debugging allows tracing of execution flow or variables identified by symbolic names
  • Source listing including line numbers, nesting level indicators, and a cross-reference listing through the CROSS command

Additional Features

  • Standard ND user/compiler interface
  • Pointer check, index check, subrange check, and overflow check may be switched on
  • Separate compilation of modules
  • The compiler produces error messages providing line numbers and error reasons
  • In case of runtime errors, information is given about line number and function where the error occurred
  • Possibility to let the preprocessor run alone
  • Preprocessed files can be used as input for the compiler
  • Full separation of code and data
  • Constant expressions within declarations and declarations in local blocks are supported
  • Powerful expression syntax
  • Complex initializations at compile time and runtime
  • Heap allocation is efficiently combined with the ND-500 hardware instructions for heap administration
  • The heap space is dynamically extended at runtime, if necessary
  • Function variables and functions returning structures, structure assignments
  • Enumeration types
  • Inclusion of text from multiple source files and conditional compilation
  • Compiler options set by commands or directives
  • I/O buffering on sequential files
  • Dynamic opening and closing of files during program execution
  • Operations for bit manipulations are part of the language
  • Extensive mathematical functions are available
  • Inline hardware instructions can be used for mathematical functions supported by the ND-500 hardware

*UNIX is a registered trademark of AT&T in the USA and other countries.


Page 3

The C Programming Language

Library functions and header files

The C runtime library contains a set of I/O and file-control routines, character and string handling functions, mathematical functions and general functions.

I/O and File-Control Routines

Function Description Function Names
Get a character from a stream GETC, FGETC, GETCHAR
Get a word or a string from a stream GETS, FGETS, GETW
Push a character back into a stream UNGETC
Put a character into a stream PUTC, FPUTC, PUTCHAR
Put a word or a string into a stream PUTS, FPUTS, PUTW
Create a file CREAT
Open a file/stream OPEN, FOPEN, FREOPEN, FDOPEN
Read from a file/stream READ, FREAD
Write to a file/stream WRITE, FWRITE
Close a file/stream CLOSE, FCLOSE
Assign buffering to a stream SETBUF, SETBUFFER
Flush buffer to the file FFLUSH
Formatted input SCANF, FSCANF, SSCANF
Formatted output PRINTF, FPRINTF, SPRINTF
Set/inspect file pointer LSEEK, FSEEK, REWIND, FTELL
Get file number FILENO
Look if file is binary FISBINARY
Error routines FERROR, EOF, CLEARERR
Print error PERROR
Make a unique file name MKTEMP
Rename a file RENAME
Find if file is a terminal ISATTY
Name of terminal TTYNAME
Number of terminal TTYLSLOT
Name of user currently logged in GETLOGIN
Test if file is accessible ACCESS
Set default file access mode UMASK
Change access mode of a file CHMOD
Get file-descriptor information STAT, LSTAT, FSTAT
Maximum no. of file descriptors GETDTABLESIZE
Duplicate a link to a file descriptor DUP, DUP2
Size of physical file page GETPAGESIZE
User/process identification GETUID, GETPID
Truncate a file to specified length TRUNCATE, FTRUNCATE
Delete a file from a directory UNLINK
New setting of last read/write access UTIMES

Character Handling Functions

Test if character is: Function Names
A letter ISALPHA
An uppercase letter ISUPPER
A lowercase letter ISLOWER
A digit ISDIGIT
A hexadecimal digit ISXDIGIT
Alphanumeric ISALNUM
Space, tab, CR, LF, FF ISSPACE
A punctuation character ISPUNCT
A char. that can be printed ISPRINT
A non-space printing char. ISGRAPH
A control character ISCNTRL
An ASCII character ISASCII
Convert character to: Function Names
Uppercase letter TOUPPER
Lowercase letter TOLOWER
ASCII character TOASCII

Page 4

The C Programming Language

String-handling functions

Function Description
Concatenate strings STRCAT, STRNCAT, STRCATN
Copy string STRCPY, STRNCPY, STRCPYN
Compare strings STRCMP, STRNCMP, STRCMPN
String length STRLEN
Search in string for:
    First/last occurrence of character STRCHR, INDEX, STRRCHR, RINDEX
    First occurrence of any char. from other string STRPBRK
    First chars. also/not in other string STRSPN, STRCSPN
    Text tokens STRTOK
Convert string to long integer value STRTOL

Mathematical functions

Function Description
Sine SIN
Cosine COS
Tangent TAN
Arc sine ASIN
Arc cosine ACOS
Arc tangent ATAN, ATAN2
Hyperbolic sine SINH
Hyperbolic cosine COSH
Hyperbolic tangent TANH
Exponential function EXP
Natural/base10/base2 logarithm LOG, LOG10, LOG2
Square root function SQRT
Integer and real power functions POW, IPOW, DPOW
Absolute integer/real value ABS, FABS
Largest/smallest integer value not greater/less than the argument FLOOR, CEIL
Euclidian distance HYPOT, CABS
Log gamma function GAMMA
Bessel functions J0, J1, JN, Y0, Y1, YN
Error functions ERF, ERFC
Integer part of real values DINT, DINTR
Manipulate parts of real values FREXP, LDEXP, MODF
Modulo function FMOD
Random number generator RAND, SRAND

General functions

Function Description
Convert ASCII to float/integer/long integer ATOF, ATOI, ATOL
Convert float to string ECVT, FCVT, GCVT
Memory allocation MALLOC, CALLOC, REALLOC, FREE
Memory operations MEMCPY, MEMSET, MEMCHR, MEMCMP, MEMCCPY
Swap bytes SWAB
Time routines GETTIMEOFDAY, TIME, FTIME, TIMES CTIME, LOCALTIME, GMTIME, ASCTIME
Suspended process SLEEP
Programming of global jumps SETJMP, LONGJMP
Execution of a SINTRAN command SYSTEM
Call another program EXECVE, EXECLP, EXECVP
Exit from program to operating system EXIT-EXIT

Header files

Description File
Standard input/output STDIO:H
File control FCNTL:H
C runtime errors ERRNO:H
Standard types for system functions TYPES:H
Standard predicates for characters CTYPE:H
Flags for operations on file descriptors FILE:H
File descriptor contents STAT:H
Mathematical functions MATH:H
Definitions for global jumps SETJMP:H
String functions STRING:H
Memory operation functions MEMORY:H
Time definitions TIME:H, TIMEB:H
Definitions for process times in Hz TIMES:H

Page 5

The C Programming Language

Product Description

ND C conforms to the standard description of 'The C Programming Language' by Brian W. Kernighan and Denis M. Ritchie (Prentice-Hall Inc. 1978).

The implemented library functions are, to a very high degree, compatible with those of NDIX and UNIX. At the same time the runtime system supports ND's standard subsystems.

The compiler generates code in standard NRF format that can be loaded by the standard linkage loader.

The compiler is called NC. Together with the standard header files it is contained in a separate user (CAT-NC-500).

Error Detection and Debugging

The ND Symbolic Debugger may be used to debug a C program, performing line-by-line or routine call tracing, tracing the changes of a variable, restricting the legal range and displaying the value of any variable. All communication with the Symbolic Debugger uses the symbolic program names, and program locations are identified by label or line number.

The information used by the Symbolic Debugger is stored separately from the program code, and will not affect the program speed. Thus, the program code being debugged will be exactly equal to a program compiled without the debug information generated, ensuring that the effect of the program is exactly the same. After debugging, no recompilation is required to execute the program in the ordinary manner.

Documentation

C Reference Manual ........................................ ND-60.251 EN


Page 6

Corporate Headquarters

Olaf Helsets vei 6
P.O. Box 6, Bogerud
0623 Oslo 6
Norway
Tel.: +47-2-68000
Telex: 79612 nor da
Telefax: +47-2-726924 (A)
Telefax: +47-2-622696 (A)
New wing:
Tel.: +47-2-622696 (A)
Telefax: +47-2-653916

Norway Offices

Oslo

Olaf Helsets vei 6
Tel.: +47-2-68000 (A)
Telefax: +47-2-726924 (A)

Bergen

Tel.: +47-5-478000
Sandnes/Stavanger
Persviken, tel.: +47-5-33000

Trondheim

Tel.: +47-7-675790
Telefax: +47-7-971926

ND Comtec Head Office

Olaf Helsets vei 6
P.O. Box 9, Bogerud
0621 Oslo 6
Norway
Tel.: +47-2-692000
Telex: 79612 norndc a
Telefax: +47-2-721921 (A)

Sweden

Olaf Helsets vei 6
Demark, tel.: +45-86 265066
West Germany, tel.: +49-89-35110 66268
United Kingdom, tel.: +44-21-225 3644
France, tel.: +33-1-42814868
USA + Canada, tel.: +1-415-3286882

ND Nordic Data AB

Kvarnbergsgatan 2
P.O. Box 273
S-195 42 Upplands Väsby
Sweden
Tel.: +46 8-796 9000
Telex: 6513 75629 nordata s
Telefax: +46-8-760 8627 (A)

Gothenburg

Tel.: +46-31-947670

Malmo

Tel.: +46-40-75010

ND-Silvedata Sweden

85 Sand Sundsvall
Sweden
Tel.: +46-60-153150

Växjö

Tel.: +46-470-18500

Stockholm

Tel.: +46-760 98400

ND Nordic Data A/S

Laurbjergsvej 13
P.O. Box 250
2750 Ballerup
Denmark
Tel.: +45-2-68055
Telefax: +45-2-692644 (A)

Copenhagen

Tel.: +45 2-68255/682100
Århus, tel.: +45-86151796

Aalborg

Tel.: +45-98373216

Finland

ND Nordic Data Ab Oy
Puistokatu 2
00170 Helsinki, Finland
Tel.: +358-0-1342016
Telefax: +358-0-350462

West Germany

NordData GmbH
ThomasstraBe 10-12
638 08 Bad Hornburg v.d.H.
West Germany
Tel.: 049-61771 886
Telefax: 049-61772130 (A)

Berlin

Tel.: +49-30-6207596

Hamburg

Tel.: +49-40-527005

Munich

Tel.: +49-89-337010

Nuremberg

Tel.: +49-911-7337502

Stuttgart

Tel.: +49-711-9817650

Düsseldorf

Tel.: +49-211-512395

Frankfurt

Tel.: +49-69-500003-0

The Netherlands

NDK Norddata Nederland B.V.
Bosweg 45
P.O. Box 500, 3400 AM Nieuwegein
The Netherlands
Tel.: +031-34070801
Telefax: +31-34072400

France

NDK Datawave S.A.S.
Avenue du Jura 01, 210 Ferney-Voltaire
France
Tel.: +33-50 406275
Telefax: +33-50 428845

Switzerland

Norsk Data (Switzerland) S.A.
Chemin du Vidouze 12
CH-1008 Prilly-Lausanne
Switzerland
Tel.: +41-21-25052
Telefax: +41-21-25629 (A)

Geneva

Tel.: +41-22-98900

Glattbrugg (Zurich)

Tel.: +41-1-810003

United Kingdom

Norsk Data Ltd.
Bermvin Velece
Newbury, Berks RG16 8LU
United Kingdom
Tel.: +44-635-36644

London

Tel.: +44-1-586-9905

Manchester

Tel.: +44-61-965-382800

Edinburgh

Tel.: +44-31-558-1661

Ireland

NDK Data Enland Ltd S.A.
IDA Industrial Estate, Sentry Avenue
Dublin 9, Ireland
Tel.: +353-1-37424

USA

Norsk Data N.A., Inc.
Worcestershire Office Park
180 Worcester Park Drive
Worcester MA 01581
USA
Tel.: +1-617-366-6662

France and Italy

Matra Datavoysme S.A.
Paris
Tel.: +33-15-083660

Saudi Arabia

Norsk Data/Advanced Systems Ltd.
Tel.: + 9-651-463021

Pakistan

Norsk Data Pakistan (P) Ltd.
Tel.: +92-5-481846

Thailand

Norsk Data Thai Ltd.
Tel.: +66-2-233-0840

[Logo: ND Norsk Data]