* header file cleanup
authorStig S. Bakken <stig@php.net>
Mon, 6 Sep 1999 16:14:08 +0000 (16:14 +0000)
committerStig S. Bakken <stig@php.net>
Mon, 6 Sep 1999 16:14:08 +0000 (16:14 +0000)
* fixed --enable-thread-safety build for UNIX

I don't have a Win32 environment available, could someone please try
compiling on Win32 to see if I got all the header file stuff right there?

16 files changed:
Zend/Makefile.am
Zend/acconfig.h
Zend/acinclude.m4
Zend/config.unix.h [deleted file]
Zend/configure.in
Zend/zend-scanner.l
Zend/zend.h
Zend/zend_API.c
Zend/zend_alloc.c
Zend/zend_compile.h
Zend/zend_config.w32.h [moved from Zend/config.w32.h with 90% similarity]
Zend/zend_execute.c
Zend/zend_hash.c
Zend/zend_list.c
Zend/zend_ptr_stack.c
Zend/zend_sprintf.c

index de43d273482131e125d7e4ebd52f3cfdeccbdc2a..54759105cd6df3f7c038f21dba8ca81317e7eddb 100644 (file)
@@ -12,8 +12,14 @@ libzend_a_SOURCES=\
        zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
        zend_list.c zend_indent.c
 
+# taken from automake 1.4
+CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+
 # automake isn't too clever about "non-standard" use of lex and yacc
 
+zend-scanner.o: @ZEND_SCANNER_SRC@
+       @ZEND_SCANNER_COMPILE@
+
 zend-scanner.c: zend-scanner.l
        $(LEX) -Pzend -ozend-scanner.c -i $(srcdir)/zend-scanner.l
 
index 7a80526f5529ffa3914eb2b0e777ea1d4ea65f54..424af6f84dc5a9db7867c9ca385ae9d42fee6967 100644 (file)
@@ -1,3 +1,21 @@
+#define ZEND_API
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+@TOP@
+
 /* This is the default configuration file to read */
 #define USE_CONFIG_FILE 1
 
 /* define ulong by configure if it is missed (most probably is) */
 #undef ulong
 
-/* type check for in_addr_t */
-#undef in_addr_t
-
-/* Define if you have dirent.h but opendir() resides in libc rather than in libdir */
-/* This will cause HAVE_DIRENT_H defined twice sometimes, but it should be problem */
-#define HAVE_DIRENT_H 0
-
-/* Define if you have struct flock */
-#define HAVE_STRUCT_FLOCK 0
-
-/* Define if you have the resolv library (-lresolv). */
-#define HAVE_LIBRESOLV 0
-
 /* Undefine if you want stricter XML/SGML compliance by default */
 /* (this disables "<?expression?>" by default) */
 #define T_DEFAULT_SHORT_OPEN_TAG 1
@@ -32,9 +37,6 @@
 #define REGEX 0
 #define HSREGEX 0
 
-/* Define if you have libdl (used for dynamic linking) */
-#define HAVE_LIBDL 0
-
 #undef ZEND_DEBUG
 
 /* Define if you want to enable bc style precision math support */
 
 /* Define to compile Zend thread safe */
 #undef ZTS
+
+@BOTTOM@
+
+/* Define if you have stdiostream.h */
+#undef HAVE_STDIOSTREAM_H
+
+#ifdef HAVE_LIBDL
+# ifdef HAVE_DLFCN_H
+#  include <dlfcn.h>
+# endif
+# define DL_LOAD(libname)      dlopen(libname, RTLD_NOW)
+# define DL_UNLOAD             dlclose
+# define DL_FETCH_SYMBOL       dlsym
+# define DL_HANDLE             void *
+# define ZEND_EXTENSIONS_SUPPORT 1
+#else
+# define DL_HANDLE             void *
+# define ZEND_EXTENSIONS_SUPPORT 0
+#endif
+
+#if ZEND_BROKEN_SPRINTF
+int zend_sprintf(char *buffer, const char *format, ...);
+#else
+# define zend_sprintf sprintf
+#endif
+
+#if ZEND_DEBUG
+# define inline
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
index 9b1421eb6e429edd98f289554229bfb47eb02954..f8a1eb75d87528e0b2bdc8ceda1b4d0155b917c9 100644 (file)
@@ -5,16 +5,16 @@ dnl This file contains local autoconf functions.
 dnl
 dnl Check for broken sprintf()
 dnl
