Skip to content

Commit

Permalink
launch vkcom on k2 (#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
astrophysik authored Nov 6, 2024
1 parent a40bb1a commit fdd63cb
Show file tree
Hide file tree
Showing 28 changed files with 335 additions and 390 deletions.
4 changes: 3 additions & 1 deletion builtin-functions/kphp-light/functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
require_once __DIR__ . '/array.txt';
require_once __DIR__ . '/confdata.txt';
require_once __DIR__ . '/crypto.txt';
require_once __DIR__ . '/rpc.txt';
require_once __DIR__ . '/hash.txt';
require_once __DIR__ . '/job-workers.txt';
require_once __DIR__ . '/rpc.txt';
require_once __DIR__ . '/string.txt';
require_once __DIR__ . '/kphp-toggles.txt';

/** defined in runtime-core.h **/
function likely ($x ::: bool) ::: bool;
Expand Down
10 changes: 5 additions & 5 deletions builtin-functions/kphp-light/job-workers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ function get_job_workers_number(): int;

// === Job Worker Old API =================================================================================

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function kphp_job_worker_start(KphpJobWorkerRequest $request, float $timeout): future<KphpJobWorkerResponse> | false;

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function kphp_job_worker_start_no_reply(KphpJobWorkerRequest $request, float $timeout): bool;

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function kphp_job_worker_start_multi(KphpJobWorkerRequest[] $request, float $timeout): (future<KphpJobWorkerResponse> | false)[];

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function kphp_job_worker_fetch_request() ::: KphpJobWorkerRequest;
// returns 0 on success, < 0 - on errors. All possible error codes are constants like KphpJobWorkerResponseError::JOB_STORE_RESPONSE_*
/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function kphp_job_worker_store_response(KphpJobWorkerResponse $response) ::: int;
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php

/** @kphp-extern-func-info generate-stub */
function kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle() ::: void;
function set_detect_incorrect_encoding_names_warning(bool $show) ::: void;

/** @kphp-extern-func-info generate-stub */
function set_detect_incorrect_encoding_names_warning(bool $show) ::: void;
function kphp_turn_on_host_tag_in_inner_statshouse_metrics_toggle() ::: void;

/** @kphp-extern-func-info generate-stub */
function set_json_log_on_timeout_mode(bool $enabled) ::: void;
Expand Down
51 changes: 28 additions & 23 deletions builtin-functions/kphp-light/rpc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ final class KphpRpcRequestsExtraInfo {
}

/** @kphp-extern-func-info interruptible */
function rpc_send_request($actor ::: string, $arr ::: array, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[];
function rpc_send_requests($actor ::: string, $arr ::: array, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[];

/** @kphp-extern-func-info interruptible */
function rpc_send_typed_query_request($actor ::: string, @tl\RpcFunction[] $query_functions, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[];
function rpc_send_typed_query_requests($actor ::: string, @tl\RpcFunction[] $query_functions, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[];

/** @kphp-extern-func-info interruptible */
function rpc_fetch_response($query_ids ::: array) ::: mixed[][];
function rpc_fetch_responses($query_ids ::: array) ::: mixed[][];

/** @kphp-extern-func-info interruptible */
function rpc_fetch_typed_response(int[] $query_ids) ::: @tl\RpcResponse[];
function rpc_fetch_typed_responses(int[] $query_ids) ::: @tl\RpcResponse[];

/** @kphp-extern-func-info can_throw */
function fetch_int () ::: int;
Expand All @@ -56,6 +56,12 @@ function fetch_double () ::: float;
/** @kphp-extern-func-info can_throw */
function fetch_string () ::: string;

function store_int ($v ::: int) ::: bool;
function store_long ($v ::: int) ::: bool;
function store_string ($v ::: string) ::: bool;
function store_double ($v ::: float) ::: bool;
function store_float ($v ::: float) ::: bool;


// === Rpc Old API =================================================================================

Expand All @@ -76,48 +82,47 @@ function typed_rpc_tl_query_result (int[] $query_ids) ::: @tl\RpcResponse[];
function rpc_parse ($data) ::: bool;

function rpc_clean() ::: bool;
/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function rpc_queue_create ($request_ids ::: mixed = TODO) ::: int;
/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function rpc_queue_empty ($queue_id ::: int) ::: bool;
/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function rpc_queue_next ($queue_id ::: int, $timeout ::: float = -1.0) ::: int | false;
/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function rpc_queue_push ($queue_id ::: int, $request_ids ::: mixed) ::: int;
/** @kphp-extern-func-info interruptible generate-stub */
function rpc_tl_pending_queries_count () ::: int;

function rpc_tl_query_result_synchronously ($query_ids ::: array) ::: mixed[][];

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function store_error ($error_code ::: int, $error_text ::: string) ::: bool;
/** @kphp-extern-func-info generate-stub */
function store_int ($v ::: int) ::: bool;
/** @kphp-extern-func-info generate-stub */
function store_long ($v ::: int) ::: bool;
/** @kphp-extern-func-info generate-stub */
function store_string ($v ::: string) ::: bool;
/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function store_finish() ::: bool;

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function set_fail_rpc_on_int32_overflow ($fail_rpc ::: bool) ::: bool;

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function rpc_tl_query_one (\RpcConnection $rpc_conn, $arr ::: mixed, $timeout ::: float = -1.0) ::: int;

/** @kphp-extern-func-info can_throw generate-stub */
/** @kphp-extern-func-info can_throw interruptible generate-stub */
function rpc_server_fetch_request() ::: @tl\RpcFunction;
/** @kphp-extern-func-info can_throw generate-stub */
/** @kphp-extern-func-info can_throw interruptible generate-stub */
function rpc_server_store_response(@tl\RpcFunctionReturnResult $response) ::: void;


/** @kphp-extern-func-info tl_common_h_dep generate-stub */
/** @kphp-extern-func-info tl_common_h_dep interruptible generate-stub */
function typed_rpc_tl_query_result_synchronously (int[] $query_ids) ::: @tl\RpcResponse[];

/** @kphp-extern-func-info tl_common_h_dep interruptible generate-stub */
function typed_rpc_tl_query_result_one (int $query_id) ::: @tl\RpcResponse;

/** @kphp-extern-func-info generate-stub can_throw */

/** @kphp-extern-func-info interruptible generate-stub can_throw */
function fetch_lookup_int () ::: int;

/** @kphp-extern-func-info generate-stub */
/** @kphp-extern-func-info interruptible generate-stub */
function new_rpc_connection ($str ::: string, $port ::: int, $actor_id ::: mixed = 0, $timeout ::: float = 0.3, $connect_timeout ::: float = 0.3, $reconnect_timeout ::: float = 17.0) ::: \RpcConnection; // TODO: make actor_id int


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,120 +9,130 @@ define('PHP_URL_PATH', 5);
define('PHP_URL_QUERY', 6);
define('PHP_URL_FRAGMENT', 7);


function addcslashes ($str ::: string, $what ::: string) ::: string;
function addslashes ($str ::: string) ::: string;

function chr ($v ::: int) ::: string;

function bin2hex ($str ::: string) ::: string;
function hex2bin ($str ::: string) ::: string;

function count_chars ($str ::: string, $mode ::: int = 0) ::: mixed;


function htmlentities ($str ::: string) ::: string;
function html_entity_decode ($str ::: string, $flags ::: int = ENT_COMPAT, $encoding ::: string = "cp1251") ::: string;
function htmlspecialchars ($str ::: string, $flags ::: int = ENT_COMPAT) ::: string;
function htmlspecialchars_decode ($str ::: string, $flags ::: int = ENT_COMPAT) ::: string;


function nl2br ($str ::: string, $is_xhtml ::: bool = true) ::: string;
function number_format ($number ::: float, $decimals ::: int = 0, $dec_point ::: string = '.', $thousands_sep ::: string = ',') ::: string;
function ord ($c ::: string) ::: int;

/** @kphp-extern-func-info generate-stub */
function parse_str ($str ::: string, &$arr ::: mixed) ::: void; // TODO: why no ::: array? // TODO because it is an output parameter, input can have any type and it's ok.
/** @kphp-extern-func-info generate-stub */
function parse_url ($str ::: string, $component ::: int = -1) ::: mixed;
/** @kphp-extern-func-info generate-stub */

function strcasecmp ($str1 ::: string, $str2 ::: string) ::: int;
/** @kphp-extern-func-info generate-stub */

function strcmp ($str1 ::: string, $str2 ::: string) ::: int;
/** @kphp-extern-func-info generate-stub */

function stripslashes ($str ::: string) ::: string;
/** @kphp-extern-func-info generate-stub */

function strip_tags ($str ::: string, $allow ::: string|string[] = "") ::: string;
/** @kphp-extern-func-info generate-stub */

function strnatcmp ($str1 ::: string, $str2 ::: string) ::: int;
/** @kphp-extern-func-info generate-stub */

function strncmp ($str1 ::: string, $str2 ::: string, $len ::: int) ::: int;

/** @kphp-extern-func-info generate-stub */
function str_starts_with ($haystack ::: string, $needle ::: string) ::: bool;
/** @kphp-extern-func-info generate-stub */

function str_ends_with ($haystack ::: string, $needle ::: string) ::: bool;

/** @kphp-extern-func-info generate-stub */
function strtr ($subject ::: string, $replace_pairs ::: mixed, $third ::: mixed = TODO) ::: string;//TODO

function str_replace ($search, $replace, $subject, &$count ::: int = TODO) ::: ^3 | string;

function str_ireplace ($search, $replace, $subject, &$count ::: int = TODO) ::: ^3 | string;
/** @kphp-extern-func-info generate-stub */

function str_split ($str ::: string, $split_length ::: int = 1) ::: string[];
/** @kphp-extern-func-info generate-stub */

function strpos ($haystack ::: string, $needle ::: mixed, $offset ::: int = 0) ::: int | false;
/** @kphp-extern-func-info generate-stub */

function stripos ($haystack ::: string, $needle ::: mixed, $offset ::: int = 0) ::: int | false;
/** @kphp-extern-func-info generate-stub */

function strrpos ($haystack ::: string, $needle ::: mixed, $offset ::: int = 0) ::: int | false;
/** @kphp-extern-func-info generate-stub */

function strripos ($haystack ::: string, $needle ::: mixed, $offset ::: int = 0) ::: int | false;
/** @kphp-extern-func-info generate-stub */

function strstr ($haystack ::: string, $needle ::: mixed, $before_needle ::: bool = false) ::: string | false;
/** @kphp-extern-func-info generate-stub */

function stristr ($haystack ::: string, $needle ::: mixed, $before_needle ::: bool = false) ::: string | false;
/** @kphp-extern-func-info generate-stub */

function strrchr ($haystack ::: string, $needle ::: mixed) ::: string | false;
/** @kphp-extern-func-info generate-stub */

function strrev ($str ::: string) ::: string;
/** @kphp-extern-func-info generate-stub */

function strtolower ($str ::: string) ::: string;
/** @kphp-extern-func-info generate-stub */

function strtoupper ($str ::: string) ::: string;
/** @kphp-extern-func-info generate-stub */
function wordwrap ($str ::: string, $width ::: int = 75, $break ::: string = '\n', $cut ::: bool = false) ::: string;

function wordwrap ($str ::: string, $width ::: int = 75, $break ::: string = '\n', $cut ::: bool = false) ::: string;
/** @kphp-extern-func-info generate-stub */
function str_getcsv($str ::: string, string $delimiter ::: string = ",", string $enclosure ::: string = "\"", string $escape ::: string = "\\") ::: mixed[] | false;


/**
* @kphp-internal-param-readonly $str
*/
function substr ($str ::: string, $start ::: int, $length ::: int = PHP_INT_MAX) ::: string | false;
/** @kphp-extern-func-info generate-stub */

function substr_count ($haystack ::: string, $needle ::: string, $offset ::: int = 0, $length ::: int = PHP_INT_MAX) ::: int;
/** @kphp-extern-func-info generate-stub */

function substr_replace (string $str, string $replacement, $start ::: int, $length ::: int = PHP_INT_MAX) ::: string;
/** @kphp-extern-func-info generate-stub */

function substr_compare ($main_str ::: string, $str ::: string, $offset ::: int, $length ::: int = PHP_INT_MAX, $case_insensitivity ::: bool = false) ::: int | false;


define('STR_PAD_LEFT', 0);
define('STR_PAD_RIGHT', 1);
define('STR_PAD_BOTH', 2);

/** @kphp-extern-func-info generate-stub */
function str_pad ($input ::: string, $len ::: int, $pad_str ::: string = " ", $pad_type ::: int = STR_PAD_RIGHT) ::: string;
/** @kphp-extern-func-info generate-stub */

function str_repeat ($s ::: string, $multiplier ::: int) ::: string;


/**
* @kphp-internal-param-readonly $s
*/
function trim ($s ::: string, $what ::: string = " \n\r\t\v\0") ::: string;
/** @kphp-extern-func-info generate-stub */

function ltrim ($s ::: string, $what ::: string = " \n\r\t\v\0") ::: string;
/** @kphp-extern-func-info generate-stub */

function rtrim ($s ::: string, $what ::: string = " \n\r\t\v\0") ::: string;


function similar_text ($first ::: string, $second ::: string, float &$percent = TODO) ::: int;


/** @kphp-extern-func-info generate-stub */
function mb_check_encoding ($str ::: string, $encoding ::: string = "cp1251") ::: bool;
/** @kphp-extern-func-info generate-stub */
function mb_strlen ($str ::: string, $encoding ::: string = "cp1251") ::: int;
/** @kphp-extern-func-info generate-stub */
function mb_strpos ($haystack ::: string, $needle ::: string, $offset ::: int = 0, $encoding ::: string = "cp1251") ::: int | false;
/** @kphp-extern-func-info generate-stub */
function mb_stripos ($haystack ::: string, $needle ::: string, $offset ::: int = 0, $encoding ::: string = "cp1251") ::: int | false;
/** @kphp-extern-func-info generate-stub */
function mb_strtolower ($str ::: string, $encoding ::: string = "cp1251") ::: string;
/** @kphp-extern-func-info generate-stub */
function mb_strtoupper ($str ::: string, $encoding ::: string = "cp1251") ::: string;
/** @kphp-extern-func-info generate-stub */
function mb_substr ($str ::: string, $start ::: int, $length ::: mixed = PHP_INT_MAX, $encoding ::: string = "cp1251") ::: string;

/** @kphp-extern-func-info generate-stub */


function lcfirst ($str ::: string) ::: string;
/** @kphp-extern-func-info generate-stub */
function ucfirst ($str ::: string) ::: string;
/** @kphp-extern-func-info generate-stub */
function ucwords ($str ::: string) ::: string;



/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
Expand Down
2 changes: 0 additions & 2 deletions builtin-functions/kphp-light/unsupported-functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require_once __DIR__ . '/unsupported/error.txt';
require_once __DIR__ . '/unsupported/file.txt';
require_once __DIR__ . '/unsupported/fork.txt';
require_once __DIR__ . '/unsupported/kml.txt';
require_once __DIR__ . '/unsupported/kphp-toggles.txt';
require_once __DIR__ . '/unsupported/kphp-tracing.txt';
require_once __DIR__ . '/unsupported/kphp_internal.txt';
require_once __DIR__ . '/unsupported/math.txt';
Expand All @@ -16,7 +15,6 @@ require_once __DIR__ . '/unsupported/regex.txt';
require_once __DIR__ . '/unsupported/serialize.txt';
require_once __DIR__ . '/unsupported/server.txt';
require_once __DIR__ . '/unsupported/spl.txt';
require_once __DIR__ . '/unsupported/string.txt';
require_once __DIR__ . '/unsupported/time.txt';
require_once __DIR__ . '/unsupported/uberh3.txt';
require_once __DIR__ . '/unsupported/vkext.txt';
10 changes: 2 additions & 8 deletions builtin-functions/kphp-light/unsupported/math.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ function atan ($v ::: float) ::: float;
*/
function atan2 ($y ::: float, $x ::: float) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function ceil ($v ::: float) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function cos ($v ::: float) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function deg2rad ($v ::: float) ::: float;
Expand All @@ -58,7 +55,6 @@ function deg2rad ($v ::: float) ::: float;
*/
function exp ($v ::: float) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function floor ($v ::: float) ::: float;
Expand All @@ -68,12 +64,10 @@ function floor ($v ::: float) ::: float;
*/
function fmod ($x ::: float, $y ::: float) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function log ($v ::: float, $base ::: float = 2.7182818284590452353602874713527) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function round ($v ::: float, $precision ::: int = 0) ::: float;
Expand All @@ -83,7 +77,6 @@ function round ($v ::: float, $precision ::: int = 0) ::: float;
*/
function sin ($v ::: float) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function sqrt ($v ::: float) ::: float;
Expand All @@ -93,7 +86,6 @@ function sqrt ($v ::: float) ::: float;
*/
function tan ($v ::: float) ::: float;
/**
* @kphp-extern-func-info generate-stub
* @kphp-pure-function
*/
function pi() ::: float;
Expand Down Expand Up @@ -166,4 +158,6 @@ function is_infinite ($v ::: float) ::: bool;
function is_nan ($v ::: float) ::: bool;
/** @kphp-extern-func-info generate-stub */
function random_int($l ::: int, $r ::: int) ::: int | false;
/** @kphp-extern-func-info generate-stub */
function random_bytes($length ::: int) ::: string | false;

Loading

0 comments on commit fdd63cb

Please sign in to comment.