A preprocessor for loop implementation and some derived list handling macros. More...
#include "p99_block.h"
Include dependency graph for p99_for.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Defines | |
| #define | P99_AALLOC(T, VB, N) P00_AALLOC(P99_ATYPE(T, , VB, N)) |
| Allocate a new matrix of base type T and with N dimensions as given by VB. | |
| #define | P99_AARG(TYPE, NAME, DIM, VAR) |
| Declare a pointer to array function argument of basetype TYPE, with name NAME, dimension DIM and naming scheme for the length variables VAR{0}, ... VAR{DIM - 1}. | |
| #define | P99_ACALL(ARR, N, TYPE) |
| Pass a pointer to an N dimensional array ARR to a function. | |
| #define | P99_ALEN(ARR, N) |
| Produce the length of the argument array ARR in terms of number of elements. | |
| #define | P99_ALENS(ARR, N) P99_FOR(ARR, N, P00_ALENS0, P00_ALEN, P99_REP(N,)) |
| Produce a list of the lengths of the argument array ARR in terms of the number of elements in the first N dimensions. | |
| #define | P99_ANAME(NAME, DIM, VAR) |
| Declare list of variable names as produced by P99_AARG. | |
| #define | P99_ANDS(...) P99_BIGOP(P00_AND, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative logical and of all the arguments. | |
| #define | P99_ARE_EQ(FIRST,...) P99_FOR(== (FIRST), P99_NARG(__VA_ARGS__), P00_AND, P00_ISIT, __VA_ARGS__) |
| Check if the arguments in the list are all equal. | |
| #define | P99_ARE_ORDERED(OP,...) P00_ARE_ORDERED(OP, P99_NARG(__VA_ARGS__), __VA_ARGS__) |
| Check if the arguments in the list are ordered according to the operation OP. | |
| #define | P99_AREF(T, ARR,...) T P99_ARRAY(*const ARR, __VA_ARGS__) |
| #define | P99_AREF1(T, ARR,...) T P99_ARRAY(ARR, static const 1, __VA_ARGS__) |
| #define | P99_ARRAY(ARR,...) (ARR)P99_SUBSCRIPT(__VA_ARGS__) |
| #define | P99_ATYPE(T, A, B, N) P99_AREF(T, A, P99_ALENS(*B, N)) |
| Declare a new matrix A of base type T and with N dimensions as given by B. | |
| #define | P99_BANDS(...) P99_BIGOP(P00_BAND, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative bitwise and of all the arguments. | |
| #define | P99_BIGFUNC(FUNC, M,...) P99_FOR(FUNC, M, P00_FUNC, P00_IDT, __VA_ARGS__) |
| Realize the right associative call of binary function FUNC of all the arguments. | |
| #define | P99_BIGOP(OP, M,...) P99_FOR( , M, OP, P00_IDT, __VA_ARGS__) |
| Realize the right associative operation OP of all the arguments. | |
| #define | P99_BORS(...) P99_BIGOP(P00_BOR, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative bitwise or of all the arguments. | |
| #define | P99_CASERANGE(START, LEN,...) |
| implement a range syntax for case labels. | |
| #define | P99_CDIM(NAME,...) P00_CDIM(P99_NARG(__VA_ARGS__), NAME, __VA_ARGS__) |
| Compute an absolute index in a multidimensional array in the same way as C. | |
| #define | P99_DEFINE_STRUCT(NAME,...) |
| Declare a structure of name NAME composed of the field declarations that are given in the remaining arguments. | |
| #define | P99_DIV(A, B) P99_CHS(A, P99_FOR(B, 32, P00_SEQ, P00_IDI, P00_ALL_ONES())) |
| Generate the quotient of non-negative decimal numbers A and B at preprocessing time. | |
| #define | P99_DO(TYPE, VAR, LOW, LEN, INCR) for(;;) |
| A fortran like do-loop with bounds that are fixed at the beginning. | |
| #define | P99_FOR(NAME, N, OP, FUNC,...) |
| A preprocessor pseudo iterator. | |
| #define | P99_FORALL(NAME,...) P00_FORALL(P99_NARG(__VA_ARGS__), NAME, __VA_ARGS__) |
A multi-index for loop. | |
| #define | P99_IS_INF(FIRST,...) P99_FOR(> (FIRST), P99_NARG(__VA_ARGS__), P00_AND, P00_ISIT, __VA_ARGS__) |
| Check if argument FIRST is less than or equal to the other elements in the list. | |
| #define | P99_IS_MAX(FIRST,...) P99_FOR(<= (FIRST), P99_NARG(__VA_ARGS__), P00_AND, P00_ISIT, __VA_ARGS__) |
| Check if argument FIRST is strictly greater than the other elements in the list. | |
| #define | P99_IS_MIN(FIRST,...) P99_FOR(>= (FIRST), P99_NARG(__VA_ARGS__), P00_AND, P00_ISIT, __VA_ARGS__) |
| Check if argument FIRST is less than the other elements in the list. | |
| #define | P99_IS_ONE(FIRST,...) P99_FOR(== (FIRST), P99_NARG(__VA_ARGS__), P00_OR, P00_ISIT, __VA_ARGS__) |
| Check if argument FIRST is equal to one of the other elements in the list. | |
| #define | P99_IS_SUP(FIRST,...) P99_FOR(< (FIRST), P99_NARG(__VA_ARGS__), P00_AND, P00_ISIT, __VA_ARGS__) |
| Check if argument FIRST is greater than or equal to the other elements in the list. | |
| #define | P99_LITERAL(...) P99_SEQ(P00_LITERAL, __VA_ARGS__) |
| Copy local variables back to the fields of same name inside a literal. | |
| #define | P99_MAC_ARGS(...) |
Declare macro parameters as local variables as if the macro were declared as a type generic inline function. | |
| #define | P99_MACRO_VAR(NAME, EXPR, QUAL) |
| Define a variable with NAME that has the type and value of EXPR. If QUAL is given it must be a qualifier list that is added to the resulting type. | |
| #define | P99_NAME(N, NAME) P99_FOR(NAME, N, P00_SEQ, P00_NAME_I, P99_REP(N,)) |
generate lists of names of the form NAME0, NAME1, ... | |
| #define | P99_ORS(...) P99_BIGOP(P00_OR, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative logical or of all the arguments. | |
| #define | P99_PARALLEL_DO(TYPE, VAR, LOW, LEN, INCR) for(;;) |
| as P99_DO but performs the iterations out of order | |
| #define | P99_PARALLEL_FOR _Pragma(P99_PARALLEL_PRAGMA) for |
Declare a for loop for which all iterations can be run independently and out of order. | |
| #define | P99_PARALLEL_FORALL(NAME,...) P00_PARALLEL_FORALL(P99_NARG(__VA_ARGS__), NAME, __VA_ARGS__) |
A multi-index for loop who's dependent statement or block may be executed out of order. | |
| #define | P99_PRAGMA_DO(PRAG, TYPE, VAR, LOW, LEN, INCR) for(;;) |
as P99_DO but allows you to additionally place a pragma directive in front of the generated for loop | |
| #define | P99_PRODS(...) P99_BIGOP(P00_PROD, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative product of all the arguments. | |
| #define | P99_QUOTS(...) P99_BIGOP(P00_QUOT, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative quotient of all the arguments. | |
| #define | P99_REPEAT(MACRO, N) P99_FOR(MACRO, N, P00_SEQ, P00_REPEAT, P99_DUPL(N,)) |
| Apply the macro MACRO N times. | |
| #define | P99_REVS(...) P00_REVS(P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Revert the argument list. | |
| #define | P99_SEP(MACRO,...) P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, (;), __VA_ARGS__) |
| Apply the macro MACRO to the rest of the argument list. | |
| #define | P99_SEQ(MACRO,...) P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, (,), __VA_ARGS__) |
| Apply the macro MACRO to the rest of the argument list. | |
| #define | P99_SER(MACRO,...) P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, ( ), __VA_ARGS__) |
| Apply the macro MACRO to the rest of the argument list. | |
| #define | P99_STRUCT_LITERAL(TYPE,...) (TYPE){ P99_SEQ(P00_LITERAL, __VA_ARGS__) } |
| Copy local variables back to the fields of same name inside a compound literal of type TYPE. | |
| #define | P99_STRUCT_TYPE0(TYPE,...) P99_FOR(TYPE, P99_NARG(__VA_ARGS__), P00_SEQ, P00_STRUCT_TYPE0, __VA_ARGS__) |
| Transform the argument list into a list of lvalue for the fields of type TYPE. | |
| #define | P99_STRUCT_TYPES(TYPE,...) P99_FOR(TYPE, P99_NARG(__VA_ARGS__), P00_SEQ, P00_STRUCT_TYPES, __VA_ARGS__) |
| Transform the argument list into a list of field types for type TYPE. | |
| #define | P99_STRUCT_UNUSE(TYPE, VAR,...) P99_FOR((TYPE, VAR), P99_NARG(__VA_ARGS__), P00_SEP, P00_STRUCT_UNUSE, __VA_ARGS__) |
| Copy local variables back to the fields of variable VAR. | |
| #define | P99_STRUCT_USE(TYPE, VAR,...) P99_FOR((TYPE, VAR), P99_NARG(__VA_ARGS__), P00_SEP, P00_STRUCT_USE, __VA_ARGS__) |
| Use the fields of variable VAR of type TYPE. | |
| #define | P99_SUBSCRIPT(...) P99_SER(P00_SUBSCRIPT, __VA_ARGS__) |
Transform the list of arguments x0, x1, ... to array subscripts [x0][x1]... | |
| #define | P99_SUMS(...) P99_BIGOP(P00_SUM, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative sum of all the arguments. | |
| #define | P99_TOKJOIN(TOK,...) |
| join a list with a specific token given as the first argument | |
| #define | P99_UNROLL(MACRO, N) P99_FOR(MACRO, N, P00_SEP, P00_REPEAT, P99_DUPL(N,)) |
| Apply the macro MACRO N times. | |
| #define | P99_XORS(...) P99_BIGOP(P00_XOR, P99_NARG(__VA_ARGS__),__VA_ARGS__) |
| Realize the right associative bitwise exclusive or of all the arguments. | |
1.7.6.1