summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2000-09-06 20:27:12 +0000
committerAndi Gutmans <andi@php.net>2000-09-06 20:27:12 +0000
commitb8a95da22ab157b85fb1cf6c55c1ce71da420248 (patch)
tree67dfcb88a43d1a16bb1c613711feb32ccd8438a2 /TSRM
parent180c337885981c4cf1e6f6facf64d549fe6a932d (diff)
downloadphp-git-b8a95da22ab157b85fb1cf6c55c1ce71da420248.tar.gz
- Centralize some configuration stuff
- Use inline in my strtok_r implementation
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_config.w32.h9
-rw-r--r--TSRM/tsrm_config_common.h22
-rw-r--r--TSRM/tsrm_strtok_r.c7
-rw-r--r--TSRM/tsrm_virtual_cwd.c14
-rw-r--r--TSRM/tsrm_virtual_cwd.h10
5 files changed, 38 insertions, 24 deletions
diff --git a/TSRM/tsrm_config.w32.h b/TSRM/tsrm_config.w32.h
index 709d9003f9..405d8c7c8f 100644
--- a/TSRM/tsrm_config.w32.h
+++ b/TSRM/tsrm_config.w32.h
@@ -2,5 +2,14 @@
#define TSRM_CONFIG_W32_H
#define HAVE_UTIME 1
+#define HAVE_ALLOCA 1
+
+#undef inline
+#ifdef ZEND_WIN32_FORCE_INLINE
+# define inline __forceinline
+#else
+# define inline
+#endif
+
#endif
diff --git a/TSRM/tsrm_config_common.h b/TSRM/tsrm_config_common.h
new file mode 100644
index 0000000000..1bec4d86f8
--- /dev/null
+++ b/TSRM/tsrm_config_common.h
@@ -0,0 +1,22 @@
+#ifndef TSRM_CONFIG_COMMON_H
+#define TSRM_CONFIG_COMMON_H
+
+#if WINNT|WIN32
+# define TSRM_WIN32
+#endif
+
+#ifndef TSRM_WIN32
+# include "tsrm_config.h"
+#else
+# include "tsrm_config.w32.h"
+#endif
+
+#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2))
+# define tsrm_do_alloca(p) alloca(p)
+# define tsrm_free_alloca(p)
+#else
+# define tsrm_do_alloca(p) malloc(p)
+# define tsrm_free_alloca(p) free(p)
+#endif
+
+#endif /* TSRM_CONFIG_COMMON_H */
diff --git a/TSRM/tsrm_strtok_r.c b/TSRM/tsrm_strtok_r.c
index b631825140..e9ad26a7ac 100644
--- a/TSRM/tsrm_strtok_r.c
+++ b/TSRM/tsrm_strtok_r.c
@@ -1,8 +1,9 @@
-#include "tsrm_strtok_r.h"
-
#include <stdio.h>
-static int in_character_class(char ch, const char *delim)
+#include "tsrm_config_common.h"
+#include "tsrm_strtok_r.h"
+
+static inline int in_character_class(char ch, const char *delim)
{
while (*delim) {
if (*delim == ch) {
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index e1d7d492c3..e19a8b2513 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -37,16 +37,6 @@
#define MAXPATHLEN 256
#endif
-#ifndef do_alloca
-# if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(TSRM_WIN32))
-# define do_alloca(p) alloca(p)
-# define free_alloca(p)
-# else
-# define do_alloca(p) malloc(p)
-# define free_alloca(p) free(p)
-# endif
-#endif
-
#ifdef TSRM_WIN32
#include <io.h>
#endif
@@ -444,14 +434,14 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
if (length == COPY_WHEN_ABSOLUTE && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
length++;
}
- temp = (char *) do_alloca(length+1);
+ temp = (char *) tsrm_do_alloca(length+1);
memcpy(temp, path, length);
temp[length] = 0;
#if VIRTUAL_CWD_DEBUG
fprintf (stderr, "Changing directory to %s\n", temp);
#endif
retval = p_chdir(temp);
- free_alloca(temp);
+ tsrm_free_alloca(temp);
return retval;
}
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index 0a882c364c..eee3ad0480 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -22,15 +22,7 @@
#ifndef VIRTUAL_CWD_H
#define VIRTUAL_CWD_H
-#ifdef WIN32
-# define TSRM_WIN32
-#endif
-
-#ifndef TSRM_WIN32
-# include "tsrm_config.h"
-#else
-# include "tsrm_config.w32.h"
-#endif
+#include "tsrm_config_common.h"
#include <sys/types.h>
#include <sys/stat.h>