Documentation  |   Table of Contents   |  < Previous   |  Next >   |  Index

12    Palm Types

Programming Basics

Exploring Palm OS®

PalmTypes.h defines a number of basic types and constants used throughout Palm OS, along with a number of macros to do byte-swapping (for endianness) and time interval conversion.

The contents of this chapter is organized as follows:

Palm Types Structures and Types
Palm Types Constants
Palm Types Functions and Macros

Palm Types Structures and Types ^TOP^

Boolean Typedef ^TOP^

Purpose

A boolean type.

Declared In

PalmTypes.h

Prototype

typedef unsigned char Boolean

Comments

Use the TRUE and FALSE, or true and false, constants with Boolean variables.

coord Typedef ^TOP^

Purpose

A single floating-point coordinate type.


NOTE: This type is provided for compatibility purposes; applications should use fcoord_t instead.

Declared In

PalmTypes.h

Prototype

typedef float coord

See Also

Coord, fcoord_t

Coord Typedef ^TOP^

Purpose

A single fixed-point coordinate type, used for screen and window coordinates.

Declared In

PalmTypes.h

Prototype

typedef int16_t Coord

See Also

coord

Enum16 Typedef ^TOP^

Purpose

An enum type that can have up to 65,535 enumerated constants.

Declared In

PalmTypes.h

Prototype

typedef uint16_t Enum16

See Also

Enum8, SignedEnum16

Enum8 Typedef ^TOP^

Purpose

An enum type that can have up to 255 enumerated constants.

Declared In

PalmTypes.h

Prototype

typedef uint8_t Enum8

See Also

Enum16, SignedEnum8

fcoord_t Typedef ^TOP^

Purpose

A single floating-point coordinate type, used in conjunction with the graphics context drawing functions.

Declared In

PalmTypes.h

Prototype

typedef float fcoord_t

See Also

coord, Coord

MemHandle Struct ^TOP^

Purpose

A handle to a location in memory. Unlike a pointer, a handle can be used to reference memory that may be relocated.

Declared In

PalmTypes.h

Prototype

typedef struct _opaque *MemHandle

Fields

None.

See Also

MemPtr, SysHandle

MemPtr Typedef ^TOP^

Purpose

A pointer to a location in memory.

Declared In

PalmTypes.h

Prototype

typedef void *MemPtr

See Also

MemHandle

ProcPtr Typedef ^TOP^

Purpose

Pointer to a function that returns a 32-bit integer.

Declared In

PalmTypes.h

Prototype

int32_t (*ProcPtr) ()


SignedEnum16 Typedef ^TOP^

Purpose

An enum type whose enumerated constant values can range from
-32,768 to +32,767.

Declared In

PalmTypes.h

Prototype

typedef int16_t SignedEnum16

See Also

Enum16, SignedEnum8

SignedEnum8 Typedef ^TOP^

Purpose

An enum type whose enumerated constant values can range from
-128 to +127.

Declared In

PalmTypes.h

Prototype

typedef int8_t SignedEnum8

See Also

Enum8, SignedEnum16

SysHandle Typedef ^TOP^

Purpose

A virtual address.

Declared In

PalmTypes.h

Prototype

typedef uint32_t SysHandle

VAddr Typedef ^TOP^

Purpose

A virtual address, used by the ErrThrow()/ErrCatch() exception-handling mechanism.

Declared In

PalmTypes.h

Prototype

typedef uint32_t VAddr

wchar16_t Typedef ^TOP^

Purpose

A 16-bit character type.

Declared In

PalmTypes.h

Prototype

typedef uint16_t wchar16_t

See Also

wchar32_t

wchar32_t Typedef ^TOP^

Purpose

A 32-bit "wide" character type.

Declared In

PalmTypes.h

Prototype

typedef uint32_t wchar32_t

Comments

wchar16_t

Palm Types Constants ^TOP^

Time Constants ^TOP^

Purpose

Various multiples of one nanosecond. These constants are used by the nanosecond conversion macros documented in "Palm Types Functions and Macros."

Declared In

PalmTypes.h

Constants

#define P_ONE_MICROSECOND (P_ONE_NANOSECOND*1000)
One microsecond.
#define P_ONE_MILLISECOND (P_ONE_MICROSECOND*1000)
One millisecond.
#define P_ONE_NANOSECOND ((nsecs_t)1)
One nanosecond.
#define P_ONE_SECOND (P_ONE_MILLISECOND*1000)
One second.

Boolean Values Enum ^TOP^

Purpose

Defines values that can be used with Boolean variables.

Declared In

PalmTypes.h

Constants

false
A "false" value that can be used with Boolean variables.
true
A "true" value that can be used with Boolean variables.

Miscellaneous Constants ^TOP^

Purpose

PalmTypes.h also defines these constants.

Declared In

