Mac OS 9
ToolUtils.h File Reference

Toolbox Utilities Interfaces. More...

#include <MacTypes.h>
#include <FixMath.h>
#include <TextUtils.h>
#include <Icons.h>
#include <Quickdraw.h>

Go to the source code of this file.

Macros

#define HiWord(x)   ((short)((long)(x) >> 16))
 
#define LoWord(x)   ((short)(x))
 

Functions

Boolean BitTst (const void *bytePtr, long bitNum)
 
void BitSet (void *bytePtr, long bitNum)
 Set a specified bit in a bit string to a 1. More...
 
void BitClr (void *bytePtr, long bitNum)
 

Variables

 x = op1 & op2
 
</pre > *par Copyright
 
</pre > *par long value2
 
</pre > *par short count
 

Detailed Description

Toolbox Utilities Interfaces.

Introduced In: System 7.5
Avaliable From: Universal Interfaces 3.4.1
Copyright: © 1990-2001 by Apple Computer, Inc., all rights reserved

For bug reports, consult the following page on the World Wide Web:

http://developer.apple.com/bugreporter/

Function Documentation

◆ BitClr()

void BitClr ( void *  bytePtr,
long  bitNum 
)
\brief Clear a specified bit in a bit string to a 0

<pre>BitClr clears a specified bit in a bit string to a 0.

bytePtr is the address of the first byte of a sequence of bytes. bitNumidentifies the bit to clear. It is a positive offset from the first bit in the byte addressed by bytePtr. Bits are identified by a logical mapping (matching that used for screen pixels), rather than the normal high-to-low numbering used in CPU operations. See BitTst for details.

Returns
none
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ BitSet()

void BitSet ( void *  bytePtr,
long  bitNum 
)

Set a specified bit in a bit string to a 1.

  @par Non-Carbon CFM:   in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ BitTst()

Boolean BitTst ( const void *  bytePtr,
long  bitNum 
)

©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©© Note:

The following routines that used to be in this header file, have moved to more appropriate headers.

FixMath.h:      FixMul
                FixRatio
                FixRound

Icons.h:        GetIcon
                PlotIcon

Quickdraw.h:    AngleFromSlope
                DeltaPoint
                GetCursor
                GetIndPattern
                GetPattern
                GetPicture
                PackBits
                ScreenRes
                ShieldCursor
                SlopeFromAngle
                UnpackBits

TextUtils.h:    Munger
                GetIndString
                GetString
                NewString
                SetString

©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©

\brief Determine state of a bit in a bit string

<pre>Any bit in the bit string can be accessed individually via BitTst, BitSet,

and BitClr. Other Toolbox BitXxx functions apply to bitwise operations between long integers and not relevant for C programmers.

Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

Variable Documentation

◆ x

x = op1 & op2
\brief Obtain bitwise AND of two 32-bit longs
\param    op1 32-bit value to be masked
Parameters
op232-bit mask to apply
BitAnd returns the logical product (a bitwise AND) of two 32-bit values.
The operands are not changed.
op1and . . .
op2are 32-bit long operands. The bit pattern of op1 is masked by the
bits of op2.
Returns
a long integer; the result of ( op1 & op2 ).
Note
Bits in op1 that are also set in op2 are set to 1 in the result. All other
bits of the result are cleared to 0. Note that op1 and op2 can be in either
order without affecting the result.
This capability is native to the CPU and can be performed much faster
using the C & (bitwise AND) operator.
longx, op1, op2;
x = BitAnd( op1, op2); /* is equivalent to . . . 

\brief Obtain bitwise OR of two 32-bit longs
\param    op1 32-bit values . . .
Parameters
op2
. . . to be ORed
    
BitOr returns the logical sum (a bitwise OR) of two 32-bit values. The
operands are not changed.
op1and . . .
op2are 32-bit long operands.
Returns
 
a long integer; the result of ( op1 | op2 ).
Note
 
Bits that are set in either op1 or op2 are set to 1 in the result. All other
bits of the result are cleared to 0.
This capability is native to the CPU and can be performed much faster
using the C | (bitwise OR) operator or the Assembler OR or ORI opcode.
longx, op1, op2;
x = BitOr( op1, op2); /* is equivalent to . . . 

\brief Obtain bitwise XOR of two 32-bit longs
\param    op1 32-bit values . . .
Parameters
op2
. . . to be XORed
    
BitXor returns the exclusive OR (a bitwise XOR) of two 32-bit values. The
operands are not changed.
op1and . . .
op2are 32-bit long operands.
Returns
 
a long integer; the result of ( op1 ^ op2 ).
Note
 
A bit in the result is set to 1 when bits of op1 and op2 contain opposite
values; other bits are cleared.  Alternative explanation: the bits of op2
"toggle" the bits of op1 .
This capability is native to the CPU and can be performed much faster
using the C ^ (bitwise XOR) operator.
longx, op1, op2;
x = BitXor( op1, op2); /* is equivalent to . . . 

\brief Obtain bitwise NOT (complement) of two longs

<pre>BitNot returns the complement (a bitwise NOT) of a 32-bit operand.
operand is a 32-bit long operand.
Returns
 
a long integer; the result of ~operand.
Note
 
Bits of operand that are 0 are set to 1 in the result; all other bits of the
result are cleared to 0.
This capability is native to the CPU and can be performed much faster
using the C ~ (bitwise NOT) operator.
longx, operand;
x = BitNot( operand); /* is equivalent to . . . 

\brief Obtain result of left- or right-shifted 32-bit value
\param    op 32-bit values to be shifted
<pre>BitShift returns the value of bit-shifted a 32-bit operand. Bit shifting can
be used for fast multiplication and division by a power of 2. opis a 32-bit long operand. countspecifies the direction and extent of the shift operation. The bits are shifted ABS( count ) positions. count is always treated MOD 32 (should range from -31 to +31). <0(negative values) shift to the right >0(positive values) shift to the left 0Nothing happens
Returns
 
a long integer; the result of ( op << count ) or (op >> (-count )).
Note
 
Bits of op are shifted either right or left, depending on the sign of count .
Bits shifted off the end are lost and the vacated positions are cleared to 0.
Note that a left shift is the same as an unsigned multiplication by 2, 4, 8,
etc.  A right shift is the same as unsigned division by 2, 4, 8, etc.
This capability is native to the CPU and can be performed much faster
using the C >> and << (bitwise shift) operators or the assembler LSL or
LSR opcodes.
longx, operand;
shortcount;
x = BitShift ( operand, count ); /* is equivalent to . . .