Copy disabled (too large)
Download .txt
Showing preview only (24,965K chars total). Download the full file to get everything.
Repository: Leon2012/php-ext
Branch: master
Commit: a0969990e6f8
Files: 528
Total size: 23.7 MB
Directory structure:
gitextract_337cjps5/
├── 001.md
├── 002.md
├── 003.md
├── 004.md
├── 01.md
├── 02.md
├── 03.md
├── 04.md
├── 05.md
├── 06.md
├── 07.md
├── 08.md
├── 09.md
├── 10.md
├── 11.md
├── 12.md
├── 13.md
├── 14.md
├── README.md
└── codes/
├── array/
│ ├── .deps
│ ├── .libs/
│ │ ├── array.lai
│ │ ├── array.o
│ │ └── array.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── array.c
│ ├── array.la
│ ├── array.lo
│ ├── array.php
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_array.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── consts/
│ ├── .deps
│ ├── .libs/
│ │ ├── consts.lai
│ │ ├── consts.o
│ │ └── consts.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── consts.c
│ ├── consts.la
│ ├── consts.lo
│ ├── consts.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_consts.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── fcall/
│ ├── .deps
│ ├── .libs/
│ │ ├── fcall.lai
│ │ ├── fcall.o
│ │ └── fcall.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── fcall.c
│ ├── fcall.la
│ ├── fcall.lo
│ ├── fcall.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_fcall.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── global/
│ ├── .deps
│ ├── .libs/
│ │ ├── global.lai
│ │ ├── global.o
│ │ └── global.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── global.c
│ ├── global.la
│ ├── global.lo
│ ├── global.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_global.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── globalss/
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── config.m4
│ ├── config.w32
│ ├── globalss.c
│ ├── globalss.php
│ ├── php_globalss.h
│ └── tests/
│ └── 001.phpt
├── inis/
│ ├── .deps
│ ├── .libs/
│ │ ├── inis.lai
│ │ ├── inis.o
│ │ └── inis.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── inis.c
│ ├── inis.la
│ ├── inis.lo
│ ├── inis.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_inis.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── libs/
│ ├── .deps
│ ├── .libs/
│ │ ├── libs.lai
│ │ ├── libs.o
│ │ └── libs.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libs.c
│ ├── libs.la
│ ├── libs.lo
│ ├── libs.php
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_libs.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── objects1/
│ ├── .deps
│ ├── .libs/
│ │ ├── objects1.lai
│ │ ├── objects1.o
│ │ └── objects1.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── objects1.c
│ ├── objects1.la
│ ├── objects1.lo
│ ├── objects1.php
│ ├── php_objects1.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── objects2/
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── config.m4
│ ├── config.w32
│ ├── objects2.c
│ ├── objects2.php
│ ├── php_objects2.h
│ └── tests/
│ └── 001.phpt
├── objects3/
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── config.m4
│ ├── config.w32
│ ├── objects3.c
│ ├── objects3.php
│ ├── php_objects3.h
│ └── tests/
│ └── 001.phpt
├── params/
│ ├── .deps
│ ├── .libs/
│ │ ├── params.lai
│ │ ├── params.o
│ │ └── params.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── params.c
│ ├── params.la
│ ├── params.lo
│ ├── params.php
│ ├── php_params.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── php_hello/
│ ├── .deps
│ ├── .libs/
│ │ ├── php_hello.lai
│ │ ├── php_hello.o
│ │ └── php_hello.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_hello.c
│ ├── php_hello.la
│ ├── php_hello.lo
│ ├── php_hello.php
│ ├── php_php_hello.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── resource/
│ ├── .deps
│ ├── .libs/
│ │ ├── resource.lai
│ │ ├── resource.o
│ │ └── resource.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_resource.h
│ ├── resource.c
│ ├── resource.la
│ ├── resource.lo
│ ├── resource.php
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── return/
│ ├── .deps
│ ├── .libs/
│ │ ├── return.lai
│ │ ├── return.o
│ │ └── return.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_return.h
│ ├── return.c
│ ├── return.la
│ ├── return.lo
│ ├── return.php
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
└── zval1/
├── .svnignore
├── CREDITS
├── EXPERIMENTAL
├── config.m4
├── config.w32
├── php_zval1.h
├── tests/
│ └── 001.phpt
├── zval1.c
└── zval1.php
================================================
FILE CONTENTS
================================================
================================================
FILE: 001.md
================================================
# gdb调试PHP扩展函数
1,编译debug版的php
git clone https://github.com/php/php-src.git
cd php-src
CFLAGS=-ggdb3
./configure --prefix=/opt/php-debug --enable-debug --enable-cli --without-pear --enable-embed --enable-phpdbg
make
make install
mkdir /opt/php-debug/conf/
cp php.ini-development /opt/php-debug/conf/php.ini
2,创建debug信息的扩展
./ext_skel --extname=hello2
cd hello2
#vi config.m4
#添加下面信息
if test -z "$PHP_DEBUG"; then
AC_ARG_ENABLE(debug,
[ --enable-debug compile with debugging symbols],[
PHP_DEBUG=$enableval
],[ PHP_DEBUG=no
])
fi
/opt/php-debug/bin/phpize
./configure --with-php-config=/opt/php-debug/bin/php-config --enable-debug
make
sudo make install
3,调试echo函数
#查找符号表
sh-3.2# nm /opt/php-debug/bin/php | grep echo
00000001004a9f70 t _zend_do_echo
gdb /opt/php-debug/bin/php
#设置断点
(gdb) break zend_do_echo
#运行
(gdb) run -c /opt/php-debug/conf/php.ini -q /Users/kentchen/Downloads/test.php
#输出堆栈
(gdb) bt
#0 zend_do_echo (arg=0x7fff5fbfc2a0) at Zend/zend_compile.c:866
#1 0x0000000100474bbd in zendparse () at Zend/zend_language_parser.c:4469
#2 0x000000010047b5be in compile_file (file_handle=0x7fff5fbff3b0, type=8) at Zend/zend_language_scanner.l:588
#3 0x00000001002b8250 in phar_compile_file (file_handle=0x7fff5fbff3b0, type=8) at ext/phar/phar.c:3384
#4 0x00000001004e51b5 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at Zend/zend.c:1322
#5 0x000000010043137c in php_execute_script (primary_file=0x7fff5fbff3b0) at main/main.c:2506
#6 0x00000001005b0415 in do_cli (argc=5, argv=0x100c03f00) at sapi/cli/php_cli.c:994
#7 0x00000001005af143 in main (argc=5, argv=0x100c03f00) at sapi/cli/php_cli.c:1378
#继续执行,输出结果
(gdb) c
4,调试扩展函数
#查找符号表
nm /opt/php-debug/lib/php/extensions/debug-non-zts-20121212/hello2.so | grep confirm_hello2_compiled
0000000000000cf0 T _zif_confirm_hello2_compiled
sh-3.2# gdb /opt/php-debug/bin/php
#设置断点
(gdb) break zif_confirm_hello2_compiled
Function "zif_confirm_hello2_compiled" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (zif_confirm_hello2_compiled) pending.
#执行php script
(gdb) run -c /opt/php-debug/conf/php.ini -q hello2.php
Starting program: /opt/php-debug/bin/php -c /opt/php-debug/conf/php.ini -q hello2.php
#next
(gdb) n
160 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
#next
(gdb) n
164 len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "hello2", arg);
#输出变量arg
(gdb) p arg
$1 = 0x100d24c90 "hello2"
#输出变量arg_len
(gdb) p arg_len
$2 = 6
#next
(gdb) n
165 RETURN_STRINGL(strg, len, 0);
#输出变量
(gdb) p len
$5 = 109
(gdb) p strg
$6 = 0x100be84a8 "Congratulations! You have successfully modified ext/hello2/config.m4. Module hello2 is now compiled into PHP."
#Continuing
(gdb) c
Continuing.
Congratulations! You have successfully modified ext/hello2/config.m4. Module hello2 is now compiled into PHP.
warning: Temporarily disabling breakpoints for unloaded shared library "/opt/php-debug/lib/php/extensions/debug-non-zts-20121212/hello2.so"
[Inferior 1 (process 3162) exited normally]
(gdb) define phpbt
set $ed=execute_data
while $ed
print ((zend_execute_data *)$ed)->function_state.function->common.function_name
set $ed = ((zend_execute_data *)$ed)->prev_execute_data
end
end
(gdb) define hashkeys
set $p = (HashTable*)$arg0->pListHead
while $p
output (Bucket*)$p
echo \t
x/s (char*)(((Bucket*)$p)->arKey)
set $p = ((Bucket*)$p)->pListNext
end
end
(gdb) define bucketdata
print **(zval**)(((struct bucket *) $arg0)->pData)
end
(gdb) hashkeys executor_globals.included_files
(Bucket *) 0x7ffff7fe1be0 0x7ffff7fe1c28: "/temp/echo.php"
================================================
FILE: 002.md
================================================
# 常用全局宏
1,创建一个新的扩展
./ext_skel --extname=globals
2,常用全局宏
A) SG() SAPI Globals (main/SAPI.h)
typedef struct {
const char *request_method;
char *query_string;
char *post_data, *raw_post_data;
char *cookie_data;
long content_length;
uint post_data_length, raw_post_data_length;
char *path_translated;
char *request_uri;
const char *content_type;
zend_bool headers_only;
zend_bool no_headers;
zend_bool headers_read;
sapi_post_entry *post_entry;
char *content_type_dup;
/* for HTTP authentication */
char *auth_user;
char *auth_password;
char *auth_digest;
/* this is necessary for the CGI SAPI module */
char *argv0;
char *current_user;
int current_user_length;
/* this is necessary for CLI module */
int argc;
char **argv;
int proto_num;
} sapi_request_info;
typedef struct _sapi_globals_struct {
void *server_context;
sapi_request_info request_info;
sapi_headers_struct sapi_headers;
int read_post_bytes;
unsigned char headers_sent;
struct stat global_stat;
char *default_mimetype;
char *default_charset;
HashTable *rfc1867_uploaded_files;
long post_max_size;
int options;
zend_bool sapi_started;
double global_request_time;
HashTable known_post_content_types;
zval *callback_func;
zend_fcall_info_cache fci_cache;
zend_bool callback_run;
} sapi_globals_struct;
#ifdef ZTS
# define SG(v) TSRMG(sapi_globals_id, sapi_globals_struct *, v)
SAPI_API extern int sapi_globals_id;
#else
# define SG(v) (sapi_globals.v)
extern SAPI_API sapi_globals_struct sapi_globals;
//访问SG变量
#include "main/SAPI.h"
php_printf("default_mimetype : %s\n", SG(default_mimetype));
B) EG() 这个宏可以用来访问符号表,函数,资源信息和常量。 (zend/zend_globals_macros.h)
struct _zend_executor_globals {
zval **return_value_ptr_ptr;
zval uninitialized_zval;
zval *uninitialized_zval_ptr;
zval error_zval;
zval *error_zval_ptr;
/* symbol table cache */
HashTable *symtable_cache[SYMTABLE_CACHE_SIZE];
HashTable **symtable_cache_limit;
HashTable **symtable_cache_ptr;
zend_op **opline_ptr;
HashTable *active_symbol_table;
HashTable symbol_table; /* main symbol table */
HashTable included_files; /* files already included */
JMP_BUF *bailout;
int error_reporting;
int orig_error_reporting;
int exit_status;
zend_op_array *active_op_array;
HashTable *function_table; /* function symbol table */
HashTable *class_table; /* class table */
HashTable *zend_constants; /* constants table */
zend_class_entry *scope;
zend_class_entry *called_scope; /* Scope of the calling class */
zval *This;
long precision;
int ticks_count;
zend_bool in_execution;
HashTable *in_autoload;
zend_function *autoload_func;
zend_bool full_tables_cleanup;
/* for extended information support */
zend_bool no_extensions;
#ifdef ZEND_WIN32
zend_bool timed_out;
OSVERSIONINFOEX windows_version_info;
#endif
HashTable regular_list;
HashTable persistent_list;
zend_vm_stack argument_stack;
int user_error_handler_error_reporting;
zval *user_error_handler;
zval *user_exception_handler;
zend_stack user_error_handlers_error_reporting;
zend_ptr_stack user_error_handlers;
zend_ptr_stack user_exception_handlers;
zend_error_handling_t error_handling;
zend_class_entry *exception_class;
/* timeout support */
int timeout_seconds;
int lambda_count;
HashTable *ini_directives;
HashTable *modified_ini_directives;
zend_ini_entry *error_reporting_ini_entry;
zend_objects_store objects_store;
zval *exception, *prev_exception;
zend_op *opline_before_exception;
zend_op exception_op[3];
struct _zend_execute_data *current_execute_data;
struct _zend_module_entry *current_module;
zend_property_info std_property_info;
zend_bool active;
zend_op *start_op;
void *saved_fpu_cw_ptr;
#if XPFPA_HAVE_CW
XPFPA_CW_DATATYPE saved_fpu_cw;
#endif
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};
//调用
&EG(symbol_table)
C) CG() 用来访问核心全局变量。(zend/zend_globals_macros.h)
struct _zend_compiler_globals {
zend_stack bp_stack;
zend_stack switch_cond_stack;
zend_stack foreach_copy_stack;
zend_stack object_stack;
zend_stack declare_stack;
zend_class_entry *active_class_entry;
/* variables for list() compilation */
zend_llist list_llist;
zend_llist dimension_llist;
zend_stack list_stack;
zend_stack function_call_stack;
char *compiled_filename;
int zend_lineno;
zend_op_array *active_op_array;
HashTable *function_table; /* function symbol table */
HashTable *class_table; /* class table */
HashTable filenames_table;
HashTable *auto_globals;
zend_bool parse_error;
zend_bool in_compilation;
zend_bool short_tags;
zend_bool asp_tags;
zend_declarables declarables;
zend_bool unclean_shutdown;
zend_bool ini_parser_unbuffered_errors;
zend_llist open_files;
long catch_begin;
struct _zend_ini_parser_param *ini_parser_param;
int interactive;
zend_uint start_lineno;
zend_bool increment_lineno;
znode implementing_class;
zend_uint access_type;
char *doc_comment;
zend_uint doc_comment_len;
zend_uint compiler_options; /* set of ZEND_COMPILE_* constants */
zval *current_namespace;
HashTable *current_import;
zend_bool in_namespace;
zend_bool has_bracketed_namespaces;
zend_compiler_context context;
zend_stack context_stack;
/* interned strings */
char *interned_strings_start;
char *interned_strings_end;
char *interned_strings_top;
char *interned_strings_snapshot_top;
HashTable interned_strings;
const zend_encoding **script_encoding_list;
size_t script_encoding_list_size;
zend_bool multibyte;
zend_bool detect_unicode;
zend_bool encoding_declared;
#ifdef ZTS
zval ***static_members_table;
int last_static_member;
#endif
};
typedef struct _zend_compiler_globals zend_compiler_globals;
#ifdef ZTS
# define CG(v) TSRMG(compiler_globals_id, zend_compiler_globals *, v)
int zendparse(void *compiler_globals);
#else
# define CG(v) (compiler_globals.v)
extern ZEND_API struct _zend_compiler_globals compiler_globals;
int zendparse(void);
#endif
//调用
php_printf("compiled_filename : %s\n", CG(compiled_filename));
D) PG() PHP全局变量。我们知道php.ini会映射一个或者多个PHP全局结构。(main/php_globals.h)
struct _php_core_globals {
zend_bool implicit_flush;
long output_buffering;
zend_bool sql_safe_mode;
zend_bool enable_dl;
char *output_handler;
char *unserialize_callback_func;
long serialize_precision;
long memory_limit;
long max_input_time;
zend_bool track_errors;
zend_bool display_errors;
zend_bool display_startup_errors;
zend_bool log_errors;
long log_errors_max_len;
zend_bool ignore_repeated_errors;
zend_bool ignore_repeated_source;
zend_bool report_memleaks;
char *error_log;
char *doc_root;
char *user_dir;
char *include_path;
char *open_basedir;
char *extension_dir;
char *php_binary;
char *sys_temp_dir;
char *upload_tmp_dir;
long upload_max_filesize;
char *error_append_string;
char *error_prepend_string;
char *auto_prepend_file;
char *auto_append_file;
arg_separators arg_separator;
char *variables_order;
HashTable rfc1867_protected_variables;
short connection_status;
short ignore_user_abort;
unsigned char header_is_being_sent;
zend_llist tick_functions;
zval *http_globals[6];
zend_bool expose_php;
zend_bool register_argc_argv;
zend_bool auto_globals_jit;
char *docref_root;
char *docref_ext;
zend_bool html_errors;
zend_bool xmlrpc_errors;
long xmlrpc_error_number;
zend_bool activated_auto_globals[8];
zend_bool modules_activated;
zend_bool file_uploads;
zend_bool during_request_startup;
zend_bool allow_url_fopen;
zend_bool enable_post_data_reading;
zend_bool always_populate_raw_post_data;
zend_bool report_zend_debug;
int last_error_type;
char *last_error_message;
char *last_error_file;
int last_error_lineno;
char *disable_functions;
char *disable_classes;
zend_bool allow_url_include;
zend_bool exit_on_timeout;
#ifdef PHP_WIN32
zend_bool com_initialized;
#endif
long max_input_nesting_level;
long max_input_vars;
zend_bool in_user_include;
char *user_ini_filename;
long user_ini_cache_ttl;
char *request_order;
zend_bool mail_x_header;
char *mail_log;
zend_bool in_error_log;
#ifdef PHP_WIN32
zend_bool windows_show_crt_warning;
#endif
};
typedef struct _php_core_globals php_core_globals;
#ifdef ZTS
# define PG(v) TSRMG(core_globals_id, php_core_globals *, v)
extern PHPAPI int core_globals_id;
#else
# define PG(v) (core_globals.v)
extern ZEND_API struct _php_core_globals core_globals;
#endif
//调用
php_printf("user_ini_filename : %s\n", PG(user_ini_filename));
E) FG() 文件全局变量。大多数文件I/O或相关的全局变量的数据流都塞进标准扩展出口结构。(ext/standard/file.h)
typedef struct {
int pclose_ret;
size_t def_chunk_size;
long auto_detect_line_endings;
long default_socket_timeout;
char *user_agent; /* for the http wrapper */
char *from_address; /* for the ftp and http wrappers */
char *user_stream_current_filename; /* for simple recursion protection */
php_stream_context *default_context;
HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
HashTable *stream_filters; /* per-request copy of stream_filters_hash */
HashTable *wrapper_errors; /* key: wrapper address; value: linked list of char* */
int pclose_wait;
} php_file_globals;
#ifdef ZTS
#define FG(v) TSRMG(file_globals_id, php_file_globals *, v)
extern PHPAPI int file_globals_id;
#else
#define FG(v) (file_globals.v)
extern PHPAPI php_file_globals file_globals;
#endif
F) TSRMLS相关
#define TSRMLS_FETCH( ) void ***tsrm_ls = (void ***) ts_resource_ex(0, NULL)
#define TSRMG(id,type,el) (((type) (*((void ***) \
tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(id)])->el)
#define TSRMLS_D void ***tsrm_ls
#define TSRMLS_DC , TSRMLS_D
#define TSRMLS_C tsrm_ls
#define TSRMLS_CC , TSRMLS_C
================================================
FILE: 003.md
================================================
# ZVAL
1,创建一个新的扩展
./ext_skel --extname=zval1
2,zval结构
#Zend/zend.h
typedef union _zvalue_value {
long lval; /* long 值 */
double dval; /* double 值 */
struct { /* 字符串类型值 */
char *val;
int len;
} str;
HashTable *ht; /* hash table value */
zend_object_value obj; /* 对像类型值 */
} zvalue_value;
struct _zval_struct {
/* Variable information */
zvalue_value value; /* 值 */
zend_uint refcount__gc; /* 引用计数 */
zend_uchar type; /* 类型 */
zend_uchar is_ref__gc; /* 是否引用 */
};
3,zval类型
#define IS_NULL 0
#define IS_LONG 1
#define IS_DOUBLE 2
#define IS_BOOL 3
#define IS_ARRAY 4
#define IS_OBJECT 5
#define IS_STRING 6
#define IS_RESOURCE 7
#define IS_CONSTANT 8
#define IS_CONSTANT_ARRAY 9
#define IS_CALLABLE 10
4,宏
#宏的名字的规则,Z_XXXX -> zvale, Z_XXXX_P -> *zval, Z_XXXX_PP -> **zval
#Zend/zend_alloc.h
#define ALLOC_ZVAL(z) (z) = (zval *) emalloc(sizeof(zval))
#define FREE_ZVAL(z) efree_rel(z)
#define ALLOC_ZVAL_REL(z) (z) = (zval *) emalloc_rel(sizeof(zval))
#define FREE_ZVAL_REL(z) efree_rel(z)
#Zend/zend.h
#define INIT_PZVAL(z) (z)->refcount__gc = 1;(z)->is_ref__gc = 0;
#define INIT_ZVAL(z) z = zval_used_for_init;
#define ZVAL_FALSE(z) ZVAL_BOOL(z, 0) //设置zval
#define ZVAL_TRUE(z) ZVAL_BOOL(z, 1)
/* struct操作宏 */
#define Z_LVAL(zval) (zval).value.lval //获取long值
#define Z_BVAL(zval) ((zend_bool)(zval).value.lval) //获取bool值
#define Z_DVAL(zval) (zval).value.dval //获取double值
#define Z_STRVAL(zval) (zval).value.str.val //获取string的指针
#define Z_STRLEN(zval) (zval).value.str.len //获取string的长度
#define Z_ARRVAL(zval) (zval).value.ht //获取hashtable值
#define Z_OBJVAL(zval) (zval).value.obj //获取object值
#define Z_OBJ_HANDLE(zval) Z_OBJVAL(zval).handle //
#define Z_OBJ_HT(zval) Z_OBJVAL(zval).handlers //
#define Z_OBJCE(zval) zend_get_class_entry(&(zval) TSRMLS_CC) //
#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC) //
#define Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf //
#define Z_RESVAL(zval) (zval).value.lval //获取long值
#define Z_OBJDEBUG(zval,is_tmp) (Z_OBJ_HANDLER((zval),get_debug_info)? Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&is_tmp TSRMLS_CC): (is_tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL)) //
/* 指针操作宏 */
#define Z_LVAL_P(zval_p) Z_LVAL(*zval_p)
#define Z_BVAL_P(zval_p) Z_BVAL(*zval_p)
#define Z_DVAL_P(zval_p) Z_DVAL(*zval_p)
#define Z_STRVAL_P(zval_p) Z_STRVAL(*zval_p)
#define Z_STRLEN_P(zval_p) Z_STRLEN(*zval_p)
#define Z_ARRVAL_P(zval_p) Z_ARRVAL(*zval_p)
#define Z_OBJPROP_P(zval_p) Z_OBJPROP(*zval_p)
#define Z_OBJCE_P(zval_p) Z_OBJCE(*zval_p)
#define Z_RESVAL_P(zval_p) Z_RESVAL(*zval_p)
#define Z_OBJVAL_P(zval_p) Z_OBJVAL(*zval_p)
#define Z_OBJ_HANDLE_P(zval_p) Z_OBJ_HANDLE(*zval_p)
#define Z_OBJ_HT_P(zval_p) Z_OBJ_HT(*zval_p)
#define Z_OBJ_HANDLER_P(zval_p, h) Z_OBJ_HANDLER(*zval_p, h) #define Z_OBJDEBUG_P(zval_p,is_tmp) Z_OBJDEBUG(*zval_p,is_tmp)
/* */
#define Z_LVAL_PP(zval_pp) Z_LVAL(**zval_pp)
#define Z_BVAL_PP(zval_pp) Z_BVAL(**zval_pp)
#define Z_DVAL_PP(zval_pp) Z_DVAL(**zval_pp)
#define Z_STRVAL_PP(zval_pp) Z_STRVAL(**zval_pp)
#define Z_STRLEN_PP(zval_pp) Z_STRLEN(**zval_pp)
#define Z_ARRVAL_PP(zval_pp) Z_ARRVAL(**zval_pp)
#define Z_OBJPROP_PP(zval_pp) Z_OBJPROP(**zval_pp)
#define Z_OBJCE_PP(zval_pp) Z_OBJCE(**zval_pp)
#define Z_RESVAL_PP(zval_pp) Z_RESVAL(**zval_pp)
#define Z_OBJVAL_PP(zval_pp) Z_OBJVAL(**zval_pp)
#define Z_OBJ_HANDLE_PP(zval_p) Z_OBJ_HANDLE(**zval_p)
#define Z_OBJ_HT_PP(zval_p) Z_OBJ_HT(**zval_p)
#define Z_OBJ_HANDLER_PP(zval_p, h) Z_OBJ_HANDLER(**zval_p, h)
#define Z_OBJDEBUG_PP(zval_pp,is_tmp) Z_OBJDEBUG(**zval_pp,is_tmp)
/* 获取zval的变量类型 */
#define Z_TYPE(zval) (zval).type
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
#define Z_TYPE_PP(zval_pp) Z_TYPE(**zval_pp)
/* zval初始化宏 */
#define ALLOC_ZVAL(z) (z) = (zval *) emalloc(sizeof(zval)) //初始化zval,分配内存
#define FREE_ZVAL(z) efree_rel(z) //释放zvalue内存
#define ALLOC_ZVAL_REL(z)(z) = (zval *) emalloc_rel(sizeof(zval))
#define FREE_ZVAL_REL(z) efree_rel(z)
/* HashTable初始化宏 */
#define ALLOC_HASHTABLE(ht) (ht) = (HashTable *) emalloc(sizeof(HashTable)) //初始化HashTable
#define FREE_HASHTABLE(ht) efree(ht)
#define ALLOC_HASHTABLE_REL(ht) (ht) = (HashTable *) emalloc_rel(sizeof(HashTable))
#define FREE_HASHTABLE_REL(ht) efree_rel(ht)
#define INIT_PZVAL(z) (z)->refcount__gc = 1; (z)->is_ref__gc = 0; //设置refcount
#define INIT_ZVAL(z) z = zval_used_for_init;
#define ALLOC_INIT_ZVAL(zp) ALLOC_ZVAL(zp); INIT_ZVAL(*zp); //分配内存并设置默认值
#define MAKE_STD_ZVAL(zv) ALLOC_ZVAL(zv); INIT_PZVAL(zv); //分配内存并设置默认值
#define PZVAL_IS_REF(z) Z_ISREF_P(z)
/* 拷贝zval的值 */
#define ZVAL_COPY_VALUE(z, v) \
do { \
(z)->value = (v)->value; \
Z_TYPE_P(z) = Z_TYPE_P(v); \
} while (0)
#define INIT_PZVAL_COPY(z, v) \
do { \
ZVAL_COPY_VALUE(z, v); \
Z_SET_REFCOUNT_P(z, 1); \
Z_UNSET_ISREF_P(z); \
} while (0)
#define ZVAL_IS_NULL(z) (Z_TYPE_P(z)==IS_NULL) //判断zval是否为NULL
/* 设置zval为resource类型值 */
#define ZVAL_RESOURCE(z, l) do { \
zval *__z = (z); \
Z_LVAL_P(__z) = l; \
Z_TYPE_P(__z) = IS_RESOURCE;\
} while (0)
/* 设置zval为bool类型值 */
#define ZVAL_BOOL(z, b) do { \
zval *__z = (z); \
Z_LVAL_P(__z) = ((b) != 0); \
Z_TYPE_P(__z) = IS_BOOL; \
} while (0)
/* 设置zval为NULL */
#define ZVAL_NULL(z) { \
Z_TYPE_P(z) = IS_NULL; \
}
/* 设置zval为long值 */
#define ZVAL_LONG(z, l) { \
zval *__z = (z); \
Z_LVAL_P(__z) = l; \
Z_TYPE_P(__z) = IS_LONG; \
}
/* 设置zval为double值 */
#define ZVAL_DOUBLE(z, d) { \
zval *__z = (z); \
Z_DVAL_P(__z) = d; \
Z_TYPE_P(__z) = IS_DOUBLE; \
}
/* 设置zval为string值 */
#define ZVAL_STRING(z, s, duplicate) do { \
const char *__s=(s); \
zval *__z = (z); \
Z_STRLEN_P(__z) = strlen(__s); \
Z_STRVAL_P(__z) = (duplicate?estrndup(__s, Z_STRLEN_P(__z)):(char*)__s);\
Z_TYPE_P(__z) = IS_STRING; \
} while (0)
/* 设置zval为string值 */
#define ZVAL_STRINGL(z, s, l, duplicate) do { \
const char *__s=(s); int __l=l; \
zval *__z = (z); \
Z_STRLEN_P(__z) = __l; \
Z_STRVAL_P(__z) = (duplicate?estrndup(__s, __l):(char*)__s);\
Z_TYPE_P(__z) = IS_STRING; \
} while (0)
/* 设置zval为empty string值 */
#define ZVAL_EMPTY_STRING(z) do { \
zval *__z = (z); \
Z_STRLEN_P(__z) = 0; \
Z_STRVAL_P(__z) = STR_EMPTY_ALLOC();\
Z_TYPE_P(__z) = IS_STRING; \
} while (0)
/* 设置zval为zval值 */
#define ZVAL_ZVAL(z, zv, copy, dtor) { \
zend_uchar is_ref = Z_ISREF_P(z); \
zend_uint refcount = Z_REFCOUNT_P(z); \
ZVAL_COPY_VALUE(z, zv); \
if (copy) { \
zval_copy_ctor(z); \
} \
if (dtor) { \
if (!copy) { \
ZVAL_NULL(zv); \
} \
zval_ptr_dtor(&zv); \
} \
Z_SET_ISREF_TO_P(z, is_ref); \
Z_SET_REFCOUNT_P(z, refcount); \
}
5,类型转换
convert_to_long(zval *op); //zval -> long
convert_to_double(zval *op); //zval -> double
convert_to_null(zval *op); //zval -> null
convert_to_boolean(zval *op); //zval -> boolean
convert_to_array(zval *op); //zval -> array
convert_to_object(zval *op); //zval -> object
#define convert_to_cstring(op) if ((op)->type != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); }
#define convert_to_string(op) if ((op)->type != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
ZEND_API double zend_string_to_double(const char *number, zend_uint length);
ZEND_API int zval_is_true(zval *op);
================================================
FILE: 004.md
================================================
# ZendMM
1, php内存管理内置函数
void *emalloc(size_t size) 分配 size 字节的内存。
void *ecalloc(size_t nmemb, size_t size) 给 nmemb 元素分配 size 字节的缓冲区并初始化为零。
void *erealloc(void *ptr, size_t size) 修改使用 emalloc 分配的缓冲区 ptr 的大小为 size 字节。
void efree(void *ptr) 释放 ptr 指向的缓冲区。缓冲区必须是由 emalloc 分配的。
void *safe_emalloc(size_t nmemb, size_t size, size_t offset)
char *estrdup(const char *s) 分配一个可存放 NULL 结尾的字符串 s 的缓冲区,并将 s复制到缓冲区内。
char *estrndup(const char *s, unsigned int length) 类似于 estrdup,但 NULL 结尾的字符串长度是已知的。
2,由emalloc分配的内存都是在zend_mm_heap上
//zend_mm_mem_handlers
typedef struct _zend_mm_mem_handlers {
const char *name;
zend_mm_storage* (*init)(void *params);
void (*dtor)(zend_mm_storage *storage);
void (*compact)(zend_mm_storage *storage);
zend_mm_segment* (*_alloc)(zend_mm_storage *storage, size_t size);
zend_mm_segment* (*_realloc)(zend_mm_storage *storage, zend_mm_segment *ptr, size_t size);
void (*_free)(zend_mm_storage *storage, zend_mm_segment *ptr);
} zend_mm_mem_handlers;
//zend_mm_segment
typedef struct _zend_mm_segment {
size_t size;
struct _zend_mm_segment *next_segment;
} zend_mm_segment;
//zend_mm_storage结构
struct _zend_mm_storage {
const zend_mm_mem_handlers *handlers;//zend_mm_storage方法 (ZEND_MM_MEM_MALLOC_DSC)
void *data;
};
//zend_mm_heap结构
struct _zend_mm_heap {
int use_zend_alloc;
void *(*_malloc)(size_t);
void (*_free)(void*);
void *(*_realloc)(void*, size_t);
size_t free_bitmap;
size_t large_free_bitmap;
size_t block_size;
size_t compact_size;
zend_mm_segment *segments_list;
zend_mm_storage *storage;
size_t real_size;
size_t real_peak;
size_t limit;
size_t size;
size_t peak;
size_t reserve_size;
void *reserve;
int overflow;
int internal;
#if ZEND_MM_CACHE
unsigned int cached;
zend_mm_free_block *cache[ZEND_MM_NUM_BUCKETS];
#endif
zend_mm_free_block *free_buckets[ZEND_MM_NUM_BUCKETS*2];
zend_mm_free_block *large_free_buckets[ZEND_MM_NUM_BUCKETS];
zend_mm_free_block *rest_buckets[2];
int rest_count;
#if ZEND_MM_CACHE_STAT
struct {
int count;
int max_count;
int hit;
int miss;
} cache_stat[ZEND_MM_NUM_BUCKETS+1];
#endif
};
//zend_alloc_globals结构
typedef struct _zend_alloc_globals {
zend_mm_heap *mm_heap;
}
//AG宏定义
# define AG(v) TSRMG(alloc_globals_id, zend_alloc_globals *, v)
//emalloc函数原型
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
TSRMLS_FETCH();
if (UNEXPECTED(!AG(mm_heap)->use_zend_alloc)) {
return AG(mm_heap)->_malloc(size);
}
return _zend_mm_alloc_int(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
}
3,ZendMM环境变量
USE_ZEND_ALLOC 是否使用 ZendMM 进行内存管理。
ZEND_MM_MEM_TYPE 指定内存分配的方案,默认 malloc
ZEND_MM_COMPACT 指定压缩边界值
//默认ZEND_MM_MEM_TYPE初始化
# define ZEND_MM_MEM_MALLOC_DSC {"malloc", zend_mm_mem_dummy_init, zend_mm_mem_dummy_dtor, zend_mm_mem_dummy_compact, zend_mm_mem_malloc_alloc, zend_mm_mem_malloc_realloc, zend_mm_mem_malloc_free}
# define ZEND_MM_MEM_WIN32_DSC {"win32", zend_mm_mem_win32_init, zend_mm_mem_win32_dtor, zend_mm_mem_win32_compact, zend_mm_mem_win32_alloc, zend_mm_mem_win32_realloc, zend_mm_mem_win32_free}
# define ZEND_MM_MEM_MMAP_ZERO_DSC {"mmap_zero", zend_mm_mem_mmap_zero_init, zend_mm_mem_mmap_zero_dtor, zend_mm_mem_dummy_compact, zend_mm_mem_mmap_zero_alloc, zend_mm_mem_mmap_realloc, zend_mm_mem_mmap_free}
# define ZEND_MM_MEM_MMAP_ANON_DSC {"mmap_anon", zend_mm_mem_dummy_init, zend_mm_mem_dummy_dtor, zend_mm_mem_dummy_compact, zend_mm_mem_mmap_anon_alloc, zend_mm_mem_mmap_realloc, zend_mm_mem_mmap_free}
4,ZendMM 流程
->SAPI
->php_module_startup (main.c 2065)
->zend_startup() //zend引擎启动
->start_memory_manager(TSRMLS_C) //开始内存管理
->ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor) //初始化AG
->alloc_globals_ctor(&alloc_globals) //申请内存
//分配内存,读取环境变量USE_ZEND_ALLOC,如果USE_ZEND_ALLOC==0 则禁用 ZendMMApi(emalloc/efree/...)
//初始化mm_heap的代码(USE_ZEND_ALLOC != 0)
alloc_globals->mm_heap = malloc(sizeof(struct _zend_mm_heap));
memset(alloc_globals->mm_heap, 0, sizeof(struct _zend_mm_heap));
alloc_globals->mm_heap->use_zend_alloc = 0;
alloc_globals->mm_heap->_malloc = malloc;
alloc_globals->mm_heap->_free = free;
alloc_globals->mm_heap->_realloc = realloc;
//初始化mm_heap的代码(USE_ZEND_ALLOC != 0), 则启用 ZendMMApi(emalloc/efree/...)
alloc_globals->mm_heap = zend_mm_startup();
->zend_mm_startup() //读取内存分配方案(默认malloc)
->zend_mm_startup_ex() //实例化zend_mm_heap分配内存 (heap = malloc(sizeof(struct _zend_mm_heap));)
->emalloc() //申请内存,
//zend_mm_heap->use_zend_alloc==0 调用 mm_heap->_malloc方法初始化分配内存
//zend_mm_heap->use_zend_alloc!=0 调用 _zend_mm_alloc_int
->_zend_mm_alloc_int()
->ZEND_MM_STORAGE_ALLOC(segment_size) //
-> heap->storage->handlers->_alloc
//ZEND_MM_MEM_WIN32_DSC
->zend_mm_mem_win32_alloc()
->HeapAlloc((HANDLE)storage->data, HEAP_NO_SERIALIZE, size)//最终把内存分配到了heap->storage->data
//ZEND_MM_MEM_MALLOC_DSC
->zend_mm_mem_malloc_alloc()
->return (zend_mm_segment*)malloc(size) //最终把内存分配到了 heap->segments_list
//ZEND_MM_MEM_MMAP_ZERO_DSC
->zend_mm_mem_mmap_zero_alloc()
->(zend_mm_segment*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zend_mm_dev_zero_fd, 0) //通过mmap把内存影射到heap->storage
//ZEND_MM_MEM_MMAP_ANON_DSC
->zend_mm_mem_mmap_anon_alloc
->(zend_mm_segment*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0)
//最终把内存分配到了 heap->segments_list
->alloc_globals_dtor() //释放内存
->shutdown_memory_manager (main.c 2410) //结束内存管理
->zend_mm_shutdown(AG(mm_heap), full_shutdown, silent TSRMLS_CC) //最终调用释放内存的方法
5,总结
a) ZEND_MM_MEM_WIN32_DSC|ZEND_MM_MEM_MMAP_ZERO_DSC 内存保存到了 heap->storage
ZEND_MM_MEM_MMAP_ANON_DSC|ZEND_MM_MEM_MALLOC_DSC 内存保存到了 heap->segments_list
b)
================================================
FILE: 01.md
================================================
# 创建一个新的扩展
1,下载php源码
git clone https://github.com/php/php-src.git
2,创建扩展
PHP提供了一个命令用于生成扩展的基本文件架构,只要调用该命令即可。
cd php-src/ext/
./ext_skel --extname=php_hello
选择自已喜欢的编辑器,打开 php-src/ext/php_hello目录,上面的命令已经帮我们生成好了一些文件。
最主要的是 config.m4, php_php_hello.h, php_hello.c 这三个文件。
config.m4 编译配置文件
php_php_hello.h 扩展头文件
php_hello.c 扩展源码
3,修改config.m4
PHP_ARG_ENABLE(php_hello, whether to enable php_hello support,
Make sure that the comment is aligned:
[ --enable-php_hello Enable php_hello support])
if test "$PHP_PHP_HELLO" != "no"; then
PHP_NEW_EXTENSION(php_hello, php_hello.c, $ext_shared)
fi
4,修改 php_hello.c
PHP_FUNCTION(confirm_php_hello_compiled)
{
php_printf("hello world!\n");
return;
}
5,编译扩展
cd php_hello
phpize
./configure --with-php-config=/usr/bin/php-config
make
sudo make install
6,运行测试文件
php -q php_hello.php
7,运行结果
Functions available in the test extension:
confirm_php_hello_compiled
hello world!
================================================
FILE: 02.md
================================================
# 参数传递
1,创建一个新的扩展
./ext_skel --extname=params
2,修改config.m4,去掉没用的注释语句
cd params
vi config.m4
3,编写代码
vi php_params.h
#注释掉下面的代码
//PHP_FUNCTION(confirm_params_compiled);
vi params.c
#添加下面的代码
ZEND_BEGIN_ARG_INFO(params_add_arginfo, 0)
ZEND_ARG_INFO(0, a)
ZEND_ARG_INFO(0, b)
ZEND_END_ARG_INFO()
static PHP_FUNCTION(params_add) {
long a,b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &a, &b) == FAILURE) {
return;
}
RETURN_LONG(a+b);
}
4,解释
#define ZEND_FE_END { NULL, NULL, NULL, 0, 0 }
//参数相关宏的定义 (Zend/zend_API.h)
#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, 0, pass_by_ref},
#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, 0, pass_by_ref},
#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1, #classname, sizeof(#classname)-1, IS_OBJECT, allow_null, pass_by_ref},
#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, sizeof(#name)-1, NULL, 0, IS_ARRAY, allow_null, pass_by_ref},
#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, sizeof(#name)-1, NULL, 0, type_hint, allow_null, pass_by_ref},
#define ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, return_reference, required_num_args) \
static const zend_arg_info name[] = { \
{ NULL, 0, NULL, required_num_args, 0, return_reference, pass_rest_by_reference},
#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, ZEND_RETURN_VALUE, -1)
#define ZEND_END_ARG_INFO() };
//宏说明
ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) //开始参数块定义,pass_rest_by_reference为1时,强制所有参数为引用类型
ZEND_END_ARG_INFO() //结束参数块定义
ZEND_ARG_INFO //声明普通参数,可以用来表示PHP中的int, float, double, string等基本数据类型
ZEND_ARG_OBJ_INFO //声明对象类型的参数
ZEND_ARG_ARRAY_INFO //声明数组类型的参数
ZEND_ARG_PASS_INFO(pass_by_ref) //pass_by_ref为1时,强制设置后续的参数为引用类型
//展开3中ZEND_BEGIN_ARG_INFO语句
static const zend_arg_info params_add_arginfo[] = {
{NULL, 0, NULL, -1, 0, ZEND_RETURN_VALUE, 0},
{a, sizeof(a)-1, NULL, 0, 0, 0, 0},
{b, sizeof(b)-1, NULL, 0, 0, 0, 0},
};
//参数在zend中的定义(Zend/zend_compile.h)
#define ZEND_RETURN_VALUE 0
#define ZEND_RETURN_REFERENCE 1
typedef struct _zend_arg_info {
const char *name; //参数的名称
zend_uint name_len; //参数名称的长度
char *class_name; //当参数类型为类时,指定类的名称
zend_uint class_name_len; //类名称的长度
zend_uchar type_hint;
zend_bool allow_null; //是否允许设置为null
zend_bool pass_by_reference; //是否设置为引用,即使用&操作符
}
#define PHP_FUNCTION ZEND_FUNCTION //函数的实现
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
#define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
#define PHP_FE ZEND_FE (php.h)//函数的定义,第一个参数是函数名,第二个参数是函数的参数的类型
(Zend/zend_API.h)
#define ZEND_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0)
#define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
5,更多的参数类型
#define Z_TYPE_P //获取参数类型 IS_NULL|IS_BOOL|IS_LONG|IS_DOUBLE|IS_STRING|IS_ARRAY|IS_RESOURCE|IS_OBJECT
#define Z_BVAL_P //获取bool类型参数的值
#define Z_LVAL_P //获取long类型参数的值
#define Z_DVAL_P //获取float类型参数的值
#define Z_STRVAL_P //获取string类型参数的值
#define Z_STRLEN_P //获取string类型参数的长度
#define Z_ARRVAL_P //获取array类型参数的值
#define Z_RESVAL_P //获取resource类型参数的值
#define Z_OBJCE_P //获取object类型参数的值
6,zend_parse_parameters的参数
//数据类型
Boolean b zend_bool //布尔值
Long l long //长整数
Double d double //双精度浮点数
String s char *, int //符串 (也可能是空字节)和其长度
Resource r zval* // 资源, 保存在 zval*
Array a zval* //数组, 保存在 zval*
Object o zval* //任何类的)对象, 保存在 zval*
zval z zval* //实际的 zval*
zval O zval* //由class entry 指定的类的)对象, 保存在 zval*
HashTable h HashTable* //数组的哈希表
Function f char *, int //函数,方法名 (版本 > php5.1)
//操作符
| -表明剩下的参数都是可选参数。如果用户没有传进来这些参数值,那么这些值就会被初始化成默认值。
/ -表明参数解析函数将会对剩下的参数以 SEPARATE_ZVAL_IF_NOT_REF() 的方式来提供这个参数的一份拷贝,除非这些参数是一个引用。
! -表明剩下的参数允许被设定为 NULL(仅用在 a、o、O、r和z身上)。如果用户传进来了一个 NULL 值,则存储该参数的变量将会设置为 NULL。
//字符串类型参数
ZEND_BEGIN_ARG_INFO(params_str_arginfo, 0)
ZEND_ARG_INFO(0, a)
ZEND_ARG_INFO(0, b)
ZEND_END_ARG_INFO()
static PHP_FUNCTION(params_str) {
char *str = "";
int str_len = 0;
long i = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl", &str, &str_len, &i) == FAILURE) {
return;
}
php_printf("string(%d) value:", str_len);
PHPWRITE(str, str_len);
php_printf("\n");
php_printf("int(%d)\n", i);
php_printf("\n");
}
//调用上面的方法
<?php
$func = "params_str";
call_user_func($func, "hello world", 10);//传递了完整的变量
call_user_func($func);//没有传递变量
//结果
string(11) value:hello world
int(10)
string(0) value:
int(0)
================================================
FILE: 03.md
================================================
# 返回值
1,创建一个新的扩展
./ext_skel --extname=return
2,修改config.m4,去掉没用的注释语句
cd return
vi config.m4
3,zend引擎在每个zif函数里定义了一个zval*类型的形参,名称为return_value,我们需要在函数里修改这个指针,函数执行完后内核将把这个指针指向的zval值返回
#define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
//ht
//zval *return_value 返回值
//zval **return_value_ptr
//zval *this_ptr,如果此函数是一个类的方法,那么这个指针的含义和PHP语言中$this变量差不多。
//int return_value_used,代表用户端在调用此函数时有没有使用到它的返回值。
4,用于返回值的宏
a) RETURN_BOOL(0); //返回bool值
//宏的定义(Zend/zend_API.h)
#define RETURN_BOOL(b) { RETVAL_BOOL(b); return; }
#define RETVAL_BOOL(b) ZVAL_BOOL(return_value, b)//操作return_value
#define ZVAL_BOOL(z, b) do { \
zval *__z = (z); \
Z_LVAL_P(__z) = ((b) != 0); \
Z_TYPE_P(__z) = IS_BOOL; \
} while (0)
//所以展开这个RETURN_BOOL(0),最终在函数里返回值的操作即是:
do {
zval *__z = (return_value);
Z_LVAL_P(__z) = ((0) != 0); //定义return_value值
Z_TYPE_P(__z) = IS_BOOL; //定义return_value的类型
}while(0)
b) RETURN_STRING("hello world", 1); //返回字符串
//展开
do {
const char *__s = ("hello world");
zval *__z = return_value;
Z_STRLEN_P(__z) = strlen(__s);//定义长度
Z_STRVAL_P(__z) = (1?estrndup(__s, Z_STRLEN_P(__z)):(char*)__s);//定义值,estrndup函数实现字符串的复制
Z_TYPE_P(__z) = IS_STRING;
}while(0)
c)RETURN_LONG(100); //返回long值
//展开
zval *__z = return_value;
Z_LVAL_P(__z) = 100;
Z_TYPE_P(__z) = IS_LONG;
d)返回数组
array_init(return_value);//初始化return_value成数组,此操作完后就可以返回一个空的数组,$ret = array()
e)返回object
object_init(return_value);//初始化return_value成Object,此操作完成后返回一个空的对像
f)RETURN_RESOURCE(l);//返回resource
g)RETURN_NULL(); //return null;
h)RETURN_EMPTY_STRING(); //return "";
i)RETURN_ZVAL;
j)RETURN_FALSE; //return false;
k)RETURN_TRUE//return true;
#define RETVAL_RESOURCE(l) ZVAL_RESOURCE(return_value, l) //付值resource变量到系统返回值(return_value)
#define RETVAL_BOOL(b) ZVAL_BOOL(return_value, b) //付值bool变量到系统返回值(return_value)
#define RETVAL_NULL() ZVAL_NULL(return_value) //付值NULL到系统返回值(return_value)
#define RETVAL_LONG(l) ZVAL_LONG(return_value, l) //付值long变量到系统返回值(return_value)
#define RETVAL_DOUBLE(d) ZVAL_DOUBLE(return_value, d) //付值double变量到系统返回值(return_value)
#define RETVAL_STRING(s, duplicate) ZVAL_STRING(return_value, s, duplicate) //付值string变量到系统返回值(return_value)
#define RETVAL_STRINGL(s, l, duplicate) ZVAL_STRINGL(return_value, s, l, duplicate)
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value) //返回empty string
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)//返回zval变量
#define RETVAL_FALSE ZVAL_BOOL(return_value, 0) //返回false
#define RETVAL_TRUE ZVAL_BOOL(return_value, 1) //返回true
#define RETURN_RESOURCE(l) { RETVAL_RESOURCE(l); return; }
#define RETURN_BOOL(b) { RETVAL_BOOL(b); return; }
#define RETURN_NULL() { RETVAL_NULL(); return;}
#define RETURN_LONG(l) { RETVAL_LONG(l); return; }
#define RETURN_DOUBLE(d) { RETVAL_DOUBLE(d); return; }
#define RETURN_STRING(s, duplicate) { RETVAL_STRING(s, duplicate); return; }
#define RETURN_STRINGL(s, l, duplicate) { RETVAL_STRINGL(s, l, duplicate); return; }
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
#define RETURN_FALSE { RETVAL_FALSE; return; }
#define RETURN_TRUE { RETVAL_TRUE; return; }
5,数组函数
1)Zend's API for Associative Arrays
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr); //$arr = array();
add_assoc_long(arr, "a", 10); //$arr["a"] = 10;
add_asoc_unset(arr, "a"); //unset(arr["a"]);
add_assoc_bool(arr, "b", 1); //$arr["b"] = true;
add_assoc_resource(arr, "c", 10); //$arr["c"] = $resource;
add_assoc_double(arr, "d", 2.15); //$arr["d"] = 2.15;
add_assoc_string(arr, "e", "hello", 1); //$arr["e"] = "hello";最后一个参数表示字符串值是否复制
add_assoc_stringl();
zval *sub;
MAKE_STD_ZVAL(sub);
array_init(sub);
add_assoc_zval(arr, "f", sub); //$arr["f"] = $sub;
2)Zend's API for Indexed Arrays, Part 1
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr); //$arr = array();
add_index_long(arr, 1, 10); //$arr[1] = 10;
add_index_unset(arr, 1); //unset($arr[1]);
add_index_bool(arr, 2, 1); //$arr[2] = true;
add_index_resource(arr, 3, 10); //$arr[3] = $resource;
add_index_double(arr, 4, 2.15); //$arr[4] = 2.15;
add_index_string(arr, 5, "hello", 1); //$arr[5] = "hello";最后一个参数表示字符串值是否复制
add_index_stringl();
zval *sub;
MAKE_STD_ZVAL(sub);
array_init(sub);
add_index_zval(arr, 6, sub); //$arr[6] = $sub;
3)Zend's API for Indexed Arrays, Part 2
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr); //$arr = array();
add_next_index_long(arr, 10); //$arr[] = 10;
add_next_index_unset(arr); //unset($arr[]);
add_next_index_bool(arr, 1); //$arr[] = true;
add_next_index_resource(arr, 10); //$arr[] = $resource;
add_next_index_double(arr, 2.15); //$arr[] = 2.15;
add_next_index_string(arr, "hello", 1); //$arr[] = "hello";最后一个参数表示字符串值是否复制
add_next_index_stringl();
zval *sub;
MAKE_STD_ZVAL(sub);
array_init(sub);
add_next_index_zval(arr, sub); //$arr[] = $sub;
6,Object函数
zval *obj;
MAKE_STD_ZVAL(obj);
object_init(obj);//$obj = new stdClass;
add_property_long(obj, "a", 10); //$obj->a = 10;
add_property_unset(obj, "a"); //unset($obj->a);
add_property_bool(obj, "b", 1); //$obj->b = true;
add_property_resource(obj, "c", 10); //$obj->c = $resource;
add_property_double(obj, "d", 2.15); //$obj->d = 2.15;
add_property_string(obj, "e", "hello", 1);//$obj->e = "hello"; 最后一个参数表示字符串值是否复制
add_property_stringl();
zval *sub;
MAKE_STD_ZVAL(sub);
object_init(sub); //$sub = new stdClass;
add_property_zval(obj, "f", sub); //$obj->f = $sub;
7,Zval
struct _zend_object_handlers {
/* general object functions */
zend_object_add_ref_t add_ref;
zend_object_del_ref_t del_ref;
zend_object_clone_obj_t clone_obj;
/* individual object functions */
zend_object_read_property_t read_property;
zend_object_write_property_t write_property;
zend_object_read_dimension_t read_dimension;
zend_object_write_dimension_t write_dimension;
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr;
zend_object_get_t get;
zend_object_set_t set;
zend_object_has_property_t has_property;
zend_object_unset_property_t unset_property;
zend_object_has_dimension_t has_dimension;
zend_object_unset_dimension_t unset_dimension;
zend_object_get_properties_t get_properties;
zend_object_get_method_t get_method;
zend_object_call_method_t call_method;
zend_object_get_constructor_t get_constructor;
zend_object_get_class_entry_t get_class_entry;
zend_object_get_class_name_t get_class_name;
zend_object_compare_t compare_objects;
zend_object_cast_t cast_object;
zend_object_count_elements_t count_elements;
zend_object_get_debug_info_t get_debug_info;
zend_object_get_closure_t get_closure;
zend_object_get_gc_t get_gc;
};
typedef struct _zend_object_value {
zend_object_handle handle;
const zend_object_handlers *handlers;
} zend_object_value;
typedef union _zvalue_value {
long lval; /* long value */
double dval; /* double value */
struct {
char *val;
int len;
} str; /* string value */
HashTable *ht; /* hash table value */
zend_object_value obj; /* object value */
} zvalue_value;
struct _zval_struct {
/* Variable information */
zvalue_value value; /* 值 */
zend_uint refcount__gc; /* 引用计数 */
zend_uchar type; /* 变量类型 */
zend_uchar is_ref__gc; /* 是否引用变量, &$a */
};
#define ZVAL_FALSE(z) ZVAL_BOOL(z, 0) //设置zval
#define ZVAL_TRUE(z) ZVAL_BOOL(z, 1)
/* struct操作宏 */
#define Z_LVAL(zval) (zval).value.lval //获取long值
#define Z_BVAL(zval) ((zend_bool)(zval).value.lval) //获取bool值
#define Z_DVAL(zval) (zval).value.dval //获取double值
#define Z_STRVAL(zval) (zval).value.str.val //获取string的指针
#define Z_STRLEN(zval) (zval).value.str.len //获取string的长度
#define Z_ARRVAL(zval) (zval).value.ht //获取hashtable值
#define Z_OBJVAL(zval) (zval).value.obj //获取object值
#define Z_OBJ_HANDLE(zval) Z_OBJVAL(zval).handle //
#define Z_OBJ_HT(zval) Z_OBJVAL(zval).handlers //
#define Z_OBJCE(zval) zend_get_class_entry(&(zval) TSRMLS_CC) //
#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC) //
#define Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf //
#define Z_RESVAL(zval) (zval).value.lval //获取long值
#define Z_OBJDEBUG(zval,is_tmp) (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&is_tmp TSRMLS_CC):(is_tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL)) //
/* 指针操作宏 */
#define Z_LVAL_P(zval_p) Z_LVAL(*zval_p)
#define Z_BVAL_P(zval_p) Z_BVAL(*zval_p)
#define Z_DVAL_P(zval_p) Z_DVAL(*zval_p)
#define Z_STRVAL_P(zval_p) Z_STRVAL(*zval_p)
#define Z_STRLEN_P(zval_p) Z_STRLEN(*zval_p)
#define Z_ARRVAL_P(zval_p) Z_ARRVAL(*zval_p)
#define Z_OBJPROP_P(zval_p) Z_OBJPROP(*zval_p)
#define Z_OBJCE_P(zval_p) Z_OBJCE(*zval_p)
#define Z_RESVAL_P(zval_p) Z_RESVAL(*zval_p)
#define Z_OBJVAL_P(zval_p) Z_OBJVAL(*zval_p)
#define Z_OBJ_HANDLE_P(zval_p) Z_OBJ_HANDLE(*zval_p)
#define Z_OBJ_HT_P(zval_p) Z_OBJ_HT(*zval_p)
#define Z_OBJ_HANDLER_P(zval_p, h) Z_OBJ_HANDLER(*zval_p, h) #define Z_OBJDEBUG_P(zval_p,is_tmp) Z_OBJDEBUG(*zval_p,is_tmp)
/* */
#define Z_LVAL_PP(zval_pp) Z_LVAL(**zval_pp)
#define Z_BVAL_PP(zval_pp) Z_BVAL(**zval_pp)
#define Z_DVAL_PP(zval_pp) Z_DVAL(**zval_pp)
#define Z_STRVAL_PP(zval_pp) Z_STRVAL(**zval_pp)
#define Z_STRLEN_PP(zval_pp) Z_STRLEN(**zval_pp)
#define Z_ARRVAL_PP(zval_pp) Z_ARRVAL(**zval_pp)
#define Z_OBJPROP_PP(zval_pp) Z_OBJPROP(**zval_pp)
#define Z_OBJCE_PP(zval_pp) Z_OBJCE(**zval_pp)
#define Z_RESVAL_PP(zval_pp) Z_RESVAL(**zval_pp)
#define Z_OBJVAL_PP(zval_pp) Z_OBJVAL(**zval_pp)
#define Z_OBJ_HANDLE_PP(zval_p) Z_OBJ_HANDLE(**zval_p)
#define Z_OBJ_HT_PP(zval_p) Z_OBJ_HT(**zval_p)
#define Z_OBJ_HANDLER_PP(zval_p, h) Z_OBJ_HANDLER(**zval_p, h)
#define Z_OBJDEBUG_PP(zval_pp,is_tmp) Z_OBJDEBUG(**zval_pp,is_tmp)
/* 获取zval的变量类型 */
#define Z_TYPE(zval) (zval).type
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
#define Z_TYPE_PP(zval_pp) Z_TYPE(**zval_pp)
/* zval初始化宏 */
#define ALLOC_ZVAL(z) (z) = (zval *) emalloc(sizeof(zval)) //初始化zval,分配内存
#define FREE_ZVAL(z) efree_rel(z) //释放zvalue内存
#define ALLOC_ZVAL_REL(z)(z) = (zval *) emalloc_rel(sizeof(zval))
#define FREE_ZVAL_REL(z) efree_rel(z)
/* HashTable初始化宏 */
#define ALLOC_HASHTABLE(ht) (ht) = (HashTable *) emalloc(sizeof(HashTable)) //初始化HashTable
#define FREE_HASHTABLE(ht) efree(ht)
#define ALLOC_HASHTABLE_REL(ht) (ht) = (HashTable *) emalloc_rel(sizeof(HashTable))
#define FREE_HASHTABLE_REL(ht) efree_rel(ht)
#define INIT_PZVAL(z) (z)->refcount__gc = 1; (z)->is_ref__gc = 0; //设置refcount
#define INIT_ZVAL(z) z = zval_used_for_init;
#define ALLOC_INIT_ZVAL(zp) ALLOC_ZVAL(zp); INIT_ZVAL(*zp); //分配内存并设置默认值
#define MAKE_STD_ZVAL(zv) ALLOC_ZVAL(zv); INIT_PZVAL(zv); //分配内存并设置默认值
#define PZVAL_IS_REF(z) Z_ISREF_P(z)
/* 拷贝zval的值 */
#define ZVAL_COPY_VALUE(z, v) \
do { \
(z)->value = (v)->value; \
Z_TYPE_P(z) = Z_TYPE_P(v); \
} while (0)
#define INIT_PZVAL_COPY(z, v) \
do { \
ZVAL_COPY_VALUE(z, v); \
Z_SET_REFCOUNT_P(z, 1); \
Z_UNSET_ISREF_P(z); \
} while (0)
#define ZVAL_IS_NULL(z) (Z_TYPE_P(z)==IS_NULL) //判断zval是否为NULL
/* 设置zval为resource类型值 */
#define ZVAL_RESOURCE(z, l) do { \
zval *__z = (z); \
Z_LVAL_P(__z) = l; \
Z_TYPE_P(__z) = IS_RESOURCE;\
} while (0)
/* 设置zval为bool类型值 */
#define ZVAL_BOOL(z, b) do { \
zval *__z = (z); \
Z_LVAL_P(__z) = ((b) != 0); \
Z_TYPE_P(__z) = IS_BOOL; \
} while (0)
/* 设置zval为NULL */
#define ZVAL_NULL(z) { \
Z_TYPE_P(z) = IS_NULL; \
}
/* 设置zval为long值 */
#define ZVAL_LONG(z, l) { \
zval *__z = (z); \
Z_LVAL_P(__z) = l; \
Z_TYPE_P(__z) = IS_LONG; \
}
/* 设置zval为double值 */
#define ZVAL_DOUBLE(z, d) { \
zval *__z = (z); \
Z_DVAL_P(__z) = d; \
Z_TYPE_P(__z) = IS_DOUBLE; \
}
/* 设置zval为string值 */
#define ZVAL_STRING(z, s, duplicate) do { \
const char *__s=(s); \
zval *__z = (z); \
Z_STRLEN_P(__z) = strlen(__s); \
Z_STRVAL_P(__z) = (duplicate?estrndup(__s, Z_STRLEN_P(__z)):(char*)__s);\
Z_TYPE_P(__z) = IS_STRING; \
} while (0)
/* 设置zval为string值 */
#define ZVAL_STRINGL(z, s, l, duplicate) do { \
const char *__s=(s); int __l=l; \
zval *__z = (z); \
Z_STRLEN_P(__z) = __l; \
Z_STRVAL_P(__z) = (duplicate?estrndup(__s, __l):(char*)__s);\
Z_TYPE_P(__z) = IS_STRING; \
} while (0)
/* 设置zval为empty string值 */
#define ZVAL_EMPTY_STRING(z) do { \
zval *__z = (z); \
Z_STRLEN_P(__z) = 0; \
Z_STRVAL_P(__z) = STR_EMPTY_ALLOC();\
Z_TYPE_P(__z) = IS_STRING; \
} while (0)
/* 设置zval为zval值 */
#define ZVAL_ZVAL(z, zv, copy, dtor) { \
zend_uchar is_ref = Z_ISREF_P(z); \
zend_uint refcount = Z_REFCOUNT_P(z); \
ZVAL_COPY_VALUE(z, zv); \
if (copy) { \
zval_copy_ctor(z); \
} \
if (dtor) { \
if (!copy) { \
ZVAL_NULL(zv); \
} \
zval_ptr_dtor(&zv); \
} \
Z_SET_ISREF_TO_P(z, is_ref); \
Z_SET_REFCOUNT_P(z, refcount); \
}
================================================
FILE: 04.md
================================================
# INI参数设置
## 创建一个新的扩展
+ 生成扩展
```
./ext_skel --extname=inis
```
+ config.m4
```
PHP_ARG_ENABLE(inis, whether to enable inis support,
[ --enable-inis Enable inis support])
if test "$PHP_INIS" != "no"; then
PHP_NEW_EXTENSION(inis, inis.c, $ext_shared)
fi
```
+ php_inis.h
```
ZEND_BEGIN_MODULE_GLOBALS(inis)
char *name;
long level;
ZEND_END_MODULE_GLOBALS(inis)
#ifdef ZTS
#define INIS_G(v) TSRMG(inis_globals_id, zend_inis_globals *, v)
#else
#define INIS_G(v) (inis_globals.v)
#endif
```
+ inis.c
定义全局变量
```c
ZEND_DECLARE_MODULE_GLOBALS(inis)
```
设置INI参数
```c
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("inis.name","sunzy",PHP_INI_ALL,OnUpdateString,name,zend_inis_globals,inis_globals)
STD_PHP_INI_ENTRY("inis.level","1",PHP_INI_ALL,OnUpdateLong,level,zend_inis_globals,inis_globals)
PHP_INI_END()
```
初始化函数
```c
static void php_inis_init_globals(zend_inis_globals *inis_globals)
{
inis_globals->name="sunzy.org";
inis_globals->level=10;
}
```
注册&清除INI变量
```c
PHP_MINIT_FUNCTION(inis)
{
REGISTER_INI_ENTRIES();
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(inis)
{
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
```
自定义函数
```c
PHP_FUNCTION(inis_report)
{
php_printf("Name:%s\n",INIS_G(name));
php_printf("Level:%d\n",INIS_G(level));
}
```
注册自定义函数
```c
const zend_function_entry inis_functions[] = {
PHP_FE(inis_report,NULL)
PHP_FE_END /* Must be the last line in inis_functions[] */
};
```
+ 测试
测试脚本
```php
$function = "inis_report";
call_user_func($function);
```
测试
```shell
$ /usr/local/php5.6.9/bin/php -q inis.php
Functions available in the test extension:
inis_report
Name:sunzy
Level:1
```
修改php.ini
```
inis.name=test
inis.level=2
```
```shell
$ /usr/local/php5.6.9/bin/php -q inis.php
Functions available in the test extension:
inis_report
Name:test
Level:2
```
## 相关的宏
+ ZEND_DECLARE_MODULE_GLOBALS ->Zend/zend_API.h
```c
#ifdef ZTS
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
ts_rsrc_id module_name##_globals_id;
#else
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
zend_##module_name##_globals module_name##_globals;
#endif
```
```ts_rsrc_id```是[线程安全](http://walu.cc/phpbook/1.4.md)里的内容
+ PHP_INI_BEGIN、PHP_INI_END、STD_PHP_INI_ENTRY ->main/php_ini.h
```c
#define PHP_INI_BEGIN ZEND_INI_BEGIN
#define PHP_INI_END ZEND_INI_END
#define STD_PHP_INI_ENTRY STD_ZEND_INI_ENTRY
```
+ ZEND_INI_BEGIN、ZEND_INI_END、STD_ZEND_INI_ENTRY -> Zend/zend_ini.h
```c
#define ZEND_INI_BEGIN() static const zend_ini_entry ini_entries[] = {
#define ZEND_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, NULL } };
#define ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, displayer) \
{ 0, modifiable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, 0, displayer },
#define ZEND_INI_ENTRY3(name, default_value, modifiable, on_modify, arg1, arg2, arg3) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, NULL)
#define ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, displayer) \
ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL, displayer)
#define ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, arg1, arg2) \
ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL)
#ifdef ZTS
#define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
#else
#define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
#endif
```
前面扩展中对ini变量的定义展开后
```c
static const zend_ini_entry ini_entries[] = {//BEGIN
{0, PHP_INI_ALL, "inis.enable", sizeof("inis.enable"), OnUpdateBool, enable, zend_inis_globals, inis_globals... }//inis.enable定义
...
{ 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, NULL } //END
};
```
+ REGISTER_INI_ENTRIES、UNREGISTER_INI_ENTRIES ->Zend/zend_ini.h
```c
#define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number TSRMLS_CC) //注册ini变量
#define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number TSRMLS_CC) //清除ini变量
#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module) //在phpinfo中显示变量值
```
+ ZEND_INIT_MODULE_GLOBALS ->Zend/zend_ini.h
```c
#ifdef ZTS
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
#else
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
globals_ctor(&module_name##_globals);
#endif
```
初始化ini值的宏
> module_name 与传递给ZEND_BEGIN_MODULE_GLOBALS()宏相同的扩展名称。
> globals_ctor 构造函数指针。在myfile扩展里,函数原形与void php_myfile_init_globals(zend_myfile_globals *myfile_globals)类似
> globals_dtor 析构函数指针。例如,php_myfile_init_globals(zend_myfile_globals *myfile_globals)
================================================
FILE: 05.md
================================================
# 数组
1,创建一个扩展
```shell
./ext_skel --extname=array
```
2,hashTable函数说明
```c
typedef struct bucket {
ulong h; /* Used for numeric indexing */
uint nKeyLength;
void *pData;
void *pDataPtr;
struct bucket *pListNext;
struct bucket *pListLast;
struct bucket *pNext;
struct bucket *pLast;
const char *arKey;
} Bucket;
typedef struct _hashtable {
uint nTableSize;
uint nTableMask;
uint nNumOfElements;
ulong nNextFreeElement;
Bucket *pInternalPointer; /* Used for element traversal */
Bucket *pListHead;
Bucket *pListTail;
Bucket **arBuckets;
dtor_func_t pDestructor;
zend_bool persistent;
unsigned char nApplyCount;
zend_bool bApplyProtection;
#if ZEND_DEBUG
int inconsistent;
#endif
} HashTable;
typedef Bucket* HashPosition;
//初始化HashTable
HashTable *myht;
zval *zv;
/* Same as myht = emalloc(sizeof(HashTable)); */
ALLOC_HASHTABLE(myht);
zend_hash_init(myht, 0, NULL, ZVAL_PTR_DTOR, 0);
MAKE_STD_ZVAL(zv);
ZVAL_STRING(zv, "foo", 1);
/* In PHP: $array[42] = "foo" */
zend_hash_index_update(myht, 42, &zv, sizeof(zval *), NULL);
zend_hash_destroy(myht);
/* Same as efree(myht); */
FREE_HASHTABLE(myht);
HashTable *names, *options = NULL;
HashPosition pos;//此值是Bucket的指针,pos->h表示的即是当前值的index
zval **val;
zend_bool key_exist;
//基于string key的操作函数
key_exist = zend_hash_exists(options, "key", sizeof("key"));
//在hashtable中查找key,如果查到则返回true,只针对于"key" => "value"这样的数组
zend_hash_find(options, "hello", sizeof("hello"), (void **)&val) == SUCCESS;
//在options中查找hello,如果找到则返回SUCCESS
char *k1 = "key1";
zval *v1;
MAKE_STD_ZVAL(v1);
ZVAL_STRING(v1, "value1", 1);
zend_hash_add(names, k1, sizeof(k1), &v1, sizeof(zval *), NULL); //为添加hashtable添加一个新的元素, 即 "key1" => "value1"
zend_hash_update(names, "name", sizeof("name"), &v2, sizeof(zval *), NULL);//按key更新hashtable元素的值
zend_hash_del(names, k1, sizeof(k1));//按key删除一个元素
//基于long key的操作函数
zval *v3;
MAKE_STD_ZVAL(v3);
ZVAL_STRING(v3, "value3", 1);
zend_hash_index_update(names, 0, &v3, sizeof(zval *), NULL);//按数字索引键更新HashTable元素的值
zval **v4;
zend_hash_index_find(names, 1, &v4); //按数字索引获取HashTable元素的值
php_printf("v4 : ");
PHPWRITE(Z_STRVAL_PP(v4), Z_STRLEN_PP(v4));
php_printf("\n");
ulong idx;
idx = zend_hash_index_exists(names, 10);//按数字索引查找HashTable,如果找到返回 1, 反之则返回 0
zend_hash_index_del(names, 2); //按数字索引删除HashTable元素
//hashTable的遍历函数
zend_hash_internal_pointer_reset(names); //初始化hash指针
zend_hash_internal_pointer_reset_ex(names, &pos);//初始化hash指针,并付值给pos
zend_hash_get_current_data(names, (void**) &val); //获取当前hash存储值,data should be cast to void**, ie: (void**) &data
zend_hash_get_current_data_ex(names, (void**) &val, &pos) == SUCCESS; //获取当前hash存储值
zend_hash_get_current_key(names, &key, &klen, &index, 0) == HASH_KEY_IS_LONG
zend_hash_get_current_key_ex(names, &key, &klen, &index, 0, &pos) == HASH_KEY_IS_LONG; //读取hashtable当前的KEY,返回值会有两种 HASH_KEY_IS_LONG | HASH_KEY_IS_STRING ,分别对应array("value"),array("key"=>"value")两种hashtable
zend_hash_move_forward(names);
zend_hash_move_forward_ex(names, &pos); //hash指针移至下一位
//HashTable长度
php_printf("%*carray(%d) {\n", depth * 2, ' ', zend_hash_num_elements(Z_ARRVAL_P(zv))
```
3,数组函数说明
1)Zend's API for Associative Arrays
```c
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr); //$arr = array();
add_assoc_long(arr, "a", 10); //$arr["a"] = 10;
add_asoc_unset(arr, "a"); //unset(arr["a"]);
add_assoc_bool(arr, "b", 1); //$arr["b"] = true;
add_assoc_resource(arr, "c", 10); //$arr["c"] = $resource;
add_assoc_double(arr, "d", 2.15); //$arr["d"] = 2.15;
add_assoc_string(arr, "e", "hello", 1); //$arr["e"] = "hello";最后一个参数表示字符串值是否复制
add_assoc_stringl();
zval *sub;
MAKE_STD_ZVAL(sub);
array_init(sub);
add_assoc_zval(arr, "f", sub); //$arr["f"] = $sub;
```
2)Zend's API for Indexed Arrays, Part 1
```c
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr); //$arr = array();
add_index_long(arr, 1, 10); //$arr[1] = 10;
add_index_unset(arr, 1); //unset($arr[1]);
add_index_bool(arr, 2, 1); //$arr[2] = true;
add_index_resource(arr, 3, 10); //$arr[3] = $resource;
add_index_double(arr, 4, 2.15); //$arr[4] = 2.15;
add_index_string(arr, 5, "hello", 1); //$arr[5] = "hello";最后一个参数表示字符串值是否复制
add_index_stringl();
zval *sub;
MAKE_STD_ZVAL(sub);
array_init(sub);
add_index_zval(arr, 6, sub); //$arr[6] = $sub;
```
3)Zend's API for Indexed Arrays, Part 2
```c
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr); //$arr = array();
add_next_index_long(arr, 10); //$arr[] = 10;
add_next_index_unset(arr); //unset($arr[]);
add_next_index_bool(arr, 1); //$arr[] = true;
add_next_index_resource(arr, 10); //$arr[] = $resource;
add_next_index_double(arr, 2.15); //$arr[] = 2.15;
add_next_index_string(arr, "hello", 1); //$arr[] = "hello";最后一个参数表示字符串值是否复制
add_next_index_stringl();
zval *sub;
MAKE_STD_ZVAL(sub);
array_init(sub);
add_next_index_zval(arr, sub); //$arr[] = $sub;
```
================================================
FILE: 06.md
================================================
# Global变量
1,创建一个扩展
./ext_skel --extname=global
2,扩展global变量
/*定义global变量*/
ZEND_BEGIN_MODULE_GLOBALS(global)
long counter;
char *name;
int name_len;
ZEND_END_MODULE_GLOBALS(global)
ZEND_DECLARE_MODULE_GLOBALS(global);//申明变量
GLOBAL_G(name); //获取global变量的值
GLOBAL_G(counter) = 10; //给global变量赋值
3,POST|GET|COOKIE|SERVER|ENV|REQUEST|FILES全局变量
#php-fpm 生成 POST|GET|COOKIE|SERVER|ENV|REQUEST|FILES全局变量的流程
php_cgi_startup() -> php_module_startup() -> php_startup_auto_globals() -> 保存变量到symbol_table符号表
php_cgi_startup()在 fpm/fpm/fpm_main.c中定义
php_module_startup() 在main/main.c中定义
php_startup_auto_globals() 在main/php_variables.h中定义
zend_hash_update(&EG(symbol_table), "_GET", sizeof("_GET") + 1, &vars, sizeof(zval *), NULL);
/* 读取$_SERVER变量 */
static PHP_FUNCTION(print_server_vars) {
zval **val;
if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&val) == SUCCESS) {
RETURN_ZVAL(*val, 1, 0);
}else{
RETURN_FALSE;
}
}
/* 读取$_SERVER[$name] */
ZEND_BEGIN_ARG_INFO(print_server_var_arginfo, 0)
ZEND_ARG_INFO(0, "name")
ZEND_END_ARG_INFO()
static PHP_FUNCTION(print_server_var) {
char *name;
int name_len;
zval **val;
HashTable *ht_vars = NULL;
HashPosition pos;
zval **ret_val;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &name, &name_len) == FAILURE) {
RETURN_NULL();
}
if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&val) == SUCCESS) {
ht_vars = Z_ARRVAL_PP(val);
//此处需传入大于name长度+1的值,因为字符串值后面需要'\0'
if (zend_hash_find(ht_vars, name, name_len+1, (void **)&ret_val) == SUCCESS) { RETURN_STRING(Z_STRVAL_PP(ret_val), 0);
}else{
RETURN_NULL();
}
}else{
RETURN_NULL();
}
}
4,$GLOBALS变量
/*添加globals变量*/
static PHP_FUNCTION(add_globals_vars) {
SET_VAR_LONG("_LONG", 10); //添加long变量
SET_VAR_DOUBLE("_DOUBLE", 20.5); //添加double变量
SET_VAR_STRING("_STRING", "string"); //添加string变量
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr);
add_assoc_string(arr, "e", "hello", 1);
ZEND_SET_GLOBAL_VAR("_ARRS", arr); //添加zval变量
}
/*添加globals字符串变量*/
5,相关宏
/* 设置global变量 */
#define ZEND_SET_GLOBAL_VAR(name, var) ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
#define ZEND_SET_GLOBAL_VAR_WITH_LENGTH(name, name_length, var, _refcount, _is_ref)
ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), name, name_length, var, _refcount, _is_ref)
/ *设置string类型的global变量 */
#define SET_VAR_STRING(n, v) { { zval *var;
ALLOC_ZVAL(var);
ZVAL_STRING(var, v, 0);
ZEND_SET_GLOBAL_VAR(n, var);}
}
#define SET_VAR_STRINGL(n, v, l) { {zval *var;
ALLOC_ZVAL(var);
ZVAL_STRINGL(var, v, l, 0);
ZEND_SET_GLOBAL_VAR(n, var);}
}
/* 设置long类型的global变量 */
#define SET_VAR_LONG(n, v) {{zval *var;
ALLOC_ZVAL(var);
ZVAL_LONG(var, v);
ZEND_SET_GLOBAL_VAR(n, var);}
}
/* 设置double类型的global变量 */
#define SET_VAR_DOUBLE(n, v) {{ zval *var;
ALLOC_ZVAL(var);
ZVAL_DOUBLE(var, v);
ZEND_SET_GLOBAL_VAR(n, var);}
}
#define ZEND_SET_SYMBOL(symtable, name, var){
char *_name = (name);
ZEND_SET_SYMBOL_WITH_LENGTH(symtable, _name, strlen(_name)+1, var, 1, 0);
}
#define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref){
zval **orig_var;
if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS
&& PZVAL_IS_REF(*orig_var)) {
Z_SET_REFCOUNT_P(var, Z_REFCOUNT_PP(orig_var));
Z_SET_ISREF_P(var);
if (_refcount) {
Z_SET_REFCOUNT_P(var, Z_REFCOUNT_P(var) + _refcount - 1);
}
zval_dtor(*orig_var);
**orig_var = *(var);
FREE_ZVAL(var);
} else {
Z_SET_ISREF_TO_P(var, _is_ref);
if (_refcount) {
Z_SET_REFCOUNT_P(var, _refcount);
}
zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL);
}
}
================================================
FILE: 07.md
================================================
# 常量
1,创建一个扩展
./ext_skel --extname=consts
2,代码
/*定义一个long类型的常量,
名字: CONSTS_MEANING_OF_LIFE,
值: 42
CONST_CS: 标识是否大小写敏感,一般情况CONST_CS是默认的
CONST_PERSISTENT: 表示常量是否持久化
*/
PHP_MINIT_FUNCTION(consts) //模块初始化时定义常量
{
REGISTER_LONG_CONSTANT("CONSTS_MEANING_OF_LIFE", 42, CONST_CS | CONST_PERSISTENT);
REGISTER_DOUBLE_CONSTANT("CONSTS_PI", 3.1415926, CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("CONSTS_NAME", "leon", CONST_CS|CONST_PERSISTENT);
}
PHP_RINIT_FUNCTION(consts) //每次请求时定义常量
{
char buffer[40];
srand((int)time(NULL));
snprintf(buffer, sizeof(buffer), "%d", rand());
REGISTER_STRING_CONSTANT("CONSTS_RAND", estrdup(buffer), CONST_CS);
return SUCCESS;
}
3,相关宏
/*注册LONG类型常量*/
#define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name), (lval), (flags), module_number TSRMLS_CC)
/*注册double类型常量*/
#define REGISTER_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name), (dval), (flags), module_number TSRMLS_CC)
/*注册STRING类型常量*/
#define REGISTER_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name), (str), (flags), module_number TSRMLS_CC)
/*注册STRING类型常量*/
#define REGISTER_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name), (str), (len), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags) zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (lval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags) zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (dval), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags) zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (str), (flags), module_number TSRMLS_CC)
#define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags) zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name)), (str), (len), (flags), module_number TSRMLS_CC)
#define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name), (lval), (flags), 0 TSRMLS_CC)
#define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name), (dval), (flags), 0 TSRMLS_CC)
#define REGISTER_MAIN_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name), (str), (flags), 0 TSRMLS_CC)
#define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name), (str), (len), (flags), 0 TSRMLS_CC)
================================================
FILE: 08.md
================================================
# 调用php函数
1,创建新的扩展
./ext_skel --extname=fcall
2,代码
typedef struct _zend_fcall_info {
size_t size;
HashTable *function_table;
zval *function_name;
HashTable *symbol_table;
zval **retval_ptr_ptr;
zend_uint param_count;
zval ***params;
zval *object_ptr;
zend_bool no_separation;
} zend_fcall_info;
typedef struct _zend_fcall_info_cache {
zend_bool initialized;
zend_function *function_handler;
zend_class_entry *calling_scope;
zend_class_entry *called_scope;
zval *object_ptr;
} zend_fcall_info_cache;
zend_fcall_info finfo;
zend_fcall_info_cache fcache;
char *name = NULL;
zval **params[1];
zval *arg, *retval = NULL;
zend_fcall_info_init(&fname, IS_CALLABLE_STRICT, &finfo, &fcache, &name, NULL TSRMLS_CC); //初始化fcall_info
/*填充参数*/
MAKE_STD_ZVAL(arg);
ZVAL_STRING(arg, "Hello World", 1);
params[0] = &arg;
finfo.param_count = 1; //参数数量
finfo.params = params; //参数
finfo.retval_ptr_ptr = &retval; //返回值
/*执行函数*/
zend_call_function(&finfo, &fcache TSRMLS_CC)
================================================
FILE: 09.md
================================================
# 类与对像1
1,创建一个扩展
./ext_skel --extname=objects1
2,zend_class_entry结构
struct _zend_class_entry {
char type;
char *name;
zend_uint name_length;
struct _zend_class_entry *parent;
int refcount;
zend_bool constants_updated;
zend_uint ce_flags;
HashTable function_table;
HashTable default_properties;
HashTable properties_info;
HashTable *static_members;
HashTable constants_table;
struct _zend_function_entry *builtin_functions;
union _zend_function *constructor;
union _zend_function *destructor;
union _zend_function *clone;
union _zend_function *_ _get;
union _zend_function *_ _set;
union _zend_function *_ _call;
zend_class_iterator_funcs iterator_funcs;
/* handlers */
zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC);
zend_object_iterator *(*get_iterator)
(zend_class_entry *ce, zval *object TSRMLS_DC);
int (*interface_gets_implemented)
(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC);
zend_class_entry **interfaces;
zend_uint num_interfaces;
char *filename;
zend_uint line_start;
zend_uint line_end;
char *doc_comment;
zend_uint doc_comment_len;
};
3,类的定义
static zend_class_entry *hello_ce; //申明类
/*=========================申明类的方法=======================*/
const zend_function_entry hello_methods[] = {
PHP_ME(Hello, __construct, hello___construct_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) //构造函数申明 PHP_ME(Hello, __destruct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR) //析构函数申明
PHP_ME(Hello, __toString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Hello, updateProperties, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Hello, addProperties, NULL, ZEND_ACC_PUBLIC)
{ NULL, NULL, NULL }
};
/*==========================初始化类=======================================*/
PHP_MINIT_FUNCTION(objects1)
{
/*定义一个temp class*/
zend_class_entry ce;
/*初始化这个class,第二个参数是class name, 第三个参数是class methods*/
INIT_CLASS_ENTRY(ce, "Hello", hello_methods);
/*注册这个class到zend engine*/
/*This function also returns the final class entry, so it can be stored in the global variable declared above*/
hello_ce = zend_register_internal_class(&ce TSRMLS_CC);
return SUCCESS;
}
/*====================定义类的属性======================================*/
zend_declare_property_string(hello_ce, "name", sizeof("name") - 1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_long(hello_ce, "age", sizeof("age") - 1, 0, ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_string(hello_ce, "last_name", sizeof("last_name") -1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(hello_ce, "first_name", sizeof("first_name") -1, ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_bool(hello_ce, "sex", sizeof("sex") -1, 1, ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_double(hello_ce, "score", sizeof("score") -1, 12.50, ZEND_ACC_PUBLIC TSRMLS_CC);
/*====================更新属性值=======================================*/
zval *obj;
obj = getThis();
zend_update_property_string(hello_ce, obj, "name", sizeof("name") -1, "name-update" TSRMLS_CC);//更新属性值, $this->name = name
zend_update_property_long(hello_ce, obj, "age", sizeof("age") -1, 10 TSRMLS_CC); //this->age = age
zend_update_property_string(hello_ce, obj, "last_name", sizeof("last_name") -1, "leon-update" TSRMLS_CC);//this->last_name = "leon"
zend_update_property_null(hello_ce, obj, "first_name", sizeof("first_name") - 1 TSRMLS_CC); //this->first_name = null;
zend_update_property_bool(hello_ce, obj, "sex", sizeof("sex") -1, 0 TSRMLS_CC); //this->sex = true
zend_update_property_double(hello_ce, obj, "score", sizeof("score") -1, 15.50 TSRMLS_CC); //this->score = 12.50
/*==================动态添加属性=====================================*/
zval *obj;
obj = getThis();
/*add zval property*/
zval *arr;
MAKE_STD_ZVAL(arr);
array_init(arr);
add_assoc_string(arr, "e", "hello", 1);
add_index_string(arr, 1, "hello1111", 1);
add_property_zval_ex(obj, "persons", strlen("persons")+1, arr TSRMLS_CC);
Z_DELREF_P(arr);
/*add double property*/
add_property_double(obj, "d", 10.5);
/*add bool property*/
add_property_bool(obj, "b", 1);
/*add string property*/
char *str = "hello str";
add_property_string(obj, "str", str, 1);
/*add long property*/
add_property_long(obj, "l", 12);
/*==========================构造函数=========================*/
ZEND_BEGIN_ARG_INFO(hello___construct_arginfo, 0)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, age)
ZEND_END_ARG_INFO()
static PHP_METHOD(Hello, __construct) {
char *name;
int name_len;
long age;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &name, &name_len, &age) == FAILURE) {
return;
}
zval *obj;
obj = getThis();
zend_update_property_stringl(hello_ce, obj, "name", sizeof("name") -1, name, name_len TSRMLS_CC);//更新属性值, $this->name = name
zend_update_property_long(hello_ce, obj, "age", sizeof("age") -1, age TSRMLS_CC); //this->age = age
}
/*=========================析构函数==========================*/
static PHP_METHOD(Hello, __destruct) {
php_printf("call __destruct function...\n");
}
/*========================toString========================*/
static PHP_METHOD(Hello, __toString) {
RETURN_STRING("Hello Class\n", 1);
}
4,类的控制
//fn_flags代表可以在定义方法时使用,zend_property_info.flags代表可以在定义属性时使用,ce_flags代表在定义zend_class_entry时候可用
//ZEND_ACC_CTOR 构造函数掩码 , ZEND_ACC_DTOR 析构函数掩码
//ZEND_ACC_STATIC static函数掩码
//ZEND_ACC_ABSTRACT abstract函数掩码
#define ZEND_ACC_STATIC 0x01 /* fn_flags, zend_property_info.flags */
#define ZEND_ACC_ABSTRACT 0x02 /* fn_flags */
#define ZEND_ACC_FINAL 0x04 /* fn_flags */
#define ZEND_ACC_IMPLEMENTED_ABSTRACT 0x08 /* fn_flags */
#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS 0x10 /* ce_flags */
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS 0x20 /* ce_flags */
#define ZEND_ACC_FINAL_CLASS 0x40 /* ce_flags */
#define ZEND_ACC_INTERFACE 0x80 /* ce_flags */
#define ZEND_ACC_INTERACTIVE 0x10 /* fn_flags */
#define ZEND_ACC_PUBLIC 0x100 /* fn_flags, zend_property_info.flags */
#define ZEND_ACC_PROTECTED 0x200 /* fn_flags, zend_property_info.flags */
#define ZEND_ACC_PRIVATE 0x400 /* fn_flags, zend_property_info.flags */
#define ZEND_ACC_PPP_MASK (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE)
#define ZEND_ACC_CHANGED 0x800 /* fn_flags, zend_property_info.flags */
#define ZEND_ACC_IMPLICIT_PUBLIC 0x1000 /* zend_property_info.flags; unused (1) */
#define ZEND_ACC_CTOR 0x2000 /* fn_flags */
#define ZEND_ACC_DTOR 0x4000 /* fn_flags */
#define ZEND_ACC_CLONE 0x8000 /* fn_flags */
#define ZEND_ACC_ALLOW_STATIC 0x10000 /* fn_flags */
#define ZEND_ACC_SHADOW 0x20000 /* fn_flags */
#define ZEND_ACC_DEPRECATED 0x40000 /* fn_flags */
#define ZEND_ACC_CLOSURE 0x100000 /* fn_flags */
#define ZEND_ACC_CALL_VIA_HANDLER 0x200000 /* fn_flags */
5,宏
#define INIT_CLASS_ENTRY(class_container, class_name, functions) INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL)
#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL)
define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions) INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, NULL, NULL, NULL, NULL, NULL)
define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) {
const char *cl_name = class_name;
int _len = class_name_len;
class_container.name = zend_new_interned_string(cl_name, _len+1, 0 TSRMLS_CC);
if (class_container.name == cl_name) {
class_container.name = zend_strndup(cl_name, _len);
}
class_container.name_length = _len;
INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
}
#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) {
class_container.constructor = NULL;
class_container.destructor = NULL;
class_container.clone = NULL;
class_container.serialize = NULL;
class_container.unserialize = NULL;
class_container.create_object = NULL;
class_container.interface_gets_implemented = NULL;
class_container.get_static_method = NULL;
class_container.__call = handle_fcall;
class_container.__callstatic = NULL;
class_container.__tostring = NULL;
class_container.__get = handle_propget;
class_container.__set = handle_propset;
class_container.__unset = handle_propunset;
class_container.__isset = handle_propisset;
class_container.serialize_func = NULL;
class_container.unserialize_func = NULL;
class_container.serialize = NULL;
class_container.unserialize = NULL;
class_container.parent = NULL;
class_container.num_interfaces = 0;
class_container.traits = NULL;
class_container.num_traits = 0;
class_container.trait_aliases = NULL;
class_container.trait_precedences = NULL;
class_container.interfaces = NULL;
class_container.get_iterator = NULL;
class_container.iterator_funcs.funcs = NULL;
class_container.info.internal.module = NULL;
class_container.info.internal.builtin_functions = functions;
}
================================================
FILE: 10.md
================================================
# 类与对像2(自定义object存储)
1,创建一个扩展
./ext_skel --extname=objects2
2,代码
//定义一个结构用于存储object
typedef struct _hello_object {
zend_object obj;
char *name;
int name_len;
long age;
} hello_object;
//object操作回调函数
struct _zend_object_handlers {
/* general object functions */
zend_object_add_ref_t add_ref;
zend_object_del_ref_t del_ref;
zend_object_clone_obj_t clone_obj;
/* individual object functions */
zend_object_read_property_t read_property;
zend_object_write_property_t write_property;
zend_object_read_dimension_t read_dimension;
zend_object_write_dimension_t write_dimension;
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr;
zend_object_get_t get;
zend_object_set_t set;
zend_object_has_property_t has_property;
zend_object_unset_property_t unset_property;
zend_object_has_dimension_t has_dimension;
zend_object_unset_dimension_t unset_dimension;
zend_object_get_properties_t get_properties;
zend_object_get_method_t get_method;
zend_object_call_method_t call_method;
zend_object_get_constructor_t get_constructor;
zend_object_get_class_entry_t get_class_entry;
zend_object_get_class_name_t get_class_name;
zend_object_compare_t compare_objects;
zend_object_cast_t cast_object;
zend_object_count_elements_t count_elements;
zend_object_get_debug_info_t get_debug_info;
zend_object_get_closure_t get_closure;
zend_object_get_gc_t get_gc;
};
创建一个object的流程
1,定义class和object handlers(回调方法)
static zend_class_entry *hello_ce;
static zend_object_handlers hello_handlers;
2,定义存储object的结构
typedef struct _hello_object {
zend_object obj;
char *name;
int name_len;
long age;
} hello_object;
3,在PHP_MINIT_FUNCTION中初始化class
static PHP_MINIT_FUNCTION(objects2){
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "Hello", hello_methods)
hello_ce = zend_register_internal_class(&ce TSRMLS_CC);
hello_ce->create_object = hello_ctor;//创建object的回调方法
memcpy(&hello_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
// hello_handlers->clone_obj = hello_clone;
return SUCCESS;
}
4,实现创建object的回调方法
static zend_object_value hello_ctor(zend_class_entry *ce TSRMLS_DC) {
hello_object *objval = emalloc(sizeof(hello_object));
memset(objval, 0, sizeof(hello_object));
zend_object_value retval;
zend_object_std_init(&(objval->obj), ce TSRMLS_CC);
retval.handle = zend_objects_store_put(objval ,
NULL,
(zend_objects_free_object_storage_t)hello_dtor, //翻译object的回调方法
NULL TSRMLS_CC);
retval.handlers = &hello_handlers;
return retval;
}
5,实现销毁object的回调方法
static void hello_dtor(hello_object *objval TSRMLS_CC) {
if (objval->name) {
efree(objval->name);
}
zend_object_std_dtor(&(objval->obj) TSRMLS_CC);
efree(objval);
}
6,调用存储object的结构
#define HELLO_FETCH_OBJECT(zobj) (hello_object *)zend_object_store_get_object((zobj) TSRMLS_CC)
static PHP_METHOD(Hello, __construct) {
hello_object *objval = HELLO_FETCH_OBJECT(getThis());
char *name;
int name_len;
long age;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &name, &name_len, &age) == FAILURE) {
return;
}
objval->name = estrndup(name, name_len);
objval->name_len = name_len;
objval->age = age;
}
//获取object指针
hello_object *obj = (hello_object *)zend_object_store_get_object(getThis() TSRMLS_CC)
================================================
FILE: 11.md
================================================
# 类与对像3(object handlers)
1,创建一个扩展
./ext_skel --extname=objects3
2,object handlers定义
typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type, const struct _zend_literal *key TSRMLS_DC);
typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type TSRMLS_DC);
typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value, const struct _zend_literal *key TSRMLS_DC);
typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC);
typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, int type, const struct _zend_literal *key TSRMLS_DC);
typedef void (*zend_object_set_t)(zval **object, zval *value TSRMLS_DC);
typedef zval* (*zend_object_get_t)(zval *object TSRMLS_DC);
typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists, const struct _zend_literal *key TSRMLS_DC);
typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty TSRMLS_DC);
typedef void (*zend_object_unset_property_t)(zval *object, zval *member, const struct _zend_literal *key TSRMLS_DC);
typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_DC);
typedef HashTable *(*zend_object_get_properties_t)(zval *object TSRMLS_DC);
typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp TSRMLS_DC);
typedef int (*zend_object_call_method_t)(const char *method, INTERNAL_FUNCTION_PARAMETERS);
typedef union _zend_function *(*zend_object_get_method_t)(zval **object_ptr, char *method, int method_len, const struct _zend_literal *key TSRMLS_DC);
typedef union _zend_function *(*zend_object_get_constructor_t)(zval *object TSRMLS_DC);
typedef void (*zend_object_add_ref_t)(zval *object TSRMLS_DC);
typedef void (*zend_object_del_ref_t)(zval *object TSRMLS_DC);
typedef void (*zend_object_delete_obj_t)(zval *object TSRMLS_DC);
typedef zend_object_value (*zend_object_clone_obj_t)(zval *object TSRMLS_DC);
typedef zend_class_entry *(*zend_object_get_class_entry_t)(const zval *object TSRMLS_DC);
typedef int (*zend_object_get_class_name_t)(const zval *object, const char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC);
typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC);
typedef int (*zend_object_count_elements_t)(zval *object, long *count TSRMLS_DC);
typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC);
typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval ***table, int *n TSRMLS_DC);
#所以后缀带_dimension的都是以$obj[foo]的方式访问对像,其他的是以 $obj->foo访问对像
struct _zend_object_handlers {
/* general object functions */
zend_object_add_ref_t add_ref; #添加引用
zend_object_del_ref_t del_ref; #删除引用
zend_object_clone_obj_t clone_obj; #克隆对像
/* individual object functions */
zend_object_read_property_t read_property; #$obj->foo方式读取属性值
zend_object_write_property_t write_property; #$obj->foo方式写入属性值
zend_object_read_dimension_t read_dimension; #$obj[foo]方式读取属性值
zend_object_write_dimension_t write_dimension; #$obj[foo]方式写入属性值
zend_object_get_property_ptr_ptr_t get_property_ptr_ptr;
zend_object_get_t get;
zend_object_set_t set;
zend_object_has_property_t has_property;
zend_object_unset_property_t unset_property;
zend_object_has_dimension_t has_dimension;
zend_object_unset_dimension_t unset_dimension;
zend_object_get_properties_t get_properties;
zend_object_get_method_t get_method;
zend_object_call_method_t call_method;
zend_object_get_constructor_t get_constructor;
zend_object_get_class_entry_t get_class_entry;
zend_object_get_class_name_t get_class_name;
zend_object_compare_t compare_objects;
zend_object_cast_t cast_object;
zend_object_count_elements_t count_elements;
zend_object_get_debug_info_t get_debug_info;
zend_object_get_closure_t get_closure;
zend_object_get_gc_t get_gc;
};
extern ZEND_API zend_object_handlers std_object_handlers;
3,添加object handlers
1,定义 handlers
static zend_object_handlers hello_handlers;
2,初始化 handlers
memcpy(&hello_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
hello_handlers.clone_obj = hello_clone;
//hello_handlers.get = hello_get;
hello_handlers.count_elements = hello_count_elements;
3,设置 object 的 handlers
hello_object *objval = emalloc(sizeof(hello_object));
memset(objval, 0, sizeof(hello_object));
zend_object_value retval;
zend_object_std_init(&(objval->obj), ce TSRMLS_CC);
retval.handle = zend_objects_store_put(objval ,
NULL,
(zend_objects_free_object_storage_t)hello_dtor,
NULL TSRMLS_CC);
retval.handlers = &hello_handlers;
4,实现handlers
static int hello_count_elements(zval *object, long *count TSRMLS_DC) {
zend_object_handlers *zh = zend_get_std_object_handlers();
php_printf("count: %ld\n", *count);
*count = 5;
return SUCCESS;
}
4,测试php
$obj = new Hello("leon", 32);
echo "obj count:" . count($obj)."\n"; //结果为5
================================================
FILE: 12.md
================================================
# 资源类型
1,创建一个扩展
./ext_skel --extname=resource
2,操作函数
/*resource类型在内核中的定义*/
typedef struct _zend_rsrc_list_entry {
void *ptr;
int type;
int refcount;
} zend_rsrc_list_entry;
/*添加分类
zend_register_list_destructors => 没有类别名, resource(4) of type (Unknown)
zend_register_list_destructors_ex => 有类别名, resource(4) of type (Person)
第一个回调函数会在脚本中的相应类型的资源变量被释放掉的时候触发,比如作用域结束了,或者被unset()掉了
第二个回调函数则是用在一个类似于长链接类型的资源上的,也就是这个资源创建后会一直存在于内存中,而不会在request结束后被释放掉。它将会在Web服务器进程终止时调用,相当于在MSHUTDOWN阶段被内核调用
*/
ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number);
ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, const char *type_name, int module_number);
/*注册resource
resource最终是保存在&EG(regular_list)这个系统HashTable中
*/
#define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type) zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type TSRMLS_CC);
ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type TSRMLS_DC)
{
int rsrc_id;
rsrc_id = zend_list_insert(rsrc_pointer, rsrc_type TSRMLS_CC);
if (rsrc_result) {
rsrc_result->value.lval = rsrc_id;
rsrc_result->type = IS_RESOURCE;
}
return rsrc_id;
}
ZEND_API int zend_list_insert(void *ptr, int type TSRMLS_DC)
{
int index;
zend_rsrc_list_entry le;
le.ptr=ptr;
le.type=type;
le.refcount=1;
index = zend_hash_next_free_element(&EG(regular_list));
zend_hash_index_update(&EG(regular_list), index, (void *) &le, sizeof(zend_rsrc_list_entry), NULL);
return index;
}
/*获取resource*/
#define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)
rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type);
ZEND_VERIFY_RESOURCE(rsrc);
/*校验resource*/
#define ZEND_VERIFY_RESOURCE(rsrc) \
if (!rsrc) { \
RETURN_FALSE; \
}
3,代码说明
#define PERSON_RESOURCE_TYPE "Person" //resource类型名称
static int person_len; //resource id
typedef struct _person { //resource 结构
char *name;
int name_len;
int age;
}person;
/*添加resource分类*/
PHP_MINIT_FUNCTION(resource){
person_len = zend_register_list_destructors_ex(person_dtor, NULL, PERSON_RESOURCE_TYPE, module_number);
//person_len = zend_register_list_destructors(person_dtor, NULL, module_number);
return SUCCESS;
}
/*释放resource资源,在脚本结束后执行*/
static void person_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
person *p = (person *)rsrc->ptr;
php_printf("person refcount %d\n", rsrc->refcount);
if (p->name) {
efree(p->name);
}
efree(p);
}
/*实例化并注册resource*/
ZEND_BEGIN_ARG_INFO(person_create_arginfo, 0)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, age)
ZEND_END_ARG_INFO()
static PHP_FUNCTION(person_create) {
char *name;
int name_len;
long age;
person *new_person;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &name, &name_len, &age) == FAILURE) {
return;
}
new_person = emalloc(sizeof(person));
new_person->name = estrndup(name, name_len);
new_person->name_len = name_len;
new_person->age = age;
ZEND_REGISTER_RESOURCE(return_value, new_person, person_len);
}
/*获取resource*/
ZEND_BEGIN_ARG_INFO(person_get_name_arginfo, 0)
ZEND_ARG_INFO(0, person)
ZEND_END_ARG_INFO()
static PHP_FUNCTION(person_get_name) {
zval *zperson;
person *p;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zperson) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(p, person*, &zperson, -1, PERSON_RESOURCE_TYPE, person_len);
RETURN_STRING(p->name, 1);
}
================================================
FILE: 13.md
================================================
# 包装第三方库
1,创建一个扩展
./ext_skel --extname=libs
2,配置(config.m4)
SEARCH_PATH="/usr/local /usr" #lib搜索的目录
SEARCH_FOR="/include/curl/curl.h" #lib头文件的路径
if test -r $PHP_LIBS/$SEARCH_FOR; then
LIBS_DIR=$PHP_LIBS
else # search default path list
AC_MSG_CHECKING([for libs files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
LIBS_DIR=$i #搜索到的lib的路径
AC_MSG_RESULT(found in $i)
fi
done
fi
/*验证lib是否存在*/
if test -z "$LIBS_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the libs distribution])
fi
/*编译的时候添加lib的include目录, -I/usr/include*/
PHP_ADD_INCLUDE($LIBS_DIR/include)
LIBNAME=curl #lib名称
LIBSYMBOL=curl_version #lib的一个函数,用来PHP_CHECK_LIBRARY验证lib
/*验证lib*/
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
[
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBS_DIR/$PHP_LIBDIR, LIBS_SHARED_LIBADD) #编译的时候链接lib, -llibcurl
AC_DEFINE(HAVE_LIBSLIB,1,[ ])
],[
AC_MSG_ERROR([wrong libs lib version or lib not found])
],[
-L$LIBS_DIR/$PHP_LIBDIR -lm
])
PHP_SUBST(LIBS_SHARED_LIBADD)
================================================
FILE: 14.md
================================================
# output操作
1,创建一个新的扩展
./ext_skel --extname=output1
2,修改config.m4,去掉没用的注释语句
cd output1
vi config.m4
3,编写代码
vi output1.c
#修改confirm_output_compiled
PHP_FUNCTION(confirm_output_compiled)
{
char *arg = NULL;
int arg_len, len;
char *strg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
return;
}
FILE *fp = NULL;
long fsize;
char *buffer;
size_t result;
fp = fopen(arg, "r");
if (fp == NULL) {
RETURN_FALSE;
}
fseek(fp, 0, SEEK_END);
fsize = ftell(fp);
rewind(fp);
buffer = (char *)malloc(sizeof(char) * fsize);
result = fread(buffer, 1, fsize, fp);
fclose(fp);
//输出Content-type
char *content_type = "'Content-type: image/jpeg";
sapi_header_line ctr = {0};
ctr.line = content_type;
ctr.line_len = strlen(content_type);
ctr.response_code = 200;
sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
//输出图像
php_output_write(buffer, result TSRMLS_CC);
php_output_end_all(TSRMLS_C);
free(buffer);
RETURN_TRUE;
}
4,结构
//1, 输出header操作
// SAPI.h
typedef struct {
char *line; //输出的内容,记得需要自已释放内存
uint line_len; //输出内容的长度
long response_code; //状态码
} sapi_header_line;
typedef enum { /* Parameter: */
SAPI_HEADER_REPLACE, /* sapi_header_line* */
SAPI_HEADER_ADD, /* sapi_header_line* */
SAPI_HEADER_DELETE, /* sapi_header_line* */
SAPI_HEADER_DELETE_ALL, /* void */
SAPI_HEADER_SET_STATUS /* int */
} sapi_header_op_enum;
#调用sapi_header_op输出内容
char *content_type = "'Content-type: image/jpeg";
sapi_header_line ctr = {0};
ctr.line = content_type;
ctr.line_len = strlen(content_type);
ctr.response_code = 200;
sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
//2, 输出内容操作
//main/php_output.h
ZEND_BEGIN_MODULE_GLOBALS(output)
int flags;
zend_stack handlers;
php_output_handler *active;
php_output_handler *running;
const char *output_start_filename;
int output_start_lineno;
ZEND_END_MODULE_GLOBALS(output)
#define PHP_OUTPUT_IMPLICITFLUSH 0x01
#define PHP_OUTPUT_DISABLED 0x02 //当flags=PHP_OUTPUT_DISABLED时,则会禁止输出
#define PHP_OUTPUT_WRITTEN 0x04
#define PHP_OUTPUT_SENT 0x08
#define PHP_OUTPUT_ACTIVE 0x10
#define PHP_OUTPUT_LOCKED 0x20
#define PHP_OUTPUT_ACTIVATED 0x100000
//当flags=PHP_OUTPUT_ACTIVATED,会调用sapi_module.ub_write输出, 每个SAPI都有自已的实现, cli中是调用sapi_cli_single_write()
php_output_write(); //输出,有buffer, 调用php_output_op()
php_output_write_unbuffered();//输出,没有buffer,调用PHP_OUTPUT_ACTIVATED,会调用sapi_module.ub_write
php_output_set_status(); //用于SAPI设置output.flags ,
php_output_get_status(); //获取output.flags的值
php_output_op();//
5,宏
#define PHPWRITE(str, str_len) php_output_write((str), (str_len) TSRMLS_CC)
#define PHPWRITE_H(str, str_len) php_output_write_unbuffered((str), (str_len) TSRMLS_CC)
#define PUTC(c) (php_output_write(&(c), 1 TSRMLS_CC), (c))
#define PUTC_H(c) (php_output_write_unbuffered(&(c), 1 TSRMLS_CC), (c))
#define PUTS(str) do { \
const char *__str = (str); \
php_output_write(__str, strlen(__str) TSRMLS_CC); \
} while (0)
#define PUTS_H(str) do { \
const char *__str = (str); \
php_output_write_unbuffered(__str, strlen(__str) TSRMLS_CC); \
} while (0)
================================================
FILE: README.md
================================================
# PHP扩展开发笔记
#### 目录
[1,创建一个新的扩展](./01.md)
[2,参数传递](./02.md)
[3,返回值](./03.md)
[4,INI参数设置](./04.md)
[5,数组](./05.md)
[6,Global变量](./06.md)
[7,常量](./07.md)
[8,调用php函数](./08.md)
[9,类与对象1](./09.md)
[10,类与对象2(自定义object存储)](./10.md)
[11,类与对象3(object handlers)](./11.md)
[12,资源](./12.md)
[13,包装第三方库](./13.md)
[14,output操作](./14.md)
#### 附录
[1,gdb调试PHP扩展函数](./001.md)
[2,常用全局宏](./002.md)
[3,zval](./003.md)
[4,ZendMM](./004.md)
##### 参考
[https://github.com/sgolemon/phptek2013](https://github.com/sgolemon/phptek2013)
[http://www.walu.cc/phpbook/](http://www.walu.cc/phpbook/)
[https://wikitech.wikimedia.org/wiki/GDB_with_PHP](https://wikitech.wikimedia.org/wiki/GDB_with_PHP)
================================================
FILE: codes/array/.deps
================================================
================================================
FILE: codes/array/.libs/array.lai
================================================
# array.la - a libtool library file
# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='array.so'
# Names of this library.
library_names='array.so array.so array.so'
# The name of the static archive.
old_library=''
# Libraries that this one depends upon.
dependency_libs=''
# Version information for array.
current=0
age=0
revision=0
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=yes
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/Users/kentchen/GitHub/php/php-5.5.20/ext/array/modules'
================================================
FILE: codes/array/.libs/array.so.dSYM/Contents/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.array.so</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
================================================
FILE: codes/array/.svnignore
================================================
.deps
*.lo
*.la
================================================
FILE: codes/array/CREDITS
================================================
array
================================================
FILE: codes/array/EXPERIMENTAL
================================================
================================================
FILE: codes/array/Makefile
================================================
srcdir = /Users/kentchen/GitHub/php/php-5.5.20/ext/array
builddir = /Users/kentchen/GitHub/php/php-5.5.20/ext/array
top_srcdir = /Users/kentchen/GitHub/php/php-5.5.20/ext/array
top_builddir = /Users/kentchen/GitHub/php/php-5.5.20/ext/array
EGREP = /usr/bin/grep -E
SED = /usr/bin/sed
CONFIGURE_COMMAND = './configure' '--with-php-config=php-config'
CONFIGURE_OPTIONS = '--with-php-config=php-config'
SHLIB_SUFFIX_NAME = dylib
SHLIB_DL_SUFFIX_NAME = so
ZEND_EXT_TYPE = zend_extension
RE2C = exit 0;
AWK = awk
shared_objects_array = array.lo
PHP_PECL_EXTENSION = array
PHP_MODULES = $(phplibdir)/array.la
PHP_ZEND_EX =
all_targets = $(PHP_MODULES) $(PHP_ZEND_EX)
install_targets = install-modules install-headers
prefix = /usr/local/Cellar/php55/5.5.21
exec_prefix = $(prefix)
libdir = ${exec_prefix}/lib
prefix = /usr/local/Cellar/php55/5.5.21
phplibdir = /Users/kentchen/GitHub/php/php-5.5.20/ext/array/modules
phpincludedir = /usr/local/Cellar/php55/5.5.21/include/php
CC = cc
CFLAGS = -g -O2
CFLAGS_CLEAN = $(CFLAGS)
CPP = cc -E
CPPFLAGS = -DHAVE_CONFIG_H
CXX =
CXXFLAGS =
CXXFLAGS_CLEAN = $(CXXFLAGS)
EXTENSION_DIR = /usr/local/Cellar/php55/5.5.21/lib/php/extensions/no-debug-non-zts-20121212
PHP_EXECUTABLE = /usr/local/Cellar/php55/5.5.21/bin/php
EXTRA_LDFLAGS =
EXTRA_LIBS =
INCLUDES = -I/usr/local/Cellar/php55/5.5.21/include/php -I/usr/local/Cellar/php55/5.5.21/include/php/main -I/usr/local/Cellar/php55/5.5.21/include/php/TSRM -I/usr/local/Cellar/php55/5.5.21/include/php/Zend -I/usr/local/Cellar/php55/5.5.21/include/php/ext -I/usr/local/Cellar/php55/5.5.21/include/php/ext/date/lib
LFLAGS =
LDFLAGS =
SHARED_LIBTOOL =
LIBTOOL = $(SHELL) $(top_builddir)/libtool
SHELL = /bin/sh
INSTALL_HEADERS =
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
all: $(all_targets)
@echo
@echo "Build complete."
@echo "Don't forget to run 'make test'."
@echo
build-modules: $(PHP_MODULES) $(PHP_ZEND_EX)
build-binaries: $(PHP_BINARIES)
libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
-@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so
install: $(all_targets) $(install_targets)
install-sapi: $(OVERALL_TARGET)
@echo "Installing PHP SAPI module: $(PHP_SAPI)"
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
-@if test ! -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
if test -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); \
break; \
fi; \
done; \
fi
@$(INSTALL_IT)
install-binaries: build-binaries $(install_binary_targets)
install-modules: build-modules
@test -d modules && \
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
@echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/"
@rm -f modules/*.la >/dev/null 2>&1
@$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR)
install-headers:
-@if test "$(INSTALL_HEADERS)"; then \
for i in `echo $(INSTALL_HEADERS)`; do \
i=`$(top_srcdir)/build/shtool path -d $$i`; \
paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
done; \
$(mkinstalldirs) $$paths && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
for i in `echo $(INSTALL_HEADERS)`; do \
if test "$(PHP_PECL_EXTENSION)"; then \
src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
else \
src=$$i; \
fi; \
if test -f "$(top_srcdir)/$$src"; then \
$(INSTALL_DATA) $(top_srcdir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
elif test -f "$(top_builddir)/$$src"; then \
$(INSTALL_DATA) $(top_builddir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
else \
(cd $(top_srcdir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \
cd $(top_builddir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \
fi \
done; \
fi
PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
PHP_TEST_SHARED_EXTENSIONS = ` \
if test "x$(PHP_MODULES)" != "x"; then \
for i in $(PHP_MODULES)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
done; \
fi; \
if test "x$(PHP_ZEND_EX)" != "x"; then \
for i in $(PHP_ZEND_EX)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d $(ZEND_EXT_TYPE)=$(top_builddir)/modules/$$dlname"; \
done; \
fi`
PHP_DEPRECATED_DIRECTIVES_REGEX = '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
test: all
@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
if test "$$INI_SCANNED_PATH"; then \
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
TEST_RESULT_EXIT_CODE=$$?; \
rm $(top_builddir)/tmp-php.ini; \
exit $$TEST_RESULT_EXIT_CODE; \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
clean:
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp$(PHP_MAJOR_VERSION).la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_MILTER_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
distclean: clean
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c stamp-h sapi/apache/libphp$(PHP_MAJOR_VERSION).module sapi/apache_hooks/libphp$(PHP_MAJOR_VERSION).module buildmk.stamp Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h TSRM/tsrm_config.h
rm -f php5.spec main/build-defs.h scripts/phpize
rm -f ext/date/lib/timelib_config.h ext/mbstring/oniguruma/config.h ext/mbstring/libmbfl/config.h ext/mysqlnd/php_mysqlnd_config.h
rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 ext/phar/phar.1 ext/phar/phar.phar.1
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
rm -f ext/iconv/php_have_bsd_iconv.h ext/iconv/php_have_glibc_iconv.h ext/iconv/php_have_ibm_iconv.h ext/iconv/php_have_iconv.h ext/iconv/php_have_libiconv.h ext/iconv/php_iconv_aliased_libiconv.h ext/iconv/php_iconv_supports_errno.h ext/iconv/php_php_iconv_h_path.h ext/iconv/php_php_iconv_impl.h
rm -f ext/phar/phar.phar ext/phar/phar.php
if test "$(srcdir)" != "$(builddir)"; then \
rm -f ext/phar/phar/phar.inc; \
fi
$(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f
.PHONY: all clean install distclean test
.NOEXPORT:
array.lo: /Users/kentchen/GitHub/php/php-5.5.20/ext/array/array.c
$(LIBTOOL) --mode=compile $(CC) -I. -I/Users/kentchen/GitHub/php/php-5.5.20/ext/array $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /Users/kentchen/GitHub/php/php-5.5.20/ext/array/array.c -o array.lo
$(phplibdir)/array.la: ./array.la
$(LIBTOOL) --mode=install cp ./array.la $(phplibdir)
./array.la: $(shared_objects_array) $(ARRAY_SHARED_DEPENDENCIES)
$(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_array) $(ARRAY_SHARED_LIBADD)
================================================
FILE: codes/array/Makefile.fragments
================================================
================================================
FILE: codes/array/Makefile.global
================================================
mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p
INSTALL = $(top_srcdir)/build/shtool install -c
INSTALL_DATA = $(INSTALL) -m 644
DEFS = -DPHP_ATOM_INC -I$(top_builddir)/include -I$(top_builddir)/main -I$(top_srcdir)
COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(PHP_FRAMEWORKPATH)
all: $(all_targets)
@echo
@echo "Build complete."
@echo "Don't forget to run 'make test'."
@echo
build-modules: $(PHP_MODULES) $(PHP_ZEND_EX)
build-binaries: $(PHP_BINARIES)
libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
-@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so
install: $(all_targets) $(install_targets)
install-sapi: $(OVERALL_TARGET)
@echo "Installing PHP SAPI module: $(PHP_SAPI)"
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
-@if test ! -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); then \
for i in 0.0.0 0.0 0; do \
if test -r $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i; then \
$(LN_S) $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp$(PHP_MAJOR_VERSION).$(SHLIB_DL_SUFFIX_NAME); \
break; \
fi; \
done; \
fi
@$(INSTALL_IT)
install-binaries: build-binaries $(install_binary_targets)
install-modules: build-modules
@test -d modules && \
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
@echo "Installing shared extensions: $(INSTALL_ROOT)$(EXTENSION_DIR)/"
@rm -f modules/*.la >/dev/null 2>&1
@$(INSTALL) modules/* $(INSTALL_ROOT)$(EXTENSION_DIR)
install-headers:
-@if test "$(INSTALL_HEADERS)"; then \
for i in `echo $(INSTALL_HEADERS)`; do \
i=`$(top_srcdir)/build/shtool path -d $$i`; \
paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
done; \
$(mkinstalldirs) $$paths && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
for i in `echo $(INSTALL_HEADERS)`; do \
if test "$(PHP_PECL_EXTENSION)"; then \
src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
else \
src=$$i; \
fi; \
if test -f "$(top_srcdir)/$$src"; then \
$(INSTALL_DATA) $(top_srcdir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
elif test -f "$(top_builddir)/$$src"; then \
$(INSTALL_DATA) $(top_builddir)/$$src $(INSTALL_ROOT)$(phpincludedir)/$$i; \
else \
(cd $(top_srcdir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \
cd $(top_builddir)/$$src && $(INSTALL_DATA) *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \
fi \
done; \
fi
PHP_TEST_SETTINGS = -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1'
PHP_TEST_SHARED_EXTENSIONS = ` \
if test "x$(PHP_MODULES)" != "x"; then \
for i in $(PHP_MODULES)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d extension=$$dlname"; \
done; \
fi; \
if test "x$(PHP_ZEND_EX)" != "x"; then \
for i in $(PHP_ZEND_EX)""; do \
. $$i; $(top_srcdir)/build/shtool echo -n -- " -d $(ZEND_EXT_TYPE)=$(top_builddir)/modules/$$dlname"; \
done; \
fi`
PHP_DEPRECATED_DIRECTIVES_REGEX = '^(magic_quotes_(gpc|runtime|sybase)?|(zend_)?extension(_debug)?(_ts)?)[\t\ ]*='
test: all
@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
if test "$$INI_SCANNED_PATH"; then \
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
TEST_RESULT_EXIT_CODE=$$?; \
rm $(top_builddir)/tmp-php.ini; \
exit $$TEST_RESULT_EXIT_CODE; \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
clean:
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp$(PHP_MAJOR_VERSION).la $(SAPI_CLI_PATH) $(SAPI_CGI_PATH) $(SAPI_MILTER_PATH) $(SAPI_LITESPEED_PATH) $(SAPI_FPM_PATH) $(OVERALL_TARGET) modules/* libs/*
distclean: clean
rm -f Makefile config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h main/internal_functions_cli.c main/internal_functions.c stamp-h sapi/apache/libphp$(PHP_MAJOR_VERSION).module sapi/apache_hooks/libphp$(PHP_MAJOR_VERSION).module buildmk.stamp Zend/zend_dtrace_gen.h Zend/zend_dtrace_gen.h.bak Zend/zend_config.h TSRM/tsrm_config.h
rm -f php5.spec main/build-defs.h scripts/phpize
rm -f ext/date/lib/timelib_config.h ext/mbstring/oniguruma/config.h ext/mbstring/libmbfl/config.h ext/mysqlnd/php_mysqlnd_config.h
rm -f scripts/man1/phpize.1 scripts/php-config scripts/man1/php-config.1 sapi/cli/php.1 sapi/cgi/php-cgi.1 ext/phar/phar.1 ext/phar/phar.phar.1
rm -f sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html
rm -f ext/iconv/php_have_bsd_iconv.h ext/iconv/php_have_glibc_iconv.h ext/iconv/php_have_ibm_iconv.h ext/iconv/php_have_iconv.h ext/iconv/php_have_libiconv.h ext/iconv/php_iconv_aliased_libiconv.h ext/iconv/php_iconv_supports_errno.h ext/iconv/php_php_iconv_h_path.h ext/iconv/php_php_iconv_impl.h
rm -f ext/phar/phar.phar ext/phar/phar.php
if test "$(srcdir)" != "$(builddir)"; then \
rm -f ext/phar/phar/phar.inc; \
fi
$(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f
.PHONY: all clean install distclean test
.NOEXPORT:
================================================
FILE: codes/array/Makefile.objects
================================================
array.lo: /Users/kentchen/GitHub/php/php-5.5.20/ext/array/array.c
$(LIBTOOL) --mode=compile $(CC) -I. -I/Users/kentchen/GitHub/php/php-5.5.20/ext/array $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -c /Users/kentchen/GitHub/php/php-5.5.20/ext/array/array.c -o array.lo
$(phplibdir)/array.la: ./array.la
$(LIBTOOL) --mode=install cp ./array.la $(phplibdir)
./array.la: $(shared_objects_array) $(ARRAY_SHARED_DEPENDENCIES)
$(LIBTOOL) --mode=link $(CC) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $(shared_objects_array) $(ARRAY_SHARED_LIBADD)
================================================
FILE: codes/array/acinclude.m4
================================================
dnl
dnl $Id$
dnl
dnl This file contains local autoconf functions.
dnl
dnl -------------------------------------------------------------------------
dnl Output stylize macros for configure (help/runtime)
dnl -------------------------------------------------------------------------
dnl
dnl PHP_HELP_SEPARATOR(title)
dnl
dnl Adds separator title into the configure --help display.
dnl
AC_DEFUN([PHP_HELP_SEPARATOR],[
AC_ARG_ENABLE([],[
$1
],[])
])
dnl
dnl PHP_CONFIGURE_PART(title)
dnl
dnl Adds separator title configure output (idea borrowed from mm)
dnl
AC_DEFUN([PHP_CONFIGURE_PART],[
AC_MSG_RESULT()
AC_MSG_RESULT([${T_MD}$1${T_ME}])
])
dnl -------------------------------------------------------------------------
dnl Build system helper macros
dnl -------------------------------------------------------------------------
dnl
dnl PHP_DEF_HAVE(what)
dnl
dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'
dnl
AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
dnl
dnl PHP_RUN_ONCE(namespace, variable, code)
dnl
dnl execute code, if variable is not set in namespace
dnl
AC_DEFUN([PHP_RUN_ONCE],[
changequote({,})
unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
changequote([,])
cmd="echo $ac_n \"\$$1$unique$ac_c\""
if test -n "$unique" && test "`eval $cmd`" = "" ; then
eval "$1$unique=set"
$3
fi
])
dnl
dnl PHP_EXPAND_PATH(path, variable)
dnl
dnl expands path to an absolute path and assigns it to variable
dnl
AC_DEFUN([PHP_EXPAND_PATH],[
if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
$2=$1
else
changequote({,})
ep_dir=`echo $1|$SED 's%/*[^/][^/]*/*$%%'`
changequote([,])
ep_realdir=`(cd "$ep_dir" && pwd)`
$2="$ep_realdir"/`basename "$1"`
fi
])
dnl
dnl PHP_DEFINE(WHAT [, value[, directory]])
dnl
dnl Creates builddir/include/what.h and in there #define WHAT value
dnl
AC_DEFUN([PHP_DEFINE],[
[echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h]
])
dnl
dnl PHP_SUBST(varname)
dnl
dnl Adds variable with it's value into Makefile, e.g.:
dnl CC = gcc
dnl
AC_DEFUN([PHP_SUBST],[
PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
])
dnl
dnl PHP_SUBST_OLD(varname)
dnl
dnl Same as PHP_SUBST() but also substitutes all @VARNAME@
dnl instances in every file passed to AC_OUTPUT()
dnl
AC_DEFUN([PHP_SUBST_OLD],[
PHP_SUBST($1)
AC_SUBST($1)
])
dnl
dnl PHP_OUTPUT(file)
dnl
dnl Adds "file" to the list of files generated by AC_OUTPUT
dnl This macro can be used several times.
dnl
AC_DEFUN([PHP_OUTPUT],[
PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
])
dnl -------------------------------------------------------------------------
dnl Build system base macros
dnl -------------------------------------------------------------------------
dnl
dnl PHP_CANONICAL_HOST_TARGET
dnl
AC_DEFUN([PHP_CANONICAL_HOST_TARGET],[
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_TARGET])dnl
dnl Make sure we do not continue if host_alias is empty.
if test -z "$host_alias" && test -n "$host"; then
host_alias=$host
fi
if test -z "$host_alias"; then
AC_MSG_ERROR([host_alias is not set!])
fi
])
dnl
dnl PHP_INIT_BUILD_SYSTEM
dnl
AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[
AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
test -d include || $php_shtool mkdir include
> Makefile.objects
> Makefile.fragments
dnl We need to play tricks here to avoid matching the grep line itself
pattern=define
$EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/dev/null
])
dnl
dnl PHP_GEN_GLOBAL_MAKEFILE
dnl
dnl Generates the global makefile.
dnl
AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[
cat >Makefile <<EOF
srcdir = $abs_srcdir
builddir = $abs_builddir
top_srcdir = $abs_srcdir
top_builddir = $abs_builddir
EOF
for i in $PHP_VAR_SUBST; do
eval echo "$i = \$$i" >> Makefile
done
cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile
])
dnl
dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]])
dnl
dnl Processes a file called Makefile.frag in the source directory
dnl of the most recently added extension. $(srcdir) and $(builddir)
dnl are substituted with the proper paths. Can be used to supply
dnl custom rules and/or additional targets.
dnl
AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
])
dnl
dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
dnl
dnl Adds sources which are located relative to source-path to the
dnl array of type type. Sources are processed with optional
dnl special-flags which are passed to the compiler. Sources
dnl can be either written in C or C++ (filenames shall end in .c
dnl or .cpp, respectively).
dnl
dnl Note: If source-path begins with a "/", the "/" is removed and
dnl the path is interpreted relative to the top build-directory.
dnl
dnl which array to append to?
AC_DEFUN([PHP_ADD_SOURCES],[
PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))
])
dnl
dnl _PHP_ASSIGN_BUILD_VARS(type)
dnl internal, don't use
AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[
ifelse($1,shared,[
b_c_pre=$shared_c_pre
b_cxx_pre=$shared_cxx_pre
b_c_meta=$shared_c_meta
b_cxx_meta=$shared_cxx_meta
b_c_post=$shared_c_post
b_cxx_post=$shared_cxx_post
],[
b_c_pre=$php_c_pre
b_cxx_pre=$php_cxx_pre
b_c_meta=$php_c_meta
b_cxx_meta=$php_cxx_meta
b_c_post=$php_c_post
b_cxx_post=$php_cxx_post
])dnl
b_lo=[$]$1_lo
])
dnl
dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
dnl
dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the
dnl name of the array target-var directly, as well as whether
dnl shared objects will be built from the sources.
dnl
dnl Should not be used directly.
dnl
AC_DEFUN([PHP_ADD_SOURCES_X],[
dnl relative to source- or build-directory?
dnl ac_srcdir/ac_bdir include trailing slash
case $1 in
""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
/*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
*[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
esac
dnl how to build .. shared or static?
ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
dnl iterate over the sources
old_IFS=[$]IFS
for ac_src in $2; do
dnl remove the suffix
IFS=.
set $ac_src
ac_obj=[$]1
IFS=$old_IFS
dnl append to the array which has been dynamically chosen at m4 time
$4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
dnl choose the right compiler/flags/etc. for the source-file
case $ac_src in
*.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
*.s[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
*.S[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
*.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;;
esac
dnl create a rule for the object/source combo
cat >>Makefile.objects<<EOF
$ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
$ac_comp
EOF
done
])
dnl -------------------------------------------------------------------------
dnl Compiler characteristics checks
dnl -------------------------------------------------------------------------
dnl
dnl PHP_TARGET_RDYNAMIC
dnl
dnl Checks whether -rdynamic is supported by the compiler. This
dnl is necessary for some targets to populate the global symbol
dnl table. Otherwise, dynamic modules would not be able to resolve
dnl PHP-related symbols.
dnl
dnl If successful, adds -rdynamic to PHP_LDFLAGS.
dnl
AC_DEFUN([PHP_TARGET_RDYNAMIC],[
if test -n "$GCC"; then
dnl we should use a PHP-specific macro here
PHP_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes)
if test "$gcc_rdynamic" = "yes"; then
PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic"
fi
fi
])
dnl
dnl PHP_RUNPATH_SWITCH
dnl
dnl Checks for -R, etc. switch
dnl
AC_DEFUN([PHP_RUNPATH_SWITCH],[
AC_MSG_CHECKING([if compiler supports -R])
AC_CACHE_VAL(php_cv_cc_dashr,[
SAVE_LIBS=$LIBS
LIBS="-R /usr/$PHP_LIBDIR $LIBS"
AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
LIBS=$SAVE_LIBS])
AC_MSG_RESULT([$php_cv_cc_dashr])
if test $php_cv_cc_dashr = "yes"; then
ld_runpath_switch=-R
else
AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
AC_CACHE_VAL(php_cv_cc_rpath,[
SAVE_LIBS=$LIBS
LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
LIBS=$SAVE_LIBS])
AC_MSG_RESULT([$php_cv_cc_rpath])
if test $php_cv_cc_rpath = "yes"; then
ld_runpath_switch=-Wl,-rpath,
else
dnl something innocuous
ld_runpath_switch=-L
fi
fi
if test "$PHP_RPATH" = "no"; then
ld_runpath_switch=
fi
])
dnl
dnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
dnl
AC_DEFUN([PHP_CHECK_GCC_ARG],[
gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z-,a-z_)
AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z-,a-z_), [
echo 'void somefunc() { };' > conftest.c
cmd='$CC $1 -c conftest.c'
if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then
ac_result=no
else
ac_result=yes
fi
eval $gcc_arg_name=$ac_result
rm -f conftest.*
])
if eval test "\$$gcc_arg_name" = "yes"; then
$2
else
:
$3
fi
])
dnl
dnl PHP_LIBGCC_LIBPATH(gcc)
dnl
dnl Stores the location of libgcc in libgcc_libpath
dnl
AC_DEFUN([PHP_LIBGCC_LIBPATH],[
changequote({,})
libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'`
changequote([,])
])
dnl -------------------------------------------------------------------------
dnl Macros to modify LIBS, INCLUDES, etc. variables
dnl -------------------------------------------------------------------------
dnl
dnl PHP_REMOVE_USR_LIB(NAME)
dnl
dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME
dnl
AC_DEFUN([PHP_REMOVE_USR_LIB],[
unset ac_new_flags
for i in [$]$1; do
case [$]i in
-L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;;
*[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
esac
done
$1=[$]ac_new_flags
])
dnl
dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD)
dnl
dnl Use this macro, if you need to add libraries and or library search
dnl paths to the PHP build system which are only given in compiler
dnl notation.
dnl
AC_DEFUN([PHP_EVAL_LIBLINE],[
for ac_i in $1; do
case $ac_i in
-pthread[)]
if test "$ext_shared" = "yes"; then
$2="[$]$2 -pthread"
else
PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"])
fi
;;
-l*[)]
ac_ii=`echo $ac_i|cut -c 3-`
PHP_ADD_LIBRARY($ac_ii,1,$2)
;;
-L*[)]
ac_ii=`echo $ac_i|cut -c 3-`
PHP_ADD_LIBPATH($ac_ii,$2)
;;
esac
done
])
dnl
dnl PHP_EVAL_INCLINE(headerline)
dnl
dnl Use this macro, if you need to add header search paths to the PHP
dnl build system which are only given in compiler notation.
dnl
AC_DEFUN([PHP_EVAL_INCLINE],[
for ac_i in $1; do
case $ac_i in
-I*[)]
ac_ii=`echo $ac_i|cut -c 3-`
PHP_ADD_INCLUDE($ac_ii)
;;
esac
done
])
dnl internal, don't use
AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[
PHP_RUN_ONCE(LIBPATH, $1, [
test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
LDFLAGS="$LDFLAGS -L$1"
PHP_RPATHS="$PHP_RPATHS $1"
])
])dnl
dnl
dnl
dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD])
dnl
dnl Adds a path to linkpath/runpath (LDFLAGS)
dnl
AC_DEFUN([PHP_ADD_LIBPATH],[
if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
PHP_EXPAND_PATH($1, ai_p)
ifelse([$2],,[
_PHP_ADD_LIBPATH_GLOBAL([$ai_p])
],[
if test "$ext_shared" = "yes"; then
$2="-L$ai_p [$]$2"
test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
else
_PHP_ADD_LIBPATH_GLOBAL([$ai_p])
fi
])
fi
])
dnl
dnl PHP_UTILIZE_RPATHS()
dnl
dnl builds RPATHS/LDFLAGS from PHP_RPATHS
dnl
AC_DEFUN([PHP_UTILIZE_RPATHS],[
OLD_RPATHS=$PHP_RPATHS
unset PHP_RPATHS
for i in $OLD_RPATHS; do
dnl Can be passed to native cc/libtool
PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
dnl Libtool-specific
PHP_RPATHS="$PHP_RPATHS -R $i"
dnl cc-specific
NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
done
if test "$PHP_RPATH" = "no"; then
unset PHP_RPATHS
unset NATIVE_RPATHS
fi
])
dnl
dnl PHP_ADD_INCLUDE(path [,before])
dnl
dnl add an include path.
dnl if before is 1, add in the beginning of INCLUDES.
dnl
AC_DEFUN([PHP_ADD_INCLUDE],[
if test "$1" != "/usr/include"; then
PHP_EXPAND_PATH($1, ai_p)
PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
if test "$2"; then
INCLUDES="-I$ai_p $INCLUDES"
else
INCLUDES="$INCLUDES -I$ai_p"
fi
])
fi
])
dnl internal, don't use
AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl
ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
])dnl
dnl
dnl internal, don't use
AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[
case $1 in
c|c_r|pthread*[)] ;;
*[)] ifelse($3,,[
_PHP_X_ADD_LIBRARY($1,$2,$5)
],[
if test "$ext_shared" = "yes"; then
_PHP_X_ADD_LIBRARY($1,$2,$3)
else
$4($1,$2)
fi
]) ;;
esac
])dnl
dnl
dnl
dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
dnl
dnl add a library to the link line
dnl
AC_DEFUN([PHP_ADD_LIBRARY],[
_PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
])
dnl
dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
dnl
dnl add a library to the link line (deferred, not used during configure)
dnl
AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[
_PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
])
dnl
dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
dnl
dnl add a library to the link line and path to linkpath/runpath.
dnl if shared-libadd is not empty and $ext_shared is yes,
dnl shared-libadd will be assigned the library information
dnl
AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[
ifelse($3,,[
if test -n "$2"; then
PHP_ADD_LIBPATH($2)
fi
PHP_ADD_LIBRARY($1)
],[
if test "$ext_shared" = "yes"; then
$3="-l$1 [$]$3"
if test -n "$2"; then
PHP_ADD_LIBPATH($2,$3)
fi
else
PHP_ADD_LIBRARY_WITH_PATH($1,$2)
fi
])
])
dnl
dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
dnl
dnl add a library to the link line (deferred)
dnl and path to linkpath/runpath (not deferred)
dnl if shared-libadd is not empty and $ext_shared is yes,
dnl shared-libadd will be assigned the library information
dnl
AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[
ifelse($3,,[
if test -n "$2"; then
PHP_ADD_LIBPATH($2)
fi
PHP_ADD_LIBRARY_DEFER($1)
],[
if test "$ext_shared" = "yes"; then
$3="-l$1 [$]$3"
if test -n "$2"; then
PHP_ADD_LIBPATH($2,$3)
fi
else
PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
fi
])
])
dnl
dnl PHP_ADD_FRAMEWORK(framework [,before])
dnl
dnl add a (Darwin / Mac OS X) framework to the link
dnl line. if before is 1, the framework is added
dnl to the beginning of the line.
dnl
AC_DEFUN([PHP_ADD_FRAMEWORK], [
PHP_RUN_ONCE(FRAMEWORKS, $1, [
if test "$2"; then
PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
else
PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
fi
])
])
dnl
dnl PHP_ADD_FRAMEWORKPATH(path [,before])
dnl
dnl add a (Darwin / Mac OS X) framework path to the link
dnl and include lines. default paths include (but are
dnl not limited to) /Local/Library/Frameworks and
dnl /System/Library/Frameworks, so these don't need
dnl to be specifically added. if before is 1, the
dnl framework path is added to the beginning of the
dnl relevant lines.
dnl
AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [
PHP_EXPAND_PATH($1, ai_p)
PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [
if test "$2"; then
PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
else
PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
fi
])
])
dnl
dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
dnl
dnl Adds a (Darwin / Mac OS X) framework path and the
dnl framework itself to the link and include lines.
dnl
AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [
PHP_ADD_FRAMEWORKPATH($2)
PHP_ADD_FRAMEWORK($1)
])
dnl
dnl PHP_SET_LIBTOOL_VARIABLE(var)
dnl
dnl Set libtool variable
dnl
AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
if test -z "$LIBTOOL"; then
LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
else
LIBTOOL="$LIBTOOL $1"
fi
])
dnl -------------------------------------------------------------------------
dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE
dnl -------------------------------------------------------------------------
dnl PHP_ARG_ANALYZE_EX
dnl internal
AC_DEFUN([PHP_ARG_ANALYZE_EX],[
ext_output="yes, shared"
ext_shared=yes
case [$]$1 in
shared,*[)]
$1=`echo "[$]$1"|$SED 's/^shared,//'`
;;
shared[)]
$1=yes
;;
no[)]
ext_output=no
ext_shared=no
;;
*[)]
ext_output=yes
ext_shared=no
;;
esac
PHP_ALWAYS_SHARED([$1])
])
dnl PHP_ARG_ANALYZE
dnl internal
AC_DEFUN([PHP_ARG_ANALYZE],[
ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])
ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
])
dnl
dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])
dnl Sets PHP_ARG_NAME either to the user value or to the default value.
dnl default-val defaults to no. This will also set the variable ext_shared,
dnl and will overwrite any previous variable of that name.
dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
dnl the PHP_ARG_ANALYZE_EX.
dnl
AC_DEFUN([PHP_ARG_WITH],[
php_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
])
dnl PHP_REAL_ARG_WITH
dnl internal
AC_DEFUN([PHP_REAL_ARG_WITH],[
ifelse([$2],,,[AC_MSG_CHECKING([$2])])
AC_ARG_WITH($1,[$3],$5=[$]withval,
[
$5=ifelse($4,,no,$4)
ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
])
PHP_ARG_ANALYZE($5,[$2],$6)
])
dnl
dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
dnl Sets PHP_ARG_NAME either to the user value or to the default value.
dnl default-val defaults to no. This will also set the variable ext_shared,
dnl and will overwrite any previous variable of that name.
dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
dnl the PHP_ARG_ANALYZE_EX.
dnl
AC_DEFUN([PHP_ARG_ENABLE],[
php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
])
dnl PHP_REAL_ARG_ENABLE
dnl internal
AC_DEFUN([PHP_REAL_ARG_ENABLE],[
ifelse([$2],,,[AC_MSG_CHECKING([$2])])
AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
[
$5=ifelse($4,,no,$4)
ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
])
PHP_ARG_ANALYZE($5,[$2],$6)
])
dnl -------------------------------------------------------------------------
dnl Build macros
dnl -------------------------------------------------------------------------
dnl
dnl PHP_BUILD_THREAD_SAFE
dnl
AC_DEFUN([PHP_BUILD_THREAD_SAFE],[
enable_maintainer_zts=yes
if test "$pthreads_working" != "yes"; then
AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
fi
])
dnl
dnl PHP_REQUIRE_CXX
dnl
AC_DEFUN([PHP_REQUIRE_CXX],[
if test -z "$php_cxx_done"; then
AC_PROG_CXX
AC_PROG_CXXCPP
PHP_ADD_LIBRARY(stdc++)
php_cxx_done=yes
fi
])
dnl
dnl PHP_BUILD_SHARED
dnl
AC_DEFUN([PHP_BUILD_SHARED],[
PHP_BUILD_PROGRAM
OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
php_sapi_module=shared
php_c_pre=$shared_c_pre
php_c_meta=$shared_c_meta
php_c_post=$shared_c_post
php_cxx_pre=$shared_cxx_pre
php_cxx_meta=$shared_cxx_meta
php_cxx_post=$shared_cxx_post
php_lo=$shared_lo
])
dnl
dnl PHP_BUILD_STATIC
dnl
AC_DEFUN([PHP_BUILD_STATIC],[
PHP_BUILD_PROGRAM
OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
php_sapi_module=static
])
dnl
dnl PHP_BUILD_BUNDLE
dnl
AC_DEFUN([PHP_BUILD_BUNDLE],[
PHP_BUILD_PROGRAM
OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
php_sapi_module=static
])
dnl
dnl PHP_BUILD_PROGRAM
dnl
AC_DEFUN([PHP_BUILD_PROGRAM],[
php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
php_c_post=
php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
php_cxx_post=
php_lo=lo
case $with_pic in
yes) pic_setting='-prefer-pic';;
no) pic_setting='-prefer-non-pic';;
esac
shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
shared_c_post=
shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
shared_cxx_post=
shared_lo=lo
])
dnl
dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
dnl
dnl Basically sets up the link-stage for building module-name
dnl from object_var in build-dir.
dnl
AC_DEFUN([PHP_SHARED_MODULE],[
install_modules="install-modules"
case $host_alias in
*aix*[)]
suffix=so
link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -Wl,-G -o '$3'/$1.la -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD) && mv -f '$3'/.libs/$1.so '$3'/$1.so'
;;
*netware*[)]
suffix=nlm
link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ -shared -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) ifelse($1, php5lib, , -L$(top_builddir)/netware -lphp5lib) $(translit(ifelse($1, php5lib, $1, m4_substr($1, 3)),a-z_-,A-Z__)_SHARED_LIBADD)'
;;
*[)]
suffix=la
link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)'
;;
esac
if test "x$5" = "xyes"; then
PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
else
PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
fi
PHP_SUBST($2)
cat >>Makefile.objects<<EOF
\$(phplibdir)/$1.$suffix: $3/$1.$suffix
\$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
$3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
$link_cmd
EOF
])
dnl
dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
dnl
dnl Selects the SAPI name and type (static, shared, bundle, program)
dnl and optionally also the source-files for the SAPI-specific
dnl objects.
dnl
AC_DEFUN([PHP_SELECT_SAPI],[
if test "$2" = "program"; then
PHP_BINARIES="$PHP_BINARIES $1"
elif test "$PHP_SAPI" != "none"; then
AC_MSG_ERROR([
+--------------------------------------------------------------------+
| *** ATTENTION *** |
| |
| You've configured multiple SAPIs to be build. You can build only |
| one SAPI module plus CGI, CLI and FPM binaries at the same time. |
+--------------------------------------------------------------------+
])
else
PHP_SAPI=$1
fi
PHP_ADD_BUILD_DIR([sapi/$1])
PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1"
ifelse($2,program,[
PHP_BUILD_PROGRAM
install_binaries="install-binaries"
install_binary_targets="$install_binary_targets install-$1"
PHP_SUBST(PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)
ifelse($3,,,[PHP_ADD_SOURCES_X([sapi/$1],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)])
],[
case "$2" in
static[)] PHP_BUILD_STATIC;;
shared[)] PHP_BUILD_SHARED;;
bundle[)] PHP_BUILD_BUNDLE;;
esac
install_sapi="install-sapi"
ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
])
])
dnl deprecated
AC_DEFUN([PHP_EXTENSION],[
sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
PHP_NEW_EXTENSION($1, $sources, $2, $3)
if test -r "$ext_srcdir/Makefile.frag"; then
PHP_ADD_MAKEFILE_FRAGMENT
fi
])
AC_DEFUN([PHP_ADD_BUILD_DIR],[
ifelse($2,,[
BUILD_DIR="$BUILD_DIR $1"
], [
$php_shtool mkdir -p $1
])
])
AC_DEFUN([PHP_GEN_BUILD_DIRS],[
$php_shtool mkdir -p $BUILD_DIR
])
dnl
dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]])
dnl
dnl Includes an extension in the build.
dnl
dnl "extname" is the name of the ext/ subdir where the extension resides.
dnl "sources" is a list of files relative to the subdir which are used
dnl to build the extension.
dnl "shared" can be set to "shared" or "yes" to build the extension as
dnl a dynamically loadable library. Optional parameter "sapi_class" can
dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
dnl "extra-cflags" are passed to the compiler, with
dnl @ext_srcdir@ and @ext_builddir@ being substituted.
dnl "cxx" can be used to indicate that a C++ shared module is desired.
dnl "zend_ext" indicates a zend extension.
AC_DEFUN([PHP_NEW_EXTENSION],[
ext_builddir=[]PHP_EXT_BUILDDIR($1)
ext_srcdir=[]PHP_EXT_SRCDIR($1)
ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
dnl ---------------------------------------------- Static module
[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
EXT_STATIC="$EXT_STATIC $1"
if test "$3" != "nocli"; then
EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
fi
else
if test "$3" = "shared" || test "$3" = "yes"; then
dnl ---------------------------------------------- Shared module
[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
case $host_alias in
*netware*[)]
PHP_SHARED_MODULE(php$1,shared_objects_$1, $ext_builddir, $6, $7)
;;
*[)]
PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
;;
esac
AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
fi
fi
if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
dnl ---------------------------------------------- CLI static module
[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
case "$PHP_SAPI" in
cgi|embed[)]
PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
EXT_STATIC="$EXT_STATIC $1"
;;
*[)]
PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
;;
esac
EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
fi
PHP_ADD_BUILD_DIR($ext_builddir)
dnl Set for phpize builds only
dnl ---------------------------
if test "$ext_builddir" = "."; then
PHP_PECL_EXTENSION=$1
PHP_SUBST(PHP_PECL_EXTENSION)
fi
])
dnl
dnl PHP_WITH_SHARED
dnl
dnl Checks whether $withval is "shared" or starts with "shared,XXX"
dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
dnl from $withval.
dnl
AC_DEFUN([PHP_WITH_SHARED],[
PHP_ARG_ANALYZE_EX(withval)
shared=$ext_shared
unset ext_shared ext_output
])
dnl
dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
dnl
dnl This macro is scanned by genif.sh when it builds the internal functions
dnl list, so that modules can be init'd in the correct order
dnl $1 = name of extension, $2 = extension upon which it depends
dnl $3 = optional: if true, it's ok for $2 to have not been configured
dnl default is false and should halt the build.
dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
dnl The extension on which it depends must also have been configured.
dnl See ADD_EXTENSION_DEP in win32 build
dnl
AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
AC_MSG_ERROR([
You've configured extension $1 to build statically, but it
depends on extension $2, which you've configured to build shared.
You either need to build $1 shared or build $2 statically for the
build to be successful.
])
fi
if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then
AC_MSG_ERROR([
You've configured extension $1, which depends on extension $2,
but you've either not enabled $2, or have disabled it.
])
fi
dnl Some systems require that we link $2 to $1 when building
])
dnl -------------------------------------------------------------------------
dnl Checks for structures, typedefs, broken functions, etc.
dnl -------------------------------------------------------------------------
dnl Internal helper macros
dnl
dnl _PHP_DEF_HAVE_FILE(what, filename)
AC_DEFUN([_PHP_DEF_HAVE_FILE], [
php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' `
echo "#define $php_def_have_what 1" >> $2
])
dnl
dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
dnl
AC_DEFUN([_PHP_CHECK_SIZEOF], [
php_cache_value=php_cv_sizeof_[]$1
AC_CACHE_VAL(php_cv_sizeof_[]$1, [
old_LIBS=$LIBS
LIBS=
old_LDFLAGS=$LDFLAGS
LDFLAGS=
AC_TRY_RUN([#include <stdio.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
$3
int main()
{
FILE *fp = fopen("conftestval", "w");
if (!fp) return(1);
fprintf(fp, "%d\n", sizeof($1));
return(0);
}
], [
eval $php_cache_value=`cat conftestval`
], [
eval $php_cache_value=0
], [
ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
])
LDFLAGS=$old_LDFLAGS
LIBS=$old_LIBS
])
if eval test "\$$php_cache_value" != "0"; then
ifelse([$4],[],:,[$4])
ifelse([$5],[],,[else $5])
fi
])
dnl
dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
dnl
AC_DEFUN([PHP_CHECK_SIZEOF], [
AC_MSG_CHECKING([size of $1])
_PHP_CHECK_SIZEOF($1, $2, $3, [
AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
])
AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
])
dnl
dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
dnl
AC_DEFUN([PHP_CHECK_TYPES], [
for php_typename in $1; do
AC_MSG_CHECKING([whether $php_typename exists])
_PHP_CHECK_SIZEOF($php_typename, 0, $3, [
_PHP_DEF_HAVE_FILE($php_typename, $2)
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
done
])
dnl
dnl PHP_CHECK_IN_ADDR_T
dnl
AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
AC_MSG_CHECKING([for in_addr_t])
AC_CACHE_VAL(ac_cv_type_in_addr_t,
[AC_EGREP_CPP(dnl
changequote(<<,>>)dnl
<<in_addr_t[^a-zA-Z_0-9]>>dnl
changequote([,]), [#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
AC_MSG_RESULT([$ac_cv_type_in_addr_t])
if test $ac_cv_type_in_addr_t = no; then
AC_DEFINE(in_addr_t, u_int, [ ])
fi
])
dnl
dnl PHP_TIME_R_TYPE
dnl
dnl Check type of reentrant time-related functions
dnl Type can be: irix, hpux or POSIX
dnl
AC_DEFUN([PHP_TIME_R_TYPE],[
AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
AC_TRY_RUN([
#include <time.h>
main() {
char buf[27];
struct tm t;
time_t old = 0;
int r, s;
s = gmtime_r(&old, &t);
r = (int) asctime_r(&t, buf, 26);
if (r == s && s == 0) return (0);
return (1);
}
],[
ac_cv_time_r_type=hpux
],[
AC_TRY_RUN([
#include <time.h>
main() {
struct tm t, *s;
time_t old = 0;
char buf[27], *p;
s = gmtime_r(&old, &t);
p = asctime_r(&t, buf, 26);
if (p == buf && s == &t) return (0);
return (1);
}
],[
ac_cv_time_r_type=irix
],[
ac_cv_time_r_type=POSIX
],[
ac_cv_time_r_type=POSIX
])
],[
ac_cv_time_r_type=POSIX
])
])
case $ac_cv_time_r_type in
hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
esac
])
dnl
dnl PHP_DOES_PWRITE_WORK
dnl internal
AC_DEFUN([PHP_DOES_PWRITE_WORK],[
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
$1
main() {
int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
if (fd < 0) exit(1);
if (pwrite(fd, "text", 4, 0) != 4) exit(1);
/* Linux glibc breakage until 2.2.5 */
if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
exit(0);
}
],[
ac_cv_pwrite=yes
],[
ac_cv_pwrite=no
],[
ac_cv_pwrite=no
])
])
dnl PHP_DOES_PREAD_WORK
dnl internal
AC_DEFUN([PHP_DOES_PREAD_WORK],[
echo test > conftest_in
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
$1
main() {
char buf[3];
int fd = open("conftest_in", O_RDONLY);
if (fd < 0) exit(1);
if (pread(fd, buf, 2, 0) != 2) exit(1);
/* Linux glibc breakage until 2.2.5 */
if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
exit(0);
}
],[
ac_cv_pread=yes
],[
ac_cv_pread=no
],[
ac_cv_pread=no
])
rm -f conftest_in
])
dnl
dnl PHP_PWRITE_TEST
dnl
AC_DEFUN([PHP_PWRITE_TEST],[
AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
PHP_DOES_PWRITE_WORK
if test "$ac_cv_pwrite" = "no"; then
PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
if test "$ac_cv_pwrite" = "yes"; then
ac_cv_pwrite=64
fi
fi
])
if test "$ac_cv_pwrite" != "no"; then
AC_DEFINE(HAVE_PWRITE, 1, [ ])
if test "$ac_cv_pwrite" = "64"; then
AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
fi
fi
])
dnl
dnl PHP_PREAD_TEST
dnl
AC_DEFUN([PHP_PREAD_TEST],[
AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
PHP_DOES_PREAD_WORK
if test "$ac_cv_pread" = "no"; then
PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
if test "$ac_cv_pread" = "yes"; then
ac_cv_pread=64
fi
fi
])
if test "$ac_cv_pread" != "no"; then
AC_DEFINE(HAVE_PREAD, 1, [ ])
if test "$ac_cv_pread" = "64"; then
AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
fi
fi
])
dnl
dnl PHP_MISSING_TIME_R_DECL
dnl
AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
AC_MSG_CHECKING([for missing declarations of reentrant functions])
AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
:
],[
AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
])
AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
:
],[
AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
])
AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
:
],[
AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
])
AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
:
],[
AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
])
AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
:
],[
AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
])
AC_MSG_RESULT([done])
])
dnl
dnl PHP_READDIR_R_TYPE
dnl
AC_DEFUN([PHP_READDIR_R_TYPE],[
dnl HAVE_READDIR_R is also defined by libmysql
AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
if test "$ac_cv_func_readdir_r" = "yes"; then
AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
AC_TRY_RUN([
#define _REENTRANT
#include <sys/types.h>
#include <dirent.h>
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
main() {
DIR *dir;
char entry[sizeof(struct dirent)+PATH_MAX];
struct dirent *pentry = (struct dirent *) &entry;
dir = opendir("/");
if (!dir)
exit(1);
if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
exit(0);
exit(1);
}
],[
ac_cv_what_readdir_r=POSIX
],[
AC_TRY_CPP([
#define _REENTRANT
#include <sys/types.h>
#include <dirent.h>
int readdir_r(DIR *, struct dirent *);
],[
ac_cv_what_readdir_r=old-style
],[
ac_cv_what_readdir_r=none
])
],[
ac_cv_what_readdir_r=none
])
])
case $ac_cv_what_readdir_r in
POSIX)
AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
old-style)
AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
esac
fi
])
dnl
dnl PHP_TM_GMTOFF
dnl
AC_DEFUN([PHP_TM_GMTOFF],[
AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
if test "$ac_cv_struct_tm_gmtoff" = yes; then
AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
fi
])
dnl
dnl PHP_STRUCT_FLOCK
dnl
AC_DEFUN([PHP_STRUCT_FLOCK],[
AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
AC_TRY_COMPILE([
#include <unistd.h>
#include <fcntl.h>
],
[struct flock x;],
[
ac_cv_struct_flock=yes
],[
ac_cv_struct_flock=no
])
)
if test "$ac_cv_struct_flock" = "yes" ; then
AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
fi
])
dnl
dnl PHP_SOCKLEN_T
dnl
AC_DEFUN([PHP_SOCKLEN_T],[
AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
],[
socklen_t x;
],[
ac_cv_socklen_t=yes
],[
ac_cv_socklen_t=no
]))
if test "$ac_cv_socklen_t" = "yes"; then
AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
fi
])
dnl
dnl PHP_MISSING_FCLOSE_DECL
dnl
dnl See if we have broken header files like SunOS has.
dnl
AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
AC_MSG_CHECKING([for fclose declaration])
AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
AC_MSG_RESULT([ok])
],[
AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
AC_MSG_RESULT([missing])
])
])
dnl
dnl PHP_AC_BROKEN_SPRINTF
dnl
dnl Check for broken sprintf(), C99 conformance
dnl
AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[
AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
ac_cv_broken_sprintf=no
],[
ac_cv_broken_sprintf=yes
],[
ac_cv_broken_sprintf=no
])
])
if test "$ac_cv_broken_sprintf" = "yes"; then
AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
else
AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
fi
])
dnl
dnl PHP_AC_BROKEN_SNPRINTF
dnl
dnl Check for broken snprintf(), C99 conformance
dnl
AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
AC_TRY_RUN([
#define NULL (0L)
main() {
char buf[20];
int res = 0;
res = res || (snprintf(buf, 2, "marcus") != 6);
res = res || (buf[1] != '\0');
/* Implementations may consider this as an encoding error */
snprintf(buf, 0, "boerger");
/* However, they MUST ignore the pointer */
res = res || (buf[0] != 'm');
res = res || (snprintf(NULL, 0, "boerger") != 7);
res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
exit(res);
}
],[
ac_cv_broken_snprintf=no
],[
ac_cv_broken_snprintf=yes
],[
ac_cv_broken_snprintf=no
])
])
if test "$ac_cv_broken_snprintf" = "yes"; then
AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
else
AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
fi
])
dnl
dnl PHP_SOLARIS_PIC_WEIRDNESS
dnl
dnl Solaris requires main code to be position independent in order
dnl to let shared objects find symbols. Weird. Ugly.
dnl
dnl Must be run after all --with-NN options that let the user
dnl choose dynamic extensions, and after the gcc test.
dnl
AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
AC_MSG_CHECKING([whether -fPIC is required])
if test -n "$EXT_SHARED"; then
os=`uname -sr 2>/dev/null`
case $os in
"SunOS 5.6"|"SunOS 5.7"[)]
case $CC in
gcc*|egcs*)
CFLAGS="$CFLAGS -fPIC";;
*[)]
CFLAGS="$CFLAGS -fpic";;
esac
AC_MSG_RESULT([yes]);;
*[)]
AC_MSG_RESULT([no]);;
esac
else
AC_MSG_RESULT([no])
fi
])
dnl
dnl PHP_SYS_LFS
dnl
dnl The problem is that the default compilation flags in Solaris 2.6 won't
dnl let programs access large files; you need to tell the compiler that
dnl you actually want your programs to work on large files. For more
dnl details about this brain damage please see:
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
dnl
dnl Written by Paul Eggert <eggert@twinsun.com>.
dnl
AC_DEFUN([PHP_SYS_LFS],
[dnl
# If available, prefer support for large files unless the user specified
# one of the CPPFLAGS, LDFLAGS, or LIBS variables.
AC_MSG_CHECKING([whether large file support needs explicit enabling])
ac_getconfs=''
ac_result=yes
ac_set=''
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
for ac_shellvar in $ac_shellvars; do
case $ac_shellvar in
CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
*[)] ac_lfsvar=LFS_$ac_shellvar ;;
esac
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
ac_getconf=`getconf $ac_lfsvar`
ac_getconfs=$ac_getconfs$ac_getconf
eval ac_test_$ac_shellvar=\$ac_getconf
done
case "$ac_result$ac_getconfs" in
yes[)] ac_result=no ;;
esac
case "$ac_result$ac_set" in
yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
esac
AC_MSG_RESULT([$ac_result])
case $ac_result in
yes[)]
for ac_shellvar in $ac_shellvars; do
eval $ac_shellvar=\$ac_test_$ac_shellvar
done ;;
esac
])
dnl
dnl PHP_SOCKADDR_CHECKS
dnl
AC_DEFUN([PHP_SOCKADDR_CHECKS], [
dnl Check for struct sockaddr_storage exists
AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
[struct sockaddr_storage s; s],
[ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
])
if test "$ac_cv_sockaddr_storage" = "yes"; then
AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
fi
dnl Check if field sa_len exists in struct sockaddr
AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
[static struct sockaddr sa; int n = (int) sa.sa_len; return n;],
[ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
])
if test "$ac_cv_sockaddr_sa_len" = "yes"; then
AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
fi
])
dnl
dnl PHP_DECLARED_TIMEZONE
dnl
AC_DEFUN([PHP_DECLARED_TIMEZONE],[
AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
AC_TRY_COMPILE([
#include <sys/types.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
],[
time_t foo = (time_t) timezone;
],[
ac_cv_declared_timezone=yes
],[
ac_cv_declared_timezone=no
])])
if test "$ac_cv_declared_timezone" = "yes"; then
AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
fi
])
dnl
dnl PHP_EBCDIC
dnl
AC_DEFUN([PHP_EBCDIC], [
AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
AC_TRY_RUN( [
int main(void) {
return (unsigned char)'A' != (unsigned char)0xC1;
}
],[
ac_cv_ebcdic=yes
],[
ac_cv_ebcdic=no
],[
ac_cv_ebcdic=no
])])
if test "$ac_cv_ebcdic" = "yes"; then
AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
fi
])
dnl
dnl PHP_BROKEN_GETCWD
dnl
dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
dnl component of the path has execute but not read permissions
dnl
AC_DEFUN([PHP_BROKEN_GETCWD],[
AC_MSG_CHECKING([for broken getcwd])
os=`uname -sr 2>/dev/null`
case $os in
SunOS*[)]
AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
AC_MSG_RESULT([yes]);;
*[)]
AC_MSG_RESULT([no]);;
esac
])
dnl
dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
dnl
AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
AC_MSG_CHECKING([for broken libc stdio])
AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
AC_TRY_RUN([
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fp;
long position;
char *filename = tmpnam(NULL);
fp = fopen(filename, "w");
if (fp == NULL) {
perror("fopen");
exit(2);
}
fputs("foobar", fp);
fclose(fp);
fp = fopen(filename, "a+");
position = ftell(fp);
fclose(fp);
unlink(filename);
if (position == 0)
return 1;
return 0;
}
],
[_cv_have_broken_glibc_fopen_append=no],
[_cv_have_broken_glibc_fopen_append=yes ],
AC_TRY_COMPILE([
#include <features.h>
],[
#if !__GLIBC_PREREQ(2,2)
choke me
#endif
],
[_cv_have_broken_glibc_fopen_append=yes],
[_cv_have_broken_glibc_fopen_append=no ])
)])
if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
else
AC_MSG_RESULT(no)
fi
])
dnl
dnl PHP_FOPENCOOKIE
dnl
AC_DEFUN([PHP_FOPENCOOKIE], [
AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
if test "$have_glibc_fopencookie" = "yes"; then
dnl this comes in two flavors:
dnl newer glibcs (since 2.1.2 ? )
dnl have a type called cookie_io_functions_t
AC_TRY_COMPILE([
#define _GNU_SOURCE
#include <stdio.h>
], [cookie_io_functions_t cookie;], [have_cookie_io_functions_t=yes], [])
if test "$have_cookie_io_functions_t" = "yes"; then
cookie_io_functions_t=cookie_io_functions_t
have_fopen_cookie=yes
dnl even newer glibcs have a different seeker definition...
AC_TRY_RUN([
#define _GNU_SOURCE
#include <stdio.h>
struct cookiedata {
__off64_t pos;
};
__ssize_t reader(void *cookie, char *buffer, size_t size)
{ return size; }
__ssize_t writer(void *cookie, const char *buffer, size_t size)
{ return size; }
int closer(void *cookie)
{ return 0; }
int seeker(void *cookie, __off64_t *position, int whence)
{ ((struct cookiedata*)cookie)->pos = *position; return 0; }
cookie_io_functions_t funcs = {reader, writer, seeker, closer};
main() {
struct cookiedata g = { 0 };
FILE *fp = fopencookie(&g, "r", funcs);
if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
exit(0);
exit(1);
}
], [
cookie_io_functions_use_off64_t=yes
], [
cookie_io_functions_use_off64_t=no
], [
cookie_io_functions_use_off64_t=no
])
else
dnl older glibc versions (up to 2.1.2 ?)
dnl call it _IO_cookie_io_functions_t
AC_TRY_COMPILE([
#define _GNU_SOURCE
#include <stdio.h>
], [ _IO_cookie_io_functions_t cookie; ], [have_IO_cookie_io_functions_t=yes], [])
if test "$have_cookie_io_functions_t" = "yes" ; then
cookie_io_functions_t=_IO_cookie_io_functions_t
have_fopen_cookie=yes
fi
fi
if test "$have_fopen_cookie" = "yes" ; then
AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
if test "$cookie_io_functions_use_off64_t" = "yes" ; then
AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
fi
fi
fi
])
dnl -------------------------------------------------------------------------
dnl Library/function existence and build sanity checks
dnl -------------------------------------------------------------------------
dnl
dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
dnl
dnl Wrapper for AC_CHECK_LIB
dnl
AC_DEFUN([PHP_CHECK_LIBRARY], [
save_old_LDFLAGS=$LDFLAGS
ac_stuff="$5"
save_ext_shared=$ext_shared
ext_shared=yes
PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
AC_CHECK_LIB([$1],[$2],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
$3
],[
LDFLAGS=$save_old_LDFLAGS
ext_shared=$save_ext_shared
unset ac_cv_lib_$1[]_$2
$4
])dnl
])
dnl
dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
dnl
dnl El cheapo wrapper for AC_CHECK_LIB
dnl
AC_DEFUN([PHP_CHECK_FRAMEWORK], [
save_old_LDFLAGS=$LDFLAGS
LDFLAGS="-framework $1 $LDFLAGS"
dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
dnl rewriting AC_CHECK_LIB is overkill and this only affects
dnl the "checking.." output anyway.
AC_CHECK_LIB(c,[$2],[
LDFLAGS=$save_old_LDFLAGS
$3
],[
LDFLAGS=$save_old_LDFLAGS
$4
])
])
dnl
dnl PHP_CHECK_FUNC_LIB(func, libs)
dnl
dnl This macro checks whether 'func' or '__func' exists
dnl in the specified library.
dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
dnl
dnl
dnl autoconf undefines the builtin "shift" :-(
dnl If possible, we use the builtin shift anyway, otherwise we use
dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
])
dnl
AC_DEFUN([PHP_CHECK_FUNC_LIB],[
ifelse($2,,:,[
unset ac_cv_lib_$2[]_$1
unset ac_cv_lib_$2[]___$1
unset found
AC_CHECK_LIB($2, $1, [found=yes], [
AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
])
if test "$found" = "yes"; then
ac_libs=$LIBS
LIBS="$LIBS -l$2"
AC_TRY_RUN([main() { return (0); }],[found=yes],[found=no],[found=no])
LIBS=$ac_libs
fi
if test "$found" = "yes"; then
PHP_ADD_LIBRARY($2)
PHP_DEF_HAVE($1)
PHP_DEF_HAVE(lib$2)
ac_cv_func_$1=yes
else
PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
fi
])
])
dnl
dnl PHP_CHECK_FUNC(func, ...)
dnl
dnl This macro checks whether 'func' or '__func' exists
dnl in the default libraries and as a fall back in the specified library.
dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
dnl
AC_DEFUN([PHP_CHECK_FUNC],[
unset ac_cv_func_$1
unset ac_cv_func___$1
unset found
AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
case $found in
yes[)]
PHP_DEF_HAVE($1)
ac_cv_func_$1=yes
;;
ifelse($#,1,,[
*[)] PHP_CHECK_FUNC_LIB($@) ;;
])
esac
])
dnl
dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
dnl
dnl This macro checks whether build works and given function exists.
dnl
AC_DEFUN([PHP_TEST_BUILD], [
old_LIBS=$LIBS
LIBS="$4 $LIBS"
AC_TRY_RUN([
$5
char $1();
int main() {
$1();
return 0;
}
], [
LIBS=$old_LIBS
$2
],[
LIBS=$old_LIBS
$3
],[
LIBS=$old_LIBS
])
])
dnl -------------------------------------------------------------------------
dnl Platform characteristics checks
dnl -------------------------------------------------------------------------
dnl
dnl PHP_SHLIB_SUFFIX_NAMES
dnl
dnl Determines link library suffix SHLIB_SUFFIX_NAME
dnl which can be: .so, .sl or .dylib
dnl
dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
dnl suffix can be: .so or .sl
dnl
AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
SHLIB_SUFFIX_NAME=so
SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
case $host_alias in
*hpux*[)]
SHLIB_SUFFIX_NAME=sl
SHLIB_DL_SUFFIX_NAME=sl
;;
*darwin*[)]
SHLIB_SUFFIX_NAME=dylib
SHLIB_DL_SUFFIX_NAME=so
;;
esac
])
dnl
dnl PHP_CHECK_64BIT([do if 32], [do if 64])
dnl
dnl This macro is used to detect if we're at 64-bit platform or not.
dnl It could be useful for those external libs, that have different precompiled
dnl versions in different directories.
dnl
AC_DEFUN([PHP_CHECK_64BIT],[
AC_CHECK_SIZEOF(long int, 4)
AC_MSG_CHECKING([checking if we're at 64-bit platform])
if test "$ac_cv_sizeof_long_int" = "4" ; then
AC_MSG_RESULT([no])
$1
else
AC_MSG_RESULT([yes])
$2
fi
])
dnl
dnl PHP_C_BIGENDIAN
dnl
dnl Replacement macro for AC_C_BIGENDIAN
dnl
AC_DEFUN([PHP_C_BIGENDIAN],
[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
[
ac_cv_c_bigendian_php=unknown
AC_TRY_RUN(
[
int main(void)
{
short one = 1;
char *cp = (char *)&one;
if (*cp == 0) {
return(0);
} else {
return(1);
}
}
], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
])
if test $ac_cv_c_bigendian_php = yes; then
AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
fi
])
dnl -------------------------------------------------------------------------
dnl Checks for programs: PHP_PROG_<program>
dnl -------------------------------------------------------------------------
dnl
dnl PHP_PROG_SENDMAIL
dnl
dnl Search for the sendmail binary
dnl
AC_DEFUN([PHP_PROG_SENDMAIL], [
PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
PHP_SUBST(PROG_SENDMAIL)
])
dnl
dnl PHP_PROG_AWK
dnl
dnl Some vendors force mawk before gawk; mawk is broken so we don't like that
dnl
AC_DEFUN([PHP_PROG_AWK], [
AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
case "$AWK" in
*mawk)
AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
;;
*gawk)
;;
bork)
AC_MSG_ERROR([Could not find awk; Install GNU awk])
;;
*)
AC_MSG_CHECKING([if $AWK is broken])
if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
AC_MSG_RESULT([yes])
AC_MSG_ERROR([You should install GNU awk])
else
AC_MSG_RESULT([no])
fi
;;
esac
PHP_SUBST(AWK)
])
dnl
dnl PHP_PROG_BISON
dnl
dnl Search for bison and check it's version
dnl
AC_DEFUN([PHP_PROG_BISON], [
AC_PROG_YACC
LIBZEND_BISON_CHECK
PHP_SUBST(YACC)
])
dnl
dnl PHP_PROG_LEX
dnl
dnl Search for (f)lex and check it's version
dnl
AC_DEFUN([PHP_PROG_LEX], [
dnl we only support certain flex versions
flex_version_list="2.5.4"
AC_PROG_LEX
if test "$LEX" = "flex"; then
dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
dnl this is what causes that annoying "PHP_PROG_LEX is expanded from" warning with autoconf 2.50+
dnl it should be removed once we drop support of autoconf 2.13 (if ever)
AC_DECL_YYTEXT
:
fi
dnl ## Make flex scanners use const if they can, even if __STDC__ is not
dnl ## true, for compilers like Sun's that only set __STDC__ true in
dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
AC_C_CONST
if test "$ac_cv_c_const" = "yes" ; then
LEX_CFLAGS="-DYY_USE_CONST"
fi
if test "$LEX" = "flex"; then
AC_CACHE_CHECK([for flex version], php_cv_flex_version, [
flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'`
php_cv_flex_version=invalid
for flex_check_version in $flex_version_list; do
if test "$flex_version" = "$flex_check_version"; then
php_cv_flex_version="$flex_check_version (ok)"
fi
done
])
else
flex_version=none
fi
case $php_cv_flex_version in
""|invalid[)]
if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
AC_MSG_WARN([flex versions supported for regeneration of the Zend/PHP parsers: $flex_version_list (found: $flex_version)])
else
flex_msg="Supported flex versions are: $flex_version_list"
if test "$flex_version" = "none"; then
flex_msg="flex not found. flex is required to generate the Zend/PHP parsers! $flex_msg"
else
flex_msg="Found invalid flex version: $flex_version. $flex_msg"
fi
AC_MSG_ERROR([$flex_msg])
fi
LEX="exit 0;"
;;
esac
PHP_SUBST(LEX)
])
dnl
dnl PHP_PROG_RE2C
dnl
dnl Search for the re2c binary and check the version
dnl
AC_DEFUN([PHP_PROG_RE2C],[
AC_CHECK_PROG(RE2C, re2c, re2c)
if test -n "$RE2C"; then
AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
re2c_vernum=`$RE2C --vernum 2>/dev/null`
if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
php_cv_re2c_version=invalid
else
php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
fi
])
fi
case $php_cv_re2c_version in
""|invalid[)]
AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.])
RE2C="exit 0;"
;;
esac
PHP_SUBST(RE2C)
])
dnl -------------------------------------------------------------------------
dnl Common setup macros: PHP_SETUP_<what>
dnl -------------------------------------------------------------------------
dnl
dnl PHP_SETUP_ICU([shared-add])
dnl
dnl Common setup macro for ICU
dnl
AC_DEFUN([PHP_SETUP_ICU],[
PHP_ARG_WITH(icu-dir,,
[ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no)
if test "$PHP_ICU_DIR" = "no"; then
PHP_ICU_DIR=DEFAULT
fi
if test "$PHP_ICU_DIR" = "DEFAULT"; then
dnl Try to find icu-config
AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
else
ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
fi
AC_MSG_CHECKING([for location of ICU headers and libraries])
dnl Trust icu-config to know better what the install prefix is..
icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
if test "$?" != "0" || test -z "$icu_install_prefix"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
else
AC_MSG_RESULT([$icu_install_prefix])
dnl Check ICU version
AC_MSG_CHECKING([for ICU 4.0 or greater])
icu_version_full=`$ICU_CONFIG --version`
ac_IFS=$IFS
IFS="."
set $icu_version_full
IFS=$ac_IFS
icu_version=`expr [$]1 \* 1000 + [$]2`
AC_MSG_RESULT([found $icu_version_full])
if test "$icu_version" -lt "4000"; then
AC_MSG_ERROR([ICU version 4.0 or later is required])
fi
ICU_VERSION=$icu_version
ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
PHP_EVAL_INCLINE($ICU_INCS)
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
fi
])
dnl
dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
dnl
dnl Common setup macro for kerberos
dnl
AC_DEFUN([PHP_SETUP_KERBEROS],[
found_kerberos=no
unset KERBEROS_CFLAGS
unset KERBEROS_LIBS
dnl First try to find krb5-config
if test -z "$KRB5_CONFIG"; then
AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin])
fi
dnl If krb5-config is found try using it
if test "$PHP_KERBEROS" = "yes" && test -x "$KRB5_CONFIG"; then
KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
if test -n "$KERBEROS_LIBS"; then
found_kerberos=yes
PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
fi
fi
dnl If still not found use old skool method
if test "$found_kerberos" = "no"; then
if test "$PHP_KERBEROS" = "yes"; then
PHP_KERBEROS="/usr/kerberos /usr/local /usr"
fi
for i in $PHP_KERBEROS; do
if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then
PHP_KERBEROS_DIR=$i
break
fi
done
if test "$PHP_KERBEROS_DIR"; then
found_kerberos=yes
PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1)
PHP_ADD_LIBRARY(gssapi_krb5, 1, $1)
PHP_ADD_LIBRARY(krb5, 1, $1)
PHP_ADD_LIBRARY(k5crypto, 1, $1)
PHP_ADD_LIBRARY(com_err, 1, $1)
PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include)
fi
fi
if test "$found_kerberos" = "yes"; then
ifelse([$2],[],:,[$2])
ifelse([$3],[],,[else $3])
fi
])
dnl
dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
dnl
dnl Common setup macro for openssl
dnl
AC_DEFUN([PHP_SETUP_OPENSSL],[
found_openssl=no
unset OPENSSL_INCDIR
unset OPENSSL_LIBDIR
dnl Empty variable means 'no'
test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
dnl Fallbacks for different configure options
if test "$PHP_OPENSSL" != "no"; then
PHP_OPENSSL_DIR=$PHP_OPENSSL
elif test "$PHP_IMAP_SSL" != "no"; then
PHP_OPENSSL_DIR=$PHP_IMAP_SSL
fi
dnl First try to find pkg-config
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
dnl If pkg-config is found try using it
if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
if $PKG_CONFIG --atleast-version=0.9.6 openssl; then
found_openssl=yes
OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
else
AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
fi
if test -n "$OPENSSL_LIBS"; then
PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
fi
if test -n "$OPENSSL_INCS"; then
PHP_EVAL_INCLINE($OPENSSL_INCS)
fi
fi
dnl If pkg-config fails for some reason, revert to the old method
if test "$found_openssl" = "no"; then
if test "$PHP_OPENSSL_DIR" = "yes"; then
PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
fi
for i in $PHP_OPENSSL_DIR; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
OPENSSL_LIBDIR=$i/$PHP_LIBDIR
fi
test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
done
if test -z "$OPENSSL_INCDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
fi
if test -z "$OPENSSL_LIBDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's libraries])
fi
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=-I$OPENSSL_INCDIR
AC_MSG_CHECKING([for OpenSSL version])
AC_EGREP_CPP(yes,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090600fL
yes
#endif
],[
AC_MSG_RESULT([>= 0.9.6])
],[
AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
])
CPPFLAGS=$old_CPPFLAGS
PHP_ADD_INCLUDE($OPENSSL_INCDIR)
PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
PHP_ADD_LIBRARY(crypto,,$1)
],[
AC_MSG_ERROR([libcrypto not found!])
],[
-L$OPENSSL_LIBDIR
])
old_LIBS=$LIBS
LIBS="$LIBS -lcrypto"
PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
found_openssl=yes
],[
AC_MSG_ERROR([libssl not found!])
],[
-L$OPENSSL_LIBDIR
])
LIBS=$old_LIBS
PHP_ADD_LIBRARY(ssl,,$1)
PHP_ADD_LIBRARY(crypto,,$1)
PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
fi
if test "$found_openssl" = "yes"; then
dnl For apache 1.3.x static build
OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
AC_SUBST(OPENSSL_INCDIR_OPT)
ifelse([$2],[],:,[$2])
ifelse([$3],[],,[else $3])
fi
])
dnl
dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
dnl
dnl Common setup macro for iconv
dnl
AC_DEFUN([PHP_SETUP_ICONV], [
found_iconv=no
unset ICONV_DIR
# Create the directories for a VPATH build:
$php_shtool mkdir -p ext/iconv
echo > ext/iconv/php_have_bsd_iconv.h
echo > ext/iconv/php_have_ibm_iconv.h
echo > ext/iconv/php_have_glibc_iconv.h
echo > ext/iconv/php_have_libiconv.h
echo > ext/iconv/php_have_iconv.h
echo > ext/iconv/php_php_iconv_impl.h
echo > ext/iconv/php_iconv_aliased_libiconv.h
echo > ext/iconv/php_php_iconv_h_path.h
echo > ext/iconv/php_iconv_supports_errno.h
dnl
dnl Check libc first if no path is provided in --with-iconv
dnl
if test "$PHP_ICONV" = "yes"; then
dnl Reset LIBS temporarily as it may have already been included
dnl -liconv in.
LIBS_save="$LIBS"
LIBS=
AC_CHECK_FUNC(iconv, [
found_iconv=yes
],[
AC_CHECK_FUNC(libiconv,[
PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
AC_DEFINE(HAVE_LIBICONV, 1, [ ])
found_iconv=yes
])
])
LIBS="$LIBS_save"
fi
dnl
dnl Check external libs for iconv funcs
dnl
if test "$found_iconv" = "no"; then
for i in $PHP_ICONV /usr/local /usr; do
if test -r $i/include/giconv.h; then
AC_DEFINE(HAVE_GICONV_H, 1, [ ])
ICONV_DIR=$i
iconv_lib_name=giconv
break
elif test -r $i/include/iconv.h; then
ICONV_DIR=$i
iconv_lib_name=iconv
break
fi
done
if test -z "$ICONV_DIR"; then
AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
fi
if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
then
PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
found_iconv=yes
PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
AC_DEFINE(HAVE_LIBICONV,1,[ ])
PHP_DEFINE([ICONV_ALIASED_LIBICONV],1,[ext/iconv])
AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv])
], [
PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
found_iconv=yes
], [], [
-L$ICONV_DIR/$PHP_LIBDIR
])
], [
-L$ICONV_DIR/$PHP_LIBDIR
])
fi
fi
if test "$found_iconv" = "yes"; then
PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
AC_DEFINE(HAVE_ICONV,1,[ ])
if test -n "$ICONV_DIR"; then
PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
PHP_ADD_INCLUDE($ICONV_DIR/include)
fi
$2
ifelse([$3],[],,[else $3])
fi
])
dnl
dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
dnl
dnl Common setup macro for libxml
dnl
AC_DEFUN([PHP_SETUP_LIBXML], [
AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
[
for i in $PHP_LIBXML_DIR /usr/local /usr; do
if test -x "$i/bin/xml2-config"; then
ac_cv_php_xml2_config_path="$i/bin/xml2-config"
break
fi
done
])
if test -x "$ac_cv_php_xml2_config_path"; then
XML2_CONFIG="$ac_cv_php_xml2_config_path"
libxml_full_version=`$XML2_CONFIG --version`
ac_IFS=$IFS
IFS="."
set $libxml_full_version
IFS=$ac_IFS
LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
if test "$LIBXML_VERSION" -ge "2006011"; then
LIBXML_LIBS=`$XML2_CONFIG --libs`
LIBXML_INCS=`$XML2_CONFIG --cflags`
PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
PHP_EVAL_INCLINE($LIBXML_INCS)
dnl Check that build works with given libs
AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
PHP_TEST_BUILD(xmlInitParser,
[
php_cv_libxml_build_works=yes
], [
AC_MSG_RESULT(no)
AC_MSG_ERROR([build test failed. Please check the config.log for details.])
], [
[$]$1
])
])
if test "$php_cv_libxml_build_works" = "yes"; then
AC_DEFINE(HAVE_LIBXML, 1, [ ])
fi
$2
else
AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
fi
ifelse([$3],[],,[else $3])
fi
])
dnl -------------------------------------------------------------------------
dnl Misc. macros
dnl -------------------------------------------------------------------------
dnl
dnl PHP_INSTALL_HEADERS(path [, file ...])
dnl
dnl PHP header files to be installed
dnl
AC_DEFUN([PHP_INSTALL_HEADERS],[
ifelse([$2],[],[
for header_file in $1; do
PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
])
done
], [
header_path=$1
for header_file in $2; do
hp_hf="$header_path/$header_file"
PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
])
done
])
])
dnl
dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
dnl
dnl This macro is used to get a comparable
dnl version for apache1/2.
dnl
AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
ac_IFS=$IFS
IFS="- /.
"
set $ac_output
IFS=$ac_IFS
APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
])
dnl
dnl PHP_DEBUG_MACRO(filename)
dnl
AC_DEFUN([PHP_DEBUG_MACRO],[
DEBUG_LOG=$1
cat >$1 <<X
CONFIGURE: $CONFIGURE_COMMAND
CC: $CC
CFLAGS: $CFLAGS
CPPFLAGS: $CPPFLAGS
CXX: $CXX
CXXFLAGS: $CXXFLAGS
INCLUDES: $INCLUDES
LDFLAGS: $LDFLAGS
LIBS: $LIBS
DLIBS: $DLIBS
SAPI: $PHP_SAPI
PHP_RPATHS: $PHP_RPATHS
uname -a: `uname -a`
X
cat >conftest.$ac_ext <<X
main()
{
exit(0);
}
X
(eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
rm -fr conftest*
])
dnl
dnl PHP_CONFIG_NICE(filename)
dnl
dnl Generates the config.nice file
dnl
AC_DEFUN([PHP_CONFIG_NICE],[
AC_REQUIRE([AC_PROG_EGREP])
AC_REQUIRE([LT_AC_PROG_SED])
PHP_SUBST_OLD(EGREP)
PHP_SUBST_OLD(SED)
test -f $1 && mv $1 $1.old
rm -f $1.old
cat >$1<<EOF
#! /bin/sh
#
# Created by configure
EOF
for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
eval val=\$$var
if test -n "$val"; then
echo "$var='$val' \\" >> $1
fi
done
echo "'[$]0' \\" >> $1
if test `expr -- [$]0 : "'.*"` = 0; then
CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
else
CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
fi
for arg in $ac_configure_args; do
if test `expr -- $arg : "'.*"` = 0; then
if test `expr -- $arg : "--.*"` = 0; then
break;
fi
echo "'[$]arg' \\" >> $1
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
else
if test `expr -- $arg : "'--.*"` = 0; then
break;
fi
echo "[$]arg \\" >> $1
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
fi
done
echo '"[$]@"' >> $1
chmod +x $1
CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
PHP_SUBST_OLD(CONFIGURE_COMMAND)
PHP_SUBST_OLD(CONFIGURE_OPTIONS)
])
dnl
dnl PHP_CHECK_CONFIGURE_OPTIONS
dnl
AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
for arg in $ac_configure_args; do
case $arg in
--with-*[)]
arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
;;
--without-*[)]
arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
;;
--enable-*[)]
arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
;;
--disable-*[)]
arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
;;
*[)]
continue
;;
esac
case $arg_name in
# Allow --disable-all / --enable-all
enable-all[)];;
# Allow certain libtool options
enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
# Allow certain TSRM options
with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
# Allow certain Zend options
with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
# All the rest must be set using the PHP_ARG_* macros
# PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
*[)]
# Options that exist before PHP 6
if test "$PHP_MAJOR_VERSION" -lt "6"; then
case $arg_name in
enable-zend-multibyte[)] continue;;
esac
fi
is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
if eval test "x\$$is_arg_set" = "x"; then
PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS
[$]arg"
fi
;;
esac
done
])
dnl
dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
dnl
AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [
AC_MSG_CHECKING([for PDO includes])
if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
pdo_cv_inc_path=$abs_srcdir/ext
elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
pdo_cv_inc_path=$abs_srcdir/ext
elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
pdo_cv_inc_path=$prefix/include/php/ext
fi
])
if test -n "$pdo_cv_inc_path"; then
ifelse([$1],[],:,[$1])
else
ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
fi
])
dnl
dnl PHP_DETECT_ICC
dnl Detect Intel C++ Compiler and unset $GCC if ICC found
AC_DEFUN([PHP_DETECT_ICC],
[
ICC="no"
AC_MSG_CHECKING([for icc])
AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
ICC="no"
AC_MSG_RESULT([no]),
ICC="yes"
GCC="no"
AC_MSG_RESULT([yes])
)
])
dnl PHP_DETECT_SUNCC
dnl Detect if the systems default compiler is suncc.
dnl We also set some useful CFLAGS if the user didn't set any
AC_DEFUN([PHP_DETECT_SUNCC],[
SUNCC="no"
AC_MSG_CHECKING([for suncc])
AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C],
SUNCC="no"
AC_MSG_RESULT([no]),
SUNCC="yes"
GCC="no"
test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
GCC=""
AC_MSG_RESULT([yes])
)
])
dnl
dnl PHP_CRYPT_R_STYLE
dnl detect the style of crypt_r() is any is available
dnl see APR_CHECK_CRYPT_R_STYLE() for original version
dnl
AC_DEFUN([PHP_CRYPT_R_STYLE],
[
AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
php_cv_crypt_r_style=none
AC_TRY_COMPILE([
#define _REENTRANT 1
#include <crypt.h>
],[
CRYPTD buffer;
crypt_r("passwd", "hash", &buffer);
],
php_cv_crypt_r_style=cryptd)
if test "$php_cv_crypt_r_style" = "none"; then
AC_TRY_COMPILE([
#define _REENTRANT 1
#include <crypt.h>
],[
struct crypt_data buffer;
crypt_r("passwd", "hash", &buffer);
],
php_cv_crypt_r_style=struct_crypt_data)
fi
if test "$php_cv_crypt_r_style" = "none"; then
AC_TRY_COMPILE([
#define _REENTRANT 1
#define _GNU_SOURCE
#include <crypt.h>
],[
struct crypt_data buffer;
crypt_r("passwd", "hash", &buffer);
],
php_cv_crypt_r_style=struct_crypt_data_gnu_source)
fi
])
if test "$php_cv_crypt_r_style" = "cryptd"; then
AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
fi
if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
fi
if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
fi
if test "$php_cv_crypt_r_style" = "none"; then
AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
fi
])
dnl
dnl PHP_TEST_WRITE_STDOUT
dnl
AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
AC_TRY_RUN([
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#define TEXT "This is the test message -- "
main()
{
int n;
n = write(1, TEXT, sizeof(TEXT)-1);
return (!(n == sizeof(TEXT)-1));
}
],[
ac_cv_write_stdout=yes
],[
ac_cv_write_stdout=no
],[
ac_cv_write_stdout=no
])
])
if test "$ac_cv_write_stdout" = "yes"; then
AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
fi
])
dnl
dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module])
dnl
AC_DEFUN([PHP_INIT_DTRACE],[
dnl Set paths properly when called from extension
case "$4" in
""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;;
/*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;;
*[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";;
esac
dnl providerdesc
ac_provsrc=$1
old_IFS=[$]IFS
IFS=.
set $ac_provsrc
ac_provobj=[$]1
IFS=$old_IFS
dnl header-file
ac_hdrobj=$2
dnl Add providerdesc.o or .lo into global objects when needed
case $host_alias in
*freebsd*)
PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o"
PHP_LDFLAGS="$PHP_LDFLAGS -lelf"
;;
*solaris*)
PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo"
;;
*linux*)
PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.lo"
;;
esac
dnl DTrace objects
old_IFS=[$]IFS
for ac_src in $3; do
IFS=.
set $ac_src
ac_obj=[$]1
IFS=$old_IFS
PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo"
done;
case [$]php_sapi_module in
shared[)]
for ac_lo in $PHP_DTRACE_OBJS; do
dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
done;
;;
*[)]
dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
;;
esac
dnl Generate Makefile.objects entries
dnl The empty $ac_provsrc command stops an implicit circular dependency
dnl in GNU Make which causes the .d file to be overwritten (Bug 61268)
cat>>Makefile.objects<<EOF
$abs_srcdir/$ac_provsrc:;
$ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc
CFLAGS="\$(CFLAGS_CLEAN)" dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@.bak && \$(SED) -e 's,PHP_,DTRACE_,g' \$[]@.bak > \$[]@
\$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
EOF
case $host_alias in
*solaris*|*linux*)
dtrace_prov_name="`echo $ac_provsrc | $SED -e 's#\(.*\)\/##'`.o"
dtrace_lib_dir="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/[^/]*#\1#'`/.libs"
dtrace_d_obj="`echo $ac_bdir[$]ac_provsrc | $SED -e 's#\(.*\)/\([^/]*\)#\1/.libs/\2#'`.o"
dtrace_nolib_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
for ac_lo in $PHP_DTRACE_OBJS; do
dtrace_lib_objs="[$]dtrace_lib_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
done;
dnl Always attempt to create both PIC and non-PIC DTrace objects (Bug 63692)
cat>>Makefile.objects<<EOF
$ac_bdir[$]ac_provsrc.lo: \$(PHP_DTRACE_OBJS)
echo "[#] Generated by Makefile for libtool" > \$[]@
@test -d "$dtrace_lib_dir" || mkdir $dtrace_lib_dir
if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $dtrace_d_obj -s $abs_srcdir/$ac_provsrc $dtrace_lib_objs 2> /dev/null && test -f "$dtrace_d_obj"; then [\\]
echo "pic_object=['].libs/$dtrace_prov_name[']" >> \$[]@ [;\\]
else [\\]
echo "pic_object='none'" >> \$[]@ [;\\]
fi
if CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o $ac_bdir[$]ac_provsrc.o -s $abs_srcdir/$ac_provsrc $dtrace_nolib_objs 2> /dev/null && test -f "$ac_bdir[$]ac_provsrc.o"; then [\\]
echo "non_pic_object=[']$dtrace_prov_name[']" >> \$[]@ [;\\]
else [\\]
echo "non_pic_object='none'" >> \$[]@ [;\\]
fi
EOF
;;
*)
cat>>Makefile.objects<<EOF
$ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
CFLAGS="\$(CFLAGS_CLEAN)" dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
EOF
;;
esac
])
================================================
FILE: codes/array/aclocal.m4
================================================
dnl
dnl $Id$
dnl
dnl This file contains local autoconf functions.
dnl
dnl -------------------------------------------------------------------------
dnl Output stylize macros for configure (help/runtime)
dnl -------------------------------------------------------------------------
dnl
dnl PHP_HELP_SEPARATOR(title)
dnl
dnl Adds separator title into the configure --help display.
dnl
AC_DEFUN([PHP_HELP_SEPARATOR],[
AC_ARG_ENABLE([],[
$1
],[])
])
dnl
dnl PHP_CONFIGURE_PART(title)
dnl
dnl Adds separator title configure output (idea borrowed from mm)
dnl
AC_DEFUN([PHP_CONFIGURE_PART],[
AC_MSG_RESULT()
AC_MSG_RESULT([${T_MD}$1${T_ME}])
])
dnl -------------------------------------------------------------------------
dnl Build system helper macros
dnl -------------------------------------------------------------------------
dnl
dnl PHP_DEF_HAVE(what)
dnl
dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'
dnl
AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
dnl
dnl PHP_RUN_ONCE(namespace, variable, code)
dnl
dnl execute code, if variable is not set in namespace
dnl
AC_DEFUN([PHP_RUN_ONCE],[
changequote({,})
unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
changequote([,])
cmd="echo $ac_n \"\$$1$unique$ac_c\""
if test -n "$unique" && test "`eval $cmd`" = "" ; then
eval "$1$unique=set"
$3
fi
])
dnl
dnl PHP_EXPAND_PATH(path, variable)
dnl
dnl expands path to an absolute path and assigns it to variable
dnl
AC_DEFUN([PHP_EXPAND_PATH],[
gitextract_337cjps5/
├── 001.md
├── 002.md
├── 003.md
├── 004.md
├── 01.md
├── 02.md
├── 03.md
├── 04.md
├── 05.md
├── 06.md
├── 07.md
├── 08.md
├── 09.md
├── 10.md
├── 11.md
├── 12.md
├── 13.md
├── 14.md
├── README.md
└── codes/
├── array/
│ ├── .deps
│ ├── .libs/
│ │ ├── array.lai
│ │ ├── array.o
│ │ └── array.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── array.c
│ ├── array.la
│ ├── array.lo
│ ├── array.php
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_array.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── consts/
│ ├── .deps
│ ├── .libs/
│ │ ├── consts.lai
│ │ ├── consts.o
│ │ └── consts.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── consts.c
│ ├── consts.la
│ ├── consts.lo
│ ├── consts.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_consts.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── fcall/
│ ├── .deps
│ ├── .libs/
│ │ ├── fcall.lai
│ │ ├── fcall.o
│ │ └── fcall.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── fcall.c
│ ├── fcall.la
│ ├── fcall.lo
│ ├── fcall.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_fcall.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── global/
│ ├── .deps
│ ├── .libs/
│ │ ├── global.lai
│ │ ├── global.o
│ │ └── global.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── global.c
│ ├── global.la
│ ├── global.lo
│ ├── global.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_global.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── globalss/
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── config.m4
│ ├── config.w32
│ ├── globalss.c
│ ├── globalss.php
│ ├── php_globalss.h
│ └── tests/
│ └── 001.phpt
├── inis/
│ ├── .deps
│ ├── .libs/
│ │ ├── inis.lai
│ │ ├── inis.o
│ │ └── inis.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── inis.c
│ ├── inis.la
│ ├── inis.lo
│ ├── inis.php
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_inis.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── libs/
│ ├── .deps
│ ├── .libs/
│ │ ├── libs.lai
│ │ ├── libs.o
│ │ └── libs.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libs.c
│ ├── libs.la
│ ├── libs.lo
│ ├── libs.php
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_libs.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── objects1/
│ ├── .deps
│ ├── .libs/
│ │ ├── objects1.lai
│ │ ├── objects1.o
│ │ └── objects1.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── objects1.c
│ ├── objects1.la
│ ├── objects1.lo
│ ├── objects1.php
│ ├── php_objects1.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── objects2/
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── config.m4
│ ├── config.w32
│ ├── objects2.c
│ ├── objects2.php
│ ├── php_objects2.h
│ └── tests/
│ └── 001.phpt
├── objects3/
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── config.m4
│ ├── config.w32
│ ├── objects3.c
│ ├── objects3.php
│ ├── php_objects3.h
│ └── tests/
│ └── 001.phpt
├── params/
│ ├── .deps
│ ├── .libs/
│ │ ├── params.lai
│ │ ├── params.o
│ │ └── params.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── params.c
│ ├── params.la
│ ├── params.lo
│ ├── params.php
│ ├── php_params.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── php_hello/
│ ├── .deps
│ ├── .libs/
│ │ ├── php_hello.lai
│ │ ├── php_hello.o
│ │ └── php_hello.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_hello.c
│ ├── php_hello.la
│ ├── php_hello.lo
│ ├── php_hello.php
│ ├── php_php_hello.h
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── resource/
│ ├── .deps
│ ├── .libs/
│ │ ├── resource.lai
│ │ ├── resource.o
│ │ └── resource.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_resource.h
│ ├── resource.c
│ ├── resource.la
│ ├── resource.lo
│ ├── resource.php
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
├── return/
│ ├── .deps
│ ├── .libs/
│ │ ├── return.lai
│ │ ├── return.o
│ │ └── return.so.dSYM/
│ │ └── Contents/
│ │ └── Info.plist
│ ├── .svnignore
│ ├── CREDITS
│ ├── EXPERIMENTAL
│ ├── Makefile
│ ├── Makefile.fragments
│ ├── Makefile.global
│ ├── Makefile.objects
│ ├── acinclude.m4
│ ├── aclocal.m4
│ ├── autom4te.cache/
│ │ ├── output.0
│ │ ├── requests
│ │ └── traces.0
│ ├── build/
│ │ ├── libtool.m4
│ │ ├── mkdep.awk
│ │ ├── scan_makefile_in.awk
│ │ └── shtool
│ ├── config.guess
│ ├── config.h
│ ├── config.h.in
│ ├── config.log
│ ├── config.m4
│ ├── config.nice
│ ├── config.status
│ ├── config.sub
│ ├── config.w32
│ ├── configure
│ ├── configure.in
│ ├── install-sh
│ ├── libtool
│ ├── ltmain.sh
│ ├── missing
│ ├── mkinstalldirs
│ ├── php_return.h
│ ├── return.c
│ ├── return.la
│ ├── return.lo
│ ├── return.php
│ ├── run-tests.php
│ └── tests/
│ └── 001.phpt
└── zval1/
├── .svnignore
├── CREDITS
├── EXPERIMENTAL
├── config.m4
├── config.w32
├── php_zval1.h
├── tests/
│ └── 001.phpt
├── zval1.c
└── zval1.php
SYMBOL INDEX (537 symbols across 28 files)
FILE: codes/array/array.c
function PHP_FUNCTION (line 37) | PHP_FUNCTION(array_greet) {
FILE: codes/array/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 248) | function write_information($show_html)
function save_or_mail_results (line 319) | function save_or_mail_results()
function find_files (line 875) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 911) | function test_name($name)
function test_sort (line 920) | function test_sort($a, $b)
function mail_qa_team (line 981) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1028) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1053) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1070) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1134) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1166) | function show_file_block($file, $block, $section = null)
function run_test (line 1185) | function run_test($php, $file, $env)
function comp_line (line 2136) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2145) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2187) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2254) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2264) | function error($message)
function settings2array (line 2270) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2324) | function compute_summary()
function get_summary (line 2352) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2485) | function show_start($start_time)
function show_end (line 2497) | function show_end($end_time)
function show_summary (line 2509) | function show_summary()
function show_redirect_start (line 2520) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2536) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2552) | function show_test($test_idx, $shortname)
function show_result (line 2563) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2619) | function junit_init() {
function junit_save_xml (line 2644) | function junit_save_xml() {
function junit_get_suite_xml (line 2655) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2682) | function junit_enabled() {
function junit_mark_test_as (line 2696) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2747) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2754) | function junit_get_timer($file_name) {
function junit_start_timer (line 2765) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2778) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2782) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2787) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2808) | function junit_finish_timer($file_name) {
FILE: codes/consts/consts.c
function PHP_MINIT_FUNCTION (line 96) | PHP_MINIT_FUNCTION(consts)
function PHP_MSHUTDOWN_FUNCTION (line 111) | PHP_MSHUTDOWN_FUNCTION(consts)
function PHP_RINIT_FUNCTION (line 123) | PHP_RINIT_FUNCTION(consts)
function PHP_RSHUTDOWN_FUNCTION (line 138) | PHP_RSHUTDOWN_FUNCTION(consts)
function PHP_MINFO_FUNCTION (line 146) | PHP_MINFO_FUNCTION(consts)
function PHP_FUNCTION (line 166) | PHP_FUNCTION(confirm_consts_compiled)
FILE: codes/consts/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 248) | function write_information($show_html)
function save_or_mail_results (line 319) | function save_or_mail_results()
function find_files (line 875) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 911) | function test_name($name)
function test_sort (line 920) | function test_sort($a, $b)
function mail_qa_team (line 981) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1028) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1053) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1070) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1134) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1166) | function show_file_block($file, $block, $section = null)
function run_test (line 1185) | function run_test($php, $file, $env)
function comp_line (line 2136) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2145) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2187) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2254) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2264) | function error($message)
function settings2array (line 2270) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2324) | function compute_summary()
function get_summary (line 2352) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2485) | function show_start($start_time)
function show_end (line 2497) | function show_end($end_time)
function show_summary (line 2509) | function show_summary()
function show_redirect_start (line 2520) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2536) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2552) | function show_test($test_idx, $shortname)
function show_result (line 2563) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2619) | function junit_init() {
function junit_save_xml (line 2644) | function junit_save_xml() {
function junit_get_suite_xml (line 2655) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2682) | function junit_enabled() {
function junit_mark_test_as (line 2696) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2747) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2754) | function junit_get_timer($file_name) {
function junit_start_timer (line 2765) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2778) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2782) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2787) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2808) | function junit_finish_timer($file_name) {
FILE: codes/fcall/fcall.c
function PHP_FUNCTION (line 35) | PHP_FUNCTION(fcall_bycallback) {
function PHP_FUNCTION (line 96) | PHP_FUNCTION(fcall_byname) {
FILE: codes/fcall/fcall.php
function callback (line 8) | function callback($msg) {
FILE: codes/fcall/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 248) | function write_information($show_html)
function save_or_mail_results (line 319) | function save_or_mail_results()
function find_files (line 875) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 911) | function test_name($name)
function test_sort (line 920) | function test_sort($a, $b)
function mail_qa_team (line 981) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1028) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1053) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1070) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1134) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1166) | function show_file_block($file, $block, $section = null)
function run_test (line 1185) | function run_test($php, $file, $env)
function comp_line (line 2136) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2145) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2187) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2254) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2264) | function error($message)
function settings2array (line 2270) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2324) | function compute_summary()
function get_summary (line 2352) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2485) | function show_start($start_time)
function show_end (line 2497) | function show_end($end_time)
function show_summary (line 2509) | function show_summary()
function show_redirect_start (line 2520) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2536) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2552) | function show_test($test_idx, $shortname)
function show_result (line 2563) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2619) | function junit_init() {
function junit_save_xml (line 2644) | function junit_save_xml() {
function junit_get_suite_xml (line 2655) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2682) | function junit_enabled() {
function junit_mark_test_as (line 2696) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2747) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2754) | function junit_get_timer($file_name) {
function junit_start_timer (line 2765) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2778) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2782) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2787) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2808) | function junit_finish_timer($file_name) {
FILE: codes/global/global.c
function PHP_FUNCTION (line 33) | static PHP_FUNCTION(global_inc) {
function PHP_FUNCTION (line 37) | static PHP_FUNCTION(global_get) {
function PHP_FUNCTION (line 41) | static PHP_FUNCTION(global_get_name) {
function PHP_FUNCTION (line 49) | static PHP_FUNCTION(global_name) {
function PHP_FUNCTION (line 71) | static PHP_FUNCTION(print_get_vars) {
function PHP_FUNCTION (line 81) | static PHP_FUNCTION(print_server_vars) {
function PHP_FUNCTION (line 96) | static PHP_FUNCTION(add_globals_var) {
function PHP_FUNCTION (line 111) | static PHP_FUNCTION(add_globals_vars) {
function PHP_FUNCTION (line 129) | static PHP_FUNCTION(print_server_var) {
function PHP_MINIT_FUNCTION (line 216) | PHP_MINIT_FUNCTION(global)
function PHP_MSHUTDOWN_FUNCTION (line 222) | PHP_MSHUTDOWN_FUNCTION(global)
function PHP_RINIT_FUNCTION (line 230) | PHP_RINIT_FUNCTION(global)
function PHP_RSHUTDOWN_FUNCTION (line 241) | PHP_RSHUTDOWN_FUNCTION(global)
function PHP_MINFO_FUNCTION (line 254) | PHP_MINFO_FUNCTION(global)
FILE: codes/global/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 248) | function write_information($show_html)
function save_or_mail_results (line 319) | function save_or_mail_results()
function find_files (line 875) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 911) | function test_name($name)
function test_sort (line 920) | function test_sort($a, $b)
function mail_qa_team (line 981) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1028) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1053) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1070) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1134) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1166) | function show_file_block($file, $block, $section = null)
function run_test (line 1185) | function run_test($php, $file, $env)
function comp_line (line 2136) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2145) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2187) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2254) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2264) | function error($message)
function settings2array (line 2270) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2324) | function compute_summary()
function get_summary (line 2352) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2485) | function show_start($start_time)
function show_end (line 2497) | function show_end($end_time)
function show_summary (line 2509) | function show_summary()
function show_redirect_start (line 2520) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2536) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2552) | function show_test($test_idx, $shortname)
function show_result (line 2563) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2619) | function junit_init() {
function junit_save_xml (line 2644) | function junit_save_xml() {
function junit_get_suite_xml (line 2655) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2682) | function junit_enabled() {
function junit_mark_test_as (line 2696) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2747) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2754) | function junit_get_timer($file_name) {
function junit_start_timer (line 2765) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2778) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2782) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2787) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2808) | function junit_finish_timer($file_name) {
FILE: codes/globalss/globalss.c
function PHP_MINIT_FUNCTION (line 97) | PHP_MINIT_FUNCTION(globalss)
function PHP_MSHUTDOWN_FUNCTION (line 108) | PHP_MSHUTDOWN_FUNCTION(globalss)
function PHP_RINIT_FUNCTION (line 120) | PHP_RINIT_FUNCTION(globalss)
function PHP_RSHUTDOWN_FUNCTION (line 129) | PHP_RSHUTDOWN_FUNCTION(globalss)
function PHP_MINFO_FUNCTION (line 137) | PHP_MINFO_FUNCTION(globalss)
function PHP_FUNCTION (line 151) | PHP_FUNCTION(test_sapi_global)
function PHP_FUNCTION (line 156) | PHP_FUNCTION(test_zend_global)
function PHP_FUNCTION (line 161) | PHP_FUNCTION(test_php_global)
FILE: codes/inis/inis.c
function PHP_FUNCTION (line 31) | ZEND_DECLARE_MODULE_GLOBALS(inis)
function php_inis_init_globals (line 74) | static void php_inis_init_globals(zend_inis_globals *inis_globals)
function PHP_MINIT_FUNCTION (line 82) | PHP_MINIT_FUNCTION(inis)
function PHP_MSHUTDOWN_FUNCTION (line 90) | PHP_MSHUTDOWN_FUNCTION(inis)
function PHP_RINIT_FUNCTION (line 98) | PHP_RINIT_FUNCTION(inis)
function PHP_RSHUTDOWN_FUNCTION (line 105) | PHP_RSHUTDOWN_FUNCTION(inis)
function PHP_MINFO_FUNCTION (line 112) | PHP_MINFO_FUNCTION(inis)
FILE: codes/inis/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 247) | function write_information($show_html)
function save_or_mail_results (line 318) | function save_or_mail_results()
function find_files (line 874) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 910) | function test_name($name)
function test_sort (line 919) | function test_sort($a, $b)
function mail_qa_team (line 980) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1027) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1052) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1069) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1133) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1165) | function show_file_block($file, $block, $section = null)
function run_test (line 1184) | function run_test($php, $file, $env)
function comp_line (line 2135) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2144) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2186) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2253) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2263) | function error($message)
function settings2array (line 2269) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2323) | function compute_summary()
function get_summary (line 2351) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2484) | function show_start($start_time)
function show_end (line 2496) | function show_end($end_time)
function show_summary (line 2508) | function show_summary()
function show_redirect_start (line 2519) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2535) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2551) | function show_test($test_idx, $shortname)
function show_result (line 2562) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2618) | function junit_init() {
function junit_save_xml (line 2643) | function junit_save_xml() {
function junit_get_suite_xml (line 2654) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2681) | function junit_enabled() {
function junit_mark_test_as (line 2695) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2746) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2753) | function junit_get_timer($file_name) {
function junit_start_timer (line 2764) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2777) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2781) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2786) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2807) | function junit_finish_timer($file_name) {
FILE: codes/libs/libs.c
function PHP_FUNCTION (line 56) | ZEND_GET_MODULE(libs)
FILE: codes/libs/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 247) | function write_information($show_html)
function save_or_mail_results (line 318) | function save_or_mail_results()
function find_files (line 874) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 910) | function test_name($name)
function test_sort (line 919) | function test_sort($a, $b)
function mail_qa_team (line 980) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1027) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1052) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1069) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1133) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1165) | function show_file_block($file, $block, $section = null)
function run_test (line 1184) | function run_test($php, $file, $env)
function comp_line (line 2135) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2144) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2186) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2253) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2263) | function error($message)
function settings2array (line 2269) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2323) | function compute_summary()
function get_summary (line 2351) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2484) | function show_start($start_time)
function show_end (line 2496) | function show_end($end_time)
function show_summary (line 2508) | function show_summary()
function show_redirect_start (line 2519) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2535) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2551) | function show_test($test_idx, $shortname)
function show_result (line 2562) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2618) | function junit_init() {
function junit_save_xml (line 2643) | function junit_save_xml() {
function junit_get_suite_xml (line 2654) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2681) | function junit_enabled() {
function junit_mark_test_as (line 2695) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2746) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2753) | function junit_get_timer($file_name) {
function junit_start_timer (line 2764) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2777) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2781) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2786) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2807) | function junit_finish_timer($file_name) {
FILE: codes/objects1/objects1.c
function PHP_MINIT_FUNCTION (line 137) | ZEND_GET_MODULE(objects1)
function PHP_MSHUTDOWN_FUNCTION (line 167) | PHP_MSHUTDOWN_FUNCTION(objects1)
function PHP_RINIT_FUNCTION (line 173) | PHP_RINIT_FUNCTION(objects1)
function PHP_RSHUTDOWN_FUNCTION (line 180) | PHP_RSHUTDOWN_FUNCTION(objects1)
function PHP_MINFO_FUNCTION (line 186) | PHP_MINFO_FUNCTION(objects1)
FILE: codes/objects1/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 247) | function write_information($show_html)
function save_or_mail_results (line 318) | function save_or_mail_results()
function find_files (line 874) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 910) | function test_name($name)
function test_sort (line 919) | function test_sort($a, $b)
function mail_qa_team (line 980) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1027) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1052) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1069) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1133) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1165) | function show_file_block($file, $block, $section = null)
function run_test (line 1184) | function run_test($php, $file, $env)
function comp_line (line 2135) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2144) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2186) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2253) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2263) | function error($message)
function settings2array (line 2269) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2323) | function compute_summary()
function get_summary (line 2351) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2484) | function show_start($start_time)
function show_end (line 2496) | function show_end($end_time)
function show_summary (line 2508) | function show_summary()
function show_redirect_start (line 2519) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2535) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2551) | function show_test($test_idx, $shortname)
function show_result (line 2562) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2618) | function junit_init() {
function junit_save_xml (line 2643) | function junit_save_xml() {
function junit_get_suite_xml (line 2654) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2681) | function junit_enabled() {
function junit_mark_test_as (line 2695) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2746) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2753) | function junit_get_timer($file_name) {
function junit_start_timer (line 2764) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2777) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2781) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2786) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2807) | function junit_finish_timer($file_name) {
FILE: codes/objects2/objects2.c
type hello_object (line 34) | typedef struct _hello_object {
function hello_dtor (line 79) | static void hello_dtor(hello_object *objval TSRMLS_CC) {
function zend_object_value (line 88) | static zend_object_value hello_ctor(zend_class_entry *ce TSRMLS_DC) {
function zend_object_value (line 105) | static zend_object_value hello_ctor_ex(hello_object **pobjval, zend_clas...
function zend_object_value (line 120) | static zend_object_value hello_clone(zval *zobject TSRMLS_DC) {
function zval (line 138) | static zval *hello_get(zval *zobject TSRMLS_CC) {
function PHP_MINIT_FUNCTION (line 147) | static PHP_MINIT_FUNCTION(objects2)
FILE: codes/objects3/objects3.c
type hello_object (line 35) | typedef struct _hello_object {
function hello_dtor (line 79) | static void hello_dtor(hello_object *objval TSRMLS_CC) {
function zend_object_value (line 88) | static zend_object_value hello_ctor(zend_class_entry *ce TSRMLS_DC) {
function zend_object_value (line 105) | static zend_object_value hello_ctor_ex(hello_object **pobjval, zend_clas...
function zend_object_value (line 125) | static zend_object_value hello_clone(zval *zobject TSRMLS_DC) {
function zval (line 143) | static zval *hello_get(zval *zobject TSRMLS_CC) {
function hello_count_elements (line 152) | static int hello_count_elements(zval *object, long *count TSRMLS_DC) {
function HashTable (line 159) | static HashTable* hello_get_debug_info(zval *object, int *is_temp TSRMLS...
function hello_compare_objects (line 175) | static int hello_compare_objects(zval *object1, zval *object2 TSRMLS_DC) {
function zval (line 191) | static zval* hello_read_property(zval *object, zval *member, int type, c...
function hello_get_class_name (line 197) | static int hello_get_class_name(const zval *object, const char **class_n...
function PHP_MINIT_FUNCTION (line 205) | PHP_MINIT_FUNCTION(objects3){
FILE: codes/objects3/objects3.php
function bool2str (line 35) | function bool2str($bool){
FILE: codes/params/params.c
function PHP_FUNCTION (line 43) | static PHP_FUNCTION(params_str) {
function PHP_FUNCTION (line 67) | static PHP_FUNCTION(params_add) {
function PHP_FUNCTION (line 82) | static PHP_FUNCTION(params_dump) {
function PHP_FUNCTION (line 132) | static PHP_FUNCTION(params_array) {
FILE: codes/params/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 245) | function write_information($show_html)
function save_or_mail_results (line 315) | function save_or_mail_results()
function find_files (line 871) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 907) | function test_name($name)
function test_sort (line 916) | function test_sort($a, $b)
function mail_qa_team (line 977) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1024) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1049) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1066) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1130) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1162) | function show_file_block($file, $block, $section = null)
function run_test (line 1181) | function run_test($php, $file, $env)
function comp_line (line 2132) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2141) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2183) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2250) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2260) | function error($message)
function settings2array (line 2266) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2320) | function compute_summary()
function get_summary (line 2348) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2481) | function show_start($start_time)
function show_end (line 2493) | function show_end($end_time)
function show_summary (line 2505) | function show_summary()
function show_redirect_start (line 2516) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2532) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2548) | function show_test($test_idx, $shortname)
function show_result (line 2559) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2615) | function junit_init() {
function junit_save_xml (line 2640) | function junit_save_xml() {
function junit_get_suite_xml (line 2651) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2678) | function junit_enabled() {
function junit_mark_test_as (line 2692) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2740) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2747) | function junit_get_timer($file_name) {
function junit_start_timer (line 2758) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2771) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2775) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2780) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2801) | function junit_finish_timer($file_name) {
FILE: codes/php_hello/php_hello.c
function PHP_MINIT_FUNCTION (line 94) | PHP_MINIT_FUNCTION(php_hello)
function PHP_MSHUTDOWN_FUNCTION (line 105) | PHP_MSHUTDOWN_FUNCTION(php_hello)
function PHP_RINIT_FUNCTION (line 117) | PHP_RINIT_FUNCTION(php_hello)
function PHP_RSHUTDOWN_FUNCTION (line 126) | PHP_RSHUTDOWN_FUNCTION(php_hello)
function PHP_MINFO_FUNCTION (line 134) | PHP_MINFO_FUNCTION(php_hello)
function PHP_FUNCTION (line 154) | PHP_FUNCTION(confirm_php_hello_compiled)
FILE: codes/php_hello/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 245) | function write_information($show_html)
function save_or_mail_results (line 315) | function save_or_mail_results()
function find_files (line 871) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 907) | function test_name($name)
function test_sort (line 916) | function test_sort($a, $b)
function mail_qa_team (line 977) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1024) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1049) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1066) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1130) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1162) | function show_file_block($file, $block, $section = null)
function run_test (line 1181) | function run_test($php, $file, $env)
function comp_line (line 2132) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2141) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2183) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2250) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2260) | function error($message)
function settings2array (line 2266) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2320) | function compute_summary()
function get_summary (line 2348) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2481) | function show_start($start_time)
function show_end (line 2493) | function show_end($end_time)
function show_summary (line 2505) | function show_summary()
function show_redirect_start (line 2516) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2532) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2548) | function show_test($test_idx, $shortname)
function show_result (line 2559) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2615) | function junit_init() {
function junit_save_xml (line 2640) | function junit_save_xml() {
function junit_get_suite_xml (line 2651) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2678) | function junit_enabled() {
function junit_mark_test_as (line 2692) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2740) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2747) | function junit_get_timer($file_name) {
function junit_start_timer (line 2758) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2771) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2775) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2780) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2801) | function junit_finish_timer($file_name) {
FILE: codes/resource/resource.c
type person (line 33) | typedef struct _person {
function PHP_FUNCTION (line 43) | static PHP_FUNCTION(person_create) {
function PHP_FUNCTION (line 66) | static PHP_FUNCTION(person_get_name) {
function PHP_FUNCTION (line 81) | static PHP_FUNCTION(person_set_age) {
function person_dtor (line 127) | static void person_dtor(void *pers) {
function PHP_MINIT_FUNCTION (line 139) | PHP_MINIT_FUNCTION(resource){
FILE: codes/resource/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 247) | function write_information($show_html)
function save_or_mail_results (line 318) | function save_or_mail_results()
function find_files (line 874) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 910) | function test_name($name)
function test_sort (line 919) | function test_sort($a, $b)
function mail_qa_team (line 980) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1027) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1052) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1069) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1133) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1165) | function show_file_block($file, $block, $section = null)
function run_test (line 1184) | function run_test($php, $file, $env)
function comp_line (line 2135) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2144) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2186) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2253) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2263) | function error($message)
function settings2array (line 2269) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2323) | function compute_summary()
function get_summary (line 2351) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2484) | function show_start($start_time)
function show_end (line 2496) | function show_end($end_time)
function show_summary (line 2508) | function show_summary()
function show_redirect_start (line 2519) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2535) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2551) | function show_test($test_idx, $shortname)
function show_result (line 2562) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2618) | function junit_init() {
function junit_save_xml (line 2643) | function junit_save_xml() {
function junit_get_suite_xml (line 2654) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2681) | function junit_enabled() {
function junit_mark_test_as (line 2695) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2746) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2753) | function junit_get_timer($file_name) {
function junit_start_timer (line 2764) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2777) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2781) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2786) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2807) | function junit_finish_timer($file_name) {
FILE: codes/return/return.c
function PHP_FUNCTION (line 31) | static PHP_FUNCTION(return_null) {
function PHP_FUNCTION (line 36) | static PHP_FUNCTION(return_bool) {
function PHP_FUNCTION (line 42) | static PHP_FUNCTION(return_string) {
function PHP_FUNCTION (line 47) | static PHP_FUNCTION(return_string1) {
function PHP_FUNCTION (line 53) | static PHP_FUNCTION(return_double) {
function PHP_FUNCTION (line 58) | static PHP_FUNCTION(return_long) {
function PHP_FUNCTION (line 63) | static PHP_FUNCTION(return_array) {
function PHP_FUNCTION (line 83) | static PHP_FUNCTION(return_object) {
FILE: codes/return/run-tests.php
function verify_config (line 177) | function verify_config()
function write_information (line 245) | function write_information($show_html)
function save_or_mail_results (line 315) | function save_or_mail_results()
function find_files (line 871) | function find_files($dir, $is_ext_dir = false, $ignore = false)
function test_name (line 907) | function test_name($name)
function test_sort (line 916) | function test_sort($a, $b)
function mail_qa_team (line 977) | function mail_qa_team($data, $compression, $status = false)
function save_text (line 1024) | function save_text($filename, $text, $filename_copy = null)
function error_report (line 1049) | function error_report($testname, $logname, $tested)
function system_with_timeout (line 1066) | function system_with_timeout($commandline, $env = null, $stdin = null)
function run_all_tests (line 1130) | function run_all_tests($test_files, $env, $redir_tested = null)
function show_file_block (line 1162) | function show_file_block($file, $block, $section = null)
function run_test (line 1181) | function run_test($php, $file, $env)
function comp_line (line 2132) | function comp_line($l1, $l2, $is_reg)
function count_array_diff (line 2141) | function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, ...
function generate_array_diff (line 2183) | function generate_array_diff($ar1, $ar2, $is_reg, $w)
function generate_diff (line 2250) | function generate_diff($wanted, $wanted_re, $output)
function error (line 2260) | function error($message)
function settings2array (line 2266) | function settings2array($settings, &$ini_settings)
function compute_summary (line 2320) | function compute_summary()
function get_summary (line 2348) | function get_summary($show_ext_summary, $show_html)
function show_start (line 2481) | function show_start($start_time)
function show_end (line 2493) | function show_end($end_time)
function show_summary (line 2505) | function show_summary()
function show_redirect_start (line 2516) | function show_redirect_start($tests, $tested, $tested_file)
function show_redirect_ends (line 2532) | function show_redirect_ends($tests, $tested, $tested_file)
function show_test (line 2548) | function show_test($test_idx, $shortname)
function show_result (line 2559) | function show_result($result, $tested, $tested_file, $extra = '', $temp_...
function junit_init (line 2615) | function junit_init() {
function junit_save_xml (line 2640) | function junit_save_xml() {
function junit_get_suite_xml (line 2651) | function junit_get_suite_xml($suite_name = '') {
function junit_enabled (line 2678) | function junit_enabled() {
function junit_mark_test_as (line 2692) | function junit_mark_test_as($type, $file_name, $test_name, $time = null,...
function junit_suite_record (line 2740) | function junit_suite_record($suite, $param, $value = 1) {
function junit_get_timer (line 2747) | function junit_get_timer($file_name) {
function junit_start_timer (line 2758) | function junit_start_timer($file_name) {
function junit_get_suitename_for (line 2771) | function junit_get_suitename_for($file_name) {
function junit_path_to_classname (line 2775) | function junit_path_to_classname($file_name) {
function junit_init_suite (line 2780) | function junit_init_suite($suite_name) {
function junit_finish_timer (line 2801) | function junit_finish_timer($file_name) {
FILE: codes/zval1/zval1.c
function PHP_MINIT_FUNCTION (line 106) | PHP_MINIT_FUNCTION(zval1)
function PHP_MSHUTDOWN_FUNCTION (line 117) | PHP_MSHUTDOWN_FUNCTION(zval1)
function PHP_RINIT_FUNCTION (line 129) | PHP_RINIT_FUNCTION(zval1)
function PHP_RSHUTDOWN_FUNCTION (line 138) | PHP_RSHUTDOWN_FUNCTION(zval1)
function PHP_MINFO_FUNCTION (line 146) | PHP_MINFO_FUNCTION(zval1)
function PHP_FUNCTION (line 166) | PHP_FUNCTION(dump_zval_type)
function PHP_FUNCTION (line 178) | PHP_FUNCTION(dump_zval_value)
function PHP_FUNCTION (line 219) | PHP_FUNCTION(convert_zval)
Copy disabled (too large)
Download .json
Condensed preview — 528 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (26,447K chars).
[
{
"path": "001.md",
"chars": 3930,
"preview": "# gdb调试PHP扩展函数\n\n1,编译debug版的php\n\n\tgit clone https://github.com/php/php-src.git\n\tcd php-src\n\tCFLAGS=-ggdb3\n\t./configure --"
},
{
"path": "002.md",
"chars": 10134,
"preview": "# 常用全局宏\n\n1,创建一个新的扩展\n\n\t./ext_skel --extname=globals\n\n2,常用全局宏\n\n\t\nA) SG() SAPI Globals (main/SAPI.h)\n\n\ttypedef struct {\n\t"
},
{
"path": "003.md",
"chars": 8527,
"preview": "# ZVAL\n\n1,创建一个新的扩展\n\n\t./ext_skel --extname=zval1\n\t\n2,zval结构\n\t\n\t#Zend/zend.h \n\ttypedef union _zvalue_value {\n\t\tlong lval;\t"
},
{
"path": "004.md",
"chars": 7284,
"preview": "# ZendMM\r\n\r\n1, php内存管理内置函数\r\n\r\n void *emalloc(size_t size) 分配 size 字节的内存。\r\n v"
},
{
"path": "01.md",
"chars": 976,
"preview": "# 创建一个新的扩展\n\n1,下载php源码\n\n\tgit clone https://github.com/php/php-src.git\n\n2,创建扩展\n\nPHP提供了一个命令用于生成扩展的基本文件架构,只要调用该命令即可。\n\n\tcd ph"
},
{
"path": "02.md",
"chars": 5159,
"preview": "# 参数传递\n\n1,创建一个新的扩展\n\n\t./ext_skel --extname=params\n\n2,修改config.m4,去掉没用的注释语句\n\t\n\tcd params\n\tvi config.m4\n\t\n3,编写代码\n\t\n\tvi php_"
},
{
"path": "03.md",
"chars": 13472,
"preview": "# 返回值\n\n1,创建一个新的扩展\n\n\t./ext_skel --extname=return\n\t\n2,修改config.m4,去掉没用的注释语句\n\t\n\tcd return\n\tvi config.m4\n\t\n3,zend引擎在每个zif函数里"
},
{
"path": "04.md",
"chars": 5294,
"preview": "# INI参数设置\n\n## 创建一个新的扩展\n\n+ 生成扩展\n\n```\n./ext_skel --extname=inis\n```\n\n+ config.m4\n\n```\nPHP_ARG_ENABLE(inis, whether to enab"
},
{
"path": "05.md",
"chars": 4844,
"preview": "# 数组\n\n1,创建一个扩展\n\n```shell\n./ext_skel --extname=array\n```\n\n2,hashTable函数说明\n\n```c\ntypedef struct bucket {\n\tulong h;\t\t\t\t\t\t/*"
},
{
"path": "06.md",
"chars": 4249,
"preview": "# Global变量\n\n1,创建一个扩展\n\t\n\t./ext_skel --extname=global\n\t\n\t\n2,扩展global变量\n\n\t/*定义global变量*/\n\tZEND_BEGIN_MODULE_GLOBALS(global)"
},
{
"path": "07.md",
"chars": 2730,
"preview": "# 常量\n\n1,创建一个扩展\n\t\n\t./ext_skel --extname=consts\n\t\n\t\n2,代码\n\n\t/*定义一个long类型的常量,\n\t名字: CONSTS_MEANING_OF_LIFE,\n\t值: 42\n\tCONST_CS:"
},
{
"path": "08.md",
"chars": 1036,
"preview": "# 调用php函数\n\n1,创建新的扩展\n\n\t./ext_skel --extname=fcall\n\t\n2,代码\n\n\ttypedef struct _zend_fcall_info {\n\t\tsize_t size;\n\t\tHashTable *"
},
{
"path": "09.md",
"chars": 10268,
"preview": "# 类与对像1\n\n1,创建一个扩展\n\n\t./ext_skel --extname=objects1\n\n2,zend_class_entry结构\n\n\tstruct _zend_class_entry {\n\t\tchar type;\n \t\t"
},
{
"path": "10.md",
"chars": 3680,
"preview": "# 类与对像2(自定义object存储)\n\n1,创建一个扩展\n\t\n\t./ext_skel --extname=objects2\n\t\n\n2,代码\n\t\n\t//定义一个结构用于存储object\n\ttypedef struct _hello_obj"
},
{
"path": "11.md",
"chars": 5449,
"preview": "# 类与对像3(object handlers)\n\n1,创建一个扩展\n\t\n\t./ext_skel --extname=objects3\n\t\n2,object handlers定义\n\n\n\ttypedef zval *(*zend_object"
},
{
"path": "12.md",
"chars": 3807,
"preview": "# 资源类型\n\n1,创建一个扩展\n\n\t./ext_skel --extname=resource\n\t\n2,操作函数\n\n\t/*resource类型在内核中的定义*/\t\n\ttypedef struct _zend_rsrc_list_entry"
},
{
"path": "13.md",
"chars": 1219,
"preview": "# 包装第三方库\n\n1,创建一个扩展\n\t\n\t./ext_skel --extname=libs\n\t\n2,配置(config.m4)\n\n\tSEARCH_PATH=\"/usr/local /usr\" #lib搜索的目录\n \tSEARC"
},
{
"path": "14.md",
"chars": 4216,
"preview": "# output操作\r\n\r\n1,创建一个新的扩展\r\n\r\n ./ext_skel --extname=output1\r\n\r\n2,修改config.m4,去掉没用的注释语句\r\n \r\n cd output1\r\n vi co"
},
{
"path": "README.md",
"chars": 694,
"preview": "# PHP扩展开发笔记\n\n#### 目录\n\n[1,创建一个新的扩展](./01.md)\n\n[2,参数传递](./02.md)\n\n[3,返回值](./03.md)\n\n[4,INI参数设置](./04.md)\n\n[5,数组](./05.md)\n"
},
{
"path": "codes/array/.deps",
"chars": 0,
"preview": ""
},
{
"path": "codes/array/.libs/array.lai",
"chars": 803,
"preview": "# array.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n#"
},
{
"path": "codes/array/.libs/array.so.dSYM/Contents/Info.plist",
"chars": 637,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.c"
},
{
"path": "codes/array/.svnignore",
"chars": 16,
"preview": ".deps\n*.lo\n*.la\n"
},
{
"path": "codes/array/CREDITS",
"chars": 6,
"preview": "array\n"
},
{
"path": "codes/array/EXPERIMENTAL",
"chars": 0,
"preview": ""
},
{
"path": "codes/array/Makefile",
"chars": 9101,
"preview": "srcdir = /Users/kentchen/GitHub/php/php-5.5.20/ext/array\nbuilddir = /Users/kentchen/GitHub/php/php-5.5.20/ext/array\ntop_"
},
{
"path": "codes/array/Makefile.fragments",
"chars": 0,
"preview": ""
},
{
"path": "codes/array/Makefile.global",
"chars": 6734,
"preview": "mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p\nINSTALL = $(top_srcdir)/build/shtool install -c\nINSTALL_DATA = $(INS"
},
{
"path": "codes/array/Makefile.objects",
"chars": 660,
"preview": "array.lo: /Users/kentchen/GitHub/php/php-5.5.20/ext/array/array.c\n\t$(LIBTOOL) --mode=compile $(CC) -I. -I/Users/kentche"
},
{
"path": "codes/array/acinclude.m4",
"chars": 79850,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/array/aclocal.m4",
"chars": 310225,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/array/array.c",
"chars": 4557,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/array/array.la",
"chars": 802,
"preview": "# array.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n#"
},
{
"path": "codes/array/array.lo",
"chars": 301,
"preview": "# array.lo - a libtool object file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n# "
},
{
"path": "codes/array/array.php",
"chars": 413,
"preview": "<?php\n$br = (php_sapi_name() == \"cli\")? \"\":\"<br>\";\n\nif(!extension_loaded('array')) {\n\tdl('array.' . PHP_SHLIB_SUFFIX);\n}"
},
{
"path": "codes/array/autom4te.cache/output.0",
"chars": 438105,
"preview": "@%:@! /bin/sh\n@%:@ Guess values for system-dependent variables and create Makefiles.\n@%:@ Generated by GNU Autoconf 2.69"
},
{
"path": "codes/array/autom4te.cache/requests",
"chars": 3366,
"preview": "# This file was generated.\n# It contains the lists of macros which have been traced.\n# It can be safely removed.\n\n@reque"
},
{
"path": "codes/array/autom4te.cache/traces.0",
"chars": 32406,
"preview": "m4trace:configure.in:4: -1- AC_INIT([config.m4])\nm4trace:configure.in:4: -1- m4_pattern_forbid([^_?A[CHUM]_])\nm4trace:co"
},
{
"path": "codes/array/build/libtool.m4",
"chars": 230375,
"preview": "# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-\n## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 20"
},
{
"path": "codes/array/build/mkdep.awk",
"chars": 2225,
"preview": "# +----------------------------------------------------------------------+\n# | PHP Version 5 "
},
{
"path": "codes/array/build/scan_makefile_in.awk",
"chars": 410,
"preview": "BEGIN {\n\tmode=0\n\tsources=\"\"\n}\n\t\nmode == 0 && /^LTLIBRARY_SOURCES.*\\\\$/ {\n\tif (match($0, \"[^=]*$\")) {\n\tsources=substr($0,"
},
{
"path": "codes/array/build/shtool",
"chars": 65749,
"preview": "#!/bin/sh\n##\n## GNU shtool -- The GNU Portable Shell Tool\n## Copyright (c) 1994-2008 Ralf S. Engelschall <rse@engelsch"
},
{
"path": "codes/array/config.guess",
"chars": 45079,
"preview": "#! /bin/sh\n# Attempt to guess a canonical system name.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,"
},
{
"path": "codes/array/config.h",
"chars": 1725,
"preview": "/* config.h. Generated from config.h.in by configure. */\n/* config.h.in. Generated from configure.in by autoheader. "
},
{
"path": "codes/array/config.h.in",
"chars": 1600,
"preview": "/* config.h.in. Generated from configure.in by autoheader. */\n\n/* Whether to build array as dynamic module */\n#undef C"
},
{
"path": "codes/array/config.log",
"chars": 19649,
"preview": "This file contains any messages produced by compilers while\nrunning configure, to aid debugging if configure makes a mis"
},
{
"path": "codes/array/config.m4",
"chars": 196,
"preview": "PHP_ARG_ENABLE(array, whether to enable array support,\n [ --enable-array Enable array support])\n\nif test \"$P"
},
{
"path": "codes/array/config.nice",
"chars": 91,
"preview": "#! /bin/sh\n#\n# Created by configure\n\n'./configure' \\\n'--with-php-config=php-config' \\\n\"$@\"\n"
},
{
"path": "codes/array/config.status",
"chars": 21188,
"preview": "#! /bin/sh\n# Generated by configure.\n# Run this file to recreate the current configuration.\n# Compiler output produced b"
},
{
"path": "codes/array/config.sub",
"chars": 35782,
"preview": "#! /bin/sh\n# Configuration validation subroutine script.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 199"
},
{
"path": "codes/array/config.w32",
"chars": 289,
"preview": "// $Id$\n// vim:ft=javascript\n\n// If your extension references something external, use ARG_WITH\n// ARG_WITH(\"array\", \"for"
},
{
"path": "codes/array/configure",
"chars": 437057,
"preview": "#! /bin/sh\n# Guess values for system-dependent variables and create Makefiles.\n# Generated by GNU Autoconf 2.69.\n#\n#\n# C"
},
{
"path": "codes/array/configure.in",
"chars": 4690,
"preview": "dnl This file becomes configure.in for self-contained extensions.\n\nAC_PREREQ(2.59)\nAC_INIT(config.m4)\nifdef([AC_PRESERVE"
},
{
"path": "codes/array/install-sh",
"chars": 0,
"preview": ""
},
{
"path": "codes/array/libtool",
"chars": 211096,
"preview": "#! /bin/sh\n\n# libtoolT - Provide generalized library-building support services.\n# Generated automatically by (GNU )\n# "
},
{
"path": "codes/array/ltmain.sh",
"chars": 199728,
"preview": "# ltmain.sh - Provide generalized library-building support services.\n# NOTE: Changing this file will not affect anything"
},
{
"path": "codes/array/missing",
"chars": 0,
"preview": ""
},
{
"path": "codes/array/mkinstalldirs",
"chars": 0,
"preview": ""
},
{
"path": "codes/array/php_array.h",
"chars": 1899,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/array/run-tests.php",
"chars": 79874,
"preview": "#!/usr/bin/env php\n<?php\n/*\n +----------------------------------------------------------------------+\n | PHP Version"
},
{
"path": "codes/array/tests/001.phpt",
"chars": 537,
"preview": "--TEST--\nCheck for array presence\n--SKIPIF--\n<?php if (!extension_loaded(\"array\")) print \"skip\"; ?>\n--FILE--\n<?php \necho"
},
{
"path": "codes/consts/.deps",
"chars": 0,
"preview": ""
},
{
"path": "codes/consts/.libs/consts.lai",
"chars": 810,
"preview": "# consts.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n"
},
{
"path": "codes/consts/.libs/consts.so.dSYM/Contents/Info.plist",
"chars": 638,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.c"
},
{
"path": "codes/consts/.svnignore",
"chars": 16,
"preview": ".deps\n*.lo\n*.la\n"
},
{
"path": "codes/consts/CREDITS",
"chars": 7,
"preview": "consts\n"
},
{
"path": "codes/consts/EXPERIMENTAL",
"chars": 0,
"preview": ""
},
{
"path": "codes/consts/Makefile",
"chars": 9125,
"preview": "srcdir = /Users/kentchen/GitHub/php/php-5.5.20/ext/consts\nbuilddir = /Users/kentchen/GitHub/php/php-5.5.20/ext/consts\nto"
},
{
"path": "codes/consts/Makefile.fragments",
"chars": 0,
"preview": ""
},
{
"path": "codes/consts/Makefile.global",
"chars": 6734,
"preview": "mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p\nINSTALL = $(top_srcdir)/build/shtool install -c\nINSTALL_DATA = $(INS"
},
{
"path": "codes/consts/Makefile.objects",
"chars": 675,
"preview": "consts.lo: /Users/kentchen/GitHub/php/php-5.5.20/ext/consts/consts.c\n\t$(LIBTOOL) --mode=compile $(CC) -I. -I/Users/kent"
},
{
"path": "codes/consts/acinclude.m4",
"chars": 79850,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/consts/aclocal.m4",
"chars": 310225,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/consts/autom4te.cache/output.0",
"chars": 438175,
"preview": "@%:@! /bin/sh\n@%:@ Guess values for system-dependent variables and create Makefiles.\n@%:@ Generated by GNU Autoconf 2.69"
},
{
"path": "codes/consts/autom4te.cache/requests",
"chars": 3366,
"preview": "# This file was generated.\n# It contains the lists of macros which have been traced.\n# It can be safely removed.\n\n@reque"
},
{
"path": "codes/consts/autom4te.cache/traces.0",
"chars": 32411,
"preview": "m4trace:configure.in:4: -1- AC_INIT([config.m4])\nm4trace:configure.in:4: -1- m4_pattern_forbid([^_?A[CHUM]_])\nm4trace:co"
},
{
"path": "codes/consts/build/libtool.m4",
"chars": 230375,
"preview": "# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-\n## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 20"
},
{
"path": "codes/consts/build/mkdep.awk",
"chars": 2225,
"preview": "# +----------------------------------------------------------------------+\n# | PHP Version 5 "
},
{
"path": "codes/consts/build/scan_makefile_in.awk",
"chars": 410,
"preview": "BEGIN {\n\tmode=0\n\tsources=\"\"\n}\n\t\nmode == 0 && /^LTLIBRARY_SOURCES.*\\\\$/ {\n\tif (match($0, \"[^=]*$\")) {\n\tsources=substr($0,"
},
{
"path": "codes/consts/build/shtool",
"chars": 65749,
"preview": "#!/bin/sh\n##\n## GNU shtool -- The GNU Portable Shell Tool\n## Copyright (c) 1994-2008 Ralf S. Engelschall <rse@engelsch"
},
{
"path": "codes/consts/config.guess",
"chars": 45079,
"preview": "#! /bin/sh\n# Attempt to guess a canonical system name.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,"
},
{
"path": "codes/consts/config.h",
"chars": 1727,
"preview": "/* config.h. Generated from config.h.in by configure. */\n/* config.h.in. Generated from configure.in by autoheader. "
},
{
"path": "codes/consts/config.h.in",
"chars": 1602,
"preview": "/* config.h.in. Generated from configure.in by autoheader. */\n\n/* Whether to build consts as dynamic module */\n#undef "
},
{
"path": "codes/consts/config.log",
"chars": 19650,
"preview": "This file contains any messages produced by compilers while\nrunning configure, to aid debugging if configure makes a mis"
},
{
"path": "codes/consts/config.m4",
"chars": 203,
"preview": "PHP_ARG_ENABLE(consts, whether to enable consts support,\n [ --enable-consts Enable consts support])\n\nif test"
},
{
"path": "codes/consts/config.nice",
"chars": 91,
"preview": "#! /bin/sh\n#\n# Created by configure\n\n'./configure' \\\n'--with-php-config=php-config' \\\n\"$@\"\n"
},
{
"path": "codes/consts/config.status",
"chars": 21190,
"preview": "#! /bin/sh\n# Generated by configure.\n# Run this file to recreate the current configuration.\n# Compiler output produced b"
},
{
"path": "codes/consts/config.sub",
"chars": 35782,
"preview": "#! /bin/sh\n# Configuration validation subroutine script.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 199"
},
{
"path": "codes/consts/config.w32",
"chars": 296,
"preview": "// $Id$\n// vim:ft=javascript\n\n// If your extension references something external, use ARG_WITH\n// ARG_WITH(\"consts\", \"fo"
},
{
"path": "codes/consts/configure",
"chars": 437127,
"preview": "#! /bin/sh\n# Guess values for system-dependent variables and create Makefiles.\n# Generated by GNU Autoconf 2.69.\n#\n#\n# C"
},
{
"path": "codes/consts/configure.in",
"chars": 4690,
"preview": "dnl This file becomes configure.in for self-contained extensions.\n\nAC_PREREQ(2.59)\nAC_INIT(config.m4)\nifdef([AC_PRESERVE"
},
{
"path": "codes/consts/consts.c",
"chars": 5581,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/consts/consts.la",
"chars": 809,
"preview": "# consts.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n"
},
{
"path": "codes/consts/consts.lo",
"chars": 303,
"preview": "# consts.lo - a libtool object file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n#"
},
{
"path": "codes/consts/consts.php",
"chars": 343,
"preview": "<?php\n$br = (php_sapi_name() == \"cli\")? \"\":\"<br>\";\n\nif(!extension_loaded('consts')) {\n\tdl('consts.' . PHP_SHLIB_SUFFIX);"
},
{
"path": "codes/consts/install-sh",
"chars": 0,
"preview": ""
},
{
"path": "codes/consts/libtool",
"chars": 211096,
"preview": "#! /bin/sh\n\n# libtoolT - Provide generalized library-building support services.\n# Generated automatically by (GNU )\n# "
},
{
"path": "codes/consts/ltmain.sh",
"chars": 199728,
"preview": "# ltmain.sh - Provide generalized library-building support services.\n# NOTE: Changing this file will not affect anything"
},
{
"path": "codes/consts/missing",
"chars": 0,
"preview": ""
},
{
"path": "codes/consts/mkinstalldirs",
"chars": 0,
"preview": ""
},
{
"path": "codes/consts/php_consts.h",
"chars": 2862,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/consts/run-tests.php",
"chars": 79874,
"preview": "#!/usr/bin/env php\n<?php\n/*\n +----------------------------------------------------------------------+\n | PHP Version"
},
{
"path": "codes/consts/tests/001.phpt",
"chars": 541,
"preview": "--TEST--\nCheck for consts presence\n--SKIPIF--\n<?php if (!extension_loaded(\"consts\")) print \"skip\"; ?>\n--FILE--\n<?php \nec"
},
{
"path": "codes/fcall/.deps",
"chars": 0,
"preview": ""
},
{
"path": "codes/fcall/.libs/fcall.lai",
"chars": 803,
"preview": "# fcall.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n#"
},
{
"path": "codes/fcall/.libs/fcall.so.dSYM/Contents/Info.plist",
"chars": 637,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.c"
},
{
"path": "codes/fcall/.svnignore",
"chars": 16,
"preview": ".deps\n*.lo\n*.la\n"
},
{
"path": "codes/fcall/CREDITS",
"chars": 6,
"preview": "fcall\n"
},
{
"path": "codes/fcall/EXPERIMENTAL",
"chars": 0,
"preview": ""
},
{
"path": "codes/fcall/Makefile",
"chars": 9101,
"preview": "srcdir = /Users/kentchen/GitHub/php/php-5.5.20/ext/fcall\nbuilddir = /Users/kentchen/GitHub/php/php-5.5.20/ext/fcall\ntop_"
},
{
"path": "codes/fcall/Makefile.fragments",
"chars": 0,
"preview": ""
},
{
"path": "codes/fcall/Makefile.global",
"chars": 6734,
"preview": "mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p\nINSTALL = $(top_srcdir)/build/shtool install -c\nINSTALL_DATA = $(INS"
},
{
"path": "codes/fcall/Makefile.objects",
"chars": 660,
"preview": "fcall.lo: /Users/kentchen/GitHub/php/php-5.5.20/ext/fcall/fcall.c\n\t$(LIBTOOL) --mode=compile $(CC) -I. -I/Users/kentche"
},
{
"path": "codes/fcall/acinclude.m4",
"chars": 79850,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/fcall/aclocal.m4",
"chars": 310225,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/fcall/autom4te.cache/output.0",
"chars": 438105,
"preview": "@%:@! /bin/sh\n@%:@ Guess values for system-dependent variables and create Makefiles.\n@%:@ Generated by GNU Autoconf 2.69"
},
{
"path": "codes/fcall/autom4te.cache/requests",
"chars": 3366,
"preview": "# This file was generated.\n# It contains the lists of macros which have been traced.\n# It can be safely removed.\n\n@reque"
},
{
"path": "codes/fcall/autom4te.cache/traces.0",
"chars": 32406,
"preview": "m4trace:configure.in:4: -1- AC_INIT([config.m4])\nm4trace:configure.in:4: -1- m4_pattern_forbid([^_?A[CHUM]_])\nm4trace:co"
},
{
"path": "codes/fcall/build/libtool.m4",
"chars": 230375,
"preview": "# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-\n## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 20"
},
{
"path": "codes/fcall/build/mkdep.awk",
"chars": 2225,
"preview": "# +----------------------------------------------------------------------+\n# | PHP Version 5 "
},
{
"path": "codes/fcall/build/scan_makefile_in.awk",
"chars": 410,
"preview": "BEGIN {\n\tmode=0\n\tsources=\"\"\n}\n\t\nmode == 0 && /^LTLIBRARY_SOURCES.*\\\\$/ {\n\tif (match($0, \"[^=]*$\")) {\n\tsources=substr($0,"
},
{
"path": "codes/fcall/build/shtool",
"chars": 65749,
"preview": "#!/bin/sh\n##\n## GNU shtool -- The GNU Portable Shell Tool\n## Copyright (c) 1994-2008 Ralf S. Engelschall <rse@engelsch"
},
{
"path": "codes/fcall/config.guess",
"chars": 45079,
"preview": "#! /bin/sh\n# Attempt to guess a canonical system name.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,"
},
{
"path": "codes/fcall/config.h",
"chars": 1725,
"preview": "/* config.h. Generated from config.h.in by configure. */\n/* config.h.in. Generated from configure.in by autoheader. "
},
{
"path": "codes/fcall/config.h.in",
"chars": 1600,
"preview": "/* config.h.in. Generated from configure.in by autoheader. */\n\n/* Whether to build fcall as dynamic module */\n#undef C"
},
{
"path": "codes/fcall/config.log",
"chars": 19648,
"preview": "This file contains any messages produced by compilers while\nrunning configure, to aid debugging if configure makes a mis"
},
{
"path": "codes/fcall/config.m4",
"chars": 196,
"preview": "PHP_ARG_ENABLE(fcall, whether to enable fcall support,\n [ --enable-fcall Enable fcall support])\n\nif test \"$P"
},
{
"path": "codes/fcall/config.nice",
"chars": 91,
"preview": "#! /bin/sh\n#\n# Created by configure\n\n'./configure' \\\n'--with-php-config=php-config' \\\n\"$@\"\n"
},
{
"path": "codes/fcall/config.status",
"chars": 21188,
"preview": "#! /bin/sh\n# Generated by configure.\n# Run this file to recreate the current configuration.\n# Compiler output produced b"
},
{
"path": "codes/fcall/config.sub",
"chars": 35782,
"preview": "#! /bin/sh\n# Configuration validation subroutine script.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 199"
},
{
"path": "codes/fcall/config.w32",
"chars": 289,
"preview": "// $Id$\n// vim:ft=javascript\n\n// If your extension references something external, use ARG_WITH\n// ARG_WITH(\"fcall\", \"for"
},
{
"path": "codes/fcall/configure",
"chars": 437057,
"preview": "#! /bin/sh\n# Guess values for system-dependent variables and create Makefiles.\n# Generated by GNU Autoconf 2.69.\n#\n#\n# C"
},
{
"path": "codes/fcall/configure.in",
"chars": 4690,
"preview": "dnl This file becomes configure.in for self-contained extensions.\n\nAC_PREREQ(2.59)\nAC_INIT(config.m4)\nifdef([AC_PRESERVE"
},
{
"path": "codes/fcall/fcall.c",
"chars": 4587,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/fcall/fcall.la",
"chars": 802,
"preview": "# fcall.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n#"
},
{
"path": "codes/fcall/fcall.lo",
"chars": 301,
"preview": "# fcall.lo - a libtool object file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n# "
},
{
"path": "codes/fcall/fcall.php",
"chars": 271,
"preview": "<?php\n$br = (php_sapi_name() == \"cli\")? \"\":\"<br>\";\n\nif(!extension_loaded('fcall')) {\n\tdl('fcall.' . PHP_SHLIB_SUFFIX);\n}"
},
{
"path": "codes/fcall/install-sh",
"chars": 0,
"preview": ""
},
{
"path": "codes/fcall/libtool",
"chars": 211096,
"preview": "#! /bin/sh\n\n# libtoolT - Provide generalized library-building support services.\n# Generated automatically by (GNU )\n# "
},
{
"path": "codes/fcall/ltmain.sh",
"chars": 199728,
"preview": "# ltmain.sh - Provide generalized library-building support services.\n# NOTE: Changing this file will not affect anything"
},
{
"path": "codes/fcall/missing",
"chars": 0,
"preview": ""
},
{
"path": "codes/fcall/mkinstalldirs",
"chars": 0,
"preview": ""
},
{
"path": "codes/fcall/php_fcall.h",
"chars": 1962,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/fcall/run-tests.php",
"chars": 79874,
"preview": "#!/usr/bin/env php\n<?php\n/*\n +----------------------------------------------------------------------+\n | PHP Version"
},
{
"path": "codes/fcall/tests/001.phpt",
"chars": 537,
"preview": "--TEST--\nCheck for fcall presence\n--SKIPIF--\n<?php if (!extension_loaded(\"fcall\")) print \"skip\"; ?>\n--FILE--\n<?php \necho"
},
{
"path": "codes/global/.deps",
"chars": 0,
"preview": ""
},
{
"path": "codes/global/.libs/global.lai",
"chars": 810,
"preview": "# global.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n"
},
{
"path": "codes/global/.libs/global.so.dSYM/Contents/Info.plist",
"chars": 638,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.c"
},
{
"path": "codes/global/.svnignore",
"chars": 16,
"preview": ".deps\n*.lo\n*.la\n"
},
{
"path": "codes/global/CREDITS",
"chars": 7,
"preview": "global\n"
},
{
"path": "codes/global/EXPERIMENTAL",
"chars": 0,
"preview": ""
},
{
"path": "codes/global/Makefile",
"chars": 9125,
"preview": "srcdir = /Users/kentchen/GitHub/php/php-5.5.20/ext/global\nbuilddir = /Users/kentchen/GitHub/php/php-5.5.20/ext/global\nto"
},
{
"path": "codes/global/Makefile.fragments",
"chars": 0,
"preview": ""
},
{
"path": "codes/global/Makefile.global",
"chars": 6734,
"preview": "mkinstalldirs = $(top_srcdir)/build/shtool mkdir -p\nINSTALL = $(top_srcdir)/build/shtool install -c\nINSTALL_DATA = $(INS"
},
{
"path": "codes/global/Makefile.objects",
"chars": 675,
"preview": "global.lo: /Users/kentchen/GitHub/php/php-5.5.20/ext/global/global.c\n\t$(LIBTOOL) --mode=compile $(CC) -I. -I/Users/kent"
},
{
"path": "codes/global/acinclude.m4",
"chars": 79850,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/global/aclocal.m4",
"chars": 310225,
"preview": "dnl\ndnl $Id$\ndnl\ndnl This file contains local autoconf functions.\ndnl\n\ndnl ---------------------------------------------"
},
{
"path": "codes/global/autom4te.cache/output.0",
"chars": 438175,
"preview": "@%:@! /bin/sh\n@%:@ Guess values for system-dependent variables and create Makefiles.\n@%:@ Generated by GNU Autoconf 2.69"
},
{
"path": "codes/global/autom4te.cache/requests",
"chars": 3366,
"preview": "# This file was generated.\n# It contains the lists of macros which have been traced.\n# It can be safely removed.\n\n@reque"
},
{
"path": "codes/global/autom4te.cache/traces.0",
"chars": 32411,
"preview": "m4trace:configure.in:4: -1- AC_INIT([config.m4])\nm4trace:configure.in:4: -1- m4_pattern_forbid([^_?A[CHUM]_])\nm4trace:co"
},
{
"path": "codes/global/build/libtool.m4",
"chars": 230375,
"preview": "# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-\n## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 20"
},
{
"path": "codes/global/build/mkdep.awk",
"chars": 2225,
"preview": "# +----------------------------------------------------------------------+\n# | PHP Version 5 "
},
{
"path": "codes/global/build/scan_makefile_in.awk",
"chars": 410,
"preview": "BEGIN {\n\tmode=0\n\tsources=\"\"\n}\n\t\nmode == 0 && /^LTLIBRARY_SOURCES.*\\\\$/ {\n\tif (match($0, \"[^=]*$\")) {\n\tsources=substr($0,"
},
{
"path": "codes/global/build/shtool",
"chars": 65749,
"preview": "#!/bin/sh\n##\n## GNU shtool -- The GNU Portable Shell Tool\n## Copyright (c) 1994-2008 Ralf S. Engelschall <rse@engelsch"
},
{
"path": "codes/global/config.guess",
"chars": 45079,
"preview": "#! /bin/sh\n# Attempt to guess a canonical system name.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,"
},
{
"path": "codes/global/config.h",
"chars": 1727,
"preview": "/* config.h. Generated from config.h.in by configure. */\n/* config.h.in. Generated from configure.in by autoheader. "
},
{
"path": "codes/global/config.h.in",
"chars": 1602,
"preview": "/* config.h.in. Generated from configure.in by autoheader. */\n\n/* Whether to build global as dynamic module */\n#undef "
},
{
"path": "codes/global/config.log",
"chars": 19650,
"preview": "This file contains any messages produced by compilers while\nrunning configure, to aid debugging if configure makes a mis"
},
{
"path": "codes/global/config.m4",
"chars": 203,
"preview": "PHP_ARG_ENABLE(global, whether to enable global support,\n [ --enable-global Enable global support])\n\nif test"
},
{
"path": "codes/global/config.nice",
"chars": 91,
"preview": "#! /bin/sh\n#\n# Created by configure\n\n'./configure' \\\n'--with-php-config=php-config' \\\n\"$@\"\n"
},
{
"path": "codes/global/config.status",
"chars": 21190,
"preview": "#! /bin/sh\n# Generated by configure.\n# Run this file to recreate the current configuration.\n# Compiler output produced b"
},
{
"path": "codes/global/config.sub",
"chars": 35782,
"preview": "#! /bin/sh\n# Configuration validation subroutine script.\n# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 199"
},
{
"path": "codes/global/config.w32",
"chars": 296,
"preview": "// $Id$\n// vim:ft=javascript\n\n// If your extension references something external, use ARG_WITH\n// ARG_WITH(\"global\", \"fo"
},
{
"path": "codes/global/configure",
"chars": 437127,
"preview": "#! /bin/sh\n# Guess values for system-dependent variables and create Makefiles.\n# Generated by GNU Autoconf 2.69.\n#\n#\n# C"
},
{
"path": "codes/global/configure.in",
"chars": 4690,
"preview": "dnl This file becomes configure.in for self-contained extensions.\n\nAC_PREREQ(2.59)\nAC_INIT(config.m4)\nifdef([AC_PRESERVE"
},
{
"path": "codes/global/global.c",
"chars": 6636,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/global/global.la",
"chars": 809,
"preview": "# global.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n"
},
{
"path": "codes/global/global.lo",
"chars": 303,
"preview": "# global.lo - a libtool object file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n#"
},
{
"path": "codes/global/global.php",
"chars": 637,
"preview": "<?php\n$br = (php_sapi_name() == \"cli\")? \"\":\"<br>\";\n\nif(!extension_loaded('global')) {\n\tdl('global.' . PHP_SHLIB_SUFFIX);"
},
{
"path": "codes/global/install-sh",
"chars": 0,
"preview": ""
},
{
"path": "codes/global/libtool",
"chars": 211096,
"preview": "#! /bin/sh\n\n# libtoolT - Provide generalized library-building support services.\n# Generated automatically by (GNU )\n# "
},
{
"path": "codes/global/ltmain.sh",
"chars": 199728,
"preview": "# ltmain.sh - Provide generalized library-building support services.\n# NOTE: Changing this file will not affect anything"
},
{
"path": "codes/global/missing",
"chars": 0,
"preview": ""
},
{
"path": "codes/global/mkinstalldirs",
"chars": 0,
"preview": ""
},
{
"path": "codes/global/php_global.h",
"chars": 2176,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/global/run-tests.php",
"chars": 79874,
"preview": "#!/usr/bin/env php\n<?php\n/*\n +----------------------------------------------------------------------+\n | PHP Version"
},
{
"path": "codes/global/tests/001.phpt",
"chars": 541,
"preview": "--TEST--\nCheck for global presence\n--SKIPIF--\n<?php if (!extension_loaded(\"global\")) print \"skip\"; ?>\n--FILE--\n<?php \nec"
},
{
"path": "codes/globalss/.svnignore",
"chars": 16,
"preview": ".deps\n*.lo\n*.la\n"
},
{
"path": "codes/globalss/CREDITS",
"chars": 9,
"preview": "globalss\n"
},
{
"path": "codes/globalss/EXPERIMENTAL",
"chars": 0,
"preview": ""
},
{
"path": "codes/globalss/config.m4",
"chars": 327,
"preview": " PHP_ARG_WITH(globalss, for globalss support,\n [ --with-globalss Include globalss support])\n\n PHP_ARG_ENA"
},
{
"path": "codes/globalss/config.w32",
"chars": 310,
"preview": "// $Id$\n// vim:ft=javascript\n\n// If your extension references something external, use ARG_WITH\n// ARG_WITH(\"globalss\", \""
},
{
"path": "codes/globalss/globalss.c",
"chars": 4525,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/globalss/globalss.php",
"chars": 190,
"preview": "<?php\n$br = (php_sapi_name() == \"cli\")? \"\":\"<br>\";\n\nif(!extension_loaded('globalss')) {\n\tdl('globalss.' . PHP_SHLIB_SUFF"
},
{
"path": "codes/globalss/php_globalss.h",
"chars": 2969,
"preview": "/*\n +----------------------------------------------------------------------+\n | PHP Version 5 "
},
{
"path": "codes/globalss/tests/001.phpt",
"chars": 549,
"preview": "--TEST--\nCheck for globalss presence\n--SKIPIF--\n<?php if (!extension_loaded(\"globalss\")) print \"skip\"; ?>\n--FILE--\n<?php"
},
{
"path": "codes/inis/.deps",
"chars": 0,
"preview": ""
},
{
"path": "codes/inis/.libs/inis.lai",
"chars": 796,
"preview": "# inis.la - a libtool library file\n# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.492 2008/01/30 06:40:56)\n#\n# "
},
{
"path": "codes/inis/.libs/inis.so.dSYM/Contents/Info.plist",
"chars": 636,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.c"
},
{
"path": "codes/inis/.svnignore",
"chars": 16,
"preview": ".deps\n*.lo\n*.la\n"
}
]
// ... and 328 more files (download for full content)
About this extraction
This page contains the full source code of the Leon2012/php-ext GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 528 files (23.7 MB), approximately 6.2M tokens, and a symbol index with 537 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.