PHP_METHOD(Test_Optimizers_Tan, testIntParameter) { zval *a_param = NULL, _0; zend_long a; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); zephir_fetch_params(0, 1, 0, &a_param); a = zephir_get_intval(a_param); ZVAL_LONG(&_0, a); RETURN_DOUBLE(tan(a)); }
PHP_METHOD(Test_Oo_OoParams, setAverageDefault) { zval *average_param = NULL; double average; zephir_fetch_params(0, 0, 1, &average_param); if (!average_param) { average = (double) 25; } else { average = zephir_get_doubleval(average_param); } RETURN_DOUBLE(average); }
PHP_METHOD(Test_Optimizers_Ldexp, testVar) { zval _0, _1; int x, exponent; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); x = 2; exponent = 3; ZVAL_LONG(&_0, x); ZVAL_LONG(&_1, exponent); RETURN_DOUBLE(zephir_ldexp(&_0, &_1 TSRMLS_CC)); }
PHP_METHOD(Test_Optimizers_Ldexp, testDouble) { zval _0, _1; double x, exponent; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); x = 2.0; exponent = 3.0; ZVAL_DOUBLE(&_0, x); ZVAL_DOUBLE(&_1, exponent); RETURN_DOUBLE(zephir_ldexp(&_0, &_1 TSRMLS_CC)); }
PHP_METHOD(Test_Oo_OoParams, setStrictAverage) { zval *average_param = NULL; double average; zephir_fetch_params(0, 1, 0, &average_param); if (unlikely(Z_TYPE_P(average_param) != IS_DOUBLE)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'average' must be a double") TSRMLS_CC); RETURN_NULL(); } average = Z_DVAL_P(average_param); RETURN_DOUBLE(average); }
PHP_METHOD(Test_Optimizers_Sqrt, testVarParameter) { zval *a, a_sub; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&a_sub); zephir_fetch_params(0, 1, 0, &a); RETURN_DOUBLE(zephir_sqrt(a TSRMLS_CC)); }
PHP_METHOD(Test_Optimizers_Sqrt, testVar) { zval _0; int a; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&_0); a = 4; ZVAL_LONG(&_0, a); RETURN_DOUBLE(sqrt(a)); }
U_CFUNC PHP_FUNCTION(intlcal_get_time) { CALENDAR_METHOD_INIT_VARS; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, Calendar_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_get_time: bad arguments", 0 TSRMLS_CC); RETURN_FALSE; } CALENDAR_METHOD_FETCH_OBJECT; UDate result = co->ucal->getTime(CALENDAR_ERROR_CODE(co)); INTL_METHOD_CHECK_STATUS(co, "intlcal_get_time: error calling ICU Calendar::getTime"); RETURN_DOUBLE((double)result); }
PHP_METHOD(Test_Fibonnaci, fibDouble) { double x = 0, y = 0, n = 0, z = 0; z = 0.0; x = 1.0; y = 2.0; n = 10.0; while (1) { if (!(z < n)) { break; } z = (x + y); x = y; y = z; } RETURN_DOUBLE(z); }
PHP_METHOD(Test_Optimizers_Ldexp, testIntParameter) { zval *x_param = NULL, *exponent_param = NULL, _0, _1; int x, exponent; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); zephir_fetch_params(0, 2, 0, &x_param, &exponent_param); x = zephir_get_intval(x_param); exponent = zephir_get_intval(exponent_param); ZVAL_LONG(&_0, x); ZVAL_LONG(&_1, exponent); RETURN_DOUBLE(zephir_ldexp(&_0, &_1 TSRMLS_CC)); }
/* {{{ proto int rect.fit(int nWidth, int nHeight) Adjust extents of the rectangle to fit the width/height specified. */ PHP_METHOD(rectObj, fit) { zval *zobj = getThis(); long width, height; double retval=0.0; php_rect_object *php_rect; PHP_MAPSCRIPT_ERROR_HANDLING(TRUE); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) { PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); return; } PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); php_rect = (php_rect_object *) zend_object_store_get_object(zobj TSRMLS_CC); retval = rectObj_fit(php_rect->rect, width, height); RETURN_DOUBLE(retval); }
/* {{{ proto double floor(double number) Returns the next lowest integer value from the number */ void php3_floor(INTERNAL_FUNCTION_PARAMETERS) { pval *value; TLS_VARS; if (ARG_COUNT(ht)!=1||getParameters(ht,1,&value)==FAILURE) { WRONG_PARAM_COUNT; } if (value->type == IS_STRING) { convert_string_to_number(value); } if (value->type == IS_DOUBLE) { RETURN_DOUBLE(floor(value->value.dval)); } else if (value->type == IS_LONG) { RETURN_LONG(value->value.lval); } RETURN_FALSE; }
PHP_METHOD(Test_Flow, testWhile8) { double a = 0; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; a = (double) (5); while (1) { if (!(a)) { break; } a--; } RETURN_DOUBLE(a); }
PHP_METHOD(Test_Optimizers_Sqrt, testIntParameter) { zval *a_param = NULL, _0; int a; zval this_zv; zval *this_ptr = getThis(); if (EXPECTED(this_ptr)) { ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr)); this_ptr = &this_zv; } else this_ptr = NULL; ZVAL_UNDEF(&_0); zephir_fetch_params(0, 1, 0, &a_param); a = zephir_get_intval(a_param); ZVAL_LONG(&_0, a); RETURN_DOUBLE(sqrt(a)); }
/* {{{ proto int point.distanceToPoint(pointObj) Calculates distance between two points. */ PHP_METHOD(pointObj, distanceToPoint) { zval *zobj_point2; zval *zobj = getThis(); php_point_object *php_point, *php_point2; double distance = -1; PHP_MAPSCRIPT_ERROR_HANDLING(TRUE); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zobj_point2, mapscript_ce_point) == FAILURE) { PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); return; } PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE); php_point = (php_point_object *) zend_object_store_get_object(zobj TSRMLS_CC); php_point2 = (php_point_object *) zend_object_store_get_object(zobj_point2 TSRMLS_CC); distance = pointObj_distanceToPoint(php_point->point, php_point2->point); RETURN_DOUBLE(distance); }
static void _php_gettimeofday(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ { zend_bool get_as_float = 0; struct timeval tp = {0}; struct timezone tz = {0}; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &get_as_float) == FAILURE) { return; } if (gettimeofday(&tp, &tz)) { RETURN_FALSE; } if (get_as_float) { RETURN_DOUBLE((double)(tp.tv_sec + tp.tv_usec / MICRO_IN_SEC)); } if (mode) { timelib_time_offset *offset; offset = timelib_get_time_zone_info(tp.tv_sec, get_timezone_info(TSRMLS_C)); array_init(return_value); add_ascii_assoc_long(return_value, "sec", tp.tv_sec); add_ascii_assoc_long(return_value, "usec", tp.tv_usec); add_ascii_assoc_long(return_value, "minuteswest", -offset->offset / SEC_IN_MIN); add_ascii_assoc_long(return_value, "dsttime", offset->is_dst); timelib_time_offset_dtor(offset); } else { char ret[100]; snprintf(ret, 100, "%.8F %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec); RETURN_ASCII_STRING(ret, ZSTR_DUPLICATE); } }
/* {{{ Cassandra\Timestamp::microtime(bool) */ PHP_METHOD(Timestamp, microtime) { zend_bool get_as_float = 0; cassandra_timestamp* timestamp; char *ret = NULL; long sec = -1; double usec = 0.0f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &get_as_float) == FAILURE) { return; } timestamp = (cassandra_timestamp*) zend_object_store_get_object(getThis() TSRMLS_CC); if (get_as_float) { RETURN_DOUBLE((double) timestamp->timestamp / 1000.00); } sec = (long) (timestamp->timestamp / 1000); usec = (double) ((timestamp->timestamp - (sec * 1000)) / 1000.00); spprintf(&ret, 0, "%.8F %ld", usec, sec); RETURN_STRING(ret, 0); }
PHP_METHOD(Test_Flow, testWhile9) { double c; int a, b; a = 5; while (1) { if (!(a)) { break; } b = 5; while (1) { if (!(b)) { break; } b--; } a--; } c = (double) ((a + b)); RETURN_DOUBLE(c); }
/* {{{ Cassandra\Timestamp::microtime(bool) */ PHP_METHOD(Timestamp, microtime) { zend_bool get_as_float = 0; cassandra_timestamp *self; char *ret = NULL; long sec = -1; double usec = 0.0f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &get_as_float) == FAILURE) { return; } self = PHP_CASSANDRA_GET_TIMESTAMP(getThis()); if (get_as_float) { RETURN_DOUBLE((double) self->timestamp / 1000.00); } sec = (long) (self->timestamp / 1000); usec = (double) ((self->timestamp - (sec * 1000)) / 1000.00); spprintf(&ret, 0, "%.8F %ld", usec, sec); PHP5TO7_RETVAL_STRING(ret); efree(ret); }
static void binary_deserialize(int8_t thrift_typeID, PHPInputTransport& transport, zval* return_value, HashTable* fieldspec) { ZVAL_NULL(return_value); switch (thrift_typeID) { case T_STOP: case T_VOID: RETURN_NULL(); return; case T_STRUCT: { zval* val_ptr = zend_hash_str_find(fieldspec, "class", sizeof("class")-1); if (val_ptr == nullptr) { throw_tprotocolexception("no class type in spec", INVALID_DATA); skip_element(T_STRUCT, transport); RETURN_NULL(); } char* structType = Z_STRVAL_P(val_ptr); // Create an object in PHP userland based on our spec createObject(structType, return_value); if (Z_TYPE_P(return_value) == IS_NULL) { // unable to create class entry skip_element(T_STRUCT, transport); RETURN_NULL(); } zval* spec = zend_read_static_property(Z_OBJCE_P(return_value), "_TSPEC", sizeof("_TSPEC")-1, false); if (Z_TYPE_P(spec) != IS_ARRAY) { char errbuf[128]; snprintf(errbuf, 128, "spec for %s is wrong type: %d\n", structType, Z_TYPE_P(spec)); throw_tprotocolexception(errbuf, INVALID_DATA); RETURN_NULL(); } binary_deserialize_spec(return_value, transport, Z_ARRVAL_P(spec)); return; } break; case T_BOOL: { uint8_t c; transport.readBytes(&c, 1); RETURN_BOOL(c != 0); } //case T_I08: // same numeric value as T_BYTE case T_BYTE: { uint8_t c; transport.readBytes(&c, 1); RETURN_LONG((int8_t)c); } case T_I16: { uint16_t c; transport.readBytes(&c, 2); RETURN_LONG((int16_t)ntohs(c)); } case T_I32: { uint32_t c; transport.readBytes(&c, 4); RETURN_LONG((int32_t)ntohl(c)); } case T_U64: case T_I64: { uint64_t c; transport.readBytes(&c, 8); RETURN_LONG((int64_t)ntohll(c)); } case T_DOUBLE: { union { uint64_t c; double d; } a; transport.readBytes(&(a.c), 8); a.c = ntohll(a.c); RETURN_DOUBLE(a.d); } //case T_UTF7: // aliases T_STRING case T_UTF8: case T_UTF16: case T_STRING: { uint32_t size = transport.readU32(); if (size) { char strbuf[size+1]; transport.readBytes(strbuf, size); strbuf[size] = '\0'; ZVAL_STRINGL(return_value, strbuf, size); } else { ZVAL_EMPTY_STRING(return_value); } return; } case T_MAP: { // array of key -> value uint8_t types[2]; transport.readBytes(types, 2); uint32_t size = transport.readU32(); array_init(return_value); zval *val_ptr; val_ptr = zend_hash_str_find(fieldspec, "key", sizeof("key")-1); HashTable* keyspec = Z_ARRVAL_P(val_ptr); val_ptr = zend_hash_str_find(fieldspec, "val", sizeof("val")-1); HashTable* valspec = Z_ARRVAL_P(val_ptr); for (uint32_t s = 0; s < size; ++s) { zval key, value; binary_deserialize(types[0], transport, &key, keyspec); binary_deserialize(types[1], transport, &value, valspec); if (Z_TYPE(key) == IS_LONG) { zend_hash_index_update(Z_ARR_P(return_value), Z_LVAL(key), &value); } else { if (Z_TYPE(key) != IS_STRING) convert_to_string(&key); zend_symtable_update(Z_ARR_P(return_value), Z_STR(key), &value); } zval_dtor(&key); } return; // return_value already populated } case T_LIST: { // array with autogenerated numeric keys int8_t type = transport.readI8(); uint32_t size = transport.readU32(); zval *val_ptr = zend_hash_str_find(fieldspec, "elem", sizeof("elem")-1); HashTable* elemspec = Z_ARRVAL_P(val_ptr); array_init(return_value); for (uint32_t s = 0; s < size; ++s) { zval value; binary_deserialize(type, transport, &value, elemspec); zend_hash_next_index_insert(Z_ARR_P(return_value), &value); } return; } case T_SET: { // array of key -> TRUE uint8_t type; uint32_t size; transport.readBytes(&type, 1); transport.readBytes(&size, 4); size = ntohl(size); zval *val_ptr = zend_hash_str_find(fieldspec, "elem", sizeof("elem")-1); HashTable* elemspec = Z_ARRVAL_P(val_ptr); array_init(return_value); for (uint32_t s = 0; s < size; ++s) { zval key, value; ZVAL_TRUE(&value); binary_deserialize(type, transport, &key, elemspec); if (Z_TYPE(key) == IS_LONG) { zend_hash_index_update(Z_ARR_P(return_value), Z_LVAL(key), &value); } else { if (Z_TYPE(key) != IS_STRING) convert_to_string(&key); zend_symtable_update(Z_ARR_P(return_value), Z_STR(key), &value); } zval_dtor(&key); } return; } }; char errbuf[128]; sprintf(errbuf, "Unknown thrift typeID %d", thrift_typeID); throw_tprotocolexception(errbuf, INVALID_DATA); }
PHP_METHOD(Test_Optimizers_Math, testSqrtIntValue2) { RETURN_DOUBLE(sqrt(16)); }
/** * Returns the interval which libev will check file status with stat(). * * @return double seconds * @return false if object has not been initialized */ PHP_METHOD(StatEvent, getInterval) { event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_DOUBLE(((ev_stat *)obj->watcher)->interval); }
/** * When repeating, returns the offset, otherwise it returns the absolute time for * the event trigger. * * @return double * @return false if object has not been initialized */ PHP_METHOD(PeriodicEvent, getOffset) { event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_DOUBLE(((ev_periodic *)obj->watcher)->offset); }
/** * Returns the time for the next trigger of the event, seconds. * * @return double * @return false if object has not been initialized */ PHP_METHOD(PeriodicEvent, getTime) { event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_DOUBLE(event_periodic_at(obj)); }
/** * Returns the seconds between event triggering. * * @return double * @return false If the event has not been initialized */ PHP_METHOD(TimerEvent, getRepeat) { event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC); RETURN_DOUBLE(((ev_timer *)obj->watcher)->repeat); }
PHP_METHOD(Test_Globals, getDefaultGlobals6) { RETURN_DOUBLE(ZEPHIR_GLOBAL(my_setting_3)); }
void binary_deserialize(int8_t thrift_typeID, PHPInputTransport& transport, zval* return_value, HashTable* fieldspec) { zval** val_ptr; Z_TYPE_P(return_value) = IS_NULL; // just in case switch (thrift_typeID) { case T_STOP: case T_VOID: RETURN_NULL(); return; case T_STRUCT: { if (zend_hash_find(fieldspec, "class", 6, (void**)&val_ptr) != SUCCESS) { throw_tprotocolexception("no class type in spec", INVALID_DATA); skip_element(T_STRUCT, transport); RETURN_NULL(); } char* structType = Z_STRVAL_PP(val_ptr); createObject(structType, return_value); if (Z_TYPE_P(return_value) == IS_NULL) { // unable to create class entry skip_element(T_STRUCT, transport); RETURN_NULL(); } TSRMLS_FETCH(); zval* spec = zend_read_static_property(zend_get_class_entry(return_value TSRMLS_CC), "_TSPEC", 6, false TSRMLS_CC); if (Z_TYPE_P(spec) != IS_ARRAY) { char errbuf[128]; snprintf(errbuf, 128, "spec for %s is wrong type: %d\n", structType, Z_TYPE_P(spec)); throw_tprotocolexception(errbuf, INVALID_DATA); RETURN_NULL(); } binary_deserialize_spec(return_value, transport, Z_ARRVAL_P(spec)); return; } break; case T_BOOL: { uint8_t c; transport.readBytes(&c, 1); RETURN_BOOL(c != 0); } //case T_I08: // same numeric value as T_BYTE case T_BYTE: { uint8_t c; transport.readBytes(&c, 1); RETURN_LONG(c); } case T_I16: { uint16_t c; transport.readBytes(&c, 2); RETURN_LONG(ntohs(c)); } case T_I32: { uint32_t c; transport.readBytes(&c, 4); RETURN_LONG(ntohl(c)); } case T_U64: case T_I64: { uint64_t c; transport.readBytes(&c, 8); RETURN_LONG(ntohll(c)); } case T_DOUBLE: { union { uint64_t c; double d; } a; transport.readBytes(&(a.c), 8); a.c = ntohll(a.c); RETURN_DOUBLE(a.d); } //case T_UTF7: // aliases T_STRING case T_UTF8: case T_UTF16: case T_STRING: { uint32_t size = transport.readU32(); if (size) { char* strbuf = (char*) emalloc(size + 1); transport.readBytes(strbuf, size); strbuf[size] = '\0'; ZVAL_STRINGL(return_value, strbuf, size, 0); } else { ZVAL_EMPTY_STRING(return_value); } return; } case T_MAP: { // array of key -> value uint8_t types[2]; transport.readBytes(types, 2); uint32_t size = transport.readU32(); array_init(return_value); zend_hash_find(fieldspec, "key", 4, (void**)&val_ptr); HashTable* keyspec = Z_ARRVAL_PP(val_ptr); zend_hash_find(fieldspec, "val", 4, (void**)&val_ptr); HashTable* valspec = Z_ARRVAL_PP(val_ptr); for (uint32_t s = 0; s < size; ++s) { zval *value; MAKE_STD_ZVAL(value); zval* key; MAKE_STD_ZVAL(key); binary_deserialize(types[0], transport, key, keyspec); binary_deserialize(types[1], transport, value, valspec); if (Z_TYPE_P(key) == IS_LONG) { zend_hash_index_update(return_value->value.ht, Z_LVAL_P(key), &value, sizeof(zval *), NULL); } else { if (Z_TYPE_P(key) != IS_STRING) convert_to_string(key); zend_hash_update(return_value->value.ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &value, sizeof(zval *), NULL); } zval_ptr_dtor(&key); } return; // return_value already populated } case T_LIST: { // array with autogenerated numeric keys int8_t type = transport.readI8(); uint32_t size = transport.readU32(); zend_hash_find(fieldspec, "elem", 5, (void**)&val_ptr); HashTable* elemspec = Z_ARRVAL_PP(val_ptr); array_init(return_value); for (uint32_t s = 0; s < size; ++s) { zval *value; MAKE_STD_ZVAL(value); binary_deserialize(type, transport, value, elemspec); zend_hash_next_index_insert(return_value->value.ht, &value, sizeof(zval *), NULL); } return; } case T_SET: { // array of key -> TRUE uint8_t type; uint32_t size; transport.readBytes(&type, 1); transport.readBytes(&size, 4); size = ntohl(size); zend_hash_find(fieldspec, "elem", 5, (void**)&val_ptr); HashTable* elemspec = Z_ARRVAL_PP(val_ptr); array_init(return_value); for (uint32_t s = 0; s < size; ++s) { zval* key; zval* value; MAKE_STD_ZVAL(key); MAKE_STD_ZVAL(value); ZVAL_TRUE(value); binary_deserialize(type, transport, key, elemspec); if (Z_TYPE_P(key) == IS_LONG) { zend_hash_index_update(return_value->value.ht, Z_LVAL_P(key), &value, sizeof(zval *), NULL); } else { if (Z_TYPE_P(key) != IS_STRING) convert_to_string(key); zend_hash_update(return_value->value.ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &value, sizeof(zval *), NULL); } zval_ptr_dtor(&key); } return; } }; char errbuf[128]; sprintf(errbuf, "Unknown thrift typeID %d", thrift_typeID); throw_tprotocolexception(errbuf, INVALID_DATA); }
//返回double static PHP_FUNCTION(return_double) { RETURN_DOUBLE(2.15); }
static void _timecop_gettimeofday(INTERNAL_FUNCTION_PARAMETERS, int mode) { zend_bool get_as_float = 0; long fixed_sec = 0, fixed_usec = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &get_as_float) == FAILURE) { return; } switch (TIMECOP_G(timecop_mode)) { case TIMECOP_MODE_FREEZE: fixed_sec = TIMECOP_G(freezed_timestamp); fixed_usec = 0; break; case TIMECOP_MODE_TRAVEL: { zval timeofday, *zv_sec, *zv_usec; timecop_call_orig_method_with_0_params(NULL, NULL, NULL, "gettimeofday", &timeofday); zv_sec = zend_hash_str_find(Z_ARR(timeofday), "sec", sizeof("sec")-1); if (zv_sec) { fixed_sec = Z_LVAL_P(zv_sec) + TIMECOP_G(travel_offset); } zv_usec = zend_hash_str_find(Z_ARR(timeofday), "usec", sizeof("usec")-1); if (zv_sec) { fixed_usec = Z_LVAL_P(zv_usec); } zval_ptr_dtor(&timeofday); } break; default: { const char *func_name; size_t func_name_len; zval *arg1 = NULL, tmp; int param_count = 0; if (mode) { func_name = ORIG_FUNC_NAME("gettimeofday"); func_name_len = ORIG_FUNC_NAME_SIZEOF("gettimeofday")-1; } else { func_name = ORIG_FUNC_NAME("microtime"); func_name_len = ORIG_FUNC_NAME_SIZEOF("microtime")-1; } if (get_as_float) { ZVAL_TRUE(&tmp); arg1 = &tmp; param_count = 1; } zend_call_method(NULL, NULL, NULL, func_name, func_name_len, return_value, param_count, arg1, NULL); return; } } if (get_as_float) { RETURN_DOUBLE((double)(fixed_sec + fixed_usec / MICRO_IN_SEC)); } if (mode) { zval zv_offset, zv_dst, format, timestamp; long offset = 0, is_dst = 0; ZVAL_LONG(×tamp, fixed_sec); /* offset */ ZVAL_STRING(&format, "Z"); timecop_call_orig_method_with_2_params(NULL, NULL, NULL, "date", &zv_offset, &format, ×tamp); convert_to_long(&zv_offset); offset = Z_LVAL(zv_offset); zval_ptr_dtor(&zv_offset); zval_ptr_dtor(&format); /* is_dst */ ZVAL_STRING(&format, "I"); timecop_call_orig_method_with_2_params(NULL, NULL, NULL, "date", &zv_dst, &format, ×tamp); convert_to_long(&zv_dst); is_dst = Z_LVAL(zv_dst); zval_ptr_dtor(&zv_dst); zval_ptr_dtor(&format); array_init(return_value); add_assoc_long(return_value, "sec", fixed_sec); add_assoc_long(return_value, "usec", fixed_usec); add_assoc_long(return_value, "minuteswest", -offset / SEC_IN_MIN); add_assoc_long(return_value, "dsttime", is_dst); } else { char ret[100]; snprintf(ret, 100, "%.8F %ld", fixed_usec / MICRO_IN_SEC, fixed_sec); RETURN_STRING(ret); } }