genSym.c 535 Bytes
Newer Older
1 2 3 4

#include "Rts.h"

static HsInt GenSymCounter = 0;
5
static HsInt GenSymInc = 1;
6 7

HsInt genSym(void) {
8
#if defined(THREADED_RTS)
9
    if (n_capabilities == 1) {
10
        return GenSymCounter = (GenSymCounter + GenSymInc) & 0xFFFFFF;
11
    } else {
12
        return atomic_inc((StgWord *)&GenSymCounter, GenSymInc) & 0xFFFFFF;
13
    }
14
#else
15
    return GenSymCounter = (GenSymCounter + GenSymInc) & 0xFFFFFF;
16
#endif
17 18
}

19 20 21 22
void initGenSym(HsInt NewGenSymCounter, HsInt NewGenSymInc) {
  GenSymCounter = NewGenSymCounter;
  GenSymInc = NewGenSymInc;
}