Skip to contentSkip to conversation

drm/amd/display: Remove use of division operator for long longs

PATCH In review [email protected] 2 participants 2 messages May 24, 2018 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Remove use of division operator for long longs

From: David Francis <[email protected]>

In fixed31_32.h, in dc_fixpt_shl,'/' was used for division of one long long int by another long long int. As there is no inbuilt long long int division function in c, gcc inserted its own. However, gcc does not link the library that contains this function. To avoid this, use bitwise operators instead of /

---
 drivers/gpu/drm/amd/display/include/fixed31_32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/include/fixed31_32.h +1 -1
index 76f64e9..bb0d4eb 100644
@@ -209,7 +209,7 @@ static inline struct fixed31_32 dc_fixpt_clamp(
 static inline struct fixed31_32 dc_fixpt_shl(struct fixed31_32 arg, unsigned char shift)
 {
 	ASSERT(((arg.value >= 0) && (arg.value <= LLONG_MAX >> shift)) ||
-		((arg.value < 0) && (arg.value >= (LLONG_MIN / (1LL << shift)))));
+		((arg.value < 0) && (arg.value >= ~(LLONG_MAX >> shift))));
 
 	arg.value = arg.value << shift;
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1527172812-19164-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 10 lines · On Thu, May 24, 2018 at 10:40 AM, <[email protected]> wrote:

From: David Francis <[email protected]>

In fixed31_32.h, in dc_fixpt_shl,'/' was used for division of one long long int by another long long int. As there is no inbuilt long long int division function in c, gcc inserted its own. However, gcc does not link the library that contains this function. To avoid this, use bitwise operators instead of /

Quoted 18 lines
---
 drivers/gpu/drm/amd/display/include/fixed31_32.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/include/fixed31_32.h +1 -2
index 76f64e9..bb0d4eb 100644
@@ -209,7 +209,7 @@ static inline struct fixed31_32 dc_fixpt_clamp(
 static inline struct fixed31_32 dc_fixpt_shl(struct fixed31_32 arg, unsigned char shift)
 {
        ASSERT(((arg.value >= 0) && (arg.value <= LLONG_MAX >> shift)) ||
-               ((arg.value < 0) && (arg.value >= (LLONG_MIN / (1LL << shift)))));
+               ((arg.value < 0) && (arg.value >= ~(LLONG_MAX >> shift))));
 
        arg.value = arg.value << shift;
 
--
Quoted 2 lines

2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx