summaryrefslogtreecommitdiff
path: root/ext/standard/crypt.c
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2001-09-16 20:49:57 +0000
committerSterling Hughes <sterling@php.net>2001-09-16 20:49:57 +0000
commit97fea0931c3cff32c0b027fad372492031349a5b (patch)
tree91c0e17e56eaa188ca17eab6a83f20b4f1af36c3 /ext/standard/crypt.c
parent96763e8372497ddf6ee725f194b142a7534e777d (diff)
downloadphp-git-97fea0931c3cff32c0b027fad372492031349a5b.tar.gz
Make rand thread safe when ZTS is defined.
Diffstat (limited to 'ext/standard/crypt.c')
-rw-r--r--ext/standard/crypt.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index ac619d52ef..3485cdac92 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -87,7 +87,7 @@ extern char *crypt(char *__key, char *__salt);
#endif
-#define PHP_CRYPT_RAND php_rand()
+#define PHP_CRYPT_RAND php_rand(TSRMLS_C)
static int php_crypt_rand_seeded=0;
@@ -106,7 +106,7 @@ PHP_MINIT_FUNCTION(crypt)
PHP_RINIT_FUNCTION(crypt)
{
if(!php_crypt_rand_seeded) {
- php_srand(time(0) * getpid() * (php_combined_lcg(TSRMLS_C) * 10000.0));
+ php_srand(time(0) * getpid() * (php_combined_lcg(TSRMLS_C) * 10000.0) TSRMLS_CC);
php_crypt_rand_seeded=1;
}
return SUCCESS;
@@ -115,7 +115,8 @@ PHP_RINIT_FUNCTION(crypt)
static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-static void php_to64(char *s, long v, int n) {
+static void php_to64(char *s, long v, int n)
+{
while (--n >= 0) {
*s++ = itoa64[v&0x3f];
v >>= 6;