use arc4random() instead of rand() on *BSD

This merges changes from MoarVM's libtommath.

https://github.com/MoarVM/MoarVM/commit/c629ef5912002ff54e3f5dad58f8ef1dd64deb9c
https://github.com/MoarVM/MoarVM/commit/14aa33f4cf464726e6087d44775bf7f5adb1382c