Linux内核中的64位time_t [英] 64-bit time_t in Linux Kernel

查看:318
本文介绍了Linux内核中的64位time_t的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编译了内核3.19.1,但是time_t仍然有问题.只是一个带有cout << sizeof (time_t);的简单程序,它的大小为4字节,而不是我的意图8字节.

I have compiled kernel 3.19.1 but still have a problem with time_t. Just a simple program with cout << sizeof (time_t); gives size of 4 bytes, not 8 bytes as was my intention.

我应该在make menuconfig期间打开特定选项吗?

Should I switch on a particular option during make menuconfig?

推荐答案

当前time_t在内核中仅为long:请参见

Currently time_t is just long in kernel: see __kernel_time_t type definition. So if long type on your CPU is 32-bit long, time_t also is 32-bit long. Basically, if you have 32-bit CPU -- long type on your system is also 32-bit long. If you have 64-bit CPU -- long type will be 64-bit long.

如果您需要自己的64位类型,请使用long long.如果您希望内核时间API与64位长类型(time_t)一起使用-会有点困难(这意味着更改内核源代码).例如看

If you need your own 64-bit type -- just use long long. If you want kernel time API to work with 64-bit long type as time_t -- it's a little harder (implies changing kernel sources). For example take a look here. Also you may be interested in reading next links:

[1] 补丁集:将time_t和clock_t更改为64位"

[2] [3] 最终的time_t typedef是什么?

关于将time_t更改为long long后的建筑物问题(例如__divdi3等).

Regarding building issues (with __divdi3 etc.) after changing time_t to long long.

现在您已经将time_t的大小更改为64位,任何使用time_t的代码都将尝试使用64位操作. __divdi3表示: d ouble i 整数上的 div 确定操作. 3 代表操作数计数(如1 = 2 / 3).有关详细信息,请参见.因此,显然该操作尚未针对您的平台实施.您应该自己实现(在内核代码中),或者以某种方式使用gcc中的实现.下一个链接应为您提供帮助:

Now that you have changed time_t size to 64-bits, any code that uses time_t will try to use 64-bit operations. __divdi3 means: division operation on double integers. 3 stands for count of operands (like 1 = 2 / 3). See this for details. So this operation obviously hasn't implemented for your platform. You should either implement it by yourself (in kernel code) or use implementation from gcc somehow. Next links should help you:

[1] __udivdi3未定义.如何查找代码?

[2] divdi3除法用于long long由gcc在x86上

[3] 在gcc中的哪里找到udivdi3和umoddi3?

这篇关于Linux内核中的64位time_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