📄 test_math.c
字号:
/*************************************************************************** test_math.c - Does math run in kernel-mode? ------------------- begin : 2003 authors : ineiti emails : linus.gassser@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 2003-02-28 - ineiti - begin 04/03/03 - ineiti - added a small description **************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/char desc[] ="Description:\n""Just verify whether the math works. Mostly interesting in kernel-mode,\n""where one isn't supposed to use maths. But with RTLinux, it works,\n""nevertheless...\n""The calculation is asin( 100/100 ) = 157/100\n\n";#include "spc.h"#include "std.h"#include <math.h>#define DBG_LVL 4void *start_it( void *arg ) { float x, y; x = 1.; y = asin( x ); // We can't print floats or doubles in the kernel, so we just print // a multiple of it... PR_DBG( 4, "asin(%i/100)=%i/100\n", (int)( x * 100 ), (int)( y * 100 ) ); return 0;}swr_spc_id_t spm_id;struct thread start;/** * This function is called upon "insmod" and is used to register the * different parts of the module to the SPM. */int um_module_init(void) { PR_CL( desc ); if ( swr_thread_init( &start, start_it, NULL ) < 0 ) goto first_no_stack; return 0;first_no_stack: PR_DBG( 0, "Couldn't allocate stack\n" ); return -1;}void um_module_exit( void ) { swr_thread_free( &start, NULL );}module_init( um_module_init );module_exit( um_module_exit );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -