小编Mr *_* M.的帖子

将可加载内核模块标记为in-tree

这个问题是关于linux内核4.10的.

加载树外LKM会导致内核打印警告:

module: loading out-of-tree module taints kernel.

这可以从这个check.c模块得出: if (!get_modinfo(info, "intree")) {

阅读get_modinfo它的接缝"intree"只是.ko文件中的魔法字符串livnig .

readelf在我的系统中找到的随机LKM上运行显示:

readelf -a imon.ko | grep intree 161: 00000000000006c0 9 OBJECT LOCAL DEFAULT 13 __UNIQUE_ID_intree1

在寻找intree简单的自定义hello_world时,LKM不会返回任何结果.

实际情况如此吗?

如何将某些模块标记为树内?是通过向模块添加宏(如MODULE_LICENCE),还是通过以特定方式或其他方式构建模块来完成的?

linux kernel kernel-module linux-kernel

7
推荐指数
1
解决办法
8481
查看次数

字符串的最小字典值

将字符串与operator <进行比较时,最小的字符串是什么?

更具体地说,什么是比任何其他字符串更小(使用<)的字符串?

c++ string c++11

5
推荐指数
1
解决办法
929
查看次数

模板中的未知返回类型

我有一个功能

template <typename T1, typename T2>
/*return type*/ foo(MyClass<T1>& bar1, MyClass<T2>& bar2)
{
    if (something)
        return bar1;
    else
        return bar2;
}
Run Code Online (Sandbox Code Playgroud)

问题是,我不知道这个函数会返回什么:它可以是MyClass<T1>或者MyClass<T2>.

我怎样才能让它发挥作用?

T1和T2是3个整数的结构,在编译时已知.返回类型取决于那些中较小的2:例如,对于T1 = <5, 1, 1> T2 = <4, 4, 7>返回类型应该是MyClass<T2>.

用法示例:

MyClass<5, 2, 8> m1;
MyClass<4, 2, 1> m2;
cout << foo(m1, m2); //should print m2 (I have a method used for that)
Run Code Online (Sandbox Code Playgroud)

c++ templates c++11

5
推荐指数
1
解决办法
706
查看次数

委托私有函数作为不同类中方法的参数

让我们班A有私有方法f()g().让班级B有公共方法h.是否可以将指针/委托A.g从方法A.f指向B.h

请考虑以下代码:

Class B
{
    public B() {}

    public h(/*take pointer/delegate*/)
    {
        //execute method from argument
    }
}

Class A
{
    private int x = 0;
    private void g()
    {
        x = 5;
    }

    private void f()
    {
        B b = new B();
        b.h(/*somehow pass delegate to g here*/);
    }
}
Run Code Online (Sandbox Code Playgroud)

之后A.f()叫我想A.x5.可能吗?如果是这样,怎么样?

c# delegates function-pointers

4
推荐指数
1
解决办法
1426
查看次数