wayne 发表于 2011-5-11 10:15:33

9# gxqcn
搜了一下, 修饰函数表示 no return:
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html


noreturn
    A few standard library functions, such as abort and exit, cannot return. GCC knows this automatically. Some programs define their own functions that never return. You can declare them noreturn to tell the compiler this fact. For example,

            void fatal () __attribute__ ((noreturn));
            
            void
            fatal (/* ... */)
            {
                /* ... */ /* Print error message. */ /* ... */
                exit (1);
            }
         

    The noreturn keyword tells the compiler to assume that fatal cannot return. It can then optimize without regard to what would happen if fatal ever did return. This makes slightly better code. More importantly, it helps avoid spurious warnings of uninitialized variables.

    The noreturn keyword does not affect the exceptional path when that applies: a noreturn-marked function may still return to the caller by throwing an exception or calling longjmp.

    Do not assume that registers saved by the calling function are restored before calling the noreturn function.

    It does not make sense for a noreturn function to have a return type other than void.

    The attribute noreturn is not implemented in GCC versions earlier than 2.5. An alternative way to declare that a function does not return, which works in the current version and in some older versions, is as follows:

            typedef void voidfn ();
            
            volatile voidfn fatal;
         

    This approach does not work in GNU C++.

gxqcn 发表于 2011-5-11 10:46:04

7# gxqcn
很好搜索吧:
下载地址:
http://www.oldlinux.org/Linux.old/bochs/linux-0.11-040305.zip
源自:http://www.oldlinux.org/
wayne 发表于 2011-5-11 10:12 http://bbs.emath.ac.cn/images/common/back.gif

下载了那个zip档,解压后未发现memory.c文件。

wayne 发表于 2011-5-11 11:18:05

12# gxqcn
sorry , the link is
http://www.oldlinux.org/Linux.old/kernel/0.1x/linux-0.11-040327-rh9.tar.gz

wayne 发表于 2011-5-11 11:23:43

13# wayne
顺着这个路径的上级目录,我找到了linux 1.00 的源代码:
http://www.oldlinux.org/Linux.old/kernel/1.00/
发现memory.c 文件里的oom函数 变成了:void oom(struct task_struct * task)
{
        printk("\nout of memory\n");
        task->sigaction.sa_handler = NULL;
        task->blocked &= ~(1<<(SIGKILL-1));
        send_sig(SIGKILL,task,1);
}
:D

gxqcn 发表于 2011-5-11 11:46:37

这里的 old linux 是指老版本吗?
那最新版的 memory.c 是啥样?能发上来吗?

wayne 发表于 2011-5-11 12:03:30

15# gxqcn
发现oom函数在最新版本的linux里 不见踪迹了
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=mm/memory.c;h=61e66f026563b4b473fc73922d58a984c490c827;hb=HEAD

Cache Last Updated:Wed May 11 04:01:52 2011 GMT
页: 1 [2]
查看完整版本: volatile 可以用来修饰函数返回值吗