红联Linux门户
Linux帮助

linux内核中的long long类型计算问题

发布时间:2007-04-04 00:51:44来源:红联作者:competent
编译时如果遇到

i386-linux-ld -m elf_i386 -T /build/trunk/snapgear/AscenApps/linux-2.4.32/arch/i386/vmlinux.lds -e stext arch/i386/kernel/head.o arch/i386/kernel/init_task.o init/main.o init/version.o init/do_mounts.o \
--start-group \
arch/i386/kernel/kernel.o arch/i386/mm/mm.o kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o \
drivers/acpi/acpi.o drivers/char/char.o drivers/serial/serial.o drivers/block/block.o drivers/misc/misc.o drivers/net/net.o drivers/ide/idedriver.o drivers/cdrom/driver.o drivers/pci/driver.o drivers/video/video.o drivers/media/media.o arch/i386/math-emu/math.o \
net/network.o \
/build/trunk/snapgear/AscenApps/linux-2.4.32/arch/i386/lib/lib.a /build/trunk/snapgear/AscenApps/linux-2.4.32/lib/lib.a /build/trunk/snapgear/AscenApps/linux-2.4.32/arch/i386/lib/lib.a \
--end-group \
-o vmlinux
net/network.o(.text+0x51586): In function `ipgre_rcv':
: undefined reference to `__divdi3'
make[1]: *** [vmlinux] Error 1
make[1]: Leaving directory `/build/trunk/snapgear/AscenApps/linux-2.4.32

很可能是由于内核中做了这样的运算 :

(long long)(jiffies*1000/HZ) - (long long)ntohl(ptime->tv_sec)*1000 - (long long)ntohl(ptime->tv_usec)/1000;

long long 除以1000了。改成:

(long long)((long long)(jiffies*1000/HZ) - (long long)ntohl(ptime->tv_sec)*1000 - (long long)(ntohl(ptime->tv_usec)/1000));

就可以了。
文章评论

共有 82 条评论

  1. 222.190.109.* 于 2007-07-26 17:40:03发表:

    在哪改阿我也遇到这个问题

  2. 84.220.177.* 于 2007-07-17 10:59:37发表:

    http://c483ce1ee0ec2b172c9393133c5b6e74-t.xkktxb.org c483ce1ee0ec2b172c9393133c5b6e74 http://c483ce1ee0ec2b172c9393133c5b6e74-b1.xkktxb.org c483ce1ee0ec2b172c9393133c5b6e74 http://c483ce1ee0ec2b172c9393133c5b6e74-b3.xkktxb.org 8d1f2bfe3cbc5359328d95464cab8b7c