struct lscpu_cputype *lscpu_cputype_get_default(struct lscpu_cxt *cxt);
int lscpu_read_cpuinfo(struct lscpu_cxt *cxt);
-int lscpu_read_architecture(struct lscpu_cxt *cxt);
int lscpu_read_cpulists(struct lscpu_cxt *cxt);
int lscpu_read_extra(struct lscpu_cxt *cxt);
int lscpu_read_vulnerabilities(struct lscpu_cxt *cxt);
int lscpu_read_numas(struct lscpu_cxt *cxt);
+struct lscpu_arch *lscpu_read_architecture(struct lscpu_cxt *cxt);
+void lscpu_free_architecture(struct lscpu_arch *ar);
+
struct lscpu_virt *lscpu_read_virtualization(struct lscpu_cxt *cxt);
-void lscpu_free_virt(struct lscpu_virt *virt);
+void lscpu_free_virtualization(struct lscpu_virt *virt);
struct lscpu_cpu *lscpu_new_cpu(void);
void lscpu_ref_cpu(struct lscpu_cpu *cpu);
return 0;
}
-int lscpu_read_architecture(struct lscpu_cxt *cxt)
+struct lscpu_arch *lscpu_read_architecture(struct lscpu_cxt *cxt)
{
struct utsname utsbuf;
struct lscpu_arch *ar;
struct lscpu_cputype *ct;
assert(cxt);
- assert(!cxt->arch);
- DBG(GATHER, ul_debugobj(cxt, "reading architecture"));
+ DBG(GATHER, ul_debug("reading architecture"));
if (uname(&utsbuf) == -1)
err(EXIT_FAILURE, _("error: uname failed"));
- ar = cxt->arch = xcalloc(1, sizeof(*cxt->arch));
+ ar = xcalloc(1, sizeof(*cxt->arch));
ar->name = xstrdup(utsbuf.machine);
if (cxt->noalive)
ar->bit32 = 1;
}
- return 0;
+ DBG(GATHER, ul_debugobj(ar, "arch: name=%s %s %s",
+ ar->name,
+ ar->bit64 ? "64-bit" : "",
+ ar->bit64 ? "32-bit" : ""));
+ return ar;
+}
+
+void lscpu_free_architecture(struct lscpu_arch *ar)
+{
+ if (!ar)
+ return;
+ free(ar->name);
+ free(ar);
}
int lscpu_read_cpulists(struct lscpu_cxt *cxt)
free(cxt->idx2cpunum);
free(cxt->present);
free(cxt->online);
- if (cxt->arch)
- free(cxt->arch->name);
- free(cxt->arch);
free(cxt->cputypes);
free(cxt->cpus);
free(cxt->nodemaps);
free(cxt->idx2nodenum);
- lscpu_free_virt(cxt->virt);
+ lscpu_free_virtualization(cxt->virt);
+ lscpu_free_architecture(cxt->arch);
free(cxt);
}
context_init_paths(cxt);
lscpu_read_cpuinfo(cxt);
- lscpu_read_architecture(cxt);
+ cxt->arch = lscpu_read_architecture(cxt);
+
lscpu_read_cpulists(cxt);
lscpu_read_extra(cxt);
lscpu_read_vulnerabilities(cxt);