www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos Patch - Version (X86_64) for struct_stat64 on Linux x86_64

reply Chuck Blake <cb mit.edu> writes:
Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
an awful lot of file IO.

I have a small patch that fixes it by just adding a version fork for X86_64 in
the default fallback version{} (which should perhaps be labeled Linux since
all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
its output to the 'stat' utility.  This fix is so basic and logic-free that I
seriously doubt environmental considerations matter, and in any event it is an
unhandled version{}.

This doesn't completely fix file IO, but it at least gives it a running
chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
bugs and fixes.
begin 644 stat64_x86_64.patch
M(R!(1R!C:&%N9V5S970 <&%T8V *(R!5<V5R(&-B0&UI="YE9'4*(R!$871E





M8F$Q861A-B!D+W!H;V)O<S(O<W1D+V9I;&4N9`HM+2T 82]D+W!H;V)O<S(O

M(&(O9"]P:&]B;W,R+W-T9"]F:6QE+F0)5'5E($1E8R`R."`Q.3HS,3HT,B`R

M;'-E"B` ("` >PHM("` ("` ("!S=')U8W0 <W1R=6-T7W-T870V-"` ("` 
M("` +R\ 9&ES=&EN9W5I<V  :70 9G)O;2!T:&4 <W1A=" I(&9U;F-T:6]N
M"BL ("` ("` ('9E<G-I;VX *% X-E\V-"D >R` ("` ("` ("`O+R!,:6YU

M=&%T-C0**R` ("` ("` ("` ('L**R` ("` ("` ("` ("` ("!U;&]N9R!S
M=%]D978[("` ("` ("\O($1E=FEC92X**R` ("` ("` ("` ("` ("!U;&]N
M9R!S=%]I;F\[("` ("` ("\O($9I;&4 <V5R:6%L(&YU;6)E<BX**R` ("` 
M("` ("` ("` ("!U;&]N9R!S=%]N;&EN:SL ("` ("\O($QI;FL 8V]U;G0N
M"BL ("` ("` ("` ("` ("` =6EN="` <W1?;6]D93L ("` ("`O+R!&:6QE
M(&UO9&4N"BL ("` ("` ("` ("` ("` =6EN="` <W1?=6ED.R` ("` ("`O
M+R!5<V5R($E$(&]F('1H92!F:6QE)W, ;W=N97(N(`HK("` ("` ("` ("` 
M("` ('5I;G0 ('-T7V=I9#L ("` ("` +R\ 1W)O=7` 240 ;V8 =&AE(&9I

M("` ("` ("` ("` ("` =6QO;F< <W1?<F1E=CL ("` ("`O+R!$979I8V4 
M;G5M8F5R+"!I9B!D979I8V4N"BL ("` ("` ("` ("` ("` ;&]N9R` <W1?
M<VEZ93L ("` ("`O+R!3:7IE(&]F(&9I;&4L(&EN(&)Y=&5S+ HK("` ("` 
M("` ("` ("` (&QO;F< ('-T7V)L:W-I>F4[("` +R\ 3W!T:6UA;"!B;&]C
M:R!S:7IE(&9O<B!)+T\N"BL ("` ("` ("` ("` ("` ;&]N9R` <W1?8FQO
M8VMS.R` ("`O+R!.<BX -3$R+6)Y=&4 8FQO8VMS(&%L;&]C871E9"X**R` 
M("` ("` ("` ("` ("!L;VYG("!S=%]A=&EM93L ("` ("\O(%1I;64 ;V8 
M;&%S="!A8V-E<W,N"BL ("` ("` ("` ("` ("` =6QO;F< <W1?871I;65N
M<V5C.R`O+R!.<V-E8W, ;V8 ;&%S="!A8V-E<W,N"BL ("` ("` ("` ("` 
M("` ;&]N9R` <W1?;71I;64[("` ("`O+R!4:6UE(&]F(&QA<W0 ;6]D:69I
M8V%T:6]N+ HK("` ("` ("` ("` ("` ('5L;VYG('-T7VUT:6UE;G-E8SL 
M+R\ 3G-E8W, ;V8 ;&%S="!M;V1I9FEC871I;VXN"BL ("` ("` ("` ("` 
M("` ;&]N9R` <W1?8W1I;64[("` ("`O+R!4:6UE(&]F(&QA<W0 <W1A='5S
M(&-H86YG92X**R` ("` ("` ("` ("` ("!U;&]N9R!S=%]C=&EM96YS96,[
M("\O($YS96-S(&]F(&QA<W0 <W1A='5S(&-H86YG92X**R` ("` ("` ("` 
M("` ("!L;VYG("!?7W5N=7-E9%LS73L**R` ("` ("` ("` ('T**R` ("` 
M("` ?0HK("` ("` ("!E;'-E"B` ("` ("` ('L*+2` ("` ("` ("` ('5L
M;VYG('-T7V1E=CL ("` ("` ("\O+R!D979I8V4*+2` ("` ("` ("` ('5I
M;G0 7U]P860Q.PHM("` ("` ("` ("` =6EN="!S=%]I;F\[("` ("` ("`O
M+R\ 9FEL92!S97)I86P ;G5M8F5R"BT ("` ("` ("` ("!U:6YT('-T7VUO
M9&4[("` ("` ("`O+R\ 9FEL92!M;V1E"BT ("` ("` ("` ("!U:6YT('-T
M7VYL:6YK.R` ("` ("` +R\O(&QI;FL 8V]U;G0*+2` ("` ("` ("` ('5I
M;G0 <W1?=6ED.R` ("` ("` +R\O('5S97( 240 ;V8 9FEL92=S(&]W;F5R
M"BT ("` ("` ("` ("!U:6YT('-T7V=I9#L ("` ("` ("\O+R!U<V5R($E$
M(&]F(&=R;W5P)W, ;W=N97(*+2` ("` ("` ("` ('5L;VYG('-T7W)D978[
M("` ("` ("`O+R\ :68 9&5V:6-E('1H96X 9&5V:6-E(&YU;6)E< HM("` 

M;&]N9R!S=%]S:7IE.PHM("` ("` ("` ("` :6YT('-T7V)L:W-I>F4[("` 
M("` ("`O+R\ ;W!T:6UA;"!)+T\ 8FQO8VL <VEZ90HM("` ("` ("` ("` 
M=6QO;F< <W1?8FQO8VMS.R` ("` ("` +R\O(&YU;6)E<B!O9B!A;&QO8V%T
M960 -3$R(&)Y=&4 8FQO8VMS"BT ("` ("` ("` ("!I;G0 <W1?871I;64[
M"BT ("` ("` ("` ("!U:6YT('-T7V%T:6UE;G-E8SL*+2` ("` ("` ("` 
M(&EN="!S=%]M=&EM93L*+2` ("` ("` ("` ('5I;G0 <W1?;71I;65N<V5C
M.PHM("` ("` ("` ("` :6YT('-T7V-T:6UE.PHM("` ("` ("` ("` =6EN
M="!S=%]C=&EM96YS96,["BT*+2` ("` ("` ("` ('5L;VYG('-T7VEN;S8T
M.PHK("` ("` ("` ("` <W1R=6-T('-T<G5C=%]S=&%T-C0 ("` +R\ 9&ES
M=&EN9W5I<V  :70 9G)O;2!T:&4 <W1A=" I(&9U;F-T:6]N"BL ("` ("` 
M("` ("!["BL ("` ("` ("` ("` ("` =6QO;F< <W1?9&5V.R` ("` ("`O
M+R\ 9&5V:6-E"BL ("` ("` ("` ("` ("` =6EN="` 7U]P860Q.PHK("` 
M("` ("` ("` ("` ('5I;G0 ('-T7VEN;SL ("` ("` +R\O(&9I;&4 <V5R
M:6%L(&YU;6)E< HK("` ("` ("` ("` ("` ('5I;G0 ('-T7VUO9&4[("` 
M("` +R\O(&9I;&4 ;6]D90HK("` ("` ("` ("` ("` ('5I;G0 ('-T7VYL
M:6YK.R` ("` +R\O(&QI;FL 8V]U;G0**R` ("` ("` ("` ("` ("!U:6YT
M("!S=%]U:60[("` ("` ("\O+R!U<V5R($E$(&]F(&9I;&4G<R!O=VYE< HK
M("` ("` ("` ("` ("` ('5I;G0 ('-T7V=I9#L ("` ("` +R\O('5S97( 
M240 ;V8 9W)O=7`G<R!O=VYE< HK("` ("` ("` ("` ("` ('5L;VYG('-T
M7W)D978[("` ("` +R\O(&EF(&1E=FEC92!T:&5N(&1E=FEC92!N=6UB97(*

M("` 86QI9VXH-"D =6QO;F< <W1?<VEZ93L**R` ("` ("` ("` ("` ("!I
M;G0 ("!S=%]B;&MS:7IE.R` ("\O+R!O<'1I;6%L($DO3R!B;&]C:R!S:7IE
M"BL ("` ("` ("` ("` ("` =6QO;F< <W1?8FQO8VMS.R` ("`O+R\ ;G5M
M8F5R(&]F(&%L;&]C871E9"`U,3( 8GET92!B;&]C:W,**R` ("` ("` ("` 
M("` ("!I;G0 ("!S=%]A=&EM93L**R` ("` ("` ("` ("` ("!U:6YT("!S
M=%]A=&EM96YS96,["BL ("` ("` ("` ("` ("` :6YT("` <W1?;71I;64[
M"BL ("` ("` ("` ("` ("` =6EN="` <W1?;71I;65N<V5C.PHK("` ("` 
M("` ("` ("` (&EN="` ('-T7V-T:6UE.PHK("` ("` ("` ("` ("` ('5I
M;G0 ('-T7V-T:6UE;G-E8SL**R` ("` ("` ("` ("` ("!U;&]N9R!S=%]I
M;F\V-#L**R` ("` ("` ("` ('T*("` ("` ("` ?0HM"B` ("` ("` (&5X

M("` ("` 97AT97)N*$,I(&EN="!S=&%T-C0H:6X 8VAA<BHL('-T<G5C=%]S
0=&%T-C0J*3L*("` ("!]" ``
`
end
begin 644 stat.d
M:6UP;W)T('-T9"YS=&1I;RP <W1D+F9I;&4L('-T9"YS=')I;F<[" II;G0 
M;6%I;BAC:&%R6UU;72!A<F=S*2!["B` ("!V97)S:6]N("A0;W-I>"D >PH 
M("` ("` ('-T<G5C=%]S=&%T-C0 <W0 /2!V;VED.PH ("` ("` (&9O<F5A
M8V  *'!A=& [(&%R9W-;,2`N+B!A<F=S+FQE;F=T:%TI('L*("` ("` ("` 

M:68 *'!A=&  (3T 87)G<ULQ72D*("` ("` ("` ("` ("` ('=R:71E9FQN
M*"(B*3L*("` ("` ("` ("` =W)I=&5F;&XH(G!A=&  ("` ("` ("`Z("5S
M(BP <&%T:"D["B` ("` ("` ("` ('=R:71E9FQN*")S=%]D978 ("` ("` 
M.B`E<R(L('-T+G-T7V1E=BD["B` ("` ("` ("` ('=R:71E9FQN*")S=%]I
M;F\ ("` ("` .B`E<R(L('-T+G-T7VEN;RD["B` ("` ("` ("` ('=R:71E
M9FQN*")S=%]N;&EN:R` ("` .B`E<R(L('-T+G-T7VYL:6YK*3L*("` ("` 
M("` ("` =W)I=&5F;&XH(G-T7VUO9&4 ("` ("`Z("5O(BP <W0N<W1?;6]D
M92D["B` ("` ("` ("` ('=R:71E9FQN*")S=%]U:60 ("` ("` .B`E<R(L
M('-T+G-T7W5I9"D["B` ("` ("` ("` ('=R:71E9FQN*")S=%]G:60 ("` 
M("` .B`E<R(L('-T+G-T7V=I9"D["B` ("` ("` ("` ('=R:71E9FQN*")S
M=%]R9&5V("` ("` .B`E<R(L('-T+G-T7W)D978I.PH ("` ("` ("` ("!W
M<FET969L;B B<W1?<VEZ92` ("` (#H )7,B+"!S="YS=%]S:7IE*3L*("` 
M("` ("` ("` =W)I=&5F;&XH(G-T7V)L:W-I>F4 ("`Z("5S(BP <W0N<W1?
M8FQK<VEZ92D["B` ("` ("` ("` ('=R:71E9FQN*")S=%]B;&]C:W, ("` 
M.B`E<R(L('-T+G-T7V)L;V-K<RD["B` ("` ("` ("` ('=R:71E9FQN*")S
M=%]A=&EM92` ("` .B`E<R(L('-T+G-T7V%T:6UE*3L*("` ("` ("` ("` 
M=W)I=&5F;&XH(G-T7V%T:6UE;G-E8R`Z("5S(BP <W0N<W1?871I;65N<V5C
M*3L*("` ("` ("` ("` =W)I=&5F;&XH(G-T7VUT:6UE("` ("`Z("5S(BP 
M<W0N<W1?;71I;64I.PH ("` ("` ("` ("!W<FET969L;B B<W1?;71I;65N
M<V5C(#H )7,B+"!S="YS=%]M=&EM96YS96,I.PH ("` ("` ("` ("!W<FET
M969L;B B<W1?8W1I;64 ("` (#H )7,B+"!S="YS=%]C=&EM92D["B` ("` 
M("` ("` ('=R:71E9FQN*")S=%]C=&EM96YS96, .B`E<R(L('-T+G-T7V-T

`
end
Dec 28 2010
next sibling parent Jason House <jason.james.house gmail.com> writes:
Chuck Blake Wrote:

 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.
The correct place is bugzilla http://d.puremagic.com/issues/
Dec 28 2010
prev sibling next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
Chuck Blake wrote:
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.
 begin 644 stat64_x86_64.patch
 M(R!(1R!C:&%N9V5S970 <&%T8V *(R!5<V5R(&-B0&UI="YE9'4*(R!$871E
This is great. Could you simply email me the files, please?
Dec 28 2010
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Chuck Blake (cb mit.edu)'s article
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.
  << stat64_x86_64.patch >>
  << stat.d >>
Thanks! I'll test and merge this in with my next round of commits. :) Regards Iain
Dec 29 2010
prev sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Chuck Blake (cb mit.edu)'s article
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.
  << stat64_x86_64.patch >>
  << stat.d >>
OK, I've had a proper look, is there any reason why phobos isn't using the stat_t implementation in druntime? That would fix this... Regards
Dec 30 2010
next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Iain Buclaw (ibuclaw ubuntu.com)'s article
 == Quote from Chuck Blake (cb mit.edu)'s article
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 I have a small patch that fixes it by just adding a version fork for X86_64
in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested
this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and
comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is
an
 unhandled version{}.
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted
this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to
report
 bugs and fixes.
  << stat64_x86_64.patch >>
  << stat.d >>
OK, I've had a proper look, is there any reason why phobos isn't using the
stat_t
 implementation in druntime?
 That would fix this...
 Regards
The lazy fix (in my tree): diff -r 8a2198026630 d/phobos2/std/file.d --- a/d/phobos2/std/file.d Tue Dec 28 23:11:26 2010 +0000 +++ b/d/phobos2/std/file.d Thu Dec 30 13:40:42 2010 +0000 -98,6 +98,12 alias core.sys.posix.sys.stat.fstat fstat64; alias core.sys.posix.sys.stat.stat stat64; } + else version (linux) + { + alias core.sys.posix.sys.stat.stat_t struct_stat64; + alias core.sys.posix.sys.stat.fstat fstat64; + alias core.sys.posix.sys.stat.stat stat64; + } else { struct struct_stat64 // distinguish it from the stat() function Is there a bug report open for this? I'll have a look after breakfast. :) Regards
Dec 30 2010
prev sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
Iain Buclaw Wrote:
 
 OK, I've had a proper look, is there any reason why phobos isn't using the
stat_t
 implementation in druntime?
No good reason. I think the 64-bit version of stat_t may be screwed up (there's a bug report for it on dsource/druntime) but I'll take care of that before the next release.
Dec 30 2010
parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Sean Kelly (sean invisibleduck.org)'s article
 Iain Buclaw Wrote:
 OK, I've had a proper look, is there any reason why phobos isn't using the
stat_t
 implementation in druntime?
No good reason. I think the 64-bit version of stat_t may be screwed up
(there's a bug report for it on dsource/druntime) but I'll take care of that before the next release. You mean this one? http://d.puremagic.com/issues/show_bug.cgi?id=5206 And yes, looks like you are right. Required a little more tweaking and defining __WORDSIZE = 32 or 64 to get it correct to the C system size/alignment.
Dec 30 2010