-AC_DEFUN(AC_BROKEN_SPRINTF,[
+AC_DEFUN(AC_ZEND_BROKEN_SPRINTF,[
   AC_MSG_CHECKING([for broken sprintf])
   AC_TRY_RUN([main() { char buf[20]; exit (sprintf(buf,"testing 123")!=11); }],[
-    AC_DEFINE(BROKEN_SPRINTF,0)
+    AC_DEFINE(ZEND_BROKEN_SPRINTF,0)
     AC_MSG_RESULT(ok)
   ],[
-    AC_DEFINE(BROKEN_SPRINTF,1)
+    AC_DEFINE(ZEND_BROKEN_SPRINTF,1)
     AC_MSG_RESULT(broken)
   ],[
-    AC_DEFINE(BROKEN_SPRINTF,0)
+    AC_DEFINE(ZEND_BROKEN_SPRINTF,0)
     AC_MSG_RESULT(cannot check, guessing ok)
   ])
 ])
diff --git a/Zend/config.unix.h b/Zend/config.unix.h
deleted file mode 100644 (file)
index 149d75f..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | Zend Engine                                                          |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1998, 1999 Andi Gutmans, Zeev Suraski                  |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 0.91 of the Zend license,     |
-   | that is bundled with this package in the file LICENSE, and is        | 
-   | available at through the world-wide-web at                           |
-   | http://www.zend.com/license/0_91.txt.                                |
-   | If you did not receive a copy of the Zend license and are unable to  |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@zend.com so we can mail you a copy immediately.              |
-   +----------------------------------------------------------------------+
-   | Authors: Andi Gutmans <andi@zend.com>                                |
-   |          Zeev Suraski <zeev@zend.com>                                |
-   +----------------------------------------------------------------------+
-*/
-
-#ifndef _CONFIG_UNIX_H
-#define _CONFIG_UNIX_H
-
-#define ZEND_API
-
-#include <stdlib.h>
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if HAVE_STRING_H
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-
-#if HAVE_LIBDL
-#      include <dlfcn.h>
-#      define DL_LOAD(libname) dlopen(libname, RTLD_NOW)
-#      define DL_UNLOAD                dlclose
-#      define DL_FETCH_SYMBOL  dlsym
-#      define DL_HANDLE                void *
-#      define ZEND_EXTENSIONS_SUPPORT 1
-#else
-#      define DL_HANDLE                void *
-#      define ZEND_EXTENSIONS_SUPPORT 0
-#endif
-
-#if BROKEN_SPRINTF
-int zend_sprintf(char *buffer, const char *format, ...);
-#else
-#      define zend_sprintf sprintf
-#endif
-
-#if ZEND_DEBUG
-#      define inline
-#endif
-
-#endif /* _CONFIG_UNIX_H */
index 8f3c3fad1c617fd3c47469e1a7d92841335da577..a947b35a2a7e5e9897e0a1d63044b91ffc82b6be 100644 (file)
@@ -24,6 +24,7 @@ else
     AC_MSG_RESULT($1.$2 (ok))
 fi
 AC_PROG_CC
+AC_PROG_CXX
 AC_PROG_RANLIB
 AC_PROG_CC_C_O
 AM_PROG_LEX
@@ -56,25 +57,20 @@ AC_CHECK_LIB(c, dlopen, [
   LIBS="-ldl $LIBS"
   AC_DEFINE(HAVE_LIBDL) ], []) ])
 
-dnl The sin may be in a library which need not be specifed
-dnl as well as res_search resides in libsocket
-AC_CHECK_LIB(c, sin, [:], [
- AC_CHECK_LIB(m, sin) ])
-
 dnl Checks for header files.
 AC_HEADER_STDC
 
