Skip to contentSkip to conversation

util/cacheinfo.c: Use uintptr_t instead of unsigned long in AArch64 arch_cache_info()

PATCH Applied Cao Jiaxi 4 participants 5 messages Apr 30, 2019 – May 2, 2019

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Cao Jiaxi

author
#0 lore raw

PATCH v2 3/4 util/cacheinfo.c: Use uintptr_t instead of unsigned long in AArch64 arch_cache_info()

Windows ARM64 uses LLP64 model, which breaks current assumptions.

---
 util/cacheinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/cacheinfo.c +1 -1
index 3cd080b83d..ce6f0dbf6a 100644
@@ -107,7 +107,7 @@ static void sys_cache_info(int *isize, int *dsize)
 static void arch_cache_info(int *isize, int *dsize)
 {
     if (*isize == 0 || *dsize == 0) {
-        unsigned long ctr;
+        uintptr_t ctr;
 
         /* The real cache geometry is in CCSIDR_EL1/CLIDR_EL1/CSSELR_EL1,
            but (at least under Linux) these are marked protected by the
Signature · 1 line
2.17.1
Reviewed-by on v2 3/4
#1 lore raw
Quoted 13 lines · Cao Jiaxi

Windows ARM64 uses LLP64 model, which breaks current assumptions.

---
 util/cacheinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/cacheinfo.c +0 -0
index 3cd080b83d..ce6f0dbf6a 100644

util/cacheinfo.c static void sys_cache_info(int *isize, int *dsize) · line 113

Quoted 8 lines
util/cacheinfo.c +1 -1
@@ -107,7 +107,7 @@ static void sys_cache_info(int *isize, int *dsize)
 static void arch_cache_info(int *isize, int *dsize)
 {
     if (*isize == 0 || *dsize == 0) {
-        unsigned long ctr;
+        uintptr_t ctr;
 
         /* The real cache geometry is in CCSIDR_EL1/CLIDR_EL1/CSSELR_EL1,
            but (at least under Linux) these are marked protected by the
#2 lore raw
Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 18 lines · Cao Jiaxi

Windows ARM64 uses LLP64 model, which breaks current assumptions.

---
 util/cacheinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/cacheinfo.c +1 -1
index 3cd080b83d..ce6f0dbf6a 100644
@@ -107,7 +107,7 @@ static void sys_cache_info(int *isize, int *dsize)
 static void arch_cache_info(int *isize, int *dsize)
 {
     if (*isize == 0 || *dsize == 0) {
-        unsigned long ctr;
+        uintptr_t ctr;
 
Quoted 6 lines

util/cacheinfo.c static void sys_cache_info(int *isize, int *dsize) · line 113

Quoted 3 lines
util/cacheinfo.c +0 -0
         /* The real cache geometry is in CCSIDR_EL1/CLIDR_EL1/CSSELR_EL1,
            but (at least under Linux) these are marked protected by the

Maybe you can use a shorter commit subject, such "util/cacheinfo: Use uintptr_t on LLP64 model to satisfy Windows ARM64" (or better), so it won't be cut in git log (limited to 72 chars).

#3 lore raw
In reply to Cao Jiaxi
Quoted 12 lines · Cao Jiaxi

Windows ARM64 uses LLP64 model, which breaks current assumptions.

---
 util/cacheinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/cacheinfo.c +0 -0
index 3cd080b83d..ce6f0dbf6a 100644

util/cacheinfo.c static void sys_cache_info(int *isize, int *dsize) · line 110

Quoted 5 lines
util/cacheinfo.c +1 -1
@@ -107,7 +107,7 @@ static void sys_cache_info(int *isize, int *dsize)
 static void arch_cache_info(int *isize, int *dsize)
 {
     if (*isize == 0 || *dsize == 0) {
-        unsigned long ctr;
+        uintptr_t ctr;

Looking at the whole function, is uintptr_t really the right type to use here? ctr does not seem to contain the value of a pointer variable, so this looks wrong to me...
Do you get a compiler warning here? If so, how does it look like? Anyway, I think it would be better to use a uint64_t or uint32_t type here instead if possible?

Thomas

#4 lore raw
Quoted 5 lines · Thomas Huth
Quoted 5 lines
util/cacheinfo.c +0 -1
@@ -107,7 +107,7 @@ static void sys_cache_info(int *isize, int *dsize)
 static void arch_cache_info(int *isize, int *dsize)
 {
     if (*isize == 0 || *dsize == 0) {
-        unsigned long ctr;
Quoted 8 lines

util/cacheinfo.c static void sys_cache_info(int *isize, int *dsize) · line 110

Quoted 1 line
util/cacheinfo.c +1 -0
+        uintptr_t ctr;

Looking at the whole function, is uintptr_t really the right type to use here? ctr does not seem to contain the value of a pointer variable, so this looks wrong to me...
Do you get a compiler warning here? If so, how does it look like? Anyway, I think it would be better to use a uint64_t or uint32_t type here instead if possible?

uint64_t is the proper type to use with MRS.

r~