<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div><div>er, ok, I partly did this.</div><div><br></div><div><br></div><div>https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-sys/m3middle/src/Target.m3.diff?r1=1.95;r2=1.96;f=u</div><div><br></div><div><br></div><div>Revision 1.96: download - view: text, markup, annotated - select for diffs</div><div>Thu Apr 1 17:56:37 2010 (5 years, 5 months ago) by jkrell</div><div>Branches: MAIN</div><div>Diff to: previous 1.95: preferred, unified</div><div>Changes since revision 1.95: +1 -9 lines</div><div><br></div><div><br></div><div>leave max_align =  64 for all platforms</div><div>this effects:</div><div>  I386_FREEBSD / FreeBSD4</div><div>  I386_LINUX / LINUXLIBC6</div><div>  NetBSD2_i386</div><div><br></div><div><br></div><div><br></div><div>It does not affect any others -- not PPC, not Darwin, not 64bit, not Solaris, not NT.</div><div><br></div><div><br></div><div>but it wasn't consistent across 32bit platforms or x86.</div><div>Nor should it necessarily -- I recall Cygwin wants to align</div><div>more than cm3, implying NT does.</div><div><br></div><div><br></div><div> - Jay</div></div><br><br><div><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Mon, 21 Sep 2015 07:07:21 +0000<br>Subject: Re: [M3devel] LONGINT/LONGREAL alignment on 32bit targets?<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}

--></style>
<div dir="ltr">Hm. Same thing with double/LONGREAL.<div>Do we need to fix this??</div><div>Or just use it as evidence that our interop isn't perfect but adequate?</div><div><br></div><div><div>jair:1 jay$ cat 1.c src/Main.m3</div><div>#include <stdio.h></div><div><br></div><div>int main()</div><div>{</div><div>printf("%d\n", (int)sizeof(struct {int a; double  b;}));</div><div>return 0;</div><div>}</div><div><br></div><div>MODULE Main;</div><div>IMPORT IO, Fmt, Ctypes;</div><div><br></div><div>BEGIN</div><div>IO.Put(Fmt.Int(BYTESIZE(RECORD a:Ctypes.int; b:LONGREAL; END)));</div><div>IO.Put("\n");</div><div>END Main.</div><div><br></div><div>jair:1 jay$ rm -rf I386_DARWIN/</div><div>jair:1 jay$  cm3 -DTARGET=I386_DARWIN  </div><div>--- building in I386_DARWIN ---</div><div><br></div><div>new source -> compiling Main.m3</div><div> -> linking a</div><div>jair:1 jay$ ./I386_DARWIN/a</div><div>16</div><div>jair:1 jay$ cc -m32 1.c</div><div>jair:1 jay$ ./a.out</div><div>12</div><div>jair:1 jay$ </div><div><br></div><div><br></div><div> - Jay</div><br><br><br><br><div><hr id="ecxstopSpelling">From: jay.krell@cornell.edu<br>To: m3devel@elegosoft.com<br>Date: Mon, 21 Sep 2015 07:04:49 +0000<br>Subject: [M3devel] LONGINT alignment on 32bit targets?<br><br>

<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}

.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}


