summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2005-06-16 23:12:10 +0000
committerfoobar <sniper@php.net>2005-06-16 23:12:10 +0000
commita736f99e2f55f70c87f20b8fd109b346d0949da8 (patch)
tree33b40ab3ce3e512c7e5cfed1b92b2e2c6a9fc5b7
parent7a7cda7a4cac9c2228b88db0b044e5f1eae20a44 (diff)
downloadphp-git-a736f99e2f55f70c87f20b8fd109b346d0949da8.tar.gz
- Improve portability.
# TODO: The standalone lib needs it's own build stuff, pretty much same as # Zend has for standalone builds.
-rw-r--r--ext/date/config.m417
-rw-r--r--ext/date/lib/dow.c2
-rw-r--r--ext/date/lib/parse_date.c12
-rw-r--r--ext/date/lib/parse_date.re12
-rw-r--r--ext/date/lib/parse_tz.c10
-rw-r--r--ext/date/lib/resource/parse_date.re12
-rw-r--r--ext/date/lib/timelib.c2
-rw-r--r--ext/date/lib/timelib.h5
-rw-r--r--ext/date/lib/timelib.m450
-rw-r--r--ext/date/lib/timelib_structs.h38
-rw-r--r--ext/date/lib/tm2unixtime.c1
-rw-r--r--ext/date/lib/unixtime2tm.c12
-rw-r--r--ext/date/php_date.c1
13 files changed, 158 insertions, 16 deletions
diff --git a/ext/date/config.m4 b/ext/date/config.m4
index c9bfadfa06..bd7fd39b1b 100644
--- a/ext/date/config.m4
+++ b/ext/date/config.m4
@@ -1,9 +1,22 @@
dnl $Id$
dnl config.m4 for date extension
-PHP_DATE_CFLAGS="-I@ext_srcdir@/lib"
+sinclude(ext/date/lib/timelib.m4)
+sinclude(lib/timelib.m4)
+
+PHP_DATE_CFLAGS="-I@ext_builddir@/lib"
timelib_sources="lib/dow.c lib/parse_date.c lib/parse_tz.c
lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c"
PHP_NEW_EXTENSION(date, php_date.c $timelib_sources, no,, $PHP_DATE_CFLAGS)
-PHP_ADD_BUILD_DIR([$ext_builddir/lib])
+PHP_ADD_BUILD_DIR([$ext_builddir/lib], 1)
+
+cat >> $ext_builddir/lib/tl_config.h <<EOF
+#if PHP_WIN32
+# include "config.w32.h"
+#elif defined(NETWARE)
+# include "config.nw.h"
+#else
+# include <php_config.h>
+#endif
+EOF
diff --git a/ext/date/lib/dow.c b/ext/date/lib/dow.c
index 4066d61b4c..f37f5c1cf6 100644
--- a/ext/date/lib/dow.c
+++ b/ext/date/lib/dow.c
@@ -18,6 +18,8 @@
/* $Id$ */
+#include <tl_config.h>
+
#include "timelib_structs.h"
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index da9da38d3a..8cde2675a1 100644
--- a/ext/date/lib/parse_date.c
+++ b/ext/date/lib/parse_date.c
@@ -20,9 +20,19 @@
/* $Id$ */
-#include <stdlib.h>
+#include <tl_config.h>
+
#include <stdio.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
#include <string.h>
+#else
+#include <strings.h>
+#endif
+
#include "timelib.h"
#if defined(_MSC_VER)
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index 22c3b24d7d..af4e95c2ea 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -18,9 +18,19 @@
/* $Id$ */
-#include <stdlib.h>
+#include <tl_config.h>
+
#include <stdio.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
#include <string.h>
+#else
+#include <strings.h>
+#endif
+
#include "timelib.h"
#if defined(_MSC_VER)
diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c
index b3680c5d42..fd6bf8ff3c 100644
--- a/ext/date/lib/parse_tz.c
+++ b/ext/date/lib/parse_tz.c
@@ -18,13 +18,15 @@
/* $Id$ */
+#include <tl_config.h>
+
#include <stdio.h>
-#ifdef WIN32
-#include <winsock2.h>
+
+#ifdef HAVE_STRING_H
+#include <string.h>
#else
-#include <inttypes.h>
+#include <strings.h>
#endif
-#include <string.h>
#include "timelib.h"
#include "timezonedb.h"
diff --git a/ext/date/lib/resource/parse_date.re b/ext/date/lib/resource/parse_date.re
index 22c3b24d7d..af4e95c2ea 100644
--- a/ext/date/lib/resource/parse_date.re
+++ b/ext/date/lib/resource/parse_date.re
@@ -18,9 +18,19 @@
/* $Id$ */
-#include <stdlib.h>
+#include <tl_config.h>
+
#include <stdio.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
#include <string.h>
+#else
+#include <strings.h>
+#endif
+
#include "timelib.h"
#if defined(_MSC_VER)
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
index f5fb5e0b16..a0bc031472 100644
--- a/ext/date/lib/timelib.c
+++ b/ext/date/lib/timelib.c
@@ -18,6 +18,8 @@
/* $Id$ */
+#include <tl_config.h>
+
#include "timelib_structs.h"
#include "timelib.h"
#include <ctype.h>
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index 347c5213d8..53bd5c72f7 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -18,6 +18,9 @@
/* $Id$ */
+#ifndef __TIMELIB_H__
+#define __TIMELIB_H__
+
#include "timelib_structs.h"
#define TIMELIB_NONE 0x00
@@ -31,7 +34,6 @@
#define LONG_MIN (- LONG_MAX - 1)
#endif
-
/* From dow.c */
timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d);
@@ -71,3 +73,4 @@ void timelib_time_offset_dtor(timelib_time_offset* t);
signed long timelib_date_to_int(timelib_time *d, int *error);
void timelib_dump_date(timelib_time *d, int options);
+#endif
diff --git a/ext/date/lib/timelib.m4 b/ext/date/lib/timelib.m4
new file mode 100644
index 0000000000..b99dc0c786
--- /dev/null
+++ b/ext/date/lib/timelib.m4
@@ -0,0 +1,50 @@
+dnl
+dnl $Id$
+dnl
+dnl
+dnl TL_DEF_HAVE(what [, why])
+dnl
+dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [WHY])'
+dnl
+AC_DEFUN([TL_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___),1,[ $2 ])])dnl
+
+dnl
+dnl TL_CHECK_INT_TYPE(type)
+dnl
+AC_DEFUN([TL_CHECK_INT_TYPE],[
+AC_CACHE_CHECK([for $1], ac_cv_int_type_$1, [
+AC_TRY_COMPILE([
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#elif HAVE_STDINT_H
+# include <stdint.h>
+#endif],
+[if (($1 *) 0)
+ return 0;
+if (sizeof ($1))
+ return 0;
+], [ac_cv_int_type_$1=yes], [ac_cv_int_type_$1=no])
+])
+if test "$ac_cv_int_type_$1" = "yes"; then
+ TL_DEF_HAVE($1, [Define if $1 type is present.])
+fi
+])dnl
+
+dnl Check for types, sizes, etc. needed by timelib
+AC_CHECK_SIZEOF(long, 8)
+AC_CHECK_SIZEOF(int, 4)
+TL_CHECK_INT_TYPE(int32_t)
+TL_CHECK_INT_TYPE(uint32_t)
+
+dnl Check for headers needed by timelib
+AC_CHECK_HEADERS([ \
+sys/types.h \
+inttypes.h \
+stdint.h \
+string.h \
+stdlib.h
+])
+
diff --git a/ext/date/lib/timelib_structs.h b/ext/date/lib/timelib_structs.h
index edc11351de..830595777c 100644
--- a/ext/date/lib/timelib_structs.h
+++ b/ext/date/lib/timelib_structs.h
@@ -21,13 +21,42 @@
#ifndef __TIMELIB_STRUCTS_H__
#define __TIMELIB_STRUCTS_H__
-#include <stdlib.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#elif defined(HAVE_STDINT_H)
+#include <stdint.h>
+#endif
+
+#ifndef HAVE_INT32_T
+# if SIZEOF_INT == 4
+typedef int int32_t;
+# elif SIZEOF_LONG == 4
+typedef long int int32_t;
+# endif
+#endif
+
+#ifndef HAVE_UINT32_T
+# if SIZEOF_INT == 4
+typedef unsigned int uint32_t;
+# elif SIZEOF_LONG == 4
+typedef unsigned long int uint32_t;
+# endif
+#endif
+
#include <stdio.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
-#ifdef WIN32
-#include <winsock2.h>
#else
-#include <inttypes.h>
+#include <strings.h>
#endif
#if defined(_MSC_VER) && _MSC_VER < 1300
@@ -125,4 +154,5 @@ typedef struct timelib_time {
#define is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
#define DEBUG(s) if (0) { s }
+
#endif
diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c
index 12f621112e..f08558bcfe 100644
--- a/ext/date/lib/tm2unixtime.c
+++ b/ext/date/lib/tm2unixtime.c
@@ -18,6 +18,7 @@
/* $Id$ */
+#include <tl_config.h>
#include "timelib.h"
/* jan feb mrt apr may jun jul aug sep oct nov dec */
diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c
index e8b8078a88..035af27ff9 100644
--- a/ext/date/lib/unixtime2tm.c
+++ b/ext/date/lib/unixtime2tm.c
@@ -18,9 +18,19 @@
/* $Id$ */
-#include <stdlib.h>
+#include <tl_config.h>
+
#include <stdio.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STRING_H
#include <string.h>
+#else
+#include <strings.h>
+#endif
#if defined(_MSC_VER)
#define TIMELIB_LL_CONST(n) n ## i64
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 744342bb9d..bbcd95e7fb 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -25,7 +25,6 @@
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_date.h"
-#include "lib/timelib_structs.h"
#include "lib/timelib.h"
#include <time.h>