com php-src: use appropriate seek() and tell() on _WIN64 : Zend/zend_stream.c Zend/zend_stream.h main/st reams/cast.c main/streams/plain_wrapper.c
| From: | Anatol Belski | Date: | Mon, 11 Nov 2013 23:41:58 +0000 |
| Subject: | com php-src: use appropriate seek() and tell() on _WIN64 : Zend/zend_stream.c Zend/zend_stream.h main/st reams/cast.c main/streams/plain_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73937@lists.php.net to get a copy of this message | ||
Commit: 266a428a59b4768ac30453e468f1762b38d0b5ce
Author: Anatol Belski <ab@php.net> Tue, 12 Nov 2013 00:41:58 +0100
Parents: f90fe17424199aa8614857ebcaf5aac142ac8092
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=266a428a59b4768ac30453e468f1762b38d0b5ce
Log:
use appropriate seek() and tell() on _WIN64
Changed paths:
M Zend/zend_stream.c
M Zend/zend_stream.h
M main/streams/cast.c
M main/streams/plain_wrapper.c
Diff:
diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c
index 835fdbb..480657c 100644
--- a/Zend/zend_stream.c
+++ b/Zend/zend_stream..c
@@ -237,7 +237,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
/* *buf[size] is zeroed automatically by the kernel */
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE,
fileno(file_handle->handle.fp), 0);
if (*buf != MAP_FAILED) {
- long offset = ftell(file_handle->handle.fp);
+ zend_int_t offset = zend_ftell(file_handle->handle.fp);
file_handle->handle.stream.mmap.map = *buf;
if (offset != -1) {
diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h
index a65d258..04684ab 100644
--- a/Zend/zend_stream..h
+++ b/Zend/zend_stream.h
@@ -78,4 +78,14 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh TSRMLS_DC);
ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
END_EXTERN_C()
+#ifdef _WIN64
+# define zend_fseek _fseeki64
+# define zend_ftell _ftelli64
+# define zend_lseek _lseeki64
+#else
+# define zend_fseek fseek
+# define zend_ftell ftell
+# define zend_lseek lseek
+#endif
+
#endif
diff --git a/main/streams/cast.c b/main/streams/cast.c
index a41e006..1cf721d 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -254,7 +254,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
* the stdio layer to believe it's real location. */
pos = php_stream_tell(stream);
if (pos > 0) {
- fseek(*ret, pos, SEEK_SET);
+ zend_fseek(*ret, pos, SEEK_SET);
}
goto exit_success;
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 9821d04..fafc98c 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -256,7 +256,7 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
if (self->is_pipe) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
} else {
- stream->position = lseek(self->fd, 0, SEEK_CUR);
+ stream->position = zend_lseek(self->fd, 0, SEEK_CUR);
#ifdef ESPIPE
if (stream->position == (zend_off_t)-1 && errno == ESPIPE) {
stream->position = 0;
@@ -295,7 +295,7 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE
if (self->is_pipe) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
} else {
- stream->position = ftell(file);
+ stream->position = zend_ftell(file);
}
}
@@ -335,7 +335,7 @@ static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count
#if HAVE_FLUSHIO
if (!data->is_pipe && data->last_op == 'r') {
- fseek(data->file, 0, SEEK_CUR);
+ zend_fseek(data->file, 0, SEEK_CUR);
}
data->last_op = 'w';
#endif
@@ -366,7 +366,7 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
} else {
#if HAVE_FLUSHIO
if (!data->is_pipe && data->last_op == 'w')
- fseek(data->file, 0, SEEK_CUR);
+ zend_fseek(data->file, 0, SEEK_CUR);
data->last_op = 'r';
#endif
@@ -470,7 +470,7 @@ static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, ze
if (data->fd >= 0) {
zend_off_t result;
- result = lseek(data->fd, offset, whence);
+ result = zend_lseek(data->fd, offset, whence);
if (result == (zend_off_t)-1)
return -1;
@@ -478,8 +478,8 @@ static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, ze
return 0;
} else {
- ret = fseek(data->file, offset, whence);
- *newoffset = ftell(data->file);
+ ret = zend_fseek(data->file, offset, whence);
+ *newoffset = zend_ftell(data->file);
return ret;
}
}