--></style>
<div dir="ltr"><div>For the record, I didn't do this, way back even in:</div><div><br></div><div><br></div><div>https://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-sys/m3middle/src/Target.m3?rev=1.1;content-type=text%2Fplain</div><div><br></div><div><br></div><div>we had:</div><div><br></div><div><br></div><div>    (* build a generic 32-bit/IEEE system description *)</div><div><br></div><div>    Int64.cg_type    := CGType.Int64;</div><div>    Int64.size       := 64;</div><div>    Int64.align      := 64;</div><div>    Int64.min.x      := IChunks { 00, 00, 00, 16_8000 };</div><div>    Int64.max.x      := IChunks { FF, FF, FF, 16_7fff };</div><div><br></div><div><br></div><div><br></div><div>This is likely wrong on many/most/all 32bit targets.</div><div><br></div><div><br></div><div><br></div><div>Int64 is likely to be loaded/stored with two 32bit operations, <span style="font-size:12pt;">therefore align probably should be 32.</span></div><div><br></div><div><br></div><div>At the time, I don't think there was any way to use this type, i.e.</div><div>there was no LONGINT.</div><div><br></div><div><br></div><div>Once LONGINT came into being, if you wrote:</div><div><br></div><div><br></div><div>foo.m3</div><div>RECORD</div><div>  a: Ctypes.int;</div><div>  b: LONGINT</div><div>END;</div><div><br></div><div><br></div><div>and foo.c:</div><div>struct </div><div>{</div><div> int a;</div><div> long long b;</div><div>};</div><div><br></div><div><br></div><div>you would probably get different layout.</div><div><br></div><div><br></div><div>Let's see:</div><div><br></div><div><br></div><div>jair:src jay$ cat 1.c</div><div>int a = sizeof(struct </div><div>{</div><div> int a;</div><div> long long b;</div><div>});</div><div>jair:src jay$ cc -c -S -m32 1.c</div><div>jair:src jay$ cat 1.s</div><div><span class="ecxApple-tab-span" style="white-space:pre;">       </span>.section<span class="ecxApple-tab-span" style="white-space:pre;">        </span>__TEXT,__text,regular,pure_instructions</div><div><span class="ecxApple-tab-span" style="white-space:pre;">  </span>.macosx_version_min 10, 10</div><div><span class="ecxApple-tab-span" style="white-space:pre;">       </span>.section<span class="ecxApple-tab-span" style="white-space:pre;">        </span>__DATA,__data</div><div><span class="ecxApple-tab-span" style="white-space:pre;">    </span>.globl<span class="ecxApple-tab-span" style="white-space:pre;">  </span>_a                      ## @a</div><div><span class="ecxApple-tab-span" style="white-space:pre;">     </span>.align<span class="ecxApple-tab-span" style="white-space:pre;">  </span>2</div><div>_a:</div><div><span class="ecxApple-tab-span" style="white-space:pre;">      </span>.long<span class="ecxApple-tab-span" style="white-space:pre;">   </span>12                      ## 0xc</div><div><br></div><div><br></div><div>jair:1 jay$ cat 1.c src/Main.m3 src/m3makefile </div><div>#include <stdio.h></div><div><br></div><div>int main()</div><div>{</div><div>printf("%d\n", (int)sizeof(struct {int a; long long b;}));</div><div>return 0;</div><div>}</div><div><br></div><div>MODULE Main;</div><div>IMPORT IO, Fmt, Ctypes;</div><div><br></div><div><br></div><div>BEGIN</div><div>IO.Put(Fmt.Int(BYTESIZE(RECORD a:Ctypes.int; b:LONGINT; END)));</div><div>IO.Put("\n");</div><div>END Main.</div><div><br></div><div>import("m3core")</div><div>import("libm3")</div><div>implementation("Main")</div><div>build_standalone()</div><div>program("a")</div><div><br></div><div>jair:1 jay$ cc -m32 1.c</div><div>jair:1 jay$ ./a.out</div><div>12</div><div><br></div><div>jair:1 jay$  cm3 -DTARGET=I386_DARWIN  </div><div>--- building in I386_DARWIN ---</div><div><br></div><div>new source -> compiling Main.m3</div><div> -> linking a</div><div>jair:1 jay$ ./I386_DARWIN/a</div><div><br></div><div>16</div><div><br></div><div><br></div><div><br></div><div><br></div><div>Now, if you are going to use x86 interlocked instructions on this,</div><div>you might need higher alignment anyway. Might.</div><div><br></div><div><br></div><div><br></div><div>(Which all goes to my point -- while layout rules can't actually be removed,</div><div>they have to exist, it does behoove one to try to layout data that has</div><div>obvious portable layout, if you need interop. i.e. you just would not ever</div><div>have a record like this. You would make the likely padding explicit.</div><div>Or sort by size. Though once you put records within records, it becomes</div><div>difficult/impossible.)</div><div><br></div><div><br></div><div><br></div><div> - Jay</div><br>                                          </div>
<br>_______________________________________________
M3devel mailing list
M3devel@elegosoft.com
https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3devel</div></div>                                       </div>
<br>_______________________________________________
M3devel mailing list
M3devel@elegosoft.com
https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3devel</div>                                           </div></body>
</html>