我研究Linux内核并发现,对于int 0x80体系结构,中断syscall不能用于调用系统调用.
问题是:在int 0x80架构的情况下什么是更可取的int 0x80或syscall为什么?
编辑:我使用内核3.4
我有一个目录(root_dir),其中包含许多子目录(subdir1, subdir2, ...).
我想make在每个目录中运行root_dir,使用放置在其中的Makefile.(显然假设每个subdir...内部都有自己的Makefile).
所以基本上有两个问题:
我知道为了在特定目录中运行make,我应该注意以下事项:
$(MAKE) -C subdir
Run Code Online (Sandbox Code Playgroud) 我想将用户的输入作为Big-Integer并将其操作为For循环
BigInteger i;
for(BigInteger i=0; i<=100000; i++) {
System.out.println(i);
}
Run Code Online (Sandbox Code Playgroud)
但它不会起作用
有谁能够帮我.
我发现 Clang-12、Clang-13 和 Clang-14 具有以下标准行为c++17:
enum class FOO {
VALUE
};
enum class BAR {
VALUE
};
FOO value1{BAR::VALUE}; // OK
FOO value2 = BAR::VALUE; // Error
Run Code Online (Sandbox Code Playgroud)
为什么会有差异?我期望enum class100% 类型安全。
我写了一个应该将字符串转换为数字的函数.我看到两种可能的变体来写它:
int convert(const std::string input) {
if (input == "one") {
return 1;
} else if (input == "two") {
return 2;
}
// etc.
return 0;
}
Run Code Online (Sandbox Code Playgroud)
要么
int convert(const std::string input) {
static const map<string, int> table = {
{"one", 1},
{"two", 2}
// etc.
}
const auto result = table.find(input);
if (result == table.end())
{
return 0;
}
return result->second;
}
Run Code Online (Sandbox Code Playgroud)
哪种方式更有效/可接受/可读?
是否有类似sprintf()Linux内核的功能(如printf()- > printk())?
我是内核编程的新手,所以我想找出哪种编码风格更容易接受.例如,在错误处理的情况下,以下哪项更好?
这个:
/* some stuff */
if(error) {
/* error handling */
return -(errorcode);
}
/* normal actions */
Run Code Online (Sandbox Code Playgroud)
或者这个:
/* some stuff */
if(!error) {
/* normal actions */
} else {
/* error handling */
return -(errorcode);
}
Run Code Online (Sandbox Code Playgroud)
我在哪里可以找到关于内核编码标准的任何文档?
我有以下代码:
class A
{
public:
A(const unsigned int val) : value(val) {}
unsigned int value;
};
int main()
{
int val = 42;
A a(val);
A b{val}; // <--- Warning in GCC, error in Microsoft Visual Studio 2015
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么仅在列表初始化使用的情况下才会出现缩小转换警告?
有没有办法立即运行Cargo构建的程序gdb?cargo有很多功能,可以运行程序,所以看起来似乎有道理.
预期的命令就像是cargo debug.
C中有一个符号函数:
int sign(int x)
{
if(x > 0) return 1;
if(x < 0) return -1;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,比较成本非常高,所以我需要修改功能以减少比较次数.
我尝试了以下方法:
int sign(int x)
{
int result;
result = (-1)*(((unsigned int)x)>>31);
if (x > 0) return 1;
return result;
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我只得到一个比较.
有什么方法可以避免比较吗?
编辑 可能重复没有给出一个问题的答案,因为所有的答案是C++,使用比较(我应该避免的)或不返回-1,+1,0.
c ×3
c++ ×3
c++11 ×2
linux ×2
linux-kernel ×2
assembly ×1
biginteger ×1
coding-style ×1
debugging ×1
dictionary ×1
enums ×1
gdb ×1
gnu-make ×1
if-statement ×1
java ×1
lldb ×1
makefile ×1
narrowing ×1
printf ×1
rust ×1
rust-cargo ×1
system-calls ×1
x86 ×1