Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX 64-bit Porting and Transition Guide: HP 9000 Computers > Chapter 5 Writing Portable Code

Using portal.h

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The portal.h header file helps you to write code that is portable across HP-UX 32-bit and 64-bit systems. This header file contains macros for setting bit masks and sign bits of data types defined in <inttypes.h> and for convenience it includes the header files <limits.h> and <inttypes.h>.

To #include this header file, type:

#include <sys/portal.h>

Examples of some macros contained in portal.h follow:

  • SET_MASK_BIT(bit_num, data_type) — Creates a mask that has one bit set.

    For example:

    SET_MASK_BIT(SIGN_BIT(int64_t), int64_t)

    turns on the high bit in a 64-bit integer.

  • SIGN_BIT (data_type) — Returns the bit position of the sign bit for the specified type.

    For example:

    SIGN_BIT(int32_t)

    returns the position of the sign bit in a 32-bit integer.

  • SIGN_EXTEND (value, old_type, new_type) — Sign extends from one data type to another.

    For example:

    char c;
    int64_t i;
    i = SIGN_EXTEND(c, char, int64_t);

    converts the 8-bit integer stored in a char data type to a 64-bit integer and correctly extends the sign.

For additional information, see the man page for portal.h(5).

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.