From: Edin Kadribasic Date: Wed, 15 Jun 2005 00:11:29 +0000 (+0000) Subject: Make it compile on windows X-Git-Tag: php-5.1.0b2~190 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=289997715ac763ead51648421f563fbcc22ebbb2;p=php Make it compile on windows --- diff --git a/ext/date/lib/datetime.h b/ext/date/lib/datetime.h index e31c83233c..553a2d0941 100644 --- a/ext/date/lib/datetime.h +++ b/ext/date/lib/datetime.h @@ -23,6 +23,15 @@ #define TIMELIB_NONE 0x00 #define TIMELIB_OVERRIDE_TIME 0x01 +#ifndef LONG_MAX +#define LONG_MAX 2147483647L +#endif + +#ifndef LONG_MIN +#define LONG_MIN (- LONG_MAX - 1) +#endif + + /* From dow.c */ int timelib_day_of_week(int y, int m, int d); int timelib_daynr_from_weeknr(int y, int w, int d); @@ -35,7 +44,7 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options); void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi); /* From unixtime2tm.c */ -int timelib_apply_localtime(timelib_time *t, uint localtime); +int timelib_apply_localtime(timelib_time *t, unsigned int localtime); void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts); void timelib_unixtime2local(timelib_time *tm, timelib_sll ts, timelib_tzinfo* tz); void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz); diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 1f10a1be23..93de7af8d1 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -23,6 +23,11 @@ #include #include "datetime.h" +#ifdef PHP_WIN32 +#define strcasecmp stricmp +#define strtoll(s, f, b) _atoi64(s) +#endif + #define TIMELIB_SECOND 1 #define TIMELIB_MINUTE 2 #define TIMELIB_HOUR 3 @@ -113,14 +118,14 @@ typedef unsigned char uchar; #include "timelib_structs.h" typedef struct timelib_elems { - uint c; /* Number of elements */ + unsigned int c; /* Number of elements */ char **v; /* Values */ } timelib_elems; typedef struct Scanner { int fd; uchar *lim, *str, *ptr, *cur, *tok, *pos; - uint line, len; + unsigned int line, len; struct timelib_time *time; } Scanner; @@ -365,7 +370,7 @@ static char* timelib_ltrim(char *s) #if 0 uchar *fill(Scanner *s, uchar *cursor){ if(!s->eof){ - uint cnt = s->tok - s->bot; + unsigned int cnt = s->tok - s->bot; if(cnt){ memcpy(s->bot, s->tok, s->lim - s->tok); s->tok = s->bot; diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c index 401e635db2..f5eac2aeac 100644 --- a/ext/date/lib/parse_tz.c +++ b/ext/date/lib/parse_tz.c @@ -19,7 +19,11 @@ /* $Id$ */ #include +#ifdef PHP_WIN32 +#include +#else #include +#endif #include #include "datetime.h" diff --git a/ext/date/lib/resource/parse_date.re b/ext/date/lib/resource/parse_date.re index 1f10a1be23..93de7af8d1 100644 --- a/ext/date/lib/resource/parse_date.re +++ b/ext/date/lib/resource/parse_date.re @@ -23,6 +23,11 @@ #include #include "datetime.h" +#ifdef PHP_WIN32 +#define strcasecmp stricmp +#define strtoll(s, f, b) _atoi64(s) +#endif + #define TIMELIB_SECOND 1 #define TIMELIB_MINUTE 2 #define TIMELIB_HOUR 3 @@ -113,14 +118,14 @@ typedef unsigned char uchar; #include "timelib_structs.h" typedef struct timelib_elems { - uint c; /* Number of elements */ + unsigned int c; /* Number of elements */ char **v; /* Values */ } timelib_elems; typedef struct Scanner { int fd; uchar *lim, *str, *ptr, *cur, *tok, *pos; - uint line, len; + unsigned int line, len; struct timelib_time *time; } Scanner; @@ -365,7 +370,7 @@ static char* timelib_ltrim(char *s) #if 0 uchar *fill(Scanner *s, uchar *cursor){ if(!s->eof){ - uint cnt = s->tok - s->bot; + unsigned int cnt = s->tok - s->bot; if(cnt){ memcpy(s->bot, s->tok, s->lim - s->tok); s->tok = s->bot; diff --git a/ext/date/lib/timelib_structs.h b/ext/date/lib/timelib_structs.h index 91a61156e4..eb49ad487b 100644 --- a/ext/date/lib/timelib_structs.h +++ b/ext/date/lib/timelib_structs.h @@ -24,9 +24,13 @@ #include #include #include +#ifdef PHP_WIN32 +#include +#else #include +#endif -#if defined(WIN32) && _MSC_VER < 1300 +#if defined(PHP_WIN32) && _MSC_VER < 1300 typedef unsigned __int64 timelib_ull; typedef __int64 timelib_sll; #else @@ -34,6 +38,11 @@ typedef unsigned long long timelib_ull; typedef signed long long timelib_sll; #endif +#if defined(_MSC_VER) +#define int32_t __int32 +#define uint32_t unsigned __int32 +#endif + typedef struct ttinfo { int32_t offset; @@ -78,8 +87,8 @@ typedef struct timelib_rel_time { typedef struct timelib_time_offset { int32_t offset; - uint leap_secs; - uint is_dst; + unsigned int leap_secs; + unsigned int is_dst; char *abbr; } timelib_time_offset; @@ -90,17 +99,17 @@ typedef struct timelib_time { int z; /* GMT offset in minutes */ char *tz_abbr; /* Timezone abbreviation (display only) */ timelib_tzinfo *tz_info; /* Timezone structure */ - uint dst; /* Flag if we were parsing a DST zone */ + unsigned int dst; /* Flag if we were parsing a DST zone */ timelib_rel_time relative; timelib_sll sse; /* Seconds since epoch */ - uint have_time, have_date, have_zone, have_relative, have_weekday_relative, have_weeknr_day; + unsigned int have_time, have_date, have_zone, have_relative, have_weekday_relative, have_weeknr_day; - uint sse_uptodate; /* !0 if the sse member is up to date with the date/time members */ - uint tim_uptodate; /* !0 if the date/time members are up to date with the sse member */ - uint is_localtime; /* 1 if the current struct represents localtime, 0 if it is in GMT */ - uint zone_type; /* 1 time offset, + unsigned int sse_uptodate; /* !0 if the sse member is up to date with the date/time members */ + unsigned int tim_uptodate; /* !0 if the date/time members are up to date with the sse member */ + unsigned int is_localtime; /* 1 if the current struct represents localtime, 0 if it is in GMT */ + unsigned int zone_type; /* 1 time offset, * 3 TimeZone identifier, * 2 TimeZone abbreviation */ } timelib_time; diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index 8b117666e0..507465fac7 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -133,7 +133,7 @@ static void do_adjust_relative(timelib_time* time) static timelib_sll do_years(int year) { - uint i; + unsigned int i; timelib_sll res = 0; if (year >= 1970) { @@ -156,7 +156,7 @@ static timelib_sll do_years(int year) return res; } -static timelib_sll do_months(uint month, uint year) +static timelib_sll do_months(unsigned int month, unsigned int year) { if (is_leap(year)) { return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY); @@ -165,12 +165,12 @@ static timelib_sll do_months(uint month, uint year) } } -static timelib_sll do_days(uint day) +static timelib_sll do_days(unsigned int day) { return ((day - 1) * SECS_PER_DAY); } -static timelib_sll do_time(uint hour, uint minute, uint second) +static timelib_sll do_time(unsigned int hour, unsigned int minute, unsigned int second) { timelib_sll res = 0; diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c index 8c282cfa56..a198b405a9 100644 --- a/ext/date/lib/unixtime2tm.c +++ b/ext/date/lib/unixtime2tm.c @@ -22,6 +22,12 @@ #include #include +#if defined(_MSC_VER) +#define PHP_LL_CONST(n) n ## i64 +#else +#define PHP_LL_CONST(n) n ## ll +#endif + #include "datetime.h" static int month_tab_leap[12] = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; @@ -61,7 +67,7 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts) /* Guess why this might be for, it has to do with a pope ;-). It's also * only valid for Great Brittain and it's colonies. It needs fixing for * other locales. *sigh*, why is this crap so complex! */ - if (ts <= -6857352000ll) { + if (ts <= PHP_LL_CONST(-6857352000)) { tmp_days -= 11; } @@ -160,7 +166,7 @@ void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz) /* Converts the time stored in the struct to localtime if localtime = true, * otherwise it converts it to gmttime. This is only done when necessary * ofcourse. */ -int timelib_apply_localtime(timelib_time *t, uint localtime) +int timelib_apply_localtime(timelib_time *t, unsigned int localtime) { if (localtime) { /* Converting from GMT time to local time */ diff --git a/ext/date/php_date.c b/ext/date/php_date.c index ffa97dc8f6..e18be2df32 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -126,7 +126,7 @@ PHP_FUNCTION(strtotime) } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s", ×, &time_len) != FAILURE) { /* We have no initial timestamp */ now = timelib_time_ctor(); - timelib_unixtime2local(now, (signed long long) time(NULL), tzi); + timelib_unixtime2local(now, (timelib_sll) time(NULL), tzi); } else { timelib_tzinfo_ctor(tzi); RETURN_FALSE;