## 32位系统, 编译php实现支持大于4G文件
1、下载最新php源代码(推荐php7.4),下载命令:
`git clone -b php-7.4.28 --depth=5 https://github.com/php/php-src`
diff 代码如下
```
diff --git a/Zend/zend_long.h b/Zend/zend_long.h
@@ -40,7 +40,7 @@ typedef int64_t zend_off_t;
#else
typedef int32_t zend_long;
typedef uint32_t zend_ulong;
-typedef int32_t zend_off_t;
+typedef int64_t zend_off_t;
# define ZEND_LONG_MAX INT32_MAX
# define ZEND_LONG_MIN INT32_MIN
# define ZEND_ULONG_MAX UINT32_MAX
diff --git a/ext/standard/file.c b/ext/standard/file.c
@@ -1265,7 +1265,7 @@ PHPAPI PHP_FUNCTION(rewind)
PHPAPI PHP_FUNCTION(ftell)
{
zval *res;
- zend_long ret;
+ double ret;
php_stream *stream;
ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -1278,7 +1278,7 @@ PHPAPI PHP_FUNCTION(ftell)
if (ret == -1) {
RETURN_FALSE;
}
- RETURN_LONG(ret);
+ RETURN_DOUBLE(ret);
}
/* }}} */
@@ -1287,12 +1287,13 @@ PHPAPI PHP_FUNCTION(ftell)
PHPAPI PHP_FUNCTION(fseek)
{
zval *res;
- zend_long offset, whence = SEEK_SET;
+ zend_long whence = SEEK_SET;
+ double offset;
php_stream *stream;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_RESOURCE(res)
- Z_PARAM_LONG(offset)
+ Z_PARAM_DOUBLE(offset)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(whence)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
@@ -1592,7 +1593,7 @@ PHP_NAMED_FUNCTION(php_if_fstat)
#else
ZVAL_LONG(&stat_rdev, -1);
#endif
- ZVAL_LONG(&stat_size, stat_ssb.sb.st_size);
+ ZVAL_DOUBLE(&stat_size, stat_ssb.sb.st_size);
ZVAL_LONG(&stat_atime, stat_ssb.sb.st_atime);
ZVAL_LONG(&stat_mtime, stat_ssb.sb.st_mtime);
ZVAL_LONG(&stat_ctime, stat_ssb.sb.st_ctime);
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
@@ -879,7 +879,7 @@ PHPAPI void php_stat(const char *filename, size_t filename_length, int type, zva
case FS_INODE:
RETURN_LONG((zend_long)ssb.sb.st_ino);
case FS_SIZE:
- RETURN_LONG((zend_long)ssb.sb.st_size);
+ RETURN_DOUBLE((double)ssb.sb.st_size);
case FS_OWNER:
RETURN_LONG((zend_long)ssb.sb.st_uid);
case FS_GROUP:
@@ -936,7 +936,7 @@ PHPAPI void php_stat(const char *filename, size_t filename_length, int type, zva
#else
ZVAL_LONG(&stat_rdev, -1);
#endif
- ZVAL_LONG(&stat_size, stat_sb->st_size);
+ ZVAL_DOUBLE(&stat_size, stat_sb->st_size);
ZVAL_LONG(&stat_atime, stat_sb->st_atime);
ZVAL_LONG(&stat_mtime, stat_sb->st_mtime);
ZVAL_LONG(&stat_ctime, stat_sb->st_ctime);
```