Created
February 1, 2014 02:35
-
-
Save simonwelsh/8747179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Variant HHVM_FUNCTION(rand, ActRec* ar) { | |
| int64_t min, max; | |
| if (ar->numArgs() == 0) { | |
| min = 0; | |
| max = HHVM_FN(getrandmax)(); | |
| } else { | |
| min = ar->getExtraArg(0)->m_data.num; | |
| max = ar->getExtraArg(1)->m_data.num; | |
| } | |
| if (!s_rand_is_seeded) { | |
| s_rand_is_seeded = true; | |
| srand(math_generate_seed()); | |
| } | |
| int64_t number = rand(); | |
| if (min != 0 || max != RAND_MAX) { | |
| RAND_RANGE(number, min, max, RAND_MAX); | |
| } | |
| return number; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment