Message ID | 20181214001536.6259-1-luc.vanoostenryck@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | predefined macros for intmax_t/intptr_t/... | expand |
On 14/12/2018 00:15, Luc Van Oostenryck wrote: > Some types have already their TYPE/SIZEOF/MAX macros. > These patches add them for the missing types: ptrdiff, > int{ptr,max,64,32,16,8}_t and their unsigned version, > wchar_t, wint_t, char{16,32}_t.. > > Note: some of the types vary a lot depending on the > architecture, OS & exact ABI used. This is > specially the case for for int32_t. > The definition in these patches should now be correct > for the most common archs & ABI used for the kernel. > > Changes since v1: > * correct _MAX value of unsigned types (+ testing) > * fix definition PTYPE_WIDTH/PTYPE_TYPE > * fix inverted type for INT8/UINT8 > * define shortcur PTYPE_ALL_T > * add tests for PTRDIFF/SIZE/INTMAX/INT{8,16,32,64} > * add definitions for wint_t, char16_t & char32t > > Changes since v2: > * mv slong_ctype's entry in typenames after long_ctype > * use the type for predefined_max() > * add a temptative arch_mach initialized with the native > architecture and use it to set more correctly wchar_t, > int32_t, ... > * fix size of long double, especially on x86-64 Heh, I was just about to email you about my testing this evening, when I noticed a new series! ;-) The changes described above sound very interesting ... but I will have leave the testing until tomorrow now. :-P I have tested the v2 on Linux Mint 19 64-bit, Linux Mint 18.3 32-bit, cygwin 64-bit, fedora 28 64-bit, using gcc with versions 5.4.0, 7.3.0 and 8.0.1. (I have been meaning to update fedora to 29, but haven't got around to it). I was quite happy with v2, but v3 sounds even better! Some minor notes: - this series (v2) already goes beyond my simple patch and covers everything I required to get a clean build of both sparse (eg. selfcheck) and git. (no more need for SPARSE_FLAGS on cygwin). - __WCHAR_TYPE__, et al, is a minor problem (as I mentioned before), with -m32, -mx32, -m16 (on x86, x86-64) systems defining the type as 'long' (rather than 'int'), except on cygwin (of course), where it is defined as 'unsigned short'. - __SIZEOF_LONG_DOUBLE__ is defined as 10 (for all archs) by sparse, but it is defined as either 12 or 16 by gcc. - older gcc (in this case v5.4.0), do not define any of the __<type>_WIDTH__ macros. v7.3.0 and v8.0.1 _do_ define these macros. This is not a problem - just a reminder that gcc and clang (I don't know who is leading who here) do keep changing the interface ... ;-) Thanks for all the hard work on this! I will hopefully find time to test v3 tomorrow (or over the weekend, at least). ATB, Ramsay Jones > > > This series is available for review & testing in the repository at: > git://github.com/lucvoo/sparse-dev.git predefs-v2 > > ---------------------------------------------------------------- > Luc Van Oostenryck (19): > add detection of native platform > Consolidate 'machine detection' into "machine.h" > test endianness with __BYTE_ORDER__ > testsuite: test predef macros on LP32/LP64/LLP64 > fix '__SIZE_TYPE__' for LLP64 > allow optional "_T" suffix to __SIZEOF_XXX__ > use bits_mask() for predefined_max() > add builtin_type_suffix() > make predefined_type_size() more generic > give a type to wchar > use the type for predefined_max() > add predefined macros for wint_t > add predefined macros for [u]intptr > add predefined macros for [u]intmax > add predefined macros for [u]int{8,16}_t > add predefined macros for [u]int64_t > add predefined macros for [u]int32_t > add predefined macros for char{16,32}_t > fix the size of long double > > char.c | 4 +- > lib.c | 153 +++++++++++++--------- > lib.h | 1 + > machine.h | 77 +++++++++++ > show-parse.c | 73 ++++++----- > symbol.h | 2 + > target.c | 84 +++++++++++- > target.h | 10 +- > validation/preprocessor/predef-char-bit.c | 16 --- > validation/preprocessor/predef-llp64.c | 9 ++ > validation/preprocessor/predef-lp32.c | 9 ++ > validation/preprocessor/predef-lp64.c | 9 ++ > validation/preprocessor/predef-max.c | 18 --- > validation/preprocessor/predef-sizeof.c | 25 ---- > validation/preprocessor/predef.c | 57 ++++++++ > 15 files changed, 386 insertions(+), 161 deletions(-) > create mode 100644 machine.h > delete mode 100644 validation/preprocessor/predef-char-bit.c > create mode 100644 validation/preprocessor/predef-llp64.c > create mode 100644 validation/preprocessor/predef-lp32.c > create mode 100644 validation/preprocessor/predef-lp64.c > delete mode 100644 validation/preprocessor/predef-max.c > delete mode 100644 validation/preprocessor/predef-sizeof.c > create mode 100644 validation/preprocessor/predef.c >
On Fri, Dec 14, 2018 at 02:12:31AM +0000, Ramsay Jones wrote: > > > On 14/12/2018 00:15, Luc Van Oostenryck wrote: > > Some types have already their TYPE/SIZEOF/MAX macros. > > These patches add them for the missing types: ptrdiff, > > int{ptr,max,64,32,16,8}_t and their unsigned version, > > wchar_t, wint_t, char{16,32}_t.. > > > > Note: some of the types vary a lot depending on the > > architecture, OS & exact ABI used. This is > > specially the case for for int32_t. > > The definition in these patches should now be correct > > for the most common archs & ABI used for the kernel. > > > > Changes since v1: > > * correct _MAX value of unsigned types (+ testing) > > * fix definition PTYPE_WIDTH/PTYPE_TYPE > > * fix inverted type for INT8/UINT8 > > * define shortcur PTYPE_ALL_T > > * add tests for PTRDIFF/SIZE/INTMAX/INT{8,16,32,64} > > * add definitions for wint_t, char16_t & char32t > > > > Changes since v2: > > * mv slong_ctype's entry in typenames after long_ctype > > * use the type for predefined_max() > > * add a temptative arch_mach initialized with the native > > architecture and use it to set more correctly wchar_t, > > int32_t, ... > > * fix size of long double, especially on x86-64 > > Heh, I was just about to email you about my testing this evening, when > I noticed a new series! ;-) > > The changes described above sound very interesting ... but I will > have leave the testing until tomorrow now. :-P > > I have tested the v2 on Linux Mint 19 64-bit, Linux Mint 18.3 32-bit, > cygwin 64-bit, fedora 28 64-bit, using gcc with versions 5.4.0, 7.3.0 > and 8.0.1. (I have been meaning to update fedora to 29, but haven't > got around to it). I'm running the testsuite on Debian & Ubuntu (and more recently Alpine) on x86-64 and Ubuntu on i386 plus some others (Debian powerpc64 & sparc64, Solaris 10 & 11 but using gcc not scc, OSX) but I still haven't done a systematic comparison of -dD's output. I'm much interested to know the changes needed for cygwin). > I was quite happy with v2, but v3 sounds even better! > > Some minor notes: > > - this series (v2) already goes beyond my simple patch and > covers everything I required to get a clean build of both > sparse (eg. selfcheck) and git. (no more need for SPARSE_FLAGS > on cygwin). > > - __WCHAR_TYPE__, et al, is a minor problem (as I mentioned > before), with -m32, -mx32, -m16 (on x86, x86-64) systems > defining the type as 'long' (rather than 'int'), except > on cygwin (of course), where it is defined as 'unsigned short'. It should be OK now on -v3 but for cygwin. > - __SIZEOF_LONG_DOUBLE__ is defined as 10 (for all archs) by > sparse, but it is defined as either 12 or 16 by gcc. This should also be OK now. > - older gcc (in this case v5.4.0), do not define any of the > __<type>_WIDTH__ macros. v7.3.0 and v8.0.1 _do_ define these > macros. This is not a problem - just a reminder that gcc and > clang (I don't know who is leading who here) do keep changing > the interface ... ;-) Yes, I know but indeed it's not a problem. > Thanks for all the hard work on this! Thanks for the testing @ the feedback! > I will hopefully find time to test v3 tomorrow (or over the weekend, > at least). Great. Thank you. -- Luc