按规范「注释只讲解作用,不掺杂历史原因,尽量英文」:把 includes 下 75 个 .vp 的中文 # 注释与三引号 docstring 改写为英文,每个注释块压到 2 行以内。 保留要点:作用、约束、危险警告(不得/必须/注意)、ABI 与类型约定(如 BYTEPTR | t.CPtr = i8** 的跨模块坍缩坑)、位宽/长度约定、fail-fast 要求、内存与句柄所有权。 未动:文件头注释(规范豁免,仍是中文)、运行时中文字符串常量(printf / fatal_error / MlirFail 等用户可见消息,属代码字面量)。 验证:独立脚本比对 HEAD 与工作区的代码骨架(剥离 # 注释与三引号 docstring 后的非空行)——75 个文件逐字节一致;行尾 CRLF/LF 未被改动;全文剩余中文仅 547 行头注释、0 条行尾注释。bootstrap 三重重编 SUCCESS;全量 77/77 顺序回归通过。
52 lines
1.9 KiB
Plaintext
52 lines
1.9 KiB
Plaintext
import t, c
|
|
from openssl.types import *
|
|
|
|
# ============================================================
|
|
# openssl/err.vp — OpenSSL 错误队列
|
|
# 对应头文件: err.h
|
|
# ============================================================
|
|
|
|
# unsigned long ERR_get_error(void) -- pop queue head and return error code
|
|
extern def ERR_get_error() -> uint32
|
|
# unsigned long ERR_peek_error(void)
|
|
extern def ERR_peek_error() -> uint32
|
|
# unsigned long ERR_peek_last_error(void)
|
|
extern def ERR_peek_last_error() -> uint32
|
|
# void ERR_clear_error(void)
|
|
extern def ERR_clear_error()
|
|
|
|
# char *ERR_error_string(unsigned long e, char *buf) -- buf may be NULL (uses internal static buffer)
|
|
extern def ERR_error_string(e: uint32, buf: bytes) -> str
|
|
# void ERR_error_string_n(unsigned long e, char *buf, size_t len)
|
|
extern def ERR_error_string_n(e: uint32, buf: bytes, len: sizet)
|
|
# const char *ERR_lib_error_string(unsigned long e)
|
|
extern def ERR_lib_error_string(e: uint32) -> str
|
|
# const char *ERR_func_error_string(unsigned long e)
|
|
extern def ERR_func_error_string(e: uint32) -> str
|
|
# const char *ERR_reason_error_string(unsigned long e)
|
|
extern def ERR_reason_error_string(e: uint32) -> str
|
|
|
|
# Stack marks (for partial-failure rollback)
|
|
extern def ERR_set_mark() -> int
|
|
extern def ERR_pop_to_mark() -> int
|
|
extern def ERR_clear_last_mark() -> int
|
|
|
|
# void ERR_print_errors(BIO *bp) -- dump the whole queue to BIO (see bio.vp)
|
|
extern def ERR_print_errors(bp: BioPtr)
|
|
# void ERR_print_errors_fp(FILE *fp) -- FILE* not exposed yet
|
|
|
|
# ---- Error code unpacking (inline-macro equivalents) ----
|
|
# OpenSSL error code layout: system bit 0x80000000, library 24-31, reason 0-15
|
|
define ErrLibMask = 0xff000000
|
|
define ErrReasonMask = 0x0000ffff
|
|
define ErrSystemFlag = 0x80000000
|
|
|
|
def err_get_lib(code: uint32) -> int:
|
|
if (code & ErrSystemFlag) != 0:
|
|
return 0
|
|
return (code >> 24) & 0xff
|
|
|
|
|
|
def err_get_reason(code: uint32) -> int:
|
|
return code & ErrReasonMask
|