portal.5 (2010 09)

p
portal(5) portal(5)
NAME
portal - a "window to the future" for applications
SYNOPSIS
#include <sys/portal.h>
DESCRIPTION
This header file is a "window to the future" for applications. It will help you to:
Write code that is portable across 32-bit and 64-bit systems,
Avoid undocumented assumptions about sizes of integral types,
Write portable code that needs to be explicit about the sizes of integral types,
Write code that is portable to a platform which has different sizes of integral types, and
Share frequently used macros that are portable across 32-bit and 64-bit systems.
In addition to the macros defined in this file, it includes the header files
limits.h (see limits (5)) and
inttypes.h (see inttypes (5)).
The following macros are defined in
sys/portal.h:
SET_MASK_BIT( bit_num, type)
This macro can be used to create a mask that has one bit set. bit_num is the position of the bit to
set, and type is the data type of the mask. A -1 is returned in the case of overflow or underflow.
SET_MASK_BIT_LOOP(mask, bit_num, type)
This macro can be used to set a bit in a mask. mask is the current value of the mask, bit_num is the
position of the bit to set, and type is the data type of the mask.
SIGN_BIT(type)
This macro can be used to return the bit position of the sign bit for the specified data type. type is
the data type for which to return the position of the sign bit.
SIGN_BIT_MASK(type)
This macro can be used to return a mask for the sign bit for the specified data type. type is the data
type for which to return the sign bit mask.
SIGN_EXTEND(value, old_type, new_type)
This macro can be used to do a sign extension from one data type to another. value is the current
value that is to be sign-extended. old_type is the current data type of value and new_type is the new
data type of value .
TEST_ENDIAN(endian)
This macro can be used to check if code has been compiled big or little endian. endian is an integer
in which the result will be returned.
The following macros can be used for print formatting and scan formatting of values of data types that
can change in size based upon the compilation flag
_FILE_OFFSET_BITS
. Examples of such data types
are off_t and fpos_t .
PRIdF64 d print formatting option for a 32-bit or 64-bit size value.
PRIoF64 o print formatting option for a 32-bit or 64-bit size value.
PRIxF64 x print formatting option for a 32-bit or 64-bit size value.
PRIuF64 u print formatting option for a 32-bit or 64-bit size value.
SCNdF64 d scan formatting option for a 32-bit or 64-bit size value.
SCNoF64 o scan formatting option for a 32-bit or 64-bit size value.
SCNxF64 x scan formatting option for a 32-bit or 64-bit size value.
SCNuF64 u scan formatting option for a 32-bit or 64-bit size value.
EXAMPLES
The
SET_MASK_BIT macro in the following example will turn on the high bit in a 64-bit integer.
SET_MASK_BIT(SIGN_BIT(int64_t), int64_t)
The SET_MASK_BIT macro in the following example will be used to turn on all bits except the sign bit in
a 32-bit integer.
~SET_MASK_BIT(SIGN_BIT(int32_t), int32_t)
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)