Skip to content

Commit 71c527b

Browse files
author
bmahi496@linux.ibm.com
committed
Fixing Indentation
1 parent 68fecdb commit 71c527b

File tree

10 files changed

+627
-597
lines changed

10 files changed

+627
-597
lines changed

include/cpuinfo.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,19 @@ enum cpuinfo_uarch {
603603
cpuinfo_uarch_taishan_v110 = 0x00C00100,
604604

605605
/** IBM POWER 7. */
606-
cpuinfo_uarch_power7 = 0x00D00100,
606+
cpuinfo_uarch_power7 = 0x00D00100,
607607
/** IBM POWER 7p. */
608-
cpuinfo_uarch_power7p = 0x00D00101,
608+
cpuinfo_uarch_power7p = 0x00D00101,
609609
/** IBM POWER 8. */
610-
cpuinfo_uarch_power8 = 0x00D00200,
610+
cpuinfo_uarch_power8 = 0x00D00200,
611611
/** IBM POWER8E. */
612-
cpuinfo_uarch_power8e = 0x00D00201,
612+
cpuinfo_uarch_power8e = 0x00D00201,
613613
/** IBM POWER8NVL */
614614
cpuinfo_uarch_power8nvl = 0x00D00202,
615615
/** IBM POWER 9. */
616-
cpuinfo_uarch_power9 = 0x00D00303,
616+
cpuinfo_uarch_power9 = 0x00D00303,
617617
/** IBM POWER 10. */
618-
cpuinfo_uarch_power10 = 0x00D00400,
618+
cpuinfo_uarch_power10 = 0x00D00400,
619619
};
620620

