How do I find out the minimum OS requirements for using arc4random_uniform()
? Is it defined in BSD? If so, from what version? Does it run on any Mac OS X version? How about iOS versions? Is there any official place I can find these things out?
Asked
Active
Viewed 1,532 times
7

rid
- 61,078
- 31
- 152
- 193
-
By reading the appropriate C library on the appropriate platform.. I don't know of a "comparison compatibility matrix", though. Sometimes the documentation will say "since" or "conforms to". – Jun 03 '12 at 20:52
-
@pst, you mean I should check all possible platforms, with all possible versions, to see if I can find a man page for it? – rid Jun 03 '12 at 20:53
-
At least the platform(s) of immediate interest, yes. – Jun 03 '12 at 20:53
-
@pst, unfortunately I don't have access to all possible iOS versions and all possible BSD versions with all possible variations or all possible MacOS X versions to test on... If this is the only way, then I suppose I'll just have to refrain from using the function... – rid Jun 03 '12 at 20:55
-
1It's been in BSD [since at least 1997](https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man3/arc4random_uniform.3.html) (similar non-OSX sources agree) ... But [this says only since iOS 4.3](http://stackoverflow.com/questions/160890/generating-random-numbers-in-objective-c) .. – Jun 03 '12 at 20:56
-
@pst, indeed... That's why I was asking. `arc4random()` does seem to be defined by BSD, but `arc4random_uniform()` seems to be a recent addition, and it doesn't even have a separate man page. – rid Jun 03 '12 at 20:58
-
Recent to iOS, yes. To BSD/OSX ... not so recent. It seems like there should be a libc reference specific to iOS? – Jun 03 '12 at 20:58
-
@pst, oh, I thought iOS has always been a full BSD implementation. This makes me wonder... – rid Jun 03 '12 at 20:59
-
My mistake: looks like I was reading the dates wrong... :( – Jun 03 '12 at 21:01
1 Answers
6
If you look at stdlib.h
where it is defined, it says:
u_int32_t arc4random_uniform(u_int32_t /*upper_bound*/) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
So it is available from Lion on for desktops and iOS 4.3 on the iPhone.

pasawaya
- 11,515
- 7
- 53
- 92
-
1
-
@qegal I was wrong :( ARC4 has been part of BSB since 1997. [arc4random_uniform has only recently "been exposed"](http://lists.freedesktop.org/archives/libbsd/2011-June/000038.html). I made the incorrect assumption that the manual dates were updated on last-change. So, while it's [possibly] *been* there, it has been *exposed* recently. – Jun 03 '12 at 21:04
-
I was using this in a multiplatform environment, and ran into an issue now where it just does not work/exist for Android. Nothing to do? – Jonny Jul 16 '15 at 09:23
-