Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
study
提交
ae2c1d54
S
study
项目概览
OpenDocCN
/
study
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
study
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ae2c1d54
编写于
5月 30, 2019
作者:
C
codinghuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify: 修改php_study.h、study.cc、study.h内容
上级
934c276c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
105 deletion
+58
-105
include/study.h
include/study.h
+43
-0
php_study.h
php_study.h
+14
-33
study.cc
study.cc
+1
-72
未找到文件。
include/study.h
0 → 100644
浏览文件 @
ae2c1d54
#ifndef STUDY_H_
#define STUDY_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
// include standard library
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <signal.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include <poll.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/mman.h>
#include <sys/ipc.h>
#include <sys/wait.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/stat.h>
#endif
/* STUDY_H_ */
\ No newline at end of file
php_study.h
浏览文件 @
ae2c1d54
...
...
@@ -12,20 +12,24 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: |
| Author:
codinghuang
|
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_STUDY_H
#define PHP_STUDY_H
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "study.h"
#define PHP_STUDY_VERSION "0.1.0"
extern
zend_module_entry
study_module_entry
;
#define phpext_study_ptr &study_module_entry
#define PHP_STUDY_VERSION "0.1.0"
/* Replace with version number for your extension */
#ifdef PHP_WIN32
# define PHP_STUDY_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
...
...
@@ -38,34 +42,11 @@ extern zend_module_entry study_module_entry;
#include "TSRM.h"
#endif
/*
Declare any global variables you may need between the BEGIN
and END macros here:
/**
* Declare any global variables you may need between the BEGIN and END macros here
*/
ZEND_BEGIN_MODULE_GLOBALS
(
study
)
zend_long global_value;
char *global_string;
ZEND_END_MODULE_GLOBALS(study)
*/
/* Always refer to the globals in your function as STUDY_G(variable).
You are encouraged to rename these macros something shorter, see
examples in any other php module directory.
*/
#define STUDY_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(study, v)
#if defined(ZTS) && defined(COMPILE_DL_STUDY)
ZEND_TSRMLS_CACHE_EXTERN
()
#endif
#endif
/* PHP_STUDY_H */
ZEND_END_MODULE_GLOBALS
(
study
)
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
#endif
/* PHP_STUDY_H */
\ No newline at end of file
study.c
→
study.c
c
浏览文件 @
ae2c1d54
...
...
@@ -12,74 +12,11 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: |
| Author:
codinghuang
|
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_study.h"
#include <pthread.h>
static
void
(
*
orig_interrupt_function
)(
zend_execute_data
*
execute_data
);
void
schedule
();
static
void
create_scheduler_thread
();
static
void
new_interrupt_function
(
zend_execute_data
*
execute_data
);
void
init
()
{
orig_interrupt_function
=
zend_interrupt_function
;
zend_interrupt_function
=
new_interrupt_function
;
}
static
void
new_interrupt_function
(
zend_execute_data
*
execute_data
)
{
php_printf
(
"yeild coroutine
\n
"
);
if
(
orig_interrupt_function
)
{
orig_interrupt_function
(
execute_data
);
}
}
void
schedule
()
{
while
(
1
)
{
EG
(
vm_interrupt
)
=
1
;
usleep
(
5000
);
}
}
static
void
create_scheduler_thread
()
{
pthread_t
pidt
;
if
(
pthread_create
(
&
pidt
,
NULL
,
(
void
*
(
*
)(
void
*
))
schedule
,
NULL
)
<
0
)
{
php_printf
(
"pthread_create[PHPCoroutine Scheduler] failed"
);
}
}
PHP_FUNCTION
(
start_interrupt
)
{
init
();
create_scheduler_thread
();
};
PHP_FUNCTION
(
test
)
{
zend_string
*
str
;
str
=
zend_string_init
(
"foo"
,
strlen
(
"foo"
),
0
);
php_printf
(
"This is my string: %s
\n
"
,
ZSTR_VAL
(
str
));
php_printf
(
"It is %zd char long
\n
"
,
ZSTR_LEN
(
str
));
zend_string_release
(
str
);
};
PHP_MINIT_FUNCTION
(
study
)
{
...
...
@@ -93,9 +30,6 @@ PHP_MSHUTDOWN_FUNCTION(study)
PHP_RINIT_FUNCTION
(
study
)
{
#if defined(COMPILE_DL_STUDY) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE
();
#endif
return
SUCCESS
;
}
...
...
@@ -112,8 +46,6 @@ PHP_MINFO_FUNCTION(study)
}
const
zend_function_entry
study_functions
[]
=
{
PHP_FE
(
start_interrupt
,
NULL
)
PHP_FE
(
test
,
NULL
)
PHP_FE_END
};
...
...
@@ -131,8 +63,5 @@ zend_module_entry study_module_entry = {
};
#ifdef COMPILE_DL_STUDY
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE
()
#endif
ZEND_GET_MODULE
(
study
)
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录