621621
struct cpuinfo_processor {
@@ -2245,13 +2245,13 @@ static inline bool cpuinfo_has_riscv_v(void) {
22452245
}
22462246

22472247
#if CPUINFO_ARCH_PPC64
2248-
struct cpuinfo_powerpc_isa {
2249-
bool vsx;
2250-
bool htm;
2251-
bool mma;
2252-
};
2248+
struct cpuinfo_powerpc_isa {
2249+
bool vsx;
2250+
bool htm;
2251+
bool mma;
2252+
};
22532253

2254-
extern struct cpuinfo_powerpc_isa cpuinfo_isa;
2254+
extern struct cpuinfo_powerpc_isa cpuinfo_isa;
22552255
#endif
22562256

22572257
static inline bool cpuinfo_has_powerpc_vsx(void) {

src/linux/processors.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,29 +285,31 @@ bool cpuinfo_linux_get_processor_package_id(uint32_t processor, uint32_t package
285285

286286
bool cpuinfo_linux_get_processor_online_status(uint32_t processor, uint32_t* online_status_ptr) {
287287
char processor_online_filename[PROCESSOR_ONLINE_FILENAME_SIZE];
288-
const int chars_formatted =
289-
snprintf(processor_online_filename, PROCESSOR_ONLINE_FILENAME_SIZE, PROCESSOR_ONLINE_FILENAME_FORMAT, processor);
290-
if ((unsigned int)chars_formatted >= PROCESSOR_ONLINE_FILENAME_SIZE) {
288+
const int chars_formatted = snprintf(
289+
processor_online_filename, PROCESSOR_ONLINE_FILENAME_SIZE, PROCESSOR_ONLINE_FILENAME_FORMAT, processor);
290+
if ((unsigned int)chars_formatted >= PROCESSOR_ONLINE_FILENAME_SIZE) {
291291
cpuinfo_log_warning("failed to format filename for online status of processor %" PRIu32, processor);
292292
return 0;
293293
}
294294
uint32_t online_status;
295-
if (cpuinfo_linux_parse_small_file(processor_online_filename, PROCESSOR_ONLINE_FILESIZE, uint32_parser, &online_status)) {
295+
if (cpuinfo_linux_parse_small_file(
296+
processor_online_filename, PROCESSOR_ONLINE_FILESIZE, uint32_parser, &online_status)) {
296297
cpuinfo_log_debug(
297298
"parsed online status value of %" PRIu32 " for logical processor %" PRIu32 " from %s",
298299
online_status,
299300
processor,
300301
processor_online_filename);
301-
*online_status_ptr = online_status;
302-
return true;
302+
*online_status_ptr = online_status;
303+
return true;
303304
} else {
304-
cpuinfo_log_info(
305-
"failed to parse online status for processor %" PRIu32 " from %s", processor, processor_online_filename);
306-
return false;
305+
cpuinfo_log_info(
306+
"failed to parse online status for processor %" PRIu32 " from %s",
307+
processor,
308+
processor_online_filename);
309+
return false;
307310
}
308311
}
309312

310-
311313
static bool max_processor_number_parser(uint32_t processor_list_start, uint32_t processor_list_end, void* context) {
312314
uint32_t* processor_number_ptr = (uint32_t*)context;
313315
const uint32_t processor_list_last = processor_list_end - 1;

src/powerpc/api.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55

66
#include <cpuinfo.h>
77

8-
enum cpuinfo_powerpc_chipset_vendor {
9-
cpuinfo_powerpc_chipset_vendor_unknown = 0,
10-
cpuinfo_powerpc_chipset_vendor_ibm
11-
};
8+
enum cpuinfo_powerpc_chipset_vendor { cpuinfo_powerpc_chipset_vendor_unknown = 0, cpuinfo_powerpc_chipset_vendor_ibm };
129
void cpuinfo_powerpc_decode_vendor_uarch(
1310
uint32_t vendor_id,
1411
enum cpuinfo_vendor vendor[restrict static 1],
1512
enum cpuinfo_uarch uarch[restrict static 1]);
1613

1714
void cpuinfo_powerpc_decode_cache(
18-
struct cpuinfo_cache l1i[restrict static 1],
19-
struct cpuinfo_cache l1d[restrict static 1],
20-
struct cpuinfo_cache l2[restrict static 1],
21-
struct cpuinfo_cache l3[restrict static 1]);
15+
struct cpuinfo_cache l1i[restrict static 1],
16+
struct cpuinfo_cache l1d[restrict static 1],
17+
struct cpuinfo_cache l2[restrict static 1],
18+
struct cpuinfo_cache l3[restrict static 1]);

src/powerpc/cache.c

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
#include <stdint.h>
21
#include <stddef.h>
2+
#include <stdint.h>
33
#include <stdlib.h>
44

55
#include <stdarg.h>
6-
#include <string.h>
76
#include <stdio.h>
7+
#include <string.h>
88
#include <unistd.h>
99

1010
#include <cpuinfo.h>
1111
#include <cpuinfo/log.h>
1212
#include <powerpc/api.h>
1313
#include <sys/auxv.h>
1414

15-
#define NUM_CACHE 4
16-
#define BUF_SIZE 128
15+
#define NUM_CACHE 4
16+
#define BUF_SIZE 128
1717

18-
int path_exist(const char *path)
19-
{
18+
int path_exist(const char* path) {
2019
return (access(path, F_OK) == 0);
2120
}
2221

23-
void read_str(char *result, size_t len, const char *path)
24-
{
25-
FILE *f;
22+
void read_str(char* result, size_t len, const char* path) {
23+
FILE* f;
2624

2725
f = fopen(path, "r");
2826

@@ -34,33 +32,31 @@ void read_str(char *result, size_t len, const char *path)
3432
result[len - 1] = '\0';
3533
}
3634

37-
void decode_cache_features(uint32_t cache_features[], unsigned long geometry)
38-
{
35+
void decode_cache_features(uint32_t cache_features[], unsigned long geometry) {
3936
cache_features[1] = (geometry >> 16) & 0xffff;
4037
cache_features[2] = geometry & 0xffff;
41-
/* If associativity = 65535 it means upper limit of 16 bit of AT_L%d_CACHEGEOMETRY has reached so we calculate it from, size, sets and line_size*/
42-
if(cache_features[1] == 65535)
43-
cache_features[1] = cache_features[0]/(cache_features[2]*cache_features[3]);
38+
/* If associativity = 65535 it means upper limit of 16 bit of AT_L%d_CACHEGEOMETRY has reached so we calculate
39+
* it from, size, sets and line_size*/
40+
if (cache_features[1] == 65535)
41+
cache_features[1] = cache_features[0] / (cache_features[2] * cache_features[3]);
4442
}
4543

4644
void cpuinfo_powerpc_decode_cache(
4745
struct cpuinfo_cache l1i[restrict static 1],
4846
struct cpuinfo_cache l1d[restrict static 1],
4947
struct cpuinfo_cache l2[restrict static 1],
50-
struct cpuinfo_cache l3[restrict static 1])
51-
{
48+
struct cpuinfo_cache l3[restrict static 1]) {
5249
char buf[BUF_SIZE];
5350
char result[BUF_SIZE];
5451
uint32_t cache_features[NUM_CACHE];
5552
uint32_t i;
5653
uint32_t size = 0, sets = 0;
5754
size_t len;
5855

59-
for(i = 0; i < NUM_CACHE; i++) {
60-
61-
sprintf (buf, "/sys/devices/system/cpu/cpu%d/cache/index%d/number_of_sets", i);
62-
if(path_exist(buf))
63-
read_str(result, sizeof(result), buf);
56+
for (i = 0; i < NUM_CACHE; i++) {
57+
sprintf(buf, "/sys/devices/system/cpu/cpu%d/cache/index%d/number_of_sets", i);
58+
if (path_exist(buf))
59+
read_str(result, sizeof(result), buf);
6460

6561
sets = atoi(result);
6662
cache_features[3] = sets;
@@ -73,8 +69,8 @@ void cpuinfo_powerpc_decode_cache(
7369
size = getauxval(AT_L1D_CACHESIZE);
7470
cache_features[0] = size;
7571
decode_cache_features(cache_features, geometry);
76-
sets = size/(cache_features[1] * cache_features[2]);
77-
*l1d = (struct cpuinfo_cache) {
72+
sets = size / (cache_features[1] * cache_features[2]);
73+
*l1d = (struct cpuinfo_cache){
7874
.size = size,
7975
.associativity = cache_features[1],
8076
.line_size = cache_features[2],
@@ -88,44 +84,40 @@ void cpuinfo_powerpc_decode_cache(
8884
size = getauxval(AT_L1I_CACHESIZE);
8985
cache_features[0] = size;
9086
decode_cache_features(cache_features, geometry);
91-
sets = size/(cache_features[1] * cache_features[2]);
92-
*l1i = (struct cpuinfo_cache) {
87+
sets = size / (cache_features[1] * cache_features[2]);
88+
*l1i = (struct cpuinfo_cache){
9389
.size = size,
9490
.associativity = cache_features[1],
9591
.line_size = cache_features[2],
9692
.sets = sets,
97-
.partitions = 1
98-
};
93+
.partitions = 1};
9994
break;
10095
case 2:
10196
geometry = getauxval(AT_L2_CACHEGEOMETRY);
10297
size = getauxval(AT_L2_CACHESIZE);
10398
cache_features[0] = size;
10499
decode_cache_features(cache_features, geometry);
105-
sets = size/(cache_features[1] * cache_features[2]);
106-
*l2 = (struct cpuinfo_cache) {
100+
sets = size / (cache_features[1] * cache_features[2]);
101+
*l2 = (struct cpuinfo_cache){
107102
.size = size,
108103
.associativity = cache_features[1],
109104
.line_size = cache_features[2],
110105
.sets = sets,
111-
.partitions = 1
112-
};
106+
.partitions = 1};
113107
break;
114108
case 3:
115109
geometry = getauxval(AT_L3_CACHEGEOMETRY);
116110
size = getauxval(AT_L3_CACHESIZE);
117111
cache_features[0] = size;
118112
decode_cache_features(cache_features, geometry);
119-
sets = size/(cache_features[1] * cache_features[2]);
120-
*l3 = (struct cpuinfo_cache) {
113+
sets = size / (cache_features[1] * cache_features[2]);
114+
*l3 = (struct cpuinfo_cache){
121115
.size = size,
122116
.associativity = cache_features[1],
123117
.line_size = cache_features[2],
124118
.sets = sets,
125-
.partitions = 1
126-
};
119+
.partitions = 1};
127120
break;
128-
129121
}
130122
}
131123
}

src/powerpc/linux/api.h

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,47 @@
77

88
#include <cpuinfo.h>
99
#include <cpuinfo/common.h>
10-
#include <powerpc/api.h>
1110
#include <linux/api.h>
11+
#include <powerpc/api.h>
1212

1313
/* No hard limit in the kernel, maximum length observed on non-rogue kernels is 64 */
1414
#define CPUINFO_HARDWARE_VALUE_MAX 64
1515

1616
/* from /arch/powerpc/kernel/cputable.c */
17-
#define CPUINFO_POWERPC_LINUX_FEATURE_64 UINT32_C(0x40000000)
18-
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_ALTIVEC UINT32_C(0x10000000)
19-
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_FPU UINT32_C(0x08000000)
20-
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_MMU UINT32_C(0x04000000)
21-
#define CPUINFO_POWERPC_LINUX_FEATURE_NO_TB UINT32_C(0x00100000)
22-
#define CPUINFO_POWERPC_LINUX_FEATURE_SMT UINT32_C(0x00004000)
23-
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_DFP UINT32_C(0x00000400)
24-
#define CPUINFO_POWERPC_LINUX_FEATURE_POWER6_EXT UINT32_C(0x00000200)
25-
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_VSX UINT32_C(0x00000080)
26-
#define CPUINFO_POWERPC_LINUX_FEATURE_TRUE_LE UINT32_C(0x00000002)
17+
#define CPUINFO_POWERPC_LINUX_FEATURE_64 UINT32_C(0x40000000)
18+
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_ALTIVEC UINT32_C(0x10000000)
19+
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_FPU UINT32_C(0x08000000)
20+
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_MMU UINT32_C(0x04000000)
21+
#define CPUINFO_POWERPC_LINUX_FEATURE_NO_TB UINT32_C(0x00100000)
22+
#define CPUINFO_POWERPC_LINUX_FEATURE_SMT UINT32_C(0x00004000)
23+
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_DFP UINT32_C(0x00000400)
24+
#define CPUINFO_POWERPC_LINUX_FEATURE_POWER6_EXT UINT32_C(0x00000200)
25+
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_VSX UINT32_C(0x00000080)
26+
#define CPUINFO_POWERPC_LINUX_FEATURE_TRUE_LE UINT32_C(0x00000002)
2727
#define CPUINFO_POWERPC_LINUX_FEATURE_PPC_LE UINT32_C(0x00000001
28-
#define CPUINFO_POWERPC_LINUX_FEATURE_ARCH_2_07 UINT32_C(0x80000000)
29-
#define CPUINFO_POWERPC_LINUX_FEATURE_HTM UINT32_C(0x40000000)
30-
#define CPUINFO_POWERPC_LINUX_FEATURE_DSCR UINT32_C(0x20000000)
31-
#define CPUINFO_POWERPC_LINUX_FEATURE_EBB UINT32_C(0x10000000)
32-
#define CPUINFO_POWERPC_LINUX_FEATURE_ISEL UINT32_C(0x08000000)
33-
#define CPUINFO_POWERPC_LINUX_FEATURE_TAR UINT32_C(0x04000000)
34-
#define CPUINFO_POWERPC_LINUX_FEATURE_VEC_CRYPTO UINT32_C(0x02000000)
35-
#define CPUINFO_POWERPC_LINUX_FEATURE_HTM_NOSC UINT32_C(0x01000000)
36-
#define CPUINFO_POWERPC_LINUX_FEATURE_ARCH_3_00 UINT32_C(0x00800000)
37-
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_IEEE128 UINT32_C(0x00400000)
38-
#define CPUINFO_POWERPC_LINUX_FEATURE_DARN UINT32_C(0x00200000)
39-
#define CPUINFO_POWERPC_LINUX_FEATURE_SCV UINT32_C(0x00100000)
40-
#define CPUINFO_POWERPC_LINUX_FEATURE_HTM_NO_SUSPEND UINT32_C(0x00080000)
41-
#define CPUINFO_POWERPC_LINUX_FEATURE_ARCH_3_1 UINT32_C(0x00040000)
42-
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_MMA UINT32_C(0x00020000)
28+
#define CPUINFO_POWERPC_LINUX_FEATURE_ARCH_2_07 UINT32_C(0x80000000)
29+
#define CPUINFO_POWERPC_LINUX_FEATURE_HTM UINT32_C(0x40000000)
30+
#define CPUINFO_POWERPC_LINUX_FEATURE_DSCR UINT32_C(0x20000000)
31+
#define CPUINFO_POWERPC_LINUX_FEATURE_EBB UINT32_C(0x10000000)
32+
#define CPUINFO_POWERPC_LINUX_FEATURE_ISEL UINT32_C(0x08000000)
33+
#define CPUINFO_POWERPC_LINUX_FEATURE_TAR UINT32_C(0x04000000)
34+
#define CPUINFO_POWERPC_LINUX_FEATURE_VEC_CRYPTO UINT32_C(0x02000000)
35+
#define CPUINFO_POWERPC_LINUX_FEATURE_HTM_NOSC UINT32_C(0x01000000)
36+
#define CPUINFO_POWERPC_LINUX_FEATURE_ARCH_3_00 UINT32_C(0x00800000)
37+
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_IEEE128 UINT32_C(0x00400000)
38+
#define CPUINFO_POWERPC_LINUX_FEATURE_DARN UINT32_C(0x00200000)
39+
#define CPUINFO_POWERPC_LINUX_FEATURE_SCV UINT32_C(0x00100000)
40+
#define CPUINFO_POWERPC_LINUX_FEATURE_HTM_NO_SUSPEND UINT32_C(0x00080000)
41+
#define CPUINFO_POWERPC_LINUX_FEATURE_ARCH_3_1 UINT32_C(0x00040000)
42+
#define CPUINFO_POWERPC_LINUX_FEATURE_HAS_MMA UINT32_C(0x00020000)
4343

4444
#define CPUINFO_POWERPC_LINUX_VALID_ARCHITECTURE UINT32_C(0x00010000)
45-
#define CPUINFO_POWERPC_LINUX_VALID_IMPLEMENTER UINT32_C(0x00020000)
46-
#define CPUINFO_POWERPC_LINUX_VALID_REVISION UINT32_C(0x00040000)
47-
#define CPUINFO_POWERPC_LINUX_VALID_PROCESSOR UINT32_C(0x00080000)
48-
#define CPUINFO_POWERPC_LINUX_VALID_VERSION UINT32_C(0x00100000)
49-
#define CPUINFO_POWERPC_LINUX_VALID_FEATURES UINT32_C(0x00200000)
50-
#define CPUINFO_POWERPC_LINUX_VALID_PVR UINT32_C(0x001F0000)
45+
#define CPUINFO_POWERPC_LINUX_VALID_IMPLEMENTER UINT32_C(0x00020000)
46+
#define CPUINFO_POWERPC_LINUX_VALID_REVISION UINT32_C(0x00040000)
47+
#define CPUINFO_POWERPC_LINUX_VALID_PROCESSOR UINT32_C(0x00080000)
48+
#define CPUINFO_POWERPC_LINUX_VALID_VERSION UINT32_C(0x00100000)
49+
#define CPUINFO_POWERPC_LINUX_VALID_FEATURES UINT32_C(0x00200000)
50+
#define CPUINFO_POWERPC_LINUX_VALID_PVR UINT32_C(0x001F0000)
5151

5252
/**
5353
* Definition of a powerpc64 Linux processor. It is composed of the base processor
@@ -99,10 +99,14 @@ struct cpuinfo_powerpc_linux_processor {
9999
* @param[isa] - Reference to cpuinfo_powerpc_isa structure to populate.
100100
*/
101101
void cpuinfo_powerpc_linux_hwcap_from_getauxval(uint32_t isa_feature[]);
102-
CPUINFO_INTERNAL void cpuinfo_ppc64_linux_decode_isa_from_hwcap(uint32_t hwcap, uint32_t hwcap2, struct cpuinfo_powerpc_isa isa[restrict static 1]);
102+
CPUINFO_INTERNAL void cpuinfo_ppc64_linux_decode_isa_from_hwcap(
103+
uint32_t hwcap,
104+
uint32_t hwcap2,
105+
struct cpuinfo_powerpc_isa isa[restrict static 1]);
103106

104107
bool cpuinfo_powerpc_linux_parse_proc_cpuinfo(
105-
uint32_t max_processors_count,struct cpuinfo_powerpc_linux_processor processors[restrict static max_processors_count]);
108+
uint32_t max_processors_count,
109+
struct cpuinfo_powerpc_linux_processor processors[restrict static max_processors_count]);
106110

107111
/* Used to determine which uarch is associated with the current thread. */
108112
extern CPUINFO_INTERNAL const uint32_t* cpuinfo_linux_cpu_to_uarch_index_map;

0 commit comments

Comments
 (0)