Re: [Mingw-w64-public] [PATCH] headers: Implement the _bittest* intrinsics for arm and aarch64

2021-07-14 Thread Martin Storsjö

On Wed, 14 Jul 2021, LIU Hao wrote:


在 7/14/21 9:02 PM, Martin Storsjö 写道:

+unsigned char _bittestandset(__LONG32 *__a, __LONG32 __b)
+{
+unsigned char __v = (*__a >> __b) & 1;
+*__a |= (1 << __b);


I suggest `1UL` here, as shifting 1 to the left by 31 is undefined behavior.


Thanks, will update all these.

// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] headers: Implement the _bittest* intrinsics for arm and aarch64

2021-07-14 Thread LIU Hao

在 7/14/21 9:02 PM, Martin Storsjö 写道:

+unsigned char _bittestandset(__LONG32 *__a, __LONG32 __b)
+{
+unsigned char __v = (*__a >> __b) & 1;
+*__a |= (1 << __b);


I suggest `1UL` here, as shifting 1 to the left by 31 is undefined behavior.



+unsigned char _bittestandreset(__LONG32 *__a, __LONG32 __b)
+{
+unsigned char __v = (*__a >> __b) & 1;
+*__a &= ~(1 << __b);


Likewise.



+unsigned char _bittestandcomplement(__LONG32 *__a, __LONG32 __b)
+{
+unsigned char __v = (*__a >> __b) & 1;
+*__a = (*__a & ~(1 << __b)) | ((__v ^ 1) << __b);


Likewise.



+unsigned char _bittestandset64(__int64 *__a, __int64 __b)
+{
+unsigned char __v = (*__a >> __b) & 1;
+*__a |= (1LL << __b);


Likewise, but `1ULL`, and more follow.


--
Best regards,
LIU Hao



OpenPGP_signature
Description: OpenPGP digital signature
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public