git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v5 1/3] pager: include stdint.h because uintmax_t is used

From
Kyle Lippincott <spectral@google.com>
Date
Feb 27, 2024, 20:10 UTC
Message-ID
<CAO_smVg9phJGv=fMcHXjqvY74pHuMdousqfLMpyBcQ+fVMY90g@mail.gmail.com>
In-Reply-To
<20240227084529.GJ3263678@coredump.intra.peff.net>
On Tue, Feb 27, 2024 at 12:45 AM Jeff King <peff@peff.net> wrote:
Show 16 quoted lines
>
> On Mon, Feb 26, 2024 at 04:56:28PM -0800, Kyle Lippincott wrote:
>
> > > We use inttypes.h by default because the C standard already talks
> > > about it, and fall back to stdint.h when the platform lacks it.  But
> > > what I suspect is that nobody compiles with NO_INTTYPES_H and we
> > > would unknowingly (but not "unintentionally") start using the
> > > extended types that are only available in <inttypes.h> but not in
> > > <stdint.h> sometime in the future.  It might already have happened,
> >
> > It has. We use PRIuMAX, which is from inttypes.h.
>
> Is it always, though? That's what C99 says, but if you have a system
> that does not have inttypes.h in the first place, but does have
> stdint.h, it seems possible that it provides conversion macros elsewhere
> (either via stdint.h, or possibly just as part of stdio.h).

It's of course possible that on some platforms, stdio.h or stdint.h defines these types (or includes inttypes.h internally, which defines these types). However, I think that to be "correct" and for a compiler to claim it supports C99 (and the compiler _must_ claim that because of the guard in <git-compat-util.h>), inttypes.h must exist, and it must cause these symbols to appear. If there are platforms that are claiming to be C99 and inttypes.h doesn't exist or doesn't provide the symbols it should, I don't think we should try to support them - they can maintain platform-specific patches for whatever not-actually-C99 language the platform supports. Basically what git for windows is already doing (presumably for other reasons), as far as I can tell.

Show 25 quoted lines
>
> So it might be that things have been horribly broken on NO_INTTYPES_H
> systems for a while, and nobody is checking. But I don't think you can
> really say so without looking at such a system.
>
> And looking at config.mak.uname, it looks like Windows is such a system.
> Does it really have inttypes.h and it is getting included from somewhere
> else, making format conversion macros work? Or does it provide those
> macros elsewhere, and really needs stdint? It does look like
> compat/mingw.h includes it, but I think we wouldn't use that for msvc
> builds.
>
> > I think it's only
> > "accidentally" working if anyone uses NO_INTTYPES_H. I changed my
> > stance halfway through this investigation in my previous email, I
> > apologize for not going back and editing it to make it clear at the
> > beginning that I'd done so. My current stance is that
> > <git-compat-util.h> should be either (a) including only inttypes.h
> > (since it includes stdint.h), or (b) including both inttypes.h and
> > stdint.h (in either order), just to demonstrate that we can.
>
> It is good to clean up old conditionals if they are no longer
> applicable, as they are a burden to reason about later (as this
> discussion shows). But I am not sure about your "just to demonstrate we
> can".

Yeah, I'm also not convinced the "just to demonstrate we can" has much value. I was trying to get ahead of future discussions where we claim it's important to never include stdint.h (because people remember this discussion and how contentious it was) and think it might misbehave, and instead just include it in <git-compat-util.h> to prove it _doesn't_ misbehave, and thus start to allow usage in self-contained headers when necessary.

> It is good to try it out, but it looks like there is a non-zero
> chance that MSVC on Windows might break. It is probably better to try
> building there or looping in folks who can, rather than just making a
> change and seeing if anybody screams.

