Skip to content
Tcl Source Code History Of Ticket 931802a0f552db2e
Login

History Of Ticket 931802a0f552db2e

Artifacts Associated With Ticket 931802a0f552db2e

  1. Ticket change [6312c6358a] (rid 203741) by chrstphrchvz on 2022-09-06 09:11:04:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      Both TIP 72 and the IntObj documentation say that <tt>Tcl_WideInt</tt> (wide integer, and <tt>Tcl_WideUInt</tt> unsigned wide integer) is "at least" 64 bits. For clarity and compatibility, I would propose requiring <tt>Tcl_WideInt</tt> to be exactly 64 bits, at least until some future Tcl version.
      
      Some compilers on some platforms, such as GCC and Clang on 64-bit (but not 32-bit), already offer an <tt>__int128</tt> type. 128-bit arithmetic is accomplished using several 64-bit operations, since it is not natively supported by hardware (general purpose register file/ALU), similar to how 64-bit operations are accomplished on 32-bit platforms. But even without native 128-bit arithmetic, <tt>__int128</tt> could still be far faster than bignum for any Tcl applications doing up to 128-bit computing.
      
      However, I would think far more software, including core Tcl, would be broken by defining <tt>Tcl_WideInt</tt> as wider than 64-bit. And following TIP 484, there is presumably little interest in Tcl once again having two "native" integer types (wide and double-wide).
      
      So maybe defining <tt>Tcl_WideInt</tt> as anything other than 64 bit, e.g.<tt>__int128</tt>, should be forbidden. Alternatively, if <tt>Tcl_WideInt</tt> is to ever be redefined as (preferably exactly) 128-bit, it should be done by some future Tcl version when the ABI is allowed to change.
      
    5. is_private initialized to: "0"
    6. login: "chrstphrchvz"
    7. priority initialized to: "5 Medium"
    8. resolution initialized to: "None"
    9. severity initialized to: "Minor"
    10. status initialized to: "Open"
    11. submitter initialized to: "chrstphrchvz"
    12. subsystem initialized to: "10. Objects"
    13. title initialized to:
      Require Tcl_WideInt/Tcl_WideUInt to be exactly 64 bits
      
    14. type initialized to: "RFE"
  2. Ticket change [bb8ccef738] (rid 203742) by chrstphrchvz on 2022-09-06 09:35:11:

    1. icomment:
      Alternatively, amend any “at least 64-bit” verbiage to say something like “smallest type covering 64-bit range”. That way, the 64-bit type is always used on platforms with one, and any debates are avoided regarding what to do for an unusual platform only having type(s) larger than but not exactly 64 bits.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [06d0e04968] (rid 203743) by jan.nijtmans on 2022-09-06 10:30:37:

    1. assignee changed to: "jan.nijtmans"
    2. icomment:
      See TIP #476: 
      
      <pre>
      Whenever possible, typedef `Tcl_WideInt` to be equal to `long long`, even
      on platforms where long has the same size as `long long`.
      </pre>
      
      I don't think there's any platform (still supported by Tcl 8.7) which doesn't have "long long". Does that answer your concern?
      
      Indeed, changing Tcl_WideInt is a binary incompatible thing to do. I just consider it the same as "long long".
      
      The biggest problem using __int128 would be that there is no matching printf modifier. Does 'inttypes.h' have a definition for 'PRId128'??? I never say that anywhere. Tcl has 'TCL_LL_MODIFIER'(see the same TIP), that wouldn't work any more
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
  4. Ticket change [1d151b3ba4] (rid 203762) by jan.nijtmans on 2022-09-06 15:57:01:

    1. icomment: "Dup of [45ddcfc3b1]"
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [1b69c18c4e] (rid 204372) by chrstphrchvz on 2022-09-17 21:51:56:

    1. icomment:
      I ask mainly in case it would be nice to know that <tt>Tcl_WideInt</tt> is exactly 64-bit when writing library/extension code (a possibly more strict guarantee than it being <tt>long long</tt>), but even without this guarantee, any concerns seem remote enough for the time being.
      
      I now notice the IntObj documentation has already taken TIP 476 into account, so I am probably just behind (Tcl 8.6 not requiring C99 probably a reason for it to avoid mentioning <tt>long long</tt>). The ABI stability requirement should already be obvious to me, though maybe that is not what I should have asked about, and instead I should have asked about <tt>__int128</tt> merely as a configuration option for those not concerned about ABI compatibility with anything built with Tcl defaults. But as long as compilers have yet to provide format specifiers for <tt>__int128</tt> then I agree there isn’t much for early adopters to try; they are probably better off adding a new Tcl value type for <tt>__int128</tt> than redefining <tt>Tcl_WideInt</tt>.
      
      I had searched this site for <tt>__int128</tt> but was not lead to the existing ticket. I am fine with this ticket being closed as e.g. duplicate or out of date.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [bbac1f16f3] (rid 204626) by jan.nijtmans on 2022-09-22 15:50:54:

    1. closedate changed to: "2459845.16035722"
    2. closer changed to: "jan.nijtmans"
    3. login: "jan.nijtmans"
    4. mimetype: "text/plain"
    5. resolution changed to: "Duplicate"
    6. status changed to: "Closed"