Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ PHP 8.7 INTERNALS UPGRADE NOTES

- Unix build system changes:
. Autoconf minimum required version upgraded to 2.71.
. The PHP_PREAD_TEST and PHP_PWRITE_TEST M4 macros have been removed, along
with the HAVE_PREAD, HAVE_PWRITE, PHP_PREAD_64 and PHP_PWRITE_64 symbols.
pread() and pwrite() are POSIX and can be used unconditionally on non-Windows
platforms.

========================
3. Module changes
Expand Down
101 changes: 0 additions & 101 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1137,107 +1137,6 @@ AS_CASE([$php_cv_time_r_type],
[Define to 1 you have IRIX-style reentrant time functions.])])
])

dnl
dnl PHP_DOES_PWRITE_WORK
dnl
dnl Internal.
dnl
AC_DEFUN([PHP_DOES_PWRITE_WORK], [
AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
$1
int main(void) {
int fd = open("conftest_pwrite", O_WRONLY|O_CREAT, 0600);

if (fd < 0) return 1;
if (pwrite(fd, "text", 4, 0) != 4) return 1;
/* Linux glibc breakage until 2.2.5 */
if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) return 1;
return 0;
}
])],
[php_cv_func_pwrite=yes],
[php_cv_func_pwrite=no],
[php_cv_func_pwrite=no])
])

dnl
dnl PHP_DOES_PREAD_WORK
dnl
dnl Internal.
dnl
AC_DEFUN([PHP_DOES_PREAD_WORK], [
echo test > conftest_pread
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
$1
int main(void) {
char buf[3];
int fd = open("conftest_pread", O_RDONLY);
if (fd < 0) return 1;
if (pread(fd, buf, 2, 0) != 2) return 1;
/* Linux glibc breakage until 2.2.5 */
if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) return 1;
return 0;
}
]])],
[php_cv_func_pread=yes],
[php_cv_func_pread=no],
[php_cv_func_pread=no])
])

dnl
dnl PHP_PWRITE_TEST
dnl
AC_DEFUN([PHP_PWRITE_TEST], [
AC_CACHE_CHECK([whether pwrite works], [php_cv_func_pwrite], [
PHP_DOES_PWRITE_WORK
AS_VAR_IF([php_cv_func_pwrite], [no], [
PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
AS_VAR_IF([php_cv_func_pwrite], [yes], [php_cv_func_pwrite=64])
])
])

AS_VAR_IF([php_cv_func_pwrite], [no],, [
AC_DEFINE([HAVE_PWRITE], [1],
[Define to 1 if you have the 'pwrite' function.])
AS_VAR_IF([php_cv_func_pwrite], [64],
[AC_DEFINE([PHP_PWRITE_64], [1],
[Define to 1 if 'pwrite' declaration with 'off64_t' is missing.])])
])
])

dnl
dnl PHP_PREAD_TEST
dnl
AC_DEFUN([PHP_PREAD_TEST], [
AC_CACHE_CHECK([whether pread works], [php_cv_func_pread], [
PHP_DOES_PREAD_WORK
AS_VAR_IF([php_cv_func_pread], [no], [
PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
AS_VAR_IF([php_cv_func_pread], [yes], [php_cv_func_pread=64])
])
])

AS_VAR_IF([php_cv_func_pread], [no],, [
AC_DEFINE([HAVE_PREAD], [1],
[Define to 1 if you have the 'pread' function.])
AS_VAR_IF([php_cv_func_pread], [64],
[AC_DEFINE([PHP_PREAD_64], [1],
[Define to 1 if 'pread' declaration with 'off64_t' is missing.])])
])
])

dnl
dnl PHP_MISSING_TIME_R_DECL
dnl
Expand Down
2 changes: 0 additions & 2 deletions ext/session/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ PHP_ARG_WITH([mm],
[no])

if test "$PHP_SESSION" != "no"; then
PHP_PWRITE_TEST
PHP_PREAD_TEST
PHP_NEW_EXTENSION([session],
[mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c],
[$ext_shared],,
Expand Down
16 changes: 4 additions & 12 deletions ext/session/mod_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,8 @@ static zend_result ps_files_write(ps_files *data, zend_string *key, zend_string
return FAILURE;
}

#ifdef HAVE_PWRITE
n = pwrite(data->fd, ZSTR_VAL(val), ZSTR_LEN(val), 0);
#else
lseek(data->fd, 0, SEEK_SET);
#ifdef PHP_WIN32
lseek(data->fd, 0, SEEK_SET);
{
unsigned int to_write = SESS_FILE_BUF_SIZE(ZSTR_LEN(val));
char *buf = ZSTR_VAL(val);
Expand All @@ -253,8 +250,7 @@ static zend_result ps_files_write(ps_files *data, zend_string *key, zend_string
} while (wrote > 0);
}
#else
n = write(data->fd, ZSTR_VAL(val), ZSTR_LEN(val));
#endif
n = pwrite(data->fd, ZSTR_VAL(val), ZSTR_LEN(val), 0);
#endif

if (n != ZSTR_LEN(val)) {
Expand Down Expand Up @@ -501,11 +497,8 @@ PS_READ_FUNC(files)

*val = zend_string_alloc(sbuf.st_size, false);

#ifdef HAVE_PREAD
n = pread(data->fd, ZSTR_VAL(*val), ZSTR_LEN(*val), 0);
#else
lseek(data->fd, 0, SEEK_SET);
#ifdef PHP_WIN32
lseek(data->fd, 0, SEEK_SET);
{
unsigned int to_read = SESS_FILE_BUF_SIZE(ZSTR_LEN(*val));
char *buf = ZSTR_VAL(*val);
Expand All @@ -522,8 +515,7 @@ PS_READ_FUNC(files)

}
#else
n = read(data->fd, ZSTR_VAL(*val), ZSTR_LEN(*val));
#endif
n = pread(data->fd, ZSTR_VAL(*val), ZSTR_LEN(*val), 0);
#endif

if (n != (zend_long)sbuf.st_size) {
Expand Down
8 changes: 0 additions & 8 deletions main/php.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,6 @@ extern char **environ;

extern const char php_build_date[];

#ifdef PHP_PWRITE_64
ssize_t pwrite(int, void *, size_t, off64_t);
#endif

#ifdef PHP_PREAD_64
ssize_t pread(int, void *, size_t, off64_t);
#endif

BEGIN_EXTERN_C()
void phperror(char *error);
PHPAPI size_t php_write(void *buf, size_t size);
Expand Down
Loading