PalmTypes.h

Constants

#define FALSE (0)
A "false" value that can be used with Boolean variables.
#define NULL 0
A null value that can be used with pointers.
#define TRUE (1)
A "true" value that can be used with Boolean variables.

Palm Types Functions and Macros ^TOP^

EndianSwap16 Macro ^TOP^

Purpose

Swaps the bytes in a 16-bit value to switch between big-endian byte order and little-endian byte order.

Declared In

PalmTypes.h

Prototype

#define EndianSwap16 (
   n
)

Parameters

n
The 16-bit value to be byte-swapped.

Returns

Evaluates to a 16-bit value with endianness opposite that of the supplied value.

See Also

EndianSwap32, RsrcEndianSwap16()

EndianSwap32 Macro ^TOP^

Purpose

Swaps the bytes in a 32-bit value to switch between big-endian byte order and little-endian byte order.

Declared In

PalmTypes.h

Prototype

#define EndianSwap32 (
   n
)

Parameters

n
The 32-bit value to be byte-swapped.

Returns

Evaluates to a 32-bit value with endianness opposite that of the supplied value.

See Also

EndianSwap16, RsrcEndianSwap32()

ErrConvertFrom68k Macro ^TOP^

Purpose

Converts a 16-bit error value, of the type produced by many Palm OS functions when called through PACE, to a status_t value, as produced by many ARM-native operating system functions.

Declared In

PalmTypes.h

Prototype

#define ErrConvertFrom68k (
   x
)

Parameters

x
The 16-bit error code to be converted.

Returns

The status_t value that corresponds to the supplied error code.

See Also

ErrConvertTo68k

ErrConvertTo68k Macro ^TOP^

Purpose

Converts a status_t value, of the type produced by many ARM-native operating system functions, to a 16-bit error value, as produced by many operating system functions when called through PACE.

Declared In

PalmTypes.h

Prototype

#define ErrConvertTo68k (
   x
)

Parameters

x
The status_t value to be converted.

Returns

The 16-bit error code that corresponds to the supplied status_t value.

See Also

ErrConvertFrom68k

P_MICROSECONDS_TO_NANOSECONDS Macro ^TOP^

Purpose

Converts from microseconds to nanoseconds.

Declared In

PalmTypes.h

Prototype

#define P_MICROSECONDS_TO_NANOSECONDS (
   us
)

Parameters

us
A quantity of time, in microseconds.

Returns

Evaluates to the supplied amount of time, in nanoseconds.

Comments

This macro is equivalent to P_US2NS().

See Also

P_MILLISECONDS_TO_NANOSECONDS(), P_SECONDS_TO_NANOSECONDS(), P_NANOSECONDS_TO_MICROSECONDS()

P_MILLISECONDS_TO_NANOSECONDS Macro ^TOP^

Purpose

Converts from milliseconds to nanoseconds.

Declared In

PalmTypes.h

Prototype

#define P_MILLISECONDS_TO_NANOSECONDS (
   ms
)

Parameters

ms
A quantity of time, in milliseconds.

Returns

Evaluates to the supplied amount of time, in nanoseconds.

Comments

This macro is equivalent to P_MS2NS().

See Also

P_MICROSECONDS_TO_NANOSECONDS(), P_SECONDS_TO_NANOSECONDS(), P_NANOSECONDS_TO_MILLISECONDS()

P_MS2NS Macro ^TOP^

Purpose

Converts from milliseconds to nanoseconds.

Declared In

PalmTypes.h

Prototype

#define P_MS2NS (
   ms
)

Parameters

ms
A quantity of time, in milliseconds.

Returns

Evaluates to the supplied amount of time, in nanoseconds.

Comments

This macro is equivalent to P_MILLISECONDS_TO_NANOSECONDS().

See Also

P_S2NS(), P_US2NS(), P_NS2MS()

P_NANOSECONDS_TO_MICROSECONDS Macro ^TOP^

Purpose

Converts from nanoseconds to microseconds.

Declared In

PalmTypes.h

Prototype

#define P_NANOSECONDS_TO_MICROSECONDS (
   ns
)

Parameters

ms
A quantity of time, in nanoseconds.

Returns

Evaluates to the supplied amount of time, in microseconds.

Comments

This macro is equivalent to P_NS2US().

See Also

P_NANOSECONDS_TO_MILLISECONDS(), P_NANOSECONDS_TO_SECONDS(), P_MICROSECONDS_TO_NANOSECONDS()

P_NANOSECONDS_TO_MILLISECONDS Macro ^TOP^

Purpose

Converts from nanoseconds to milliseconds.

Declared In

PalmTypes.h

Prototype

#define P_NANOSECONDS_TO_MILLISECONDS (
   ns
)

Parameters

ms
A quantity of time, in nanoseconds.

Returns