-dnl In QNX opendir resides in libc but dirent.h is still required
-if test "`uname -s 2>/dev/null`" != "QNX"; then
-       AC_HEADER_DIRENT
-else
-       AC_CHECK_HEADERS(dirent.h)
-fi
 dnl QNX requires unix.h to allow functions in libunix to work properly
-AC_CHECK_HEADERS(fcntl.h unistd.h crypt.h sys/file.h memory.h pwd.h grp.h sys/socket.h sys/wait.h syslog.h string.h sys/varargs.h stdarg.h sys/resource.h sys/time.h signal.h netinet/in.h dlfcn.h limits.h sys/types.h sys/statvfs.h sys/statfs.h unix.h db.h ndbm.h)
+AC_CHECK_HEADERS(limits.h malloc.h string.h unistd.h stdarg.h sys/types.h signal.h unix.h dlfcn.h)
+
+dnl C++ specific header files
+AC_LANG_CPLUSPLUS
+AC_CHECK_HEADER(stdiostream.h, [ AC_DEFINE(HAVE_STDIOSTREAM_H) ])
+AC_LANG_C
 
 dnl Checks for types
 AC_TYPE_SIZE_T
+AC_TYPE_SIGNAL
 
 dnl This is required for QNX and may be some BSD derived systems
 AC_CHECK_TYPE( uint, unsigned int )
@@ -82,11 +78,10 @@ AC_CHECK_TYPE( ulong, unsigned long )
 
 dnl Checks for library functions.
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(memcpy memmove strdup strerror strcasecmp strstr flock lockf putenv tempnam usleep setlocale gettimeofday setvbuf srand48 lrand48 srandom random link symlink regcomp getlogin cuserid vsnprintf snprintf gcvt utime crypt setitimer rint unsetenv strftime setsockopt tzset statvfs statfs inet_aton getpid kill)
-AC_FUNC_UTIME_NULL
+AC_FUNC_MEMCMP
 AC_FUNC_ALLOCA
-AC_BROKEN_SPRINTF
-AC_REPLACE_FUNCS(getopt)
+AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol)
+AC_ZEND_BROKEN_SPRINTF
 
 AC_MSG_CHECKING(whether to include debugging symbols)
 AC_ARG_ENABLE(debug,
@@ -129,22 +124,35 @@ AC_ARG_ENABLE(memory-limit,
 ]) 
 
 
+dnl Sigh. This will probably break automake's automatic dependencies..
 AC_MSG_CHECKING(whether to build Zend thread-safe)
 AC_ARG_ENABLE(thread-safety,
 [  --enable-thread-safety  Whether to build Zend thread-safe.],[
-  AC_DEFINE(ZTS)
-  AC_MSG_RESULT(yes)
+  if test "$enableval" = "yes"; then
+    AC_DEFINE(ZTS)
+    ZEND_SCANNER_SRC=zend-scanner.cc
+    ZEND_SCANNER_COMPILE='$(CXXCOMPILE) -c $< -o $@'
+    AC_MSG_RESULT(yes)
+  else
+    ZEND_SCANNER_SRC=zend-scanner.c
+    ZEND_SCANNER_COMPILE='$(COMPILE) -c $<'
+    AC_MSG_RESULT(no)
+  fi
 ],[
+  ZEND_SCANNER_SRC=zend-scanner.c
+  ZEND_SCANNER_COMPILE='$(COMPILE) -c $<'
   AC_MSG_RESULT(no)
 ])
 AC_SUBST(TSRM_DIR)
 AC_SUBST(TSRM_LIB)
+AC_SUBST(ZEND_SCANNER_SRC)
+AC_SUBST(ZEND_SCANNER_COMPILE)
 
 AC_SUBST(CFLAGS_SHLIB)
 AC_SUBST(LDFLAGS_SHLIB)
 AC_SUBST(LDFLAGS_SHLIB_EXPORT)
 
-AC_OUTPUT(Makefile, [], [])
+AC_OUTPUT(Makefile)
 
 
 # Local Variables:
index 6d325180770f553d0402c82c0ee60f5b9f70e053..d113c3d520e3d143a15edd6fc07bd386988ccb15 100644 (file)
 
 #ifdef ZTS
 # include <fstream.h>
