Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 1 Fork 0

ILoveRust/linux

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
linux
/
include
/
linux.zig
linux
/
include
/
linux.zig
linux.zig 3.19 KB
Copy Edit Raw Blame History
ILoveRust authored 2025年10月05日 19:10 +08:00 . 添加include头文件文件夹
// Linux内核主头文件模块
// 转换自: include/linux/
// 转换时间: 2025年10月04日
const std = @import("std");
// 导出Linux内核的主要模块
pub const mm = @import("linux/mm.zig");
pub const slab = @import("linux/slab.zig");
pub const string = @import("linux/string.zig");
pub const atomic = @import("linux/atomic.zig");
pub const spinlock = @import("linux/spinlock.zig");
pub const list = @import("linux/list.zig");
pub const workqueue = @import("linux/workqueue.zig");
// 内核配置常量
// TODO: 这些应该从实际的内核配置中生成
pub const CONFIG_SMP = true;
pub const CONFIG_NR_CPUS = 64;
pub const CONFIG_LRU_GEN = false;
pub const CONFIG_PER_VMA_LOCK = true;
// 内核版本信息
pub const KERNEL_VERSION_MAJOR = 6;
pub const KERNEL_VERSION_MINOR = 12;
pub const KERNEL_VERSION_PATCH = 0;
// 基本内核类型定义
pub const gfp_t = u32;
pub const size_t = usize;
pub const ssize_t = isize;
pub const loff_t = i64;
pub const pid_t = i32;
pub const uid_t = u32;
pub const gid_t = u32;
pub const mode_t = u32;
pub const dev_t = u32;
pub const ino_t = u64;
pub const nlink_t = u32;
pub const off_t = i64;
pub const time_t = i64;
pub const suseconds_t = i64;
// 错误码
pub const EINVAL = 22;
pub const ENOMEM = 12;
pub const EFAULT = 14;
pub const EAGAIN = 11;
pub const EWOULDBLOCK = EAGAIN;
pub const EINTR = 4;
pub const EIO = 5;
pub const ENODEV = 19;
pub const ENOENT = 2;
pub const EPERM = 1;
pub const EACCES = 13;
// 内核常量
pub const PAGE_SIZE = 4096;
pub const PAGE_SHIFT = 12;
pub const PAGE_MASK = ~(PAGE_SIZE - 1);
// NUMA节点常量
pub const NUMA_NO_NODE = -1;
pub const MAX_NUMNODES = 1024;
// CPU相关常量
pub const NR_CPUS = CONFIG_NR_CPUS;
pub const CPU_BITS_NONE = 0;
// 内核日志级别
pub const KERN_EMERG = "<0>";
pub const KERN_ALERT = "<1>";
pub const KERN_CRIT = "<2>";
pub const KERN_ERR = "<3>";
pub const KERN_WARNING = "<4>";
pub const KERN_NOTICE = "<5>";
pub const KERN_INFO = "<6>";
pub const KERN_DEBUG = "<7>";
// 中断返回值
pub const IRQ_NONE = 0;
pub const IRQ_HANDLED = 1;
pub const IRQ_WAKE_THREAD = 2;
pub const irqreturn_t = u32;
// 内核模块导出宏的Zig等价实现
pub fn EXPORT_SYMBOL(symbol: anytype) void {
_ = symbol; // 在Zig中,导出是通过pub关键字实现的
}
// 内核打印函数声明
pub extern fn printk(fmt: [*:0]const u8, ...) i32;
// 内核初始化和清理函数类型
pub const initcall_t = *const fn() callconv(.C) i32;
pub const exitcall_t = *const fn() callconv(.C) void;
// 模块初始化和清理宏的Zig等价实现
pub fn module_init(func: initcall_t) void {
_ = func; // TODO: 实现模块初始化注册
}
pub fn module_exit(func: exitcall_t) void {
_ = func; // TODO: 实现模块清理注册
}
// 内核断言
pub fn BUG_ON(condition: bool) void {
if (condition) {
@panic("BUG: kernel assertion failed");
}
}
pub fn WARN_ON(condition: bool) bool {
if (condition) {
std.log.warn("WARNING: kernel assertion failed", .{});
return true;
}
return false;
}
// 编译时检查
comptime {
// 确保基本类型大小正确
std.debug.assert(@sizeOf(gfp_t) == 4);
std.debug.assert(@sizeOf(pid_t) == 4);
std.debug.assert(PAGE_SIZE == 4096);
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

linux现代化工程
No labels
MulanPSL-2.0
Use MulanPSL-2.0
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/iloverust/linux.git
git@gitee.com:iloverust/linux.git
iloverust
linux
linux
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /