summaryrefslogtreecommitdiff
path: root/main/php_reentrancy.h
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>1999-11-26 17:07:41 +0000
committerSascha Schumann <sas@php.net>1999-11-26 17:07:41 +0000
commit35b30a8d0c506c861475fa5ce394900adfb2f0ed (patch)
tree262f8ec640709e73f5249b5691df06c632a48ed9 /main/php_reentrancy.h
parent2f6ded9ac9bb8826eb9b3b79b8cdc018c90aff54 (diff)
downloadphp-git-35b30a8d0c506c861475fa5ce394900adfb2f0ed.tar.gz
Add reentrant versions of ctime, localtime, gmtime, asctime.
These cannot be implemented platform-independent, so we fall back to the native non-reentrant versions, but lock during each access (only if ZTS is used). To initialize/destroy the used data structures, you need to call reentrancy_startup() before sapi_startup(), and reentrancy_shutdown() after sapi_shutdown().
Diffstat (limited to 'main/php_reentrancy.h')
-rw-r--r--main/php_reentrancy.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h
new file mode 100644
index 0000000000..942a27bca3
--- /dev/null
+++ b/main/php_reentrancy.h
@@ -0,0 +1,53 @@
+#ifndef PHP_REENTRANCY_H
+#define PHP_REENTRANCY_H
+
+#include "php_config.h"
+
+#include <time.h>
+
+/* currently, PHP does not check for these functions, but assumes
+ that they are available on all systems. */
+
+#define HAVE_LOCALTIME 1
+#define HAVE_GMTIME 1
+#define HAVE_ASCTIME 1
+#define HAVE_CTIME 1
+
+
+#if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
+#define PHP_NEED_REENTRANCY 1
+#define localtime_r php_localtime_r
+struct tm *localtime_r(const time_t *const timep, struct tm *p_tm);
+#endif
+
+
+#if !defined(HAVE_CTIME_R) && defined(HAVE_CTIME)
+#define PHP_NEED_REENTRANCY 1
+#define ctime_r php_ctime_r
+char *ctime_r(const time_t *clock, char *buf);
+#endif
+
+
+#if !defined(HAVE_ASCTIME_R) && defined(HAVE_ASCTIME)
+#define PHP_NEED_REENTRANCY 1
+#define asctime_r php_asctime_r
+char *asctime_r(const struct tm *tm, char *buf);
+#endif
+
+
+#if !defined(HAVE_GMTIME_R) && defined(HAVE_GMTIME)
+#define PHP_NEED_REENTRANCY 1
+#define gmtime_r php_gmtime_r
+struct tm *gmtime_r(const time_t *const timep, struct tm *p_tm);
+#endif
+
+
+#if defined(ZTS) && defined(PHP_NEED_REENTRANCY)
+void reentrancy_startup(void);
+void reentrancy_shutdown(void);
+#else
+#define reentrancy_startup()
+#define reentrancy_shutdown()
+#endif
+
+#endif