Date: Fri, 4 Dec 2020 16:25:57 +0000 From: Alexander Richardson <arichardson@freebsd.org> To: Hans Petter Selasky <hps@selasky.org> Cc: src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org>, Konstantin Belousov <kib@freebsd.org> Subject: Re: svn commit: r368329 - head/stand/kshim Message-ID: <CA%2BZ_v8oq6dtBMuS78BTMkqxWEQaL6NhSFjfVo1eG=agNkc2ByQ@mail.gmail.com> In-Reply-To: <6f9541e4-b216-8a93-881e-e3859bff84fa@selasky.org> References: <202012041450.0B4EouQ2024632@repo.freebsd.org> <CA%2BZ_v8pwWmPx_b7oj2otpmcA1OZ5GS%2Bytf7ZhaTD0i72sW5jdA@mail.gmail.com> <6f9541e4-b216-8a93-881e-e3859bff84fa@selasky.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 4 Dec 2020 at 16:06, Hans Petter Selasky <hps@selasky.org> wrote: > > On 12/4/20 4:59 PM, Alexander Richardson wrote: > > On Fri, 4 Dec 2020 at 14:51, Hans Petter Selasky <hselasky@freebsd.org> wrote: > >> > >> Author: hselasky > >> Date: Fri Dec 4 14:50:55 2020 > >> New Revision: 368329 > >> URL: https://svnweb.freebsd.org/changeset/base/368329 > >> > >> Log: > >> Fix definition of int64_t and uint64_t when long is 64-bit. This gets the kernel > >> shim code in line with the rest of the kernel, sys/x86/include/_types.h. > >> > >> MFC after: 1 week > >> Sponsored by: Mellanox Technologies // NVIDIA Networking > >> > >> Modified: > >> head/stand/kshim/bsd_kernel.h > >> > >> Modified: head/stand/kshim/bsd_kernel.h > >> ============================================================================== > >> --- head/stand/kshim/bsd_kernel.h Fri Dec 4 14:09:12 2020 (r368328) > >> +++ head/stand/kshim/bsd_kernel.h Fri Dec 4 14:50:55 2020 (r368329) > >> @@ -208,9 +208,17 @@ typedef unsigned int uint32_t; > >> #define _INT32_T_DECLARED > >> typedef signed int int32_t; > >> #define _UINT64_T_DECLARED > >> +#ifndef __LP64__ > >> typedef unsigned long long uint64_t; > >> +#else > >> +typedef unsigned long uint64_t; > >> +#endif > >> #define _INT16_T_DECLARED > >> +#ifndef __LP64__ > >> typedef signed long long int64_t; > >> +#else > >> +typedef signed long int64_t; > >> +#endif > >> > >> typedef uint16_t uid_t; > >> typedef uint16_t gid_t; > > > > Since we no longer support ancient compilers, could we simplify this > > and just use > > typedef __UINT64_TYPE__ uint64_t; > > typedef __INT64_TYPE__ int64_t; > > ? > > > > This will work across all architectures and ABIs, and appears to work > > starting with GCC 4.5.3 and Clang 3.5: > > https://godbolt.org/z/TWavfb > > Hi Alexander, > > I'm not sure how that definition will work together with existing code, > mixing uint64_t, unsigned long, and unsigned long long. Will this cause > more compiler warnings? This also will affect user-space and ports. > > Maybe Konstantin, CC'ed, has some input on this? > > --HPS > I haven't looked at GCC's source code, but clang tries to make __UINT64_TYPE__ expand to what the target expects: it picks unsigned long/unsigned long long depending on the target OS and architecture. E.g. if I look at clang/Basic/Targets/AArch64.cpp, I can see that clang uses unsigned long for uint64_t everywhere except OpenBSD/Windows/Darwin where it uses unsigned long long. Alex
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BZ_v8oq6dtBMuS78BTMkqxWEQaL6NhSFjfVo1eG=agNkc2ByQ>