heptagon/lib/c/pervasives.h
2011-05-12 16:32:52 +02:00

14 lines
277 B
C

/* Pervasives module for the Decades compiler */
#ifndef DECADES_PERVASIVES_H
#define DECADES_PERVASIVES_H
/* between(i, n) returns idx between 0 and n-1. */
static inline int between(int idx, int n)
{
int o = (idx >= n) ? n-1 : (idx < 0 ? 0 : idx);
return o;
}
#endif