bsd: replace random() by our own function