I think I miscommunicated here, or had too many assumptions about the current state of things that I didn't actually verify. When I wrote "and seeing if the build bots or maintainers identify it as a continuing issue", I was assuming that we had build bots for all major platforms (including windows, with however it gets built: mingw or VC or whatever), and I included the "maintainers" part of it for the long tail of esoteric platforms that we either don't know about, or can't have automated builds on for whatever reason. I agree that making changes that have a high likelihood of breaking supported platforms (which gets back to that platform support thread that was started a few weeks ago) should not be done lightly, and it's not reasonable to make the change and wait for maintainers of these "supported platforms" to complain. I was relying on the build bots covering the "supported platforms" and stopping me from even sending such a patch to the mailing list :)

Show 7 quoted lines
>
> I think the "win+VS" test in the GitHub Actions CI job might cover this
> case. It is not run by default (because it was considered be mostly
> redundant with the mingw build), but it shouldn't be too hard to enable
> it for a one-off test.
>
> -Peff
Previous: Jeff KingNext: Kyle Lippincott
Message 100 of 111 in “Introduce Git Standard Library”
  1. 0/8 Introduce Git Standard LibraryCalvin Wan, Jun 27, 2023
  2. 1/8 trace2: log fsync stats in trace2 rather than wrapperCalvin Wan, Jun 27, 2023
  3. Victoria DyeJun 28, 2023
  4. Calvin WanJul 5, 2023
  5. Victoria DyeJul 5, 2023
  6. Jeff HostetlerJul 11, 2023
  7. 2/8 hex-ll: split out functionality from hexCalvin Wan, Jun 27, 2023
  8. Phillip WoodJun 28, 2023
  9. Calvin WanJun 28, 2023
  10. 3/8 object: move function to object.cCalvin Wan, Jun 27, 2023
  11. 4/8 config: correct bad boolean env value error messageCalvin Wan, Jun 27, 2023
  12. 5/8 parse: create new library for parsing strings and env valuesCalvin Wan, Jun 27, 2023
  13. Junio C HamanoJun 27, 2023
  14. 6/8 pager: remove pager_in_use()Calvin Wan, Jun 27, 2023
  15. Junio C HamanoJun 27, 2023
  16. Calvin WanJun 27, 2023
  17. Glen ChooJun 28, 2023
  18. Glen ChooJun 28, 2023
  19. Calvin WanJun 28, 2023
  20. Junio C HamanoJun 28, 2023
  21. Junio C HamanoJun 28, 2023
  22. 8/8 git-std-lib: add test file to call git-std-lib.a functionsCalvin Wan, Jun 27, 2023
  23. 7/8 git-std-lib: introduce git standard libraryCalvin Wan, Jun 27, 2023
  24. Phillip WoodJun 28, 2023
  25. Calvin WanJun 28, 2023
  26. Phillip WoodJun 30, 2023
  27. Glen ChooJun 28, 2023
  28. Calvin WanJun 28, 2023
  29. Linus ArverJun 30, 2023
  30. 0/7 Introduce Git Standard LibraryCalvin Wan, Aug 10, 2023
  31. 2/7 object: move function to object.cCalvin Wan, Aug 10, 2023
  32. Junio C HamanoAug 10, 2023
  33. Glen ChooAug 10, 2023
  34. Junio C HamanoAug 10, 2023
  35. 1/7 hex-ll: split out functionality from hexCalvin Wan, Aug 10, 2023
  36. 3/7 config: correct bad boolean env value error messageCalvin Wan, Aug 10, 2023
  37. Junio C HamanoAug 10, 2023
  38. 5/7 date: push pager.h dependency upCalvin Wan, Aug 10, 2023
  39. Glen ChooAug 10, 2023
  40. Jonathan TanAug 14, 2023
  41. 4/7 parse: create new library for parsing strings and env valuesCalvin Wan, Aug 10, 2023
  42. Glen ChooAug 10, 2023
  43. Junio C HamanoAug 10, 2023
  44. Jonathan TanAug 14, 2023
  45. Jonathan TanAug 14, 2023
  46. Junio C HamanoAug 14, 2023
  47. 7/7 git-std-lib: add test file to call git-std-lib.a functionsCalvin Wan, Aug 10, 2023
  48. Jonathan TanAug 14, 2023
  49. 6/7 git-std-lib: introduce git standard libraryCalvin Wan, Aug 10, 2023
  50. Jonathan TanAug 14, 2023
  51. Glen ChooAug 10, 2023
  52. Phillip WoodAug 15, 2023
  53. Calvin WanAug 16, 2023
  54. Junio C HamanoAug 16, 2023
  55. Phillip WoodAug 15, 2023
  56. 0/6 Introduce Git Standard LibraryCalvin Wan, Sep 8, 2023
  57. 2/6 wrapper: remove dependency to Git-specific internal fileCalvin Wan, Sep 8, 2023
  58. Jonathan TanSep 15, 2023
  59. 1/6 hex-ll: split out functionality from hexCalvin Wan, Sep 8, 2023
  60. 3/6 config: correct bad boolean env value error messageCalvin Wan, Sep 8, 2023
  61. 4/6 parse: create new library for parsing strings and env valuesCalvin Wan, Sep 8, 2023
  62. 5/6 git-std-lib: introduce git standard libraryCalvin Wan, Sep 8, 2023
  63. Phillip WoodSep 11, 2023
  64. Phillip WoodSep 27, 2023
  65. Jonathan TanSep 15, 2023
  66. phillip.wood123@gmail.comSep 26, 2023
  67. 6/6 git-std-lib: add test file to call git-std-lib.a functionsCalvin Wan, Sep 8, 2023
  68. Junio C HamanoSep 9, 2023
  69. Jonathan TanSep 15, 2023
  70. Junio C HamanoSep 15, 2023
  71. Junio C HamanoSep 8, 2023
  72. Junio C HamanoSep 8, 2023
  73. 0/4 Preliminary patches before git-std-libJonathan Tan, Sep 29, 2023
  74. 1/4 hex-ll: separate out non-hash-algo functionsJonathan Tan, Sep 29, 2023
  75. Linus ArverOct 21, 2023
  76. 2/4 wrapper: reduce scope of remove_or_warn()Jonathan Tan, Sep 29, 2023
  77. phillip.wood123@gmail.comOct 10, 2023
  78. Junio C HamanoOct 10, 2023
  79. Jonathan TanOct 10, 2023
  80. 3/4 config: correct bad boolean env value error messageJonathan Tan, Sep 29, 2023
  81. Junio C HamanoSep 29, 2023
  82. 4/4 parse: separate out parsing functions from config.hJonathan Tan, Sep 29, 2023
  83. phillip.wood123@gmail.comOct 10, 2023
  84. Jonathan TanOct 10, 2023
  85. Phillip WoodOct 10, 2023
  86. Junio C HamanoOct 10, 2023
  87. phillip.wood123@gmail.comOct 10, 2023
  88. Jonathan TanOct 10, 2023
  89. 0/3 Introduce Git Standard LibraryCalvin Wan, Feb 22, 2024
  90. 1/3 pager: include stdint.h because uintmax_t is usedCalvin Wan, Feb 22, 2024
  91. Junio C HamanoFeb 22, 2024
  92. Kyle LippincottFeb 26, 2024
  93. Junio C HamanoFeb 27, 2024
  94. Kyle LippincottFeb 27, 2024
  95. Junio C HamanoFeb 27, 2024
  96. Kyle LippincottFeb 27, 2024
  97. Junio C HamanoFeb 27, 2024
  98. Jeff KingFeb 27, 2024
  99. Jeff KingFeb 27, 2024
  100. Kyle LippincottFeb 27, 2024
  101. Kyle LippincottFeb 24, 2024
  102. Junio C HamanoFeb 24, 2024
  103. 2/3 git-std-lib: introduce Git Standard LibraryCalvin Wan, Feb 22, 2024
  104. Phillip WoodFeb 29, 2024
  105. Junio C HamanoFeb 29, 2024
  106. Linus ArverFeb 29, 2024
  107. Junio C HamanoFeb 29, 2024
  108. Linus ArverFeb 29, 2024
  109. 3/3 test-stdlib: show that git-std-lib is independentCalvin Wan, Feb 22, 2024
  110. Junio C HamanoFeb 22, 2024
  111. Junio C HamanoMar 7, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.