/* *flagstomalloc.
*/ #define M_NOWAIT 0x0001 /* do not block */ #define M_WAITOK 0x0002 /* ok to block */ #define M_ZERO 0x0100 /* bzero the allocation */ #define M_NOVM 0x0200 /* don't ask VM for pages */ #define M_USE_RESERVE 0x0400 /* can alloc out of reserve memory */
#define M_MAGIC 877983977/* time when first defined :-) */
/* *Twomalloctypestructuresarepresent:malloc_type,whichisusedbya *typeownertodeclarethetype,andmalloc_type_internal,whichholds *malloc-ownedstatisticsandotherABI-sensitivefields,suchasthesetof *mallocstatisticsindexedbythecompile-timeMAXCPUconstant. *Applicationsshouldavoidintroducingdependenceontheallocatorprivate *datalayoutandsize. * *Themalloc_typeks_nextfieldisprotectedbymalloc_mtx.Otherfieldsin *malloc_typearestaticafterinitializationsounsynchronized. * *Statisticsinmalloc_type_statsarewrittenonlywhenholdingacritical *sectionandrunningontheCPUassociatedwiththeindexintothestat *array,butreadlock-freeresultinginpossible(minor)races,whichthe *monitoringappshouldtakeintoaccount.
*/ struct malloc_type_stats {
uint64_t mts_memalloced; /* Bytes allocated on CPU. */
uint64_t mts_memfreed; /* Bytes freed on CPU. */
uint64_t mts_numallocs; /* Number of allocates on CPU. */
uint64_t mts_numfrees; /* number of frees on CPU. */
uint64_t mts_size; /* Bitmask of sizes allocated on CPU. */
uint64_t _mts_reserved1; /* Reserved field. */
uint64_t _mts_reserved2; /* Reserved field. */
uint64_t _mts_reserved3; /* Reserved field. */
};
#ifndef MAXCPU /* necessary on Linux */ #define MAXCPU 4/* arbitrary? */ #endif
/* Removed "extern" in __Userspace__ code */ /* If we need to use MALLOC_DECLARE before using MALLOC then wehavetoremoveextern. In/usr/include/sys/malloc.hthereisthisdefinition: #defineMALLOC_DECLARE(type)\ externstructmalloc_typetype[1] andloaderisunabletofindtheexternmalloc_typebecause itmaybedefinedinoneofkernelobjectfiles. ItseemsthatMALLOC_DECLAREandMALLOC_DEFINEcannotbeusedat thesametimeforsame"type"variable.Also,inRandall'sarchitecture document,whereitspecifiesO/Sspecificmacrosandfunctions,itsays thatthenameinSCTP_MALLOCdoesnothavetobeused.
*/ #define MALLOC_DECLARE(type) \ externstruct malloc_type type[1]
#define FREE(addr, type) free((addr))
/* changed definitions of MALLOC and FREE */ /* Using memset if flag M_ZERO is specified. Todo: M_WAITOK and M_NOWAIT */ #define MALLOC(space, cast, size, type, flags) \
((space) = (cast)malloc((u_long)(size))); \ do { \ if (flags & M_ZERO) { \
memset(space,0,size); \
} \
} while (0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.