The stackoverflow discussion I linked above suggests that you could try using the following function to limit the range of the hardware random number generator. You will need to modify it slightly (so as not to use the built in RAND_MAX and rand() function), but the general approach should work.
int rand_lim(int limit) {
/*
return a random number between 0 and limit inclusive.
*/
int divisor = RAND_MAX/(limit+1);
int retval;
do {
retval = rand() / divisor;
} while (retval > limit);
return retval;
}
I used it to generate 100,000 integers between 0 and 19 and got the following uniform distribution
0 4976
1 4921
2 4980
3 5104
4 4862
5 4881
6 4970
7 5003
8 5064
9 5018
10 4930
11 5037
12 5205
13 5046
14 4906
15 4902
16 5010
17 5192
18 5005
19 4988