mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Question about calloc, free in CPU_ALLOC and CPU_FREE
@ 2022-06-29 15:49 Thomas Stüfe
  2022-06-29 16:11 ` Markus Wichmann
  2022-06-29 16:15 ` Florian Weimer
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Stüfe @ 2022-06-29 15:49 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

Greetings,

I have a small question about the way muslc implements the CPU_ALLOC and
CPU_FREE macros.

I see them defined in sched.h as:

#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
#define CPU_FREE(set) free(set)

whereas the glibc defines them as calls to functions __sched_cpu_alloc()
and __sched_cpufree():

#define __CPU_ALLOC(count) __sched_cpualloc (count)
#define __CPU_FREE(cpuset) __sched_cpufree (cpuset)

in the end both variants allocate from C-heap, but the muslc variant gets
inlined directly into the calling code. If that calling code has a function
"free" or "calloc" (okay, less likely) these get called instead. Could also
be a class local method in C++.

I realize this is not a big issue. But would it not be safer to do as the
glibc does in this case?

Thank you,

Thomas

[-- Attachment #2: Type: text/html, Size: 1131 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-29 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 15:49 [musl] Question about calloc, free in CPU_ALLOC and CPU_FREE Thomas Stüfe
2022-06-29 16:11 ` Markus Wichmann
2022-06-29 16:32   ` Thomas Stüfe
2022-06-29 16:15 ` Florian Weimer
2022-06-29 16:30   ` Thomas Stüfe

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).