Open System Services Porting Guide (G06.24+, H06.03+)
Table Of Contents
- What’s New in This Manual
- About This Manual
- 1 Introduction to Porting
- 2 The Development Environment
- 3 Useful Porting Tools
- 4 Interoperating Between User Environments
- Purpose of Interoperability
- The OSS User Environment
- OSS Commands for the Guardian User
- Guardian Commands for the UNIX User
- OSS Pathname and Guardian Filename Conversions
- Running the OSS Shell and Commands From TACL
- Running Guardian Commands From the OSS Shell
- Running OSS Processes With Guardian Attributes
- Using OSS Commands to Manage Guardian Objects
- 5 Interoperating Between Programming Environments
- 6 OSS Porting Considerations
- 7 Porting UNIX Applications to the OSS Environment
- 8 Migrating Guardian Applications to the OSS Environment
- General Migration Guidelines
- C Compiler Issues for Guardian Programs
- Using New and Extended Guardian Procedures
- Using OSS Functions in a Guardian Program
- Interoperating With OSS Programs
- Starting an OSS Program From the Guardian Environment
- C Compiler Considerations for OSS Programs
- Porting a Guardian Program to the OSS Environment
- How Arguments Are Passed to the C or C++ Program
- Differences in the Two Run-Time Environments
- Which Run-Time Routines Are Available
- Use of Common Run-Time Environment (CRE) Functions
- Replacing Guardian Procedure Calls With Equivalent OSS Functions
- Which IPC Mechanisms Can Be Used
- Interactions Between Guardian and OSS Functions
- 9 Porting From Specific UNIX Systems
- 10 Native Migration Overview
- 11 Porting or Migrating Sockets Applications
- 12 Porting Threaded Applications
- A Equivalent OSS and UNIX Commands for Guardian Users
- B Equivalent Guardian Commands for OSS and UNIX Users
- C Equivalent Inspect Debugging Commands for dbx Commands
- D Equivalent Native Inspect Debugging Commands for dbx Commands
- E Standard POSIX Threads Functions: Differences Between the Previous and Current Standards
- Glossary
- Index
Porting UNIX Applications to the OSS Environment
Open System Services Porting Guide—520573-006
7-11
General Programming Practices
Most UNIX systems provide C compilers that support both ISO/ANSI C and
Common C by using a compiler flag. If your program is written in Common C, it can be
converted to use ISO/ANSI C and tested on the UNIX platform on which it was written
before porting to the OSS environment. A number of commercially available books
contain guidelines for converting programs from Common C to ISO/ANSI C. See
Lewine’s POSIX Programmer’s Guide, which provides general guidelines for dealing
with potentially problematic variations in the C language such as:
•
Macro replacement and converting macro arguments to strings
•
Token passing
•
Name space issues
•
Function prototypes
•
New keywords such as const and volatile
•
String constants
•
Data type conversions
•
Character sets
•
Floating point data
•
Data structure alignment and layout
See also Related Reading on page xv for a list of other commercially available books
describing good practices when writing C programs that can be easily ported to UNIX
environments.
General Programming Practices
Some good programming practices to use in porting and writing programs are:
•
Use strictly conforming ISO/ANSI C language features.
•
Isolate C language features that are defined or extended by HP into specific
modules.
•
Use function prototypes.
•
Place all environment-specific function declarations in a common header file.
•
Make sure the type of a function’s actual and formal parameters are alike.
•
Define every function with an explicit return type.
•
Make sure the type of return expression and return type of a function agree.
•
Do not rely on processor architecture. Be careful to write code that does not rely on
word size, pointer size, bit fields, arithmetic precision, byte order, stack size, stack
growth, heap size, and heap growth.
•
Do not make assumptions about the size and format of any data type. Use type
short and type long instead of type int when possible.
•
Do not interchange between type int and type long.
•
Do not assign an int to or from a pointer without an explicit type cast.