linux内核数学函数,如何在内核中调用数学函数

为什么我在内核中无法调用数学函数

总是提示无法找到该函数(sin,sqrt... 都不行)

system: debian linux

下面是我的makefile文件,和源代码

//

/*********Makefile**********/

obj-m:= helloworld.o

KDIR:= /lib/modules/$(shell uname -r)/build

PWD:= $(shell pwd)

EXTRA_CFLAGS := -I/usr/include/ -ffast-math -mhard-float -lm

default:

$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:

rm -rf .*.cmd *.o *.mod.c *.ko .tmp_version

/*********hello.c**********/

#include

#include

#include

#include

MODULE_LICENSE("GPL");

static int hello_init(void) {

unsigned int cr3;

double s=3;

__asm__ ("movl %%cr3, %0":"=a"(cr3));

printk(KERN_ALERT "Hello, worldn");

printk(KERN_ALERT "The process is "%s" (pid %i)n", current->comm, current->pid);

printk(KERN_ALERT "The cr3 register is "%08X"n", cr3);

//test math function

s=sin(s);

return 0;

}

static void hello_exit(void) {

printk(KERN_ALERT "Goodbye, cruel worldn");

}

module_init(hello_init);

module_exit(hello_exit);

|

see chapter 3.3.4 of ULK3

|

你的math.h是C库提供的,它在用户空间,而不在内核空间。

|

understand linux kernel 3rd edition

|

source code static link when u are compling

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值