Use random() for random number generation on OS X and FreeBSD, and rand() elsewhere.