]> granicus.if.org Git - clang/commit
Headers: Make the type of SIZE_MAX the same as size_t
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 27 Apr 2017 21:49:45 +0000 (21:49 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 27 Apr 2017 21:49:45 +0000 (21:49 +0000)
commit7af3afd004e82e9303f02c2713d8cacd8215f1bd
treed733ae012ce128d589eb7907d088aa7d39ef6562
parentfc4c78381af3a65eb64567c94bac097b6b0246e4
Headers: Make the type of SIZE_MAX the same as size_t

size_t is usually defined as unsigned long, but on 64-bit platforms,
stdint.h currently defines SIZE_MAX using "ull" (unsigned long long).
Although this is the same width, it doesn't necessarily have the same
alignment or calling convention.  It also triggers printf warnings when
using the format flag "%zu" to print SIZE_MAX.

This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and
provides similar fixes for the other integers:

  - INTPTR_MIN
  - INTPTR_MAX
  - UINTPTR_MAX
  - PTRDIFF_MIN
  - PTRDIFF_MAX
  - INTMAX_MIN
  - INTMAX_MAX
  - UINTMAX_MAX
  - INTMAX_C()
  - UINTMAX_C()

... and fixes the typedefs for intptr_t and uintptr_t to use
__INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively
reverting r89224, r89226, and r89237 (r89221 already having been
effectively reverted).

We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and
__UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the
per-target CHECK lines in this commit since those might serve their own
purpose.

rdar://problem/11811377

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301593 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Headers/stdint.h
test/Headers/stdint-typeof-MINMAX.cpp [new file with mode: 0644]
test/Preprocessor/stdint.c