cvs: /php3/functions php_lcg.h lcg.c /php3 ChangeLog Makefile.in internal_functions.c /php3/functions uniqid.c
| From: | Sascha Schumann | Date: | Sat, 21 Aug 1999 17:41:02 +0000 |
| Subject: | cvs: /php3/functions php_lcg.h lcg.c /php3 ChangeLog Makefile.in internal_functions.c /php3/functions uniqid.c | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-10058@lists.php.net to get a copy of this message | ||
sas Sat Aug 21 13:41:02 1999 EDT
Added files:
/php3/functions php_lcg.h lcg.c
Modified files:
/php3 ChangeLog Makefile.in internal_functions.c
/php3/functions uniqid.c
Log:
- introduce LCG
- improve uniqid()
- don't segfault, if a module doesn't have a function table
Index: php3/ChangeLog
diff -u php3/ChangeLog:1.743 php3/ChangeLog:1.744
--- php3/ChangeLog:1.743 Wed Aug 18 09:35:50 1999
+++ php3/ChangeLog Sat Aug 21 13:41:01 1999
@@ -2,6 +2,9 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
???? ??, 1999, Version 3.0.13
+- Improved speed of uniqid() by using the combined LCG and removing
+ the extra usleep() (Sascha)
+- Introduced general combined linear congruential generator (Sascha)
- OciFetchInto now resets the returned array in all cases (Thies)
- Fixed flushing of cached information to disk in DBA's DB2 module (Sascha)
- DiskFreeSpace() fix (Thies)
Index: php3/Makefile.in
diff -u php3/Makefile.in:1.344 php3/Makefile.in:1.345
--- php3/Makefile.in:1.344 Fri Aug 6 12:09:24 1999
+++ php3/Makefile.in Sat Aug 21 13:41:02 1999
@@ -24,7 +24,7 @@
# +----------------------------------------------------------------------+
#
-# $Id: Makefile.in,v 1.344 1999/08/06 16:09:24 chagenbu Exp $
+# $Id: Makefile.in,v 1.345 1999/08/21 17:41:02 sas Exp $
#
prefix = @prefix@
@@ -103,7 +103,8 @@
functions/yp.c functions/dba.c functions/dba_gdbm.c \
functions/dba_dbm.c functions/dba_ndbm.c functions/dba_cdb.c \
functions/mcrypt.c functions/dba_db2.c functions/mhash.c \
- functions/pcre.c functions/posix.c functions/parsedate.c
+ functions/pcre.c functions/posix.c functions/parsedate.c \
+ functions/lcg.c
FUNCTIONS = $(FUNCTIONS_SOURCE:.c=.o)
Index: php3/internal_functions.c
diff -u php3/internal_functions.c:1.356 php3/internal_functions.c:1.357
--- php3/internal_functions.c:1.356 Fri Aug 6 12:09:24 1999
+++ php3/internal_functions.c Sat Aug 21 13:41:02 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: internal_functions.c,v 1.356 1999/08/06 16:09:24 chagenbu Exp $ */
+/* $Id: internal_functions.c,v 1.357 1999/08/21 17:41:02 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
@@ -110,6 +110,7 @@
#include "functions/php_mhash.h"
#include "functions/php3_pcre.h"
#include "functions/php3_posix.h"
+#include "functions/php_lcg.h"
#ifndef WIN32
#include <netinet/in.h>
@@ -193,6 +194,7 @@
{"ImageMagick", magick_module_ptr},
{"PCRE", pcre_module_ptr},
{"Posix", posix_module_ptr},
+ {"LCG", phpext_lcg_ptr},
{NULL, NULL}
};
@@ -632,7 +634,7 @@
#if 0
php3_printf("%s: Registering module %d\n",module->name, module->module_number);
#endif
- if (register_functions(module->functions)==FAILURE) {
+ if (module->functions && register_functions(module->functions)==FAILURE) {
php3_error(E_CORE_WARNING,"%s: Unable to register functions, unable to
load",module->name);
return FAILURE;
}
@@ -663,7 +665,7 @@
module->module_shutdown_func();
}
module->module_started=0;
- unregister_functions(module->functions,-1);
+ if(module->functions) unregister_functions(module->functions,-1);
#if HAVE_LIBDL
if (module->handle) {
Index: php3/functions/uniqid.c
diff -u php3/functions/uniqid.c:1.34 php3/functions/uniqid.c:1.35
--- php3/functions/uniqid.c:1.34 Wed Jun 16 07:34:22 1999
+++ php3/functions/uniqid.c Sat Aug 21 13:41:02 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: uniqid.c,v 1.34 1999/06/16 11:34:22 ssb Exp $ */
+/* $Id: uniqid.c,v 1.35 1999/08/21 17:41:02 sas Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
@@ -49,6 +49,7 @@
#include <sys/time.h>
#endif
+#include "php_lcg.h"
#include "uniqid.h"
/* {{{ proto string uniqid(string prefix)
@@ -58,7 +59,7 @@
#ifdef HAVE_GETTIMEOFDAY
pval *prefix;
- char uniqid[128];
+ char uniqid[138];
int sec, usec;
struct timeval tv;
TLS_VARS;
@@ -74,9 +75,6 @@
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);
@@ -84,7 +82,7 @@
/* 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