Lely core libraries
2.3.4
|
Go to the source code of this file.
Macros | |
#define | ABS(a) ((a) < 0 ? -(a) : (a)) |
Returns the absolute value of a. | |
#define | ALIGN(x, a) ALIGN_MASK((x), (__typeof__(x))(a)-1) |
Rounds x up to the nearest multiple of a. More... | |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
Returns the minimum of a and b. More... | |
#define | MAX(a, b) ((a) < (b) ? (b) : (a)) |
Returns the maximum of a and b. More... | |
#define | countof(a) (sizeof(a) / sizeof(0 [a])) |
Returns the number of array members in a. | |
#define | powerof2(x) (!((x) & ((x)-1))) |
Returns 1 if x is a power of two, and 0 otherwise. More... | |
#define | structof(ptr, type, member) |
Obtains the address of a structure from the address of one of its members. More... | |
This is the public header file of the utilities library.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file util.h.
#define ALIGN | ( | x, | |
a | |||
) | ALIGN_MASK((x), (__typeof__(x))(a)-1) |
#define MIN | ( | a, | |
b | |||
) | ((a) < (b) ? (a) : (b)) |
#define MAX | ( | a, | |
b | |||
) | ((a) < (b) ? (b) : (a)) |
#define powerof2 | ( | x | ) | (!((x) & ((x)-1))) |
#define structof | ( | ptr, | |
type, | |||
member | |||
) |
Obtains the address of a structure from the address of one of its members.
This macro only works for plain old data structures (PODSs) and performs no type or NULL checking.
ptr | a pointer to the member. |
type | the type of the structure. |
member | the name of member. |