-# include <stdiostr.h>
+# ifdef HAVE_STDIOSTR_H
+#  include <stdiostr.h>
+# endif
+# ifdef HAVE_STDIOSTREAM_H
+#  include <stdiostream.h>
+# endif
 # if WIN32||WINNT
 #  include <strstrea.h>
 # else
 # endif
 #endif
 
-#if HAVE_STDARG_H
-#include <stdarg.h>
+#ifdef HAVE_STDARG_H
+# include <stdarg.h>
 #endif
 
-#if HAVE_UNISTD_H
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
 #endif
 
 #ifdef ZTS
@@ -224,7 +229,7 @@ ZEND_API inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
                                if (!file_handle->handle.fp) {
                                        return FAILURE;
                                }
-                               file_handle->handle.is = new stdiostream(file_handle->handle.fp);
+                               file_handle->handle.is = new istdiostream(file_handle->handle.fp);
                                break;
                        }
                case ZEND_HANDLE_FP:
@@ -234,7 +239,7 @@ ZEND_API inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
                                if (!file_handle->handle.fp) {
                                        return FAILURE;
                                }
-                               file_handle->handle.is = new stdiostream(file_handle->handle.fp);
+                               file_handle->handle.is = new istdiostream(file_handle->handle.fp);
                        }       
                        break;
        }
index c43c31805be5384f643367f39179ab30f02e7bcd..5e29d56977e60a0ea48ed4d8c648dbac0dd06b8b 100644 (file)
@@ -23,8 +23,6 @@
 
 #define ZEND_VERSION "0.90"
 
-#include <stdarg.h>
-
 #ifdef __cplusplus
 #define BEGIN_EXTERN_C() extern "C" {
 #define END_EXTERN_C() }
 #define END_EXTERN_C()
 #endif
 
-
 #include <stdio.h>
 
 /*
  * general definitions
  */
 
-#if WINNT||WIN32
-#include "config.w32.h"
+#if (defined(WINNT) && WINNT) || (defined(WIN32) && WIN32)
+# include "zend_config.w32.h"
 #else
-#include "zend_config.h"
-#include "config.unix.h"
+# include "zend_config.h"
+#endif
+
+/* all HAVE_XXX test have to be after the include of zend_config above */
+
+#ifdef HAVE_UNIX_H
+# include <unix.h>
+#endif
+
+#ifdef HAVE_STDARG_H
+# include <stdarg.h>
 #endif
 
 #if ZEND_DEBUG
@@ -84,7 +90,7 @@ typedef unsigned char zend_bool;
 #undef SUCCESS
 #undef FAILURE
 #define SUCCESS 0
-#define FAILURE -1                             /* this MUST stay a negative number, or it may effect functions! */
+#define FAILURE -1                             /* this MUST stay a negative number, or it may affect functions! */
 
 
 #include "zend_hash.h"
@@ -287,3 +293,10 @@ extern zend_utility_values zend_uv;
 #define ZEND_MAX_RESERVED_RESOURCES    1
 
 #endif /* _ZEND_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
index d324d877d8e130c84fbd369cad4a765cf538542d..23db2b88f1235a5df50d0403c952d68b79ceefce 100644 (file)
@@ -26,8 +26,8 @@
 #include "zend_constants.h"
 #include "zend_operators.h"
 
-#if HAVE_STDARG_H
-#include <stdarg.h>
+#ifdef HAVE_STDARG_H
+# include <stdarg.h>
 #endif
 
 /* these variables are true statics/globals, and have to be mutex'ed on every access */
index 29aa3bca6932ad436d920c0337ce9529d0a312b0..97cc8801b162dda03a7cbbf8d3514e0e3c39a968 100644 (file)
 #include "zend.h"
 #include "zend_alloc.h"
 #include "zend_globals.h"
-#if HAVE_SIGNAL_H
-#include <signal.h>
+#ifdef HAVE_SIGNAL_H
+# include <signal.h>
 #endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
 #endif
 
 #ifndef ZTS