Evaluates to the supplied amount of time, in milliseconds.

Comments

This macro is equivalent to P_NS2MS().

See Also

P_NANOSECONDS_TO_MICROSECONDS(), P_NANOSECONDS_TO_SECONDS(), P_MILLISECONDS_TO_NANOSECONDS()

P_NANOSECONDS_TO_SECONDS Macro ^TOP^

Purpose

Converts from nanoseconds to seconds.

Declared In

PalmTypes.h

Prototype

#define P_NANOSECONDS_TO_SECONDS (
   ns
)

Parameters

ms
A quantity of time, in nanoseconds.

Returns

Evaluates to the supplied amount of time, in seconds.

Comments

This macro is equivalent to P_NS2S().

See Also

P_NANOSECONDS_TO_MICROSECONDS(), P_NANOSECONDS_TO_MILLISECONDS(), P_SECONDS_TO_NANOSECONDS()

P_NS2MS Macro ^TOP^

Purpose

Converts from nanoseconds to milliseconds.

Declared In

PalmTypes.h

Prototype

#define P_NS2MS (
   ns
)

Parameters

ms
A quantity of time, in nanoseconds.

Returns

Evaluates to the supplied amount of time, in milliseconds.

Comments

This macro is equivalent to P_NANOSECONDS_TO_MILLISECONDS().

See Also

P_NS2US(), P_NS2S(), P_MS2NS()

P_NS2S Macro ^TOP^

Purpose

Converts from nanoseconds to seconds.

Declared In

PalmTypes.h

Prototype

#define P_NS2S (
   ns
)

Parameters

s
A quantity of time, in nanoseconds.

Returns

Evaluates to the supplied amount of time, in seconds..

Comments

This macro is equivalent to P_NANOSECONDS_TO_SECONDS().

See Also

P_NS2MS(), P_NS2US(), P_S2NS()

P_NS2US Macro ^TOP^

Purpose

Converts from nanoseconds to microseconds.

Declared In

PalmTypes.h

Prototype

#define P_NS2US (
   ns
)

Parameters

ms
A quantity of time, in nanoseconds.

Returns

Evaluates to the supplied amount of time, in microseconds.

Comments

This macro is equivalent to P_NANOSECONDS_TO_MICROSECONDS().

See Also

P_NS2MS(), P_NS2S(), P_US2NS()

P_S2NS Macro ^TOP^

Purpose

Converts from seconds to nanoseconds.

Declared In

PalmTypes.h

Prototype

#define P_S2NS (
   s
)

Parameters

s
A quantity of time, in seconds.

Returns

Evaluates to the supplied amount of time, in seconds..

Comments

This macro is equivalent to P_SECONDS_TO_NANOSECONDS().

See Also

P_MS2NS(), P_US2NS(), P_NS2S()

P_SECONDS_TO_NANOSECONDS Macro ^TOP^

Purpose

Converts from seconds to nanoseconds.

Declared In

PalmTypes.h

Prototype

#define P_SECONDS_TO_NANOSECONDS (
   s
)

Parameters

s
A quantity of time, in seconds.

Returns

Evaluates to the supplied amount of time, in seconds..

Comments

This macro is equivalent to P_S2NS().

See Also

P_MICROSECONDS_TO_NANOSECONDS(), P_MILLISECONDS_TO_NANOSECONDS(), P_NANOSECONDS_TO_SECONDS()

P_US2NS Macro ^TOP^

Purpose

Converts from microseconds to nanoseconds.

Declared In

PalmTypes.h

Prototype

#define P_US2NS (
   us
)

Parameters

us
A quantity of time, in microseconds.

Returns

Evaluates to the supplied amount of time, in nanoseconds.

Comments

This macro is equivalent to P_MICROSECONDS_TO_NANOSECONDS().

See Also

P_MS2NS(), P_US2NS(), P_NS2US()

RsrcEndianSwap16 Macro ^TOP^

Purpose

Swaps the bytes in a 16-bit value within a resource to switch between big-endian byte order and little-endian byte order.

Declared In

PalmTypes.h

Prototype

#define RsrcEndianSwap16 (
   x
)

Parameters

x
The 16-bit value within the resource that is to be byte-swapped.

Returns

Evaluates to a 16-bit value with endianness opposite that of the supplied value.

See Also

EndianSwap16, RsrcEndianSwap32()

RsrcEndianSwap32 Macro ^TOP^

Purpose

Swaps the bytes in a 32-bit value within a resource to switch between big-endian byte order and little-endian byte order.

Declared In

PalmTypes.h

Prototype

#define RsrcEndianSwap32 (
   x
)

Parameters

x
The 32-bit value within the resource that is to be byte-swapped.

Returns

Evaluates to a 32-bit value with endianness opposite that of the supplied value.

See Also

EndianSwap32, RsrcEndianSwap16()