P99
Macros
p99_for.h File Reference

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.

Macros

#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. More...
 
#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}. More...
 
#define P99_ACALL(ARR, N, TYPE)
 Pass a pointer to an N dimensional array ARR to a function. More...
 
#define P99_ALEN(ARR, N)
 Produce the length of the argument array ARR in terms of number of elements. More...
 
#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. More...
 
#define P99_ANAME(NAME, DIM, VAR)
 Declare list of variable names as produced by P99_AARG. More...
 
#define P99_ANDS(...)   P99_BIGOP(P00_AND, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative logical and of all the arguments. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#define P99_BANDS(...)   P99_BIGOP(P00_BAND, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative bitwise and of all the arguments. More...
 
#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. More...
 
#define P99_BIGOP(OP, M, ...)   P99_FOR( , M, OP, P00_IDT, __VA_ARGS__)
 Realize the right associative operation OP of all the arguments. More...
 
#define P99_BORS(...)   P99_BIGOP(P00_BOR, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative bitwise or of all the arguments. More...
 
#define P99_CASERANGE(START, LEN, ...)
 implement a range syntax for case labels. More...
 
#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. More...
 
#define P99_DEFINE_STRUCT(NAME, ...)
 Declare a structure of name NAME composed of the field declarations that are given in the remaining arguments. More...
 
#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. More...
 
#define P99_DO(TYPE, VAR, LOW, LEN, INCR)   for(;;)
 A fortran like do-loop with bounds that are fixed at the beginning. More...
 
#define P99_FOR(NAME, N, OP, FUNC, ...)
 A preprocessor pseudo iterator. More...
 
#define P99_FORALL(NAME, ...)   P00_FORALL(P99_NARG(__VA_ARGS__), NAME, __VA_ARGS__)
 A multi-index for loop. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#define P99_LITERAL(...)   P99_SEQ(P00_LITERAL, __VA_ARGS__)
 Copy local variables back to the fields of same name inside a literal. More...
 
#define P99_MAC_ARGS(...)
 Declare macro parameters as local variables as if the macro were declared as a type generic inline function. More...
 
#define P99_MACRO_PVAR(NAME, EXPR, QUAL)
 Define a variable with NAME that has the type and value of EXPR, where EXPR is of a pointer type. More...
 
#define P99_MACRO_VAR(NAME, EXPR, QUAL)
 Define a variable with NAME that has the type and value of EXPR. More...
 
#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, ... More...
 
#define P99_ORS(...)   P99_BIGOP(P00_OR, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative logical or of all the arguments. More...
 
#define P99_PARALLEL_DO(TYPE, VAR, LOW, LEN, INCR)   for(;;)
 as P99_DO but performs the iterations out of order More...
 
#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. More...
 
#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. More...
 
#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 More...
 
#define P99_PRODS(...)   P99_BIGOP(P00_PROD, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative product of all the arguments. More...
 
#define P99_QUOTS(...)   P99_BIGOP(P00_QUOT, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative quotient of all the arguments. More...
 
#define P99_REPEAT(MACRO, N)   P99_FOR(MACRO, N, P00_SEQ, P00_REPEAT, P99_DUPL(N,))
 Apply the macro MACRO N times. More...
 
#define P99_REVS(...)   P00_REVS(P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Revert the argument list. More...
 
#define P99_SEA(MACRO, ...)   P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, (+), __VA_ARGS__)
 Apply the macro MACRO to the rest of the argument list. More...
 
#define P99_SEM(MACRO, ...)   P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, (*), __VA_ARGS__)
 Apply the macro MACRO to the rest of the argument list. More...
 
#define P99_SEP(MACRO, ...)   P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, (;), __VA_ARGS__)
 Apply the macro MACRO to the rest of the argument list. More...
 
#define P99_SEQ(MACRO, ...)   P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, (,), __VA_ARGS__)
 Apply the macro MACRO to the rest of the argument list. More...
 
#define P99_SER(MACRO, ...)   P00_MAP_(P99_NARG(__VA_ARGS__), MACRO, ( ), __VA_ARGS__)
 Apply the macro MACRO to the rest of the argument list. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#define P99_SUBSCRIPT(...)   P99_SER(P00_SUBSCRIPT, __VA_ARGS__)
 Transform the list of arguments x0, x1, ... to array subscripts [x0][x1]... More...
 
