Upload
-
View
1.222
Download
7
Embed Size (px)
DESCRIPTION
NetBSD6.X (i386)が2038年問題に対応しましたが、その余波で clu2c が同OSで動かなくなりました。そのりゆうについて述べます。
Citation preview
NetBSD 6.X (i386)が2038年問題に対応
その余波
東平洋史
こんなん動態保存してます
clu2c(くるーつーしー)とは何ですか?
プログラミング言語CLUの処理系
• プログラミング言語CLUで書かれたプログラムをCで書かれたプログラムに変換(CLU to C)
• Cで書かれたプログラムを実行形式(a.out)にコンパイル
CLUのプログラム
Cのプログラム
clu2c
ライブラリ
clulink実行形式
a.out
clu2cでの戻り値の処理
• Cの関数の戻り値
–正常終了か例外発生するかのフラグ
• CLUの戻り値
–大域変数に格納
retval_area[0]
retval_area[1]
…
オブジェクト
intポインタ
整数型とビット数
データモデル
システム long long long
ポインタ
ILP32 NetBSD 5.X(i386)
32 64 32
ILP32 NetBSD 6.X(i386)
32 64 32
LP64 64bit Linux 64 64 64
LP64 NetBSD 6.X (amd64)
64 64 64
clu2cでのint型(CLU)とビット数
データモデル
システムint型(CLU)
戻り値用大域変数
ポインタ
ILP32NetBSD 5.X
(i386)32 32 32
ILP32NetBSD 6.X
(i386)32 32 32
LP64 64bit Linux 64 64 64
LP64NetBSD 6.X
(amd64)64 64 64
稼働確認済みの環境(一部)
• Cygwin
• Ubuntu 13.04
– i386
– amd64
• OpenSUSE 12.3
– 32bit
– 64bit
• FreeBSD 9.1
– i386
• NetBSD 5.2
– I386
– amd64
• NetBSD 6.0.1
– i386
– amd64
• NetBSD 6.1
– i386
– amd64
稼働確認済みの環境(NetBSD)
• NetBSD 6.0.1
–i386
–amd64
• NetBSD 6.1
–i386
–amd64
• NetBSD 5.2
–I386
–amd64
NetBSD 6.Xでは
64bitでのみ可動
その前に
西暦2038年問題(C言語のtime_t型)
• 西暦2038年1月19日3時14分7秒(UTC)過ぎにC言語のtime_t型を使ったプログラムが誤作動
– 西暦1970年1月1日0時0分0秒(UTC)からの経過秒数で時間を表現
– 32ビット符号つきの整数で実装した場合に問題発生
– 西暦2038年1月19日3時14分7秒(UTC)
⇒西暦1901年12月13日20時45分7(UTC)
•2^31 – 1 = 2147483647 の次を -2^31 = -2147483648 と認識
0 1111111111111111111111111111111 = 2^31 - 1
1 0000000000000000000000000000000 = -2^31
1 1111111111111111111111111111111 = -1
先頭のビットが1の時はマイナスの数になる
NetBSD 6.X になって…
In addition to many other features, NetBSD6.0 includes significant developments in various ports. Some highlights:
• time_t is now a 64-bit quantity on all NetBSD ports. This means that the NetBSD world no longer ends in 2037.
<http://www.netbsd.org/releases/formal-6/NetBSD-6.0.html>
NetBSD 6.X のtime_t型は
64bit
clu2cでのtime_t型
intとして扱う
使用例get_atime = proc(S: _external_struct_stat) returns(int)
% effects Returns the `st_atime' member of S.
end get_atime
get_mtime = proc(S: _external_struct_stat) returns(int)
% effects Returns the `st_mtime' member of S.
end get_mtime
整数型とtime_t型とビット数
データモデル
システム time_tCLUの
int戻り値用大域変数
ポインタ
ILP32NetBSD 5.X
(i386)32 32 32 32
ILP32NetBSD 6.X
(i386)64 32 32 32
LP64 64bit Linux 64 64 64 64
LP64NetBSD 6.X
(amd64)64 64 64 64
整数型とtime_t型とビット数
データモデル
システム time_tCLUの
int戻り値用大域変数
ポインタ
ILP32NetBSD 6.X
(i386)64 32 32 32
ココだけ違う
というわけで
NetBSD 6.X で clu2c が動かない理由
• Cの time_t型が64bitになった
– NetBSD 5.X までは 32bit
• clu2cはCの time_t型をCLUの int型として扱っていた
• 32bit アプリケーションではCLUの int型を32bitにしていた
解決策(実装作業中)
• Cの time_t型専用の型を作成
• CLUの time_t型の具体表現を32/64bit両対応に
Cの time_t型ポインタ
32bit or 64bit32bit
おしまい(^.^)/~~~