Added pervasives C header
It only defines the between function for now
This commit is contained in:
parent
c8055cd1ff
commit
0256b571f7
1 changed files with 14 additions and 0 deletions
14
lib/c/pervasives.h
Normal file
14
lib/c/pervasives.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Pervasives module for the Decades compiler */
|
||||
|
||||
#ifndef DECADES_PERVASIVES_H
|
||||
#define DECADES_PERVASIVES_H
|
||||
|
||||
/* between(i, n) returns idx between 0 and n-1. */
|
||||
inline int between(int idx, int n)
|
||||
{
|
||||
int o = (idx >= n) ? n-1 : (idx < 0 ? 0 : idx);
|
||||
return o;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in a new issue