#define P99_SUMS(...)   P99_BIGOP(P00_SUM, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative sum of all the arguments. More...
 
#define P99_TOKJOIN(TOK, ...)
 join a list with a specific token given as the first argument More...
 
#define P99_UNROLL(MACRO, N)   P99_FOR(MACRO, N, P00_SEP, P00_REPEAT, P99_DUPL(N,))
 Apply the macro MACRO N times. More...
 
#define P99_XORS(...)   P99_BIGOP(P00_XOR, P99_NARG(__VA_ARGS__),__VA_ARGS__)
 Realize the right associative bitwise exclusive or of all the arguments. More...
 

Detailed Description

A preprocessor for loop implementation and some derived list handling macros.

See also
P99_FOR

Definition in file p99_for.h.

P99_ARE_EQ
#define P99_ARE_EQ(FIRST,...)
Check if the arguments in the list are all equal.
Definition: p99_for.h:401
P99_TOKJOIN
#define P99_TOKJOIN(TOK,...)
join a list with a specific token given as the first argument
Definition: p99_for.h:517
P99_FORALL
#define P99_FORALL(NAME,...)
A multi-index for loop.
Definition: p99_for.h:956
f
f
Definition: p99_str.h:138
P99_SEP
#define P99_SEP(MACRO,...)
Apply the macro MACRO to the rest of the argument list.
Definition: p99_for.h:297
P99_IS_MIN
#define P99_IS_MIN(FIRST,...)
Check if argument FIRST is less than the other elements in the list.
Definition: p99_for.h:416
P99_CDIM
#define P99_CDIM(NAME,...)
Compute an absolute index in a multidimensional array in the same way as C.
Definition: p99_for.h:580
P99_AARG
#define P99_AARG(TYPE, NAME, DIM, VAR)
Declare a pointer to array function argument of basetype TYPE, with name NAME, dimension DIM and nami...
Definition: p99_for.h:750
P99_CASERANGE
#define P99_CASERANGE(START, LEN,...)
implement a range syntax for case labels.
Definition: p99_for.h:1037
P99_IS_MAX
#define P99_IS_MAX(FIRST,...)
Check if argument FIRST is strictly greater than the other elements in the list.
Definition: p99_for.h:447
P99_PARALLEL_FOR
#define P99_PARALLEL_FOR
Declare a for loop for which all iterations can be run independently and out of order.
Definition: p99_for.h:817
P99_IS_SUP
#define P99_IS_SUP(FIRST,...)
Check if argument FIRST is greater than or equal to the other elements in the list.
Definition: p99_for.h:463
P99_IS_ONE
#define P99_IS_ONE(FIRST,...)
Check if argument FIRST is equal to one of the other elements in the list.
Definition: p99_for.h:386
P99_IS_INF
#define P99_IS_INF(FIRST,...)
Check if argument FIRST is less than or equal to the other elements in the list.
Definition: p99_for.h:432
P99_NARG
#define P99_NARG(...)
Return the length of the variable length argument list, where an empty argument list is considered to...
Definition: p99_args.h:117
P99_DUPL
#define P99_DUPL(...)
Construct a list that repeats the argument list N times.
Definition: p99_list.h:90
P99_IF_LT
#define P99_IF_LT(A, B)
Test two decimal numbers A and B for whether A is strictly less than B.
Definition: p99_if.h:120
P99_ARE_ORDERED
#define P99_ARE_ORDERED(OP,...)
Check if the arguments in the list are ordered according to the operation OP.
Definition: p99_for.h:481
P99_DO
#define P99_DO(TYPE, VAR, LOW, LEN, INCR)
A fortran like do-loop with bounds that are fixed at the beginning.
Definition: p99_for.h:882
d
d
Definition: p99_str.h:138
i
P00_CLAUSE2 i(_Pragma("weak p00_getopt_comp"))(_Pragma("weak p00_getopt_comp
P99_FOR
#define P99_FOR(NAME, N, OP, FUNC,...)
A preprocessor pseudo iterator.
Definition: p99_for.h:92