GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Common macros. More...
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
#include <core/gp_compiler.h>
Go to the source code of this file.
Macros | |
#define | GP_MIN(a, b) |
Returns a minimum of the two numbers. | |
#define | GP_MIN3(a, b, c) |
Returns a minimum of the three numbers. | |
#define | GP_MAX(a, b) |
Returns a maximum of the two numbers. | |
#define | GP_MAX3(a, b, c) |
Returns a maximum of the three numbers. | |
#define | GP_CONCAT2(a, b) a##b |
A macro to concatenate two strings. | |
#define | GP_UNIQUE_ID(prefix) GP_UNIQUE_ID__(prefix, __COUNTER__) |
Generates an unique C identifier with a given prefix. | |
#define | GP_ABS(a) |
Returns an absolute value. | |
#define | GP_ABS_DIFF(a, b) |
Computes an absolute value of a difference. | |
#define | GP_ALIGN2(a) |
Aligns a value to be even. | |
#define | GP_SWAP(a, b) |
Swaps a and b. | |
#define | GP_ARRAY_SIZE(array) (sizeof(array) / sizeof(*array)) |
Computes number of elements of a statically defined array size. | |
#define | GP_CONTAINER_OF(ptr, structure, member) ((structure *)((char *)(ptr) - offsetof(structure, member))) |
Converts from a pointer to a struct field to a pointer to the struct itself. | |
Common macros.
Definition in file gp_common.h.
#define GP_ABS | ( | a | ) |
Returns an absolute value.
a | A number. |
Definition at line 110 of file gp_common.h.
#define GP_ABS_DIFF | ( | a, | |
b | |||
) |
Computes an absolute value of a difference.
a | A number. |
b | A number. |
Definition at line 123 of file gp_common.h.
#define GP_ALIGN2 | ( | a | ) |
Aligns a value to be even.
a | An integer number. |
Definition at line 135 of file gp_common.h.
#define GP_ARRAY_SIZE | ( | array | ) | (sizeof(array) / sizeof(*array)) |
Computes number of elements of a statically defined array size.
array | An array. |
Definition at line 168 of file gp_common.h.
#define GP_CONCAT2 | ( | a, | |
b | |||
) | a##b |
A macro to concatenate two strings.
a | A string constant. |
b | A string constant. |
Definition at line 88 of file gp_common.h.
#define GP_CONTAINER_OF | ( | ptr, | |
structure, | |||
member | |||
) | ((structure *)((char *)(ptr) - offsetof(structure, member))) |
Converts from a pointer to a struct field to a pointer to the struct itself.
The inverse functions is part of the C language and is called offsetof().
ptr | A pointer to a structure member. |
structure | A structure C type e.g. struct foo. |
member | A structure member name. |
Definition at line 180 of file gp_common.h.
#define GP_MAX | ( | a, | |
b | |||
) |
Returns a maximum of the two numbers.
a | A number. |
b | A number. |
Definition at line 59 of file gp_common.h.
#define GP_MAX3 | ( | a, | |
b, | |||
c | |||
) |
Returns a maximum of the three numbers.
a | A number. |
b | A number. |
c | A number. |
Definition at line 73 of file gp_common.h.
#define GP_MIN | ( | a, | |
b | |||
) |
Returns a minimum of the two numbers.
a | A number. |
b | A number. |
Definition at line 31 of file gp_common.h.
#define GP_MIN3 | ( | a, | |
b, | |||
c | |||
) |
Returns a minimum of the three numbers.
a | A number. |
b | A number. |
c | A number. |
Definition at line 45 of file gp_common.h.
#define GP_SWAP | ( | a, | |
b | |||
) |
Swaps a and b.
a | A value to be swapped. |
b | A value to be swapped. |
Definition at line 148 of file gp_common.h.
#define GP_UNIQUE_ID | ( | prefix | ) | GP_UNIQUE_ID__(prefix, __COUNTER__) |
Generates an unique C identifier with a given prefix.
This is intended to be used to generate an unique indentifier for functions or structures generated by macros.
prefix | A prefix for the unique ID. |
Definition at line 102 of file gp_common.h.