@@ -124,7 +124,7 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
 
        if (!p) {
                fprintf(stderr,"FATAL:  emalloc():  Unable to allocate %ld bytes\n", (long) size);
-#if ZEND_DEBUG && HAVE_KILL && HAVE_GETPID
+#if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID)
                kill(getpid(), SIGSEGV);
 #else
                exit(1);
index 291390f41b5e53514361e629159598a6f2e278f8..7b9a6421915efd9445947048f3fd28a9cb008e09 100644 (file)
@@ -23,8 +23,8 @@
 
 #include "zend.h"
 
-#if HAVE_STDARG_H
-#include <stdarg.h>
+#ifdef HAVE_STDARG_H
+# include <stdarg.h>
 #endif
 
 #include "zend_llist.h"
@@ -34,9 +34,9 @@
 #define DEBUG_ZEND 0
 
 #ifndef ZTS
-#define SUPPORT_INTERACTIVE 1
+# define SUPPORT_INTERACTIVE 1
 #else
-#define SUPPORT_INTERACTIVE 0
+# define SUPPORT_INTERACTIVE 0
 #endif
 
 #define FREE_PNODE(znode)      zval_dtor(&znode->u.constant);
similarity index 90%
rename from Zend/config.w32.h
rename to Zend/zend_config.w32.h
index 6fe160e72a0cb716bfdac4455ea5e125855563c3..b4184b241e66012209ff619e0fc695e36a82678d 100644 (file)
@@ -31,10 +31,14 @@ typedef unsigned int uint;
 #define HAVE_ALLOCA 1
 #include <malloc.h>
 
-#define HAVE_DIRENT_H 0
-
-#define HAVE_KILL      0
-#define HAVE_GETPID    1
+#undef HAVE_KILL
+#define HAVE_GETPID 1
+#define HAVE_ALLOCA_H 1
+#define HAVE_MEMCPY 1
+#define HAVE_STRDUP 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIOSTR_H 1
+#define istdiostream stdiostream
 
 #ifdef inline
 #undef inline
index a55313f95d77899f2fac783cd40a1f4e4a088fed..d4696ccd94457e8e0769493628368f45985f5820 100644 (file)
@@ -21,8 +21,8 @@
 #include <stdio.h>
 #include <signal.h>
 
-#if (HAVE_ALLOCA && HAVE_ALLOCA_H)
-#include <alloca.h>
+#if defined(HAVE_ALLOCA) && defined(HAVE_ALLOCA_H)
+# include <alloca.h>
 #endif
 
 #include "zend.h"
index db14bdf7701343a5f038c40fe655fa8c0f22fe50..19e45a47efc5fa3b0337fd8a0361c58cd645ea97 100644 (file)
 */
 
 
+#include "zend.h"
+
 #include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
 
-#include "zend.h"
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
 
+#ifdef HAVE_LIMITS_H
+# include <limits.h>
+#endif
 
 #define HANDLE_NUMERIC(key,length,func) { \
        register char *tmp=key; \
index 0aade1c525d38f0ae6ad813b82fc574c5456978f..21555cacea24f3cef1c69e6609e6ff22b1aae119 100644 (file)
@@ -25,7 +25,6 @@
 #include "zend_API.h"
 #include "zend_globals.h"
 
-
 ZEND_API int le_index_ptr;
 
 static inline int zend_list_do_insert(HashTable *list,void *ptr, int type)
index 3048d99c2a40bcae886e0bde5cf4e8e2867a2864..17ed0a4b1f0e566e24023da89e5eb0dbe3f13a7c 100644 (file)
 
 #include "zend.h"
 #include "zend_ptr_stack.h"
-#if HAVE_STDARG_H
-#include <stdarg.h>
+#ifdef HAVE_STDARG_H
+# include <stdarg.h>
 #endif
 
-
 ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack)
 {
        stack->top_element = stack->elements = (void **) emalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE);
index 1094451cec730120272518e001af7a7d575a34cc..878ba32d2891b99e3ee3452dc82257f38e1f3e82 100644 (file)
@@ -22,8 +22,8 @@
 
 #include "zend.h"
 
-#if HAVE_STDARG_H
-#include <stdarg.h>
+#ifdef HAVE_STDARG_H
+# include <stdarg.h>
 #endif
 
 #if BROKEN_SPRINTF