This section lists the Support Kit's general-purpose functions (including function-like macros), constants, and defined types. These elements are used throughout the Be application-programming interface.
Not listed here are constants that are used as error codes. These are listed in Error Codes .
long atomic_add(long *atomic_variable, long add_value) long atomic_and(long *atomic_variable, long and_value) long atomic_or(long *atomic_variable, long or_value)
These functions perform the named operations (addition, bitwise AND, or bitwise OR) on the value found in atomic_variable, thus:
*atomic_variable += add_value *atomic_variable &= and_value *atomic_variable |= or_value
The functions return the previous value of *atomic_variable (in other words, they return the value that atomic_variable pointed to before the operation was performed).
The significance of these functions is that they're guaranteed to be atomic: If two threads attempt to access the same atomic variable at the same time (through these functions), one of the two threads will be made to wait until the other thread has completed the operation and updated the atomic_variable value.
class_name(object) is_instance_of(object, class) is_kind_of(object, class) cast_as(object, class)
These macros are part of the class information mechanism. In all cases, object is a pointer to an object, and class is a class designator (such as, literally, BView or BFile) and not a string (not "BView" or "BFile").
class_name() returns a pointer to the name of object 's class.
is_instance_of() returns TRUE if object is a direct instance of class.
is_kind_of() returns TRUE if object is an instance of class, or if it inherits from class.
cast_as() if object is a kind of class (in the is_kind_of() sense), then cast_as() returns a pointer to object cast as an instance of class. Otherwise it returns NULL.
Declared in: <support/SupportDefs.h>
min(a, b) max(a, b)
These macros compare two integers or floating-point numbers. min() returns the lesser of the two (or b if they're equal); max() returns the greater of the two (or a if they're equal).
short read_16_swap(short *address) long read_32_swap(long *address) void write_16_swap(short *address, short value) void write_32_swap(long *address, long value)
The read... functions read a 16- or 32-bit value from address, reverse the order of the bytes in the value, and return the swapped value directly.
The write... functions swap the bytes in value and write the swapped value to address.
ulong real_time_clock(void) void set_real_time_clock(ulong seconds) long time_zone(void) void set_time_zone(long seconds)
These functions measure and set time in seconds:
Warning: The time_zone() and set_time_zone() functions are currently unimplemented. If you call them, you will crash.
These functions aren't intended for scrupulously accurate measurement.
See also: system_time() in the Kernel Kit
<support/SupportDefs.h>
Defined constant | Value |
---|---|
FALSE | 0 |
TRUE | 1 |
These constants are used as values for bool variables (the bool type is listed in the next section).
Declared in: <support/SupportDefs.h>
const char *B_EMPTY_STRING
This constant provides a global pointer to an empty string ("").
Declared in: <support/SupportDefs.h>
Defined constant | Value |
---|---|
NIL | 0 |
NULL | 0 |
These constants represent "empty" values. They're synonyms that can be used interchangeably.
Declared in: <support/SupportDefs.h>
typedef unsigned char bool
This is the Be version of the basic boolean type. The TRUE and FALSE constants (listed above) are defined as boolean values.
Declared in: <support/SupportDefs.h>
typedef int (*B_PFI)() typedef long (*B_PFL)() typedef void (*B_PFV)()
These types are pointers to functions that return int , long, and void values respectively.
Declared in: <support/SupportDefs.h>
typedef unsigned char uchar typedef unsigned int uint typedef unsigned long ulong typedef unsigned short ushort
These type names are defined as convenient shorthands for the standard unsigned types.
Declared in: <support/SupportDefs.h>
typedef volatile char vchar typedef volatile int vint typedef volatile long vlong typedef volatile short vshort
These type names are defined as shorthands for declaring volatile data.
Declared in: <support/SupportDefs.h>
typedef volatile unsigned char vuchar typedef volatile unsigned int vuint typedef volatile unsigned long vulong typedef volatile unsigned short vushort
These type names are defined as shorthands for specifying an integral data type to be both
unsigned and volatile.
The Be Book, HTML Edition, for Developer Release 8 of the Be Operating System.
Copyright © 1996 Be, Inc. All rights reserved.
Be, the Be logo, BeBox, BeOS, BeWare, and GeekPort are trademarks of Be, Inc.
Last modified September 6, 1996.