Adds fmt_limit_units(buf, len, limit, units_mode) to src/lib/xcelimit.c, a units-mode-aware sibling of fmt_limit() following the fmt_jobid()/fmt_jobid_ex() extended-sibling pattern. Reuses fmt_limit()'s exact consumer-dump loop untouched; only the final value line branches: percent limits always render bare "%f%%" regardless of mode, byte-valued (or "swp"-special-cased) absolute values render via xce_format_units_value() (task 7), everything else keeps the unconditional "%f". fmt_limit() itself is now a one-line XCE_UNITS_RAW wrapper around fmt_limit_units() -- provably byte-identical to its prior output for every input shape, so its 5 existing direct unit tests needed zero changes (the regression proof this refactor relies on). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
38 lines
1.6 KiB
C
38 lines
1.6 KiB
C
#if !defined(_XCELIMIT_H_)
|
|
|
|
#define _XCELIMIT_H_ 1
|
|
|
|
#include <rtti.h>
|
|
#include <stdarg.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "group.h"
|
|
#include "kvmgr.h"
|
|
#include "utils.h"
|
|
#include "xce/types.h"
|
|
|
|
extern int build_consumer(xce_consumer_t**, var, xce_consumer_type_t, int,
|
|
xce_group_config_t*, char*);
|
|
extern void kill_consumer(xce_consumer_t*);
|
|
extern int build_limit(xce_limit_t**, var, var, var, var, xce_limit_config_t*);
|
|
extern int match_limit(xce_limit_t*, int, ...);
|
|
extern int build_vres_name(char**, xce_limit_t*, char*, char*, char*);
|
|
extern int is_host_based_limit(var, xce_limit_t*);
|
|
extern int fmt_consumer(char*, int, xce_consumer_t*);
|
|
extern int fmt_limit(char*, int, xce_limit_t*);
|
|
/* fmt_limit_units() -- scheduler-sim-diagnostics spec, Requirement 6, task
|
|
* 8.1. Sibling of fmt_limit() (the fmt_jobid()/fmt_jobid_ex() pattern):
|
|
* identical consumer-dump loop, but the final configured-value line renders
|
|
* a byte-valued, non-percentage resource's amount via xce_format_units_value()
|
|
* according to the supplied units_mode instead of always the bare "%f".
|
|
* fmt_limit() itself is now a one-line wrapper: fmt_limit_units(buf, len,
|
|
* limit, XCE_UNITS_RAW) -- byte-identical to its own pre-existing output. */
|
|
extern int fmt_limit_units(char*, int, xce_limit_t*, xce_units_mode_t);
|
|
extern void kill_limit(xce_limit_t*);
|
|
extern int instantiate_limit(xce_vres_t**, var, xce_limit_t*, char*, char*,
|
|
char*);
|
|
extern void kill_vres(xce_vres_t*);
|
|
extern int add_vres(xce_resource_t**, var, char*, int);
|
|
|
|
#endif
|