Skip to content
Browse files

Refactor

  • Loading branch information...
1 parent d7cf6de commit eadc530d1ebddd70b1cf78bca86d0fb9b64b6498 @rsky committed Sep 1, 2012
Showing with 92 additions and 92 deletions.
  1. +23 −23 device.c
  2. +50 −50 opencl.c
  3. +19 −19 platform.c
View
46 device.c
@@ -9,8 +9,8 @@
#include "device.h"
-#define get_info_func ((phpcl_get_info_func_t)phpcl_get_device_info)
-#define get_info_ex_func ((phpcl_get_info_ex_func_t)phpcl_get_device_info_ex)
+#define get_info ((phpcl_get_info_func_t)_get_device_info)
+#define get_info_ex ((phpcl_get_info_ex_func_t)_get_device_info_ex)
/* {{{ globals */
@@ -93,24 +93,24 @@ static const phpcl_info_param_t device_info_params[] = {
};
/* }}} */
-/* {{{ phpcl_get_device_info() */
-
-static cl_int phpcl_get_device_info(cl_device_id device,
- void *reserved __attribute__ ((unused)),
- cl_device_info name,
- size_t value_size,
- void *value,
- size_t *value_size_ret)
+/* {{{ _get_device_info() */
+
+static cl_int _get_device_info(cl_device_id device,
+ void *reserved __attribute__ ((unused)),
+ cl_device_info name,
+ size_t value_size,
+ void *value,
+ size_t *value_size_ret)
{
return clGetDeviceInfo(device, name, value_size, value, value_size_ret);
}
/* }}} */
-/* {{{ phpcl_get_device_info_ex() */
+/* {{{ _get_device_info_ex() */
-static zval *phpcl_get_device_info_ex(cl_device_id device,
- void *reserved,
- cl_device_info name TSRMLS_DC)
+static zval *_get_device_info_ex(cl_device_id device,
+ void *reserved,
+ cl_device_info name TSRMLS_DC)
{
cl_int err = CL_SUCCESS;
zval *zinfo;
@@ -149,9 +149,9 @@ static zval *phpcl_get_device_info_ex(cl_device_id device,
}
/* }}} */
-/* {{{ phpcl_get_device_info_all() */
+/* {{{ _get_device_info_all() */
-static void phpcl_get_device_info_all(INTERNAL_FUNCTION_PARAMETERS,
+static void _get_device_info_all(INTERNAL_FUNCTION_PARAMETERS,
cl_device_id device)
{
const phpcl_info_param_t *param = device_info_params;
@@ -162,7 +162,7 @@ static void phpcl_get_device_info_all(INTERNAL_FUNCTION_PARAMETERS,
add_assoc_string(return_value, "id", buf, 1);
while (param->key != NULL) {
- zval *entry = phpcl_get_info(get_info_func, get_info_ex_func,
+ zval *entry = phpcl_get_info(get_info, get_info_ex,
device, NULL, param TSRMLS_CC);
if (entry) {
add_assoc_zval(return_value, param->key, entry);
@@ -174,9 +174,9 @@ static void phpcl_get_device_info_all(INTERNAL_FUNCTION_PARAMETERS,
}
/* }}} */
-/* {{{ phpcl_get_device_info_by_name() */
+/* {{{ _get_device_info_by_name() */
-static void phpcl_get_device_info_by_name(INTERNAL_FUNCTION_PARAMETERS,
+static void _get_device_info_by_name(INTERNAL_FUNCTION_PARAMETERS,
cl_device_id device, cl_int name)
{
const phpcl_info_param_t *param = device_info_params;
@@ -185,7 +185,7 @@ static void phpcl_get_device_info_by_name(INTERNAL_FUNCTION_PARAMETERS,
while (param->key != NULL) {
if (param->name == name) {
- zval *entry = phpcl_get_info(get_info_func, get_info_ex_func,
+ zval *entry = phpcl_get_info(get_info, get_info_ex,
device, NULL, param TSRMLS_CC);
if (entry) {
RETVAL_ZVAL(entry, 0, 1);
@@ -260,7 +260,7 @@ PHP_FUNCTION(cl_get_device_ids)
}
/* }}} */
-/* {{{ array cl_get_device_info(resource cl_device_id device[, int name]) */
+/* {{{ mixed cl_get_device_info(resource cl_device_id device[, int name]) */
PHP_FUNCTION(cl_get_device_info)
{
@@ -278,9 +278,9 @@ PHP_FUNCTION(cl_get_device_info)
"cl_device_id", phpcl_le_device());
if (ZEND_NUM_ARGS() == 2) {
- phpcl_get_device_info_by_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, device, (cl_int)name);
+ _get_device_info_by_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, device, (cl_int)name);
} else {
- phpcl_get_device_info_all(INTERNAL_FUNCTION_PARAM_PASSTHRU, device);
+ _get_device_info_all(INTERNAL_FUNCTION_PARAM_PASSTHRU, device);
}
}
View
100 opencl.c
@@ -31,43 +31,43 @@ static PHP_MINIT_FUNCTION(opencl);
static PHP_MINFO_FUNCTION(opencl);
/* module function helpers */
-static void phpcl_register_constants(int module_number TSRMLS_DC);
-static void phpcl_register_resources(int module_number TSRMLS_DC);
+static void _register_constants(int module_number TSRMLS_DC);
+static void _register_resources(int module_number TSRMLS_DC);
/* resource destructors */
-static void phpcl_free_context(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-static void phpcl_free_command_queue(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-static void phpcl_free_mem(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-static void phpcl_free_program(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-static void phpcl_free_kernel(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-static void phpcl_free_event(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-static void phpcl_free_sampler(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void _free_context(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void _free_command_queue(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void _free_mem(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void _free_program(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void _free_kernel(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void _free_event(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void _free_sampler(zend_rsrc_list_entry *rsrc TSRMLS_DC);
/* internal destructors */
-static void phpcl_release_context(phpcl_context_t *ptr TSRMLS_DC);
-static void phpcl_release_command_queue(phpcl_command_queue_t *ptr TSRMLS_DC);
-static void phpcl_release_mem(phpcl_mem_t *ptr TSRMLS_DC);
-static void phpcl_release_program(phpcl_program_t *ptr TSRMLS_DC);
-static void phpcl_release_kernel(phpcl_kernel_t *ptr TSRMLS_DC);
-static void phpcl_release_event(phpcl_event_t *ptr TSRMLS_DC);
-static void phpcl_release_sampler(phpcl_sampler_t *ptr TSRMLS_DC);
+static void _release_context(phpcl_context_t *ptr TSRMLS_DC);
+static void _release_command_queue(phpcl_command_queue_t *ptr TSRMLS_DC);
+static void _release_mem(phpcl_mem_t *ptr TSRMLS_DC);
+static void _release_program(phpcl_program_t *ptr TSRMLS_DC);
+static void _release_kernel(phpcl_kernel_t *ptr TSRMLS_DC);
+static void _release_event(phpcl_event_t *ptr TSRMLS_DC);
+static void _release_sampler(phpcl_sampler_t *ptr TSRMLS_DC);
/* }}} */
/* {{{ argument informations */
/* platform */
-ZEND_BEGIN_ARG_INFO_EX(arg_info_cl_get_platform_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_platform_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
ZEND_ARG_INFO(0, platform)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()
/* device */
-ZEND_BEGIN_ARG_INFO_EX(arg_info_cl_get_device_ids, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_device_ids, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
ZEND_ARG_INFO(0, platform)
ZEND_ARG_INFO(0, device_type)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arg_info_cl_get_device_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_device_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
ZEND_ARG_INFO(0, device)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()
@@ -78,10 +78,10 @@ ZEND_END_ARG_INFO()
static zend_function_entry phpcl_functions[] = {
/* platform */
PHP_FE(cl_get_platform_ids, NULL)
- PHP_FE(cl_get_platform_info, arg_info_cl_get_platform_info)
+ PHP_FE(cl_get_platform_info, arginfo_get_platform_info)
/* device */
- PHP_FE(cl_get_device_ids, arg_info_cl_get_device_ids)
- PHP_FE(cl_get_device_info, arg_info_cl_get_device_info)
+ PHP_FE(cl_get_device_ids, arginfo_get_device_ids)
+ PHP_FE(cl_get_device_info, arginfo_get_device_info)
/* terminate */
{ NULL, NULL, NULL }
};
@@ -121,8 +121,8 @@ ZEND_GET_MODULE(opencl)
static PHP_MINIT_FUNCTION(opencl)
{
- phpcl_register_constants(module_number TSRMLS_CC);
- phpcl_register_resources(module_number TSRMLS_CC);
+ _register_constants(module_number TSRMLS_CC);
+ _register_resources(module_number TSRMLS_CC);
return SUCCESS;
}
@@ -292,12 +292,12 @@ int phpcl_le_sampler(void)
}
/* }}} */
-/* {{{ phpcl_register_constants() */
+/* {{{ _register_constants() */
#define PHP_CL_REGISTER_CONSTANT(name) \
REGISTER_LONG_CONSTANT(#name, name, CONST_PERSISTENT | CONST_CS)
-static void phpcl_register_constants(int module_number TSRMLS_DC)
+static void _register_constants(int module_number TSRMLS_DC)
{
/* Error Codes */
PHP_CL_REGISTER_CONSTANT(CL_SUCCESS);
@@ -663,13 +663,13 @@ static void phpcl_register_constants(int module_number TSRMLS_DC)
}
/* }}} */
-/* {{{ phpcl_register_resources() */
+/* {{{ _register_resources() */
#define PHP_CL_REGISTER_RESOURCE(name) \
le_##name = zend_register_list_destructors_ex(\
- phpcl_free_##name, NULL, "cl_" #name, module_number)
+ _free_##name, NULL, "cl_" #name, module_number)
-static void phpcl_register_resources(int module_number TSRMLS_DC)
+static void _register_resources(int module_number TSRMLS_DC)
{
le_platform = zend_register_list_destructors_ex(
NULL, NULL, "cl_platform", module_number);
@@ -687,81 +687,81 @@ static void phpcl_register_resources(int module_number TSRMLS_DC)
/* }}} */
/* {{{ resource destructors */
-static void phpcl_free_context(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_context(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- phpcl_release_context((phpcl_context_t *)rsrc->ptr TSRMLS_CC);
+ _release_context((phpcl_context_t *)rsrc->ptr TSRMLS_CC);
}
-static void phpcl_free_command_queue(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_command_queue(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- phpcl_release_command_queue((phpcl_command_queue_t *)rsrc->ptr TSRMLS_CC);
+ _release_command_queue((phpcl_command_queue_t *)rsrc->ptr TSRMLS_CC);
}
-static void phpcl_free_mem(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_mem(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- phpcl_release_mem((phpcl_mem_t *)rsrc->ptr TSRMLS_CC);
+ _release_mem((phpcl_mem_t *)rsrc->ptr TSRMLS_CC);
}
-static void phpcl_free_program(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_program(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- phpcl_release_program((phpcl_program_t *)rsrc->ptr TSRMLS_CC);
+ _release_program((phpcl_program_t *)rsrc->ptr TSRMLS_CC);
}
-static void phpcl_free_kernel(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_kernel(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- phpcl_release_kernel((phpcl_kernel_t *)rsrc->ptr TSRMLS_CC);
+ _release_kernel((phpcl_kernel_t *)rsrc->ptr TSRMLS_CC);
}
-static void phpcl_free_event(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_event(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- phpcl_release_event((phpcl_event_t *)rsrc->ptr TSRMLS_CC);
+ _release_event((phpcl_event_t *)rsrc->ptr TSRMLS_CC);
}
-static void phpcl_free_sampler(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _free_sampler(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- phpcl_release_sampler((phpcl_sampler_t *)rsrc->ptr TSRMLS_CC);
+ _release_sampler((phpcl_sampler_t *)rsrc->ptr TSRMLS_CC);
}
/* }}} */
/* {{{ internal destructors */
-static void phpcl_release_context(phpcl_context_t *ptr TSRMLS_DC)
+static void _release_context(phpcl_context_t *ptr TSRMLS_DC)
{
clReleaseContext(ptr->context);
efree(ptr);
}
-static void phpcl_release_command_queue(phpcl_command_queue_t *ptr TSRMLS_DC)
+static void _release_command_queue(phpcl_command_queue_t *ptr TSRMLS_DC)
{
clReleaseCommandQueue(ptr->command_queue);
efree(ptr);
}
-static void phpcl_release_mem(phpcl_mem_t *ptr TSRMLS_DC)
+static void _release_mem(phpcl_mem_t *ptr TSRMLS_DC)
{
clReleaseMemObject(ptr->mem);
efree(ptr);
}
-static void phpcl_release_program(phpcl_program_t *ptr TSRMLS_DC)
+static void _release_program(phpcl_program_t *ptr TSRMLS_DC)
{
clReleaseProgram(ptr->program);
efree(ptr);
}
-static void phpcl_release_kernel(phpcl_kernel_t *ptr TSRMLS_DC)
+static void _release_kernel(phpcl_kernel_t *ptr TSRMLS_DC)
{
clReleaseKernel(ptr->kernel);
efree(ptr);
}
-static void phpcl_release_event(phpcl_event_t *ptr TSRMLS_DC)
+static void _release_event(phpcl_event_t *ptr TSRMLS_DC)
{
clReleaseEvent(ptr->event);
efree(ptr);
}
-static void phpcl_release_sampler(phpcl_sampler_t *ptr TSRMLS_DC)
+static void _release_sampler(phpcl_sampler_t *ptr TSRMLS_DC)
{
clReleaseSampler(ptr->sampler);
efree(ptr);
View
38 platform.c
@@ -9,8 +9,8 @@
#include "platform.h"
-#define get_info_func ((phpcl_get_info_func_t)phpcl_get_platform_info)
-#define get_info_ex_func NULL
+#define get_info ((phpcl_get_info_func_t)_get_platform_info)
+#define get_info_ex NULL
/* {{{ globals */
@@ -24,22 +24,22 @@ static const phpcl_info_param_t platform_info_params[] = {
};
/* }}} */
-/* {{{ phpcl_get_platform_info() */
-
-static cl_int phpcl_get_platform_info(cl_platform_id platform,
- void *reserved __attribute__ ((unused)),
- cl_platform_info name,
- size_t value_size,
- void *value,
- size_t *value_size_ret)
+/* {{{ _get_platform_info() */
+
+static cl_int _get_platform_info(cl_platform_id platform,
+ void *reserved __attribute__ ((unused)),
+ cl_platform_info name,
+ size_t value_size,
+ void *value,
+ size_t *value_size_ret)
{
return clGetPlatformInfo(platform, name, value_size, value, value_size_ret);
}
/* }}} */
-/* {{{ phpcl_get_platform_info_all() */
+/* {{{ _get_platform_info_all() */
-static void phpcl_get_platform_info_all(INTERNAL_FUNCTION_PARAMETERS,
+static void _get_platform_info_all(INTERNAL_FUNCTION_PARAMETERS,
cl_platform_id platform)
{
const phpcl_info_param_t *param = platform_info_params;
@@ -50,7 +50,7 @@ static void phpcl_get_platform_info_all(INTERNAL_FUNCTION_PARAMETERS,
add_assoc_string(return_value, "id", buf, 1);
while (param->key != NULL) {
- zval *entry = phpcl_get_info(get_info_func, get_info_ex_func,
+ zval *entry = phpcl_get_info(get_info, get_info_ex,
platform, NULL, param TSRMLS_CC);
if (entry) {
add_assoc_zval(return_value, param->key, entry);
@@ -62,9 +62,9 @@ static void phpcl_get_platform_info_all(INTERNAL_FUNCTION_PARAMETERS,
}
/* }}} */
-/* {{{ phpcl_get_platform_info_by_name() */
+/* {{{ _get_platform_info_by_name() */
-static void phpcl_get_platform_info_by_name(INTERNAL_FUNCTION_PARAMETERS,
+static void _get_platform_info_by_name(INTERNAL_FUNCTION_PARAMETERS,
cl_platform_id platform, cl_int name)
{
const phpcl_info_param_t *param = platform_info_params;
@@ -73,7 +73,7 @@ static void phpcl_get_platform_info_by_name(INTERNAL_FUNCTION_PARAMETERS,
while (param->key != NULL) {
if (param->name == name) {
- zval *entry = phpcl_get_info(get_info_func, get_info_ex_func,
+ zval *entry = phpcl_get_info(get_info, get_info_ex,
platform, NULL, param TSRMLS_CC);
if (entry) {
RETVAL_ZVAL(entry, 0, 1);
@@ -133,7 +133,7 @@ PHP_FUNCTION(cl_get_platform_ids)
}
/* }}} */
-/* {{{ array cl_get_platform_info(resource cl_platform_id platform[, int name]) */
+/* {{{ mixed cl_get_platform_info(resource cl_platform_id platform[, int name]) */
PHP_FUNCTION(cl_get_platform_info)
{
@@ -151,9 +151,9 @@ PHP_FUNCTION(cl_get_platform_info)
"cl_platform_id", phpcl_le_platform());
if (ZEND_NUM_ARGS() == 2) {
- phpcl_get_platform_info_by_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, platform, (cl_int)name);
+ _get_platform_info_by_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, platform, (cl_int)name);
} else {
- phpcl_get_platform_info_all(INTERNAL_FUNCTION_PARAM_PASSTHRU, platform);
+ _get_platform_info_all(INTERNAL_FUNCTION_PARAM_PASSTHRU, platform);
}
}

0 comments on commit eadc530

Please sign in to comment.
Something went wrong with that request. Please try again.