<commit_before>/**
 * @file lsslot_chrp_cpu.c
 * @brief routines for lsslot_chrp_cpu command
 *
 * Copyright (C) IBM Corporation 2006
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "dr.h"
#include "drcpu.h"

/**
 * list_cpus
 * @brief list all cpus
 *
 */
void
list_cpus(struct dr_info *dr_info)
{
	struct dr_node *cpu;
	struct thread *t;
	char *fmt_s = "%-11s%-20s%-13s%-13s\n";
	char *fmt = "%-11s%-20s%-12x";

	printf(fmt_s, "drc-name", "OFDT-node", "drc_index", "thread id(s)");

	for (cpu = dr_info->all_cpus; cpu != NULL; cpu = cpu->next) {
		if (cpu->is_owned || output_level >= DEBUG) {
			printf(fmt, cpu->drc_name, cpu->name ? cpu->name : "--",
			       cpu->drc_index);
			for (t = cpu->cpu_threads; t; t = t->sibling)
				printf(" %x", t->id);
			printf("\n");
		}
	}

	return;
}

/**
 * list_caches
 * @brief list all caches
 *
 */
void
list_caches(struct dr_info *dr_info)
{
	struct cache_info *cache = NULL;

	printf("cache-name              phandle\n");

	for (cache = dr_info->all_caches; cache != NULL; cache = cache->next)
		printf("%-21s%-8x\n", cache->name, cache->phandle);

	return;
}

/**
 * list_all_cpus_and_caches
 * @bried list all of the cpus and caches
 *
 */
void
list_cpus_and_caches(struct dr_info *dr_info)
{
	struct dr_node *cpu = NULL;
	struct thread *t;
	int thread_id_field_sz = 14;
	char *fmt_s = "%-11s%-20s%-13s%-13s%-11s%-11s\n";
	char *fmt = "%-11s%-20s%-12x%";
	char *fmt_caches = "%-11s%-11s\n";

	printf(fmt_s, "drc-name", "OFDT-node", "drc_index", "thread id(s)",
	       "l2-cache", "l3-cache");

	for (cpu = dr_info->all_cpus; cpu != NULL; cpu = cpu->next) {
		int i, count = 0;
		struct cache_info *l2_cache = NULL;
		struct cache_info *l3_cache = NULL;

		printf(fmt, cpu->drc_name, cpu->name ? cpu->name : "--",
		       cpu->drc_index);

		for (t = cpu->cpu_threads; t; t = t->sibling) {
			printf(" %x", t->id);
			count += 2;
		}
<commit_msg>lsslot: Correct formatting fopr printing cpus and caches<commit_after>/**
 * @file lsslot_chrp_cpu.c
 * @brief routines for lsslot_chrp_cpu command
 *
 * Copyright (C) IBM Corporation 2006
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "dr.h"
#include "drcpu.h"

/**
 * list_cpus
 * @brief list all cpus
 *
 */
void
list_cpus(struct dr_info *dr_info)
{
	struct dr_node *cpu;
	struct thread *t;
	char *fmt_s = "%-11s%-20s%-13s%-13s\n";
	char *fmt = "%-11s%-20s%-12x";

	printf(fmt_s, "drc-name", "OFDT-node", "drc_index", "thread id(s)");

	for (cpu = dr_info->all_cpus; cpu != NULL; cpu = cpu->next) {
		if (cpu->is_owned || output_level >= DEBUG) {
			printf(fmt, cpu->drc_name, cpu->name ? cpu->name : "--",
			       cpu->drc_index);
			for (t = cpu->cpu_threads; t; t = t->sibling)
				printf(" %x", t->id);
			printf("\n");
		}
	}

	return;
}

/**
 * list_caches
 * @brief list all caches
 *
 */
void
list_caches(struct dr_info *dr_info)
{
	struct cache_info *cache = NULL;

	printf("cache-name              phandle\n");

	for (cache = dr_info->all_caches; cache != NULL; cache = cache->next)
		printf("%-21s%-8x\n", cache->name, cache->phandle);

	return;
}

/**
 * list_all_cpus_and_caches
 * @bried list all of the cpus and caches
 *
 */
void
list_cpus_and_caches(struct dr_info *dr_info)
{
	struct dr_node *cpu = NULL;
	struct thread *t;
	int thread_id_field_sz = 17;
	char *fmt_s = "%-10s%-18s%-11s%-17s%-15s%-15s\n";
	char *fmt = "%-10s%-18s%-11x%";
	char *fmt_caches = "%-15s%-15s\n";

	printf(fmt_s, "drc-name", "OFDT-node", "drc_index", "thread id(s)",
	       "l2-cache", "l3-cache");

	for (cpu = dr_info->all_cpus; cpu != NULL; cpu = cpu->next) {
		int i, count = 0;
		struct cache_info *l2_cache = NULL;
		struct cache_info *l3_cache = NULL;

		printf(fmt, cpu->drc_name, cpu->name ? cpu->name : "--",
		       cpu->drc_index);

		for (t = cpu->cpu_threads; t; t = t->sibling) {
			printf("%x ", t->id);
			count += 2;
		}

{'fraction_non_alphanumeric': 0.1558322651529024, 'fraction_numerical': 0.023072697308185314, 'mean_word_length': 3.48440065681445, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6617106', 'n_tokens_mistral': 2202, 'n_tokens_neox': 2021, 'n_words': 600}