* header file cleanup

* 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?
This commit is contained in:
Stig S. Bakken 1999-09-06 16:14:08 +00:00
parent 4d5491e285
commit 009025e00d
16 changed files with 158 additions and 140 deletions

View 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

View 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
@ -11,19 +29,6 @@
/* 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 */
@ -48,3 +50,39 @@
/* 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:
*/

View 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)
])
])

View File

@ -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 */

View 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:

View File

@ -51,7 +51,12 @@
#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
@ -59,12 +64,12 @@
# 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;
}

View 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() }
@ -33,18 +31,26 @@
#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:
*/

View 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 */

View File

@ -23,11 +23,11 @@
#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);

View 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);

View 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

View 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"

View File

@ -18,12 +18,17 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "zend.h"
#include <stdio.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; \

View 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)

View File

@ -20,11 +20,10 @@
#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);

View 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