php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29531 fread() undeclared when compiles with sfio
Submitted: 2004-08-05 11:58 UTC Modified: 2004-10-09 01:00 UTC
From: pk at nodex dot ru Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 4.3.9 OS: Solaris 9
Private report: No CVE-ID: None
 [2004-08-05 11:58 UTC] pk at nodex dot ru
Description:
------------
I`m trying to compile php with sfio lib. for stdio bug workaround.

It configures and  compiles is fine, but simple test.php script shows:
Fatal error: Call to undefined function:  fread() in /usr/home/kuzmich/apache/php-4.3.8/sapi/cli/test.php on line 3

Reproduce code:
---------------
test.php:
<?
    $p = fopen("./test".microtime(),"w+");
    $buf = fread ($p,10);
    fclose($p);
    echo $buf;
?>

configure script:
CFLAGS="-I/home/kuzmich/sfio/include -I/usr/include -I/usr/local/include -I/opt/sfw/include" \
CXXFLAGS="-I/home/kuzmich/sfio/include -I/usr/include -I/usr/local/include -I/opt/sfw/include" \
CPPFLAGS="-I/home/kuzmich/sfio/include -I/usr/include -I/usr/local/include -I/opt/sfw/include" \
LDFLAGS="-L/usr/local/mnogosearch/lib -lmnogosearch -ludmsearch" \
EXTRA_LIBS=" -lstdio -lsfio -liconv -L/usr/local/mnogosearch/lib -lmnogosearch -ludmsearch" \
LIBS=" -lstdio -lsfio -liconv -L/usr/local/mnogosearch/lib -lmnogosearch -ludmsearch" \
./configure \
--with-apache=/usr/home/export/compile/apache/apache \
--with-mod_charset \
--with-pgsql=/usr/local/pgsql \
--disable-debug \
--enable-calendar \
--enable-inline-otimization \
--with-zlib \
--with-gd=/usr/local \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/local/lib \
--with-xpm-dir=/usr/lib \
--with-freetype-dir=/usr/local \
--with-zlib-dir=/usr/lib \
--with-freetype-dir=/usr/local/freetype2 \
--enable-wddx \
--with-curl \
--with-expat \
--enable-trans-sid \
--with-iconv \
--enable-xslt \
--with-xslt-sablot \
--with-imap \
--with-imap-ssl \
--with-openssl=/usr/local/ssl \
--with-mnogosearch=/usr/local/mnogosearch \
--enable-dbase \
--with-mysql=/usr/local/mysql



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-12 13:34 UTC] wez@php.net
Can you confirm that sfio does something along the lines of:
#define fread   sfio_fread

in its headers?

 [2004-08-12 13:38 UTC] pk at nodex dot ru
Sfio have lines:
#define fread                   _stdfread

Difintion of stdfread:
extern ssize_t  _stdfread _ARG_((Void_t*, size_t, size_t, Sfio_t*));
 [2004-08-12 13:57 UTC] wez@php.net
So, the fread() function will be callable from your script as _stdfread() instead ?

We need to use the NAMED variety of the PHP_FUNCTION and PHP_FE macros to avoid this issue.
 [2004-08-12 14:11 UTC] pk at nodex dot ru
SFIO redefine fopen call with _stdfread in precompilation.
And any C sources compilling good with sfio.

SFIO is transparent for sources.

Can you give me the patch for this issue?
 [2004-08-12 14:35 UTC] wez@php.net
If I had the time to patch it, I would have done it already.
Maybe someone else will do it in the meantime.
 [2004-08-12 14:53 UTC] pk at nodex dot ru
Please find your time for this.
I work with PHP 4.2.3 for now and i can`t upgrade because this 
issue is have a place.
 [2004-08-12 15:13 UTC] tony2001@php.net
http://tony2001.phpclub.net/dev/tmp/fread.diff - probably this may help (diff was done against HEAD).
 [2004-08-12 15:46 UTC] pk at nodex dot ru
Result is:
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:93: `zif__stdfread' undeclared here (not in a function)
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:93: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:93: (near initialization for `php_zlib_functions[7].handler')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:93: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:93: (near initialization for `php_zlib_functions[7]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:94: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:94: (near initialization for `php_zlib_functions[8]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:95: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:95: (near initialization for `php_zlib_functions[9]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:96: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:96: (near initialization for `php_zlib_functions[10]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:97: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:97: (near initialization for `php_zlib_functions[11]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:98: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:98: (near initialization for `php_zlib_functions[12]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:99: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:99: (near initialization for `php_zlib_functions[13]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:100: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:100: (near initialization for `php_zlib_functions[14]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:101: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:101: (near initialization for `php_zlib_functions[15]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:102: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:102: (near initialization for `php_zlib_functions[16]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:103: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:103: (near initialization for `php_zlib_functions[17]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:104: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:104: (near initialization for `php_zlib_functions[18]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:105: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:105: (near initialization for `php_zlib_functions[19]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:106: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:106: (near initialization for `php_zlib_functions[20]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:107: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:107: (near initialization for `php_zlib_functions[21]')
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:108: initializer element is not constant
/usr/home/kuzmich/apache/php-4.3.8/ext/zlib/zlib.c:108: (near initialization for `php_zlib_functions[22]')
 [2004-08-12 16:18 UTC] tony2001@php.net
Change the line in ext/zlib/zlib.c with 
PHP_FALIAS(gzread,		fread,			NULL)
to 
PHP_NAMED_FE(gzread,		php_if_fread,		NULL)
 [2004-08-17 07:26 UTC] tony2001@php.net
It seems, that http://tony2001.phpclub.net/dev/tmp/fread.diff solves the problem, but currently I got no possibility to test it myself.
Could anyone (with sfio installed) test it, plz?
The patch was done against HEAD, but similar patch will work with 4.3.9 too.
 [2004-10-01 10:14 UTC] sniper@php.net
Try the patch again using latest CVS snapshot.
 [2004-10-09 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 13:01:29 2024 UTC