summaryrefslogtreecommitdiff
path: root/ext/standard/uniqid.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>1999-08-21 17:22:08 +0000
committerSascha Schumann <sas@php.net>1999-08-21 17:22:08 +0000
commitc9bb8db0add8141b863d2272f62f97f2ec82abaa (patch)
tree8df901e1591ead5249048b56a81de629b624f3d6 /ext/standard/uniqid.c
parent6313238c63d8b714e926b6a444f251fc631d73a8 (diff)
downloadphp-git-c9bb8db0add8141b863d2272f62f97f2ec82abaa.tar.gz
get rid of that usleep() and add some entropy using the combined lcg
Diffstat (limited to 'ext/standard/uniqid.c')
-rw-r--r--ext/standard/uniqid.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c
index 773ade9a67..c5f241f7ca 100644
--- a/ext/standard/uniqid.c
+++ b/ext/standard/uniqid.c
@@ -35,6 +35,7 @@
#include <sys/time.h>
#endif
+#include "../lcg/php_lcg.h"
#include "uniqid.h"
/* {{{ proto string uniqid(string prefix)
@@ -43,7 +44,7 @@ PHP_FUNCTION(uniqid)
{
#ifdef HAVE_GETTIMEOFDAY
pval *prefix;
- char uniqid[128];
+ char uniqid[138];
int sec, usec;
struct timeval tv;
@@ -57,10 +58,6 @@ PHP_FUNCTION(uniqid)
php_error(E_WARNING, "The prefix to uniqid should not be more than 114 characters.");
return;
}
- /* dont need this on windows so lets not do it*/
-#if HAVE_USLEEP && !(WIN32|WINNT)
- usleep(1);
-#endif
gettimeofday((struct timeval *) &tv, (struct timezone *) NULL);
sec = (int) tv.tv_sec;
usec = (int) (tv.tv_usec % 1000000);
@@ -68,7 +65,7 @@ PHP_FUNCTION(uniqid)
/* The max value usec can have is 0xF423F, so we use only five hex
* digits for usecs:
*/
- sprintf(uniqid, "%s%08x%05x", prefix->value.str.val, sec, usec);
+ sprintf(uniqid, "%s%08x%05x%.8f", prefix->value.str.val, sec, usec, php_combined_lcg() * 10);
RETURN_STRING(uniqid,1);
#endif