<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 19/01/2017 02:53 p.m., Eliot Miranda via Cuis-dev wrote:
    <blockquote
cite="mid:CAC20JE2V92XTiZhujGcDU7Rt87b_9bi3PAiO2ayQEB=Nj3eraQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi All,
        <div><br>
        </div>
        <div>    currently the FFI has support for 8, 16, 32 & 64
          bit integers, but no support for C's long type.  In almost all
          C implementations byte is 8 bits, short is 16 bits, int is 32
          bits and long long is 64 bits.  But long may be either 32 or
          64 bits depending on programming model.</div>
        <div><br>
        </div>
        <div>In LP32 long is 32 bits, which is used in 32-bit unix, mac
          os and windows.</div>
        <div>In LP64 long is 64 bits, which is used in 64-bit unix and
          mac os.</div>
        <div>In LLP64 long is 32 bits, which is used in 64-bit windows.</div>
        <div><br>
        </div>
        <div>So having a type which is either 32 or 64 bits depending on
          platform is useful in modeling C's long type across
          platforms.  Esteban and I propose adding such a type to FFI
          kernel, actually two types, one unsigned, one signed.  So we
          propose extending the below (these constants are used to
          define signatures for FFI calls and the contents of structs)</div>
        <div><br>
        </div>
        <div>
          <div>FFIConstants class>>#initializeTypeConstants</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>"type void"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeVoid := 0.</div>
          <div><br>
          </div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>"type bool"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeBool := 1.</div>
          <div><br>
          </div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>"basic integer types.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>note: (integerType anyMask: 1) =
            integerType isSigned"</div>
          <div><br>
          </div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeUnsignedByte := 2.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeSignedByte := 3.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeUnsignedShort := 4.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeSignedShort := 5.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeUnsignedInt := 6.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeSignedInt := 7.</div>
          <div><br>
          </div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>"64bit types"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeUnsignedLongLong := 8.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeSignedLongLong := 9.</div>
          <div><br>
          </div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>"special integer types"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeUnsignedChar := 10.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeSignedChar := 11.</div>
          <div><br>
          </div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>"float types"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeSingleFloat := 12.</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFITypeDoubleFloat := 13.</div>
          <div><br>
          </div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>"type flags"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFIFlagAtomic := 16r40000. "type is atomic"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFIFlagPointer := 16r20000. "type is
            pointer to base type"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFIFlagStructure := 16r10000. "baseType is
            structure of 64k length"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFIStructSizeMask := 16rFFFF. "mask for max
            size of structure"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFIAtomicTypeMask := 16r0F000000. "mask for
            atomic type spec"</div>
          <div><span class="gmail-Apple-tab-span" style="white-space:
              pre;"> </span>FFIAtomicTypeShift := 24. "shift for atomic
            type"</div>
          <div><br>
          </div>
          <div>to add to</div>
          <div>
            <div><span class="gmail-Apple-tab-span" style="white-space:
                pre;"> </span>"special integer types"</div>
            <div><span class="gmail-Apple-tab-span" style="white-space:
                pre;"> </span>FFITypeUnsignedChar := 10.</div>
            <div><span class="gmail-Apple-tab-span" style="white-space:
                pre;"> </span>FFITypeSignedChar := 11.</div>
          </div>
          <div>
            <div><span class="gmail-Apple-tab-span" style="white-space:
                pre;"> </span>FFITypePlatformUnsignedLong := 14.</div>
            <div><span class="gmail-Apple-tab-span" style="white-space:
                pre;"> </span>FFITypePlatformSignedLong := 15.</div>
          </div>
          <div><br>
          </div>
          <div>This is backward compatible, even if it complicates the
            marshaling a little since it used to be that all integer
            types were less than FFITypeSingleFloat.  But breaking
            backward compatibility would be a bad idea.</div>
          <div><br>
          </div>
          <div>Then in ByteArray et al we could add accessors for
            platformLongAt: platformUnsignedLongAt:.</div>
          <div><br>
          </div>
          <div>Comments, thoughts, objections?</div>
          <div class="gmail_signature">
            <div dir="ltr">
              <div><span style="font-size: small; border-collapse:
                  separate;">
                  <div>_,,,^..^,,,_<br>
                  </div>
                  <div>best, Eliot</div>
                </span></div>
            </div>
          </div>
        </div>
      </div>
      <br>
    </blockquote>
    <br>
    Looks great to me.<br>
    <br>
    Thanks,<br>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis-smalltalk.org">www.cuis-smalltalk.org</a>
<a class="moz-txt-link-freetext" href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
@JuanVuletich</pre>
  </body>
</html>