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 From Specific UNIX Systems
Open System Services Porting Guide—520573-006
9-10
Initializing Multiple-Word Entities in Chunks of
Multiple Bits
Initializing Multiple-Word Entities in Chunks of Multiple Bits
Use care when porting code that initializes multiple-word entities with specific bit
patterns. For example, on a little-endian system, the following array of two 32-bit
integer values can be used to initialize a 64-bit double entity:
u.ul[0] = 0x7fffffff;
u.ul[1] = 0xffffffff;
To produce the correct results on a big-endian system, the subscripts must be
reversed:
u.ul[1] = 0x7fffffff;
u.ul[0] = 0xffffffff;
To fix this problem, change initialization assignment statements so that bit patterns are
not used.
Using Bytes for More Than One Purpose
Sometimes code that is trying to make very efficient use of memory takes advantage of
the fact that some of the bytes in an integer often are not used. For example, if a
particular int field in a record will hold only values in the range 0 through 10,000,000,
the most significant byte will always contain zero. A 1-byte field could be stored in that
byte to make the record one byte smaller.
If the most significant byte is accessed through a character array or by casting and
dereferencing a pointer, then the code is not portable and slightly different versions are
needed on big-endian and little-endian systems. However, if bitwise operators are used
to mask, merge, and shift bytes, then the code is portable.
To fix this problem, change storage usage statements so that all data items occupy
unique locations.
Using Hexadecimal Constants as Byte Arrays
An endian problem occurs when a 32-bit value is treated both as a 32-bit value (an
integer) and as an array of four characters. For example, the following array is
equivalent to the number 0x11223344 on big-endian systems and the number
0x44332211 on little-endian systems:
char a[4] = {0x11, 0x22, 0x33, 0x44};
To fix this problem, change the program to properly preserve data typing.