interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / evidence / dagsim-parse-om / oracle.gcov

3917 lines · 187770 bytes Raw Blame History
1 -: 0:Source:tools/dagsim/dagsim.c
2 -: 0:Graph:build/dagsim-parse/oracle.gcno
3 -: 0:Data:build/dagsim-parse/oracle.gcda
4 -: 0:Runs:9
5 -: 1:/*
6 -: 2: * dagsim.c -- offline resource-DAG cost evaluator (omega-mv#583).
7 -: 3: *
8 -: 4: * See dagsim.h and spec/offline-evidence-v1.md. The scheduler is a
9 -: 5: * deterministic fluid simulation: compute engines have slots, bandwidth
10 -: 6: * resources are shared equally among the ops streaming on them at any
11 -: 7: * instant, launches are serialized per launch resource, and an op finishes
12 -: 8: * when both its own busy time and its traffic are done (perfect overlap
13 -: 9: * inside one op, which is the issue's stated floor max(F/P, Q/B)). Ops are
14 -: 10: * dispatched in file order, so the same file always gives the same bytes.
15 -: 11: */
16 -: 12:#include "dagsim.h"
17 -: 13:#include "runtime/rx_costmodel.h"
18 -: 14:
19 -: 15:#include <ctype.h>
20 -: 16:#include <math.h>
21 -: 17:#include <stdio.h>
22 -: 18:#include <stdlib.h>
23 -: 19:#include <string.h>
24 -: 20:#include <time.h>
25 -: 21:#if !CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE
26 -: 22:#include "dagsim_format.h"
27 -: 23:#endif
28 -: 24:
29 -: 25:/* ---------------------------------------------------------------- names */
30 -: 26:
31 -: 27:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE
32function oracle_ds_status_name called 12 returned 100% blocks executed 100%
33 12: 28:const char *ds_status_name(int s) {
34 12: 29: switch (s) {
35branch 0 taken 1
36branch 1 taken 1
37branch 2 taken 1
38branch 3 taken 1
39branch 4 taken 1
40branch 5 taken 1
41branch 6 taken 1
42branch 7 taken 1
43branch 8 taken 1
44branch 9 taken 2
45branch 10 taken 1
46 -: 30: case DS_OK: return "OK";
47 1: 31: case DS_REFUSED_UNKNOWN: return "REFUSED_UNKNOWN";
48 1: 32: case DS_REFUSED_STALE: return "REFUSED_STALE";
49 1: 33: case DS_REFUSED_NO_CALIBRATION: return "REFUSED_NO_CALIBRATION";
50 1: 34: case DS_REFUSED_CAPACITY: return "REFUSED_CAPACITY";
51 1: 35: case DS_REFUSED_CYCLE: return "REFUSED_CYCLE";
52 1: 36: case DS_REFUSED_UNSUPPORTED: return "REFUSED_UNSUPPORTED";
53 1: 37: case DS_REFUSED_REMOVED_REQUIRED: return "REFUSED_REMOVED_REQUIRED";
54 1: 38: case DS_REFUSED_LIFETIME: return "REFUSED_LIFETIME";
55 1: 39: case DS_PARSE_ERROR: return "PARSE_ERROR";
56 2: 40: default: return "?";
57 -: 41: }
58 -: 42:}
59 -: 43:
60function oracle_ds_prov_name called 7 returned 100% blocks executed 100%
61 7: 44:const char *ds_prov_name(int p) {
62 7: 45: switch (p) {
63branch 0 taken 1
64branch 1 taken 1
65branch 2 taken 1
66branch 3 taken 1
67branch 4 taken 2
68branch 5 taken 1
69 -: 46: case DS_PROV_UNKNOWN: return "unknown";
70 1: 47: case DS_PROV_SYNTHETIC: return "synthetic";
71 1: 48: case DS_PROV_FITTED: return "fitted";
72 1: 49: case DS_PROV_MEASURED: return "measured";
73 1: 50: case DS_PROV_SPECIFIED: return "specified";
74 2: 51: default: return "?";
75 -: 52: }
76 -: 53:}
77 -: 54:
78function prov_from_name called 18354 returned 100% blocks executed 100%
79 18354: 55:static int prov_from_name(const char *s) {
80 18354: 56: if (!strcmp(s, "unknown")) return DS_PROV_UNKNOWN;
81branch 0 taken 18340 (fallthrough)
82branch 1 taken 14
83 18340: 57: if (!strcmp(s, "synthetic")) return DS_PROV_SYNTHETIC;
84branch 0 taken 18228 (fallthrough)
85branch 1 taken 112
86 18228: 58: if (!strcmp(s, "fitted")) return DS_PROV_FITTED;
87branch 0 taken 18214 (fallthrough)
88branch 1 taken 14
89 18214: 59: if (!strcmp(s, "measured")) return DS_PROV_MEASURED;
90branch 0 taken 17640 (fallthrough)
91branch 1 taken 574
92 17640: 60: if (!strcmp(s, "specified")) return DS_PROV_SPECIFIED;
93branch 0 taken 17528 (fallthrough)
94branch 1 taken 112
95 -: 61: return -1;
96 -: 62:}
97 -: 63:
98 -: 64:/* days since 1970-01-01 for a civil date (Howard Hinnant's days_from_civil) */
99function oracle_ds_day_from_date called 353 returned 100% blocks executed 100%
100 353: 65:int ds_day_from_date(const char *s) {
101 -: 66: int y, m, d;
102 353: 67: if (!s || sscanf(s, "%d-%d-%d", &y, &m, &d) != 3) return -1;
103branch 0 taken 353 (fallthrough)
104branch 1 taken 0
105branch 2 taken 36 (fallthrough)
106branch 3 taken 317
107 317: 68: y -= m <= 2;
108 317: 69: int era = (y >= 0 ? y : y - 399) / 400;
109branch 0 taken 35 (fallthrough)
110branch 1 taken 282
111 317: 70: unsigned yoe = (unsigned)(y - era * 400);
112 317: 71: unsigned doy = (153u * (unsigned)(m + (m > 2 ? -3 : 9)) + 2u) / 5u + (unsigned)d - 1u;
113branch 0 taken 81 (fallthrough)
114branch 1 taken 236
115 317: 72: unsigned doe = yoe * 365u + yoe / 4u - yoe / 100u + doy;
116 317: 73: return era * 146097 + (int)doe - 719468;
117 -: 74:}
118 -: 75:#else
119 -: 76:const char *ds_status_name(int s) {
120 -: 77: static _Thread_local char out[256];
121 -: 78: uint64_t a[16] = {(uint32_t)s}; ds_fmt(0, a, out); return out;
122 -: 79:}
123 -: 80:const char *ds_prov_name(int p) {
124 -: 81: static _Thread_local char out[256];
125 -: 82: uint64_t a[16] = {(uint32_t)p}; ds_fmt(1, a, out); return out;
126 -: 83:}
127 -: 84:int ds_day_from_date(const char *s) {
128 -: 85: if (!s) return -1;
129 -: 86: char in[256];
130 -: 87: uint64_t a[16] = {0};
131 -: 88: for (;;) {
132 -: 89: size_t n = strnlen(s, sizeof in);
133 -: 90: memcpy(in, s, n);
134 -: 91: a[0] = n; a[13] = n < sizeof in;
135 -: 92: uint64_t rc = ds_fmt(21, a, in);
136 -: 93: if (rc == 1) return (int32_t)a[12];
137 -: 94: if (rc == 2) return -1;
138 -: 95: s += n;
139 -: 96: }
140 -: 97:}
141 -: 98:#endif
142 -: 99:
143function oracle_ds_find_op called 59201 returned 100% blocks executed 100%
144 59201: 100:int ds_find_op(const ds_model *m, const char *id) {
145 779054: 101: for (int i = 0; i < m->n_ops; i++) if (!strcmp(m->ops[i].id, id)) return i;
146branch 0 taken 43232 (fallthrough)
147branch 1 taken 719853
148branch 2 taken 763085
149branch 3 taken 15969 (fallthrough)
150 -: 102: return -1;
151 -: 103:}
152function oracle_ds_find_res called 25782 returned 100% blocks executed 100%
153 25782: 104:int ds_find_res(const ds_model *m, const char *id) {
154 71824: 105: for (int i = 0; i < m->n_res; i++) if (!strcmp(m->res[i].id, id)) return i;
155branch 0 taken 15320 (fallthrough)
156branch 1 taken 46042
157branch 2 taken 61362
158branch 3 taken 10462 (fallthrough)
159 -: 106: return -1;
160 -: 107:}
161 -: 108:
162 -: 109:/* ---------------------------------------------------------------- parse */
163 -: 110:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE
164 -: 111:/* bounded string copy; ids and sources are truncated, never overflowed */
165function sset called 370158 returned 100% blocks executed 100%
166 370158: 112:static void sset(char *dst, size_t cap, const char *src) {
167 370158: 113: size_t n = strlen(src);
168 370158: 114: if (n >= cap) n = cap - 1;
169branch 0 taken 161 (fallthrough)
170branch 1 taken 369997
171 370158: 115: memcpy(dst, src, n); dst[n] = 0;
172 370158: 116:}
173 -: 117:
174 -: 118:
175 -: 119:typedef struct { char key[32]; char val[DS_SRC]; int used; } kv;
176 -: 120:
177function split_kv called 87433 returned 100% blocks executed 100%
178 87433: 121:static int split_kv(char *line, char *keyword, size_t kwcap, kv *kvs, int maxkv, char *positional[], int *npos) {
179 87433: 122: int n = 0; *npos = 0; keyword[0] = 0;
180 87433: 123: char *p = strchr(line, '#'); if (p) *p = 0;
181branch 0 taken 21532 (fallthrough)
182branch 1 taken 65901
183 87433: 124: char *save = NULL;
184 87433: 125: char *tok = strtok_r(line, " \t\r\n", &save);
185call 0 returned 87433
186 87433: 126: if (!tok) return -1; /* empty */
187branch 0 taken 65894 (fallthrough)
188branch 1 taken 21539
189 -: 127: snprintf(keyword, kwcap, "%s", tok);
190 268481: 128: while ((tok = strtok_r(NULL, " \t\r\n", &save))) {
191call 0 returned 268481
192branch 1 taken 202594
193branch 2 taken 65887 (fallthrough)
194 202594: 129: char *eq = strchr(tok, '=');
195 202594: 130: if (!eq) { if (*npos < 8) positional[(*npos)++] = tok; continue; }
196branch 0 taken 43260 (fallthrough)
197branch 1 taken 159334
198branch 2 taken 43253 (fallthrough)
199branch 3 taken 7
200 159334: 131: if (n >= maxkv) return -2;
201branch 0 taken 159327 (fallthrough)
202branch 1 taken 7
203 159327: 132: *eq = 0;
204 159327: 133: sset(kvs[n].key, sizeof kvs[n].key, tok);
205call 0 returned 159327
206 159327: 134: sset(kvs[n].val, sizeof kvs[n].val, eq + 1);
207call 0 returned 159327
208 159327: 135: kvs[n].used = 0;
209 159327: 136: n++;
210 -: 137: }
211 -: 138: return n;
212 -: 139:}
213 -: 140:
214function get called 298512 returned 100% blocks executed 100%
215 298512: 141:static const char *get(kv *kvs, int n, const char *key) {
216 1100265: 142: for (int i = 0; i < n; i++) if (!strcmp(kvs[i].key, key)) { kvs[i].used = 1; return kvs[i].val; }
217branch 0 taken 155246 (fallthrough)
218branch 1 taken 801753
219branch 2 taken 956999
220branch 3 taken 143266 (fallthrough)
221 -: 143: return NULL;
222 -: 144:}
223 -: 145:
224function unused_key called 64389 returned 100% blocks executed 100%
225 64389: 146:static int unused_key(kv *kvs, int n, char *out, size_t cap) {
226 214602: 147: for (int i = 0; i < n; i++) if (!kvs[i].used) { snprintf(out, cap, "%s", kvs[i].key); return 1; }
227branch 0 taken 238 (fallthrough)
228branch 1 taken 150213
229branch 2 taken 150451
230branch 3 taken 64151 (fallthrough)
231 -: 148: return 0;
232 -: 149:}
233 -: 150:
234function parse_real called 31342 returned 100% blocks executed 100%
235 31342: 151:static int parse_real(const char *s, double *out) {
236 31342: 152: if (!s) return 0;
237branch 0 taken 21 (fallthrough)
238branch 1 taken 31321
239 31321: 153: char *end; double v = strtod(s, &end);
240call 0 returned 31321
241 31321: 154: if (end == s || *end) return 0;
242branch 0 taken 224
243branch 1 taken 31097 (fallthrough)
244branch 2 taken 56
245branch 3 taken 31041 (fallthrough)
246 31041: 155: if (!(v == v) || v < 0) return 0;
247branch 0 taken 28
248branch 1 taken 31013 (fallthrough)
249branch 2 taken 28
250branch 3 taken 30985 (fallthrough)
251 30985: 156: *out = v; return 1;
252 -: 157:}
253 -: 158:
254 -: 159:#define PERR(...) do { snprintf(err, errcap, "line %d: ", lineno); size_t _l = strlen(err); snprintf(err + _l, errcap - _l, __VA_ARGS__); return DS_PARSE_ERROR; } while (0)
255 -: 160:
256function parse_prov_src called 25460 returned 100% blocks executed 100%
257 25460: 161:static int parse_prov_src(kv *kvs, int n, int *prov, char *src, size_t srccap, int required, char *err, size_t errcap, int lineno) {
258 25460: 162: const char *p = get(kvs, n, "prov");
259call 0 returned 25460
260 25460: 163: const char *s = get(kvs, n, "src");
261call 0 returned 25460
262 25460: 164: if (!p) { if (required) PERR("prov= is required wherever a number appears"); *prov = -1; return DS_OK; }
263branch 0 taken 7106 (fallthrough)
264branch 1 taken 18354
265branch 2 taken 126 (fallthrough)
266branch 3 taken 6980
267 18354: 165: int v = prov_from_name(p);
268 18354: 166: if (v < 0) PERR("prov=%s is not one of specified|measured|fitted|synthetic|unknown", p);
269branch 0 taken 112 (fallthrough)
270branch 1 taken 18242
271 18242: 167: *prov = v;
272 18242: 168: if ((v == DS_PROV_MEASURED || v == DS_PROV_FITTED) && !s) PERR("prov=%s needs src=", p);
273branch 0 taken 588 (fallthrough)
274branch 1 taken 17654
275branch 2 taken 49 (fallthrough)
276branch 3 taken 539
277 17654: 169: snprintf(src, srccap, "%s", s ? s : "");
278branch 0 taken 280 (fallthrough)
279branch 1 taken 17374
280 18193: 170: return DS_OK;
281 -: 171:}
282 -: 172:
283function oracle_ds_parse_text called 3445 returned 100% blocks executed 98%
284 3445: 173:int ds_parse_text(const char *text, ds_model *m, char *err, size_t errcap) {
285 -: 174: memset(m, 0, sizeof *m);
286 3445: 175: err[0] = 0;
287 -: 176: int lineno = 0;
288 -: 177: const char *cur = text;
289 -: 178: int seen_oev = 0, seen_machine = 0, seen_build = 0;
290 -: 179: /* two-pass is not needed: ops before deps/buffers is the convention; we
291 -: 180: * resolve references at use and require definition before use. */
292 89135: 181: while (*cur) {
293branch 0 taken 87447
294branch 1 taken 1688 (fallthrough)
295 87447: 182: const char *nl = strchr(cur, '\n');
296 87447: 183: size_t len = nl ? (size_t)(nl - cur) : strlen(cur);
297branch 0 taken 87419 (fallthrough)
298branch 1 taken 28
299 -: 184: char line[1024];
300 87447: 185: lineno++;
301 89204: 186: if (len >= sizeof line) PERR("line too long");
302branch 0 taken 14 (fallthrough)
303branch 1 taken 87433
304 87433: 187: memcpy(line, cur, len); line[len] = 0;
305 87433: 188: cur = nl ? nl + 1 : cur + len;
306branch 0 taken 87405 (fallthrough)
307branch 1 taken 28
308 -: 189: char keyword[32]; kv kvs[24]; char *pos[8]; int npos;
309 87433: 190: int n = split_kv(line, keyword, sizeof keyword, kvs, 24, pos, &npos);
310call 0 returned 87433
311 87433: 191: if (n == -1) continue;
312branch 0 taken 21539 (fallthrough)
313branch 1 taken 65894
314 65894: 192: if (n == -2) PERR("too many fields");
315branch 0 taken 7 (fallthrough)
316branch 1 taken 65887
317 65887: 193: if (!strcmp(keyword, "oev")) {
318branch 0 taken 3207 (fallthrough)
319branch 1 taken 62680
320 3207: 194: const char *v = get(kvs, n, "version");
321call 0 returned 3207
322 3207: 195: if (!v || strcmp(v, "1")) PERR("oev version=1 required");
323branch 0 taken 3200 (fallthrough)
324branch 1 taken 7
325branch 2 taken 14 (fallthrough)
326branch 3 taken 3186
327 3186: 196: m->version = 1; seen_oev = 1;
328 62680: 197: } else if (!strcmp(keyword, "machine")) {
329branch 0 taken 3473 (fallthrough)
330branch 1 taken 59207
331 -: 198: const char *v;
332 3515: 199: if (!(v = get(kvs, n, "id"))) PERR("machine needs id=");
333call 0 returned 3473
334branch 1 taken 7 (fallthrough)
335branch 2 taken 3466
336 3466: 200: sset(m->machine_id, sizeof m->machine_id, v);
337call 0 returned 3466
338 3466: 201: if ((v = get(kvs, n, "soc"))) sset(m->soc, sizeof m->soc, v);
339call 0 returned 3466
340branch 1 taken 3298 (fallthrough)
341branch 2 taken 168
342call 3 returned 3298
343 6778: 202: if ((v = get(kvs, n, "cores"))) m->cores = atoi(v);
344call 0 returned 3466
345branch 1 taken 3312 (fallthrough)
346branch 2 taken 154
347 3466: 203: if ((v = get(kvs, n, "mem_bytes")) && !parse_real(v, &m->mem_bytes)) PERR("bad mem_bytes");
348call 0 returned 3466
349branch 1 taken 3312 (fallthrough)
350branch 2 taken 154
351call 3 returned 3312
352branch 4 taken 14 (fallthrough)
353branch 5 taken 3298
354 -: 204: int prov; char src[DS_SRC];
355 3452: 205: int rc = parse_prov_src(kvs, n, &prov, src, sizeof src, 1, err, errcap, lineno); if (rc) return rc;
356call 0 returned 3452
357branch 1 taken 21 (fallthrough)
358branch 2 taken 3431
359 -: 206: seen_machine = 1;
360 59207: 207: } else if (!strcmp(keyword, "build")) {
361branch 0 taken 3305 (fallthrough)
362branch 1 taken 55902
363 -: 208: const char *v;
364 3305: 209: if ((v = get(kvs, n, "repo"))) sset(m->repo, sizeof m->repo, v);
365call 0 returned 3305
366branch 1 taken 3242 (fallthrough)
367branch 2 taken 63
368call 3 returned 3242
369 3305: 210: if (!(v = get(kvs, n, "sha")) || strlen(v) != 40) PERR("build needs sha=<40 hex>");
370call 0 returned 3305
371branch 1 taken 3298 (fallthrough)
372branch 2 taken 7
373branch 3 taken 14 (fallthrough)
374branch 4 taken 3284
375 3284: 211: sset(m->build_sha, sizeof m->build_sha, v);
376call 0 returned 3284
377 3284: 212: if ((v = get(kvs, n, "physics"))) sset(m->physics, sizeof m->physics, v);
378call 0 returned 3284
379branch 1 taken 3277 (fallthrough)
380branch 2 taken 7
381call 3 returned 3277
382 -: 213: seen_build = 1;
383 55902: 214: } else if (!strcmp(keyword, "calibration")) {
384branch 0 taken 301 (fallthrough)
385branch 1 taken 55601
386 -: 215: const char *v;
387 301: 216: if (m->has_calibration) PERR("one calibration record only");
388branch 0 taken 7 (fallthrough)
389branch 1 taken 294
390 294: 217: if (!(v = get(kvs, n, "id"))) PERR("calibration needs id=");
391call 0 returned 294
392branch 1 taken 7 (fallthrough)
393branch 2 taken 287
394 287: 218: sset(m->cal_id, sizeof m->cal_id, v);
395call 0 returned 287
396 287: 219: if (!(v = get(kvs, n, "taken")) || (m->cal_taken_day = ds_day_from_date(v)) < 0) PERR("calibration needs taken=YYYY-MM-DD");
397call 0 returned 287
398branch 1 taken 280 (fallthrough)
399branch 2 taken 7
400call 3 returned 280
401branch 4 taken 70 (fallthrough)
402branch 5 taken 210
403 210: 220: if (!(v = get(kvs, n, "valid_days"))) PERR("calibration needs valid_days=");
404call 0 returned 210
405branch 1 taken 7 (fallthrough)
406branch 2 taken 203
407 203: 221: m->cal_valid_days = atoi(v);
408 203: 222: if (!(v = get(kvs, n, "load1")) || !parse_real(v, &m->cal_load1)) PERR("calibration needs load1=");
409call 0 returned 203
410branch 1 taken 196 (fallthrough)
411branch 2 taken 7
412call 3 returned 196
413branch 4 taken 14 (fallthrough)
414branch 5 taken 182
415 182: 223: if (!(v = get(kvs, n, "src"))) PERR("calibration needs src=");
416call 0 returned 182
417branch 1 taken 7 (fallthrough)
418branch 2 taken 175
419 175: 224: sset(m->cal_src, sizeof m->cal_src, v);
420call 0 returned 175
421 175: 225: if ((v = get(kvs, n, "model"))) sset(m->cal_model, sizeof m->cal_model, v);
422call 0 returned 175
423branch 1 taken 77 (fallthrough)
424branch 2 taken 98
425call 3 returned 77
426 175: 226: m->has_calibration = 1;
427 55601: 227: } else if (!strcmp(keyword, "resource")) {
428branch 0 taken 10448 (fallthrough)
429branch 1 taken 45153
430 10448: 228: if (m->n_res >= DS_MAX_RES) PERR("too many resources (max %d)", DS_MAX_RES);
431branch 0 taken 7 (fallthrough)
432branch 1 taken 10441
433 10441: 229: ds_resource *r = &m->res[m->n_res];
434call 0 returned 10441
435 -: 230: memset(r, 0, sizeof *r);
436 -: 231: const char *v;
437 10441: 232: if (!(v = get(kvs, n, "id"))) PERR("resource needs id=");
438call 0 returned 10441
439branch 1 taken 28 (fallthrough)
440branch 2 taken 10413
441 10413: 233: if (ds_find_res(m, v) >= 0) PERR("duplicate resource %s", v);
442branch 0 taken 7 (fallthrough)
443branch 1 taken 10406
444 10406: 234: sset(r->id, sizeof r->id, v);
445call 0 returned 10406
446 10406: 235: if (!(v = get(kvs, n, "kind"))) PERR("resource needs kind=");
447call 0 returned 10406
448branch 1 taken 21 (fallthrough)
449branch 2 taken 10385
450 10385: 236: if (!strcmp(v, "compute")) {
451branch 0 taken 3242 (fallthrough)
452branch 1 taken 7143
453 3242: 237: r->kind = DS_RES_COMPUTE;
454 6477: 238: if (!(v = get(kvs, n, "slots")) || (r->slots = atoi(v)) < 1) PERR("compute resource needs slots>=1");
455call 0 returned 3242
456branch 1 taken 3235 (fallthrough)
457branch 2 taken 7
458branch 3 taken 84 (fallthrough)
459branch 4 taken 3151
460 7143: 239: } else if (!strcmp(v, "bandwidth")) {
461branch 0 taken 2591 (fallthrough)
462branch 1 taken 4552
463 2591: 240: r->kind = DS_RES_BANDWIDTH;
464 2591: 241: if (!parse_real(get(kvs, n, "cap"), &r->cap) || r->cap <= 0) PERR("bandwidth resource needs cap>0");
465call 0 returned 2591
466call 1 returned 2591
467branch 2 taken 2500 (fallthrough)
468branch 3 taken 91
469branch 4 taken 42 (fallthrough)
470branch 5 taken 2458
471 2458: 242: r->lo = r->hi = r->cap;
472 2458: 243: if ((v = get(kvs, n, "lo")) && !parse_real(v, &r->lo)) PERR("bad lo");
473call 0 returned 2458
474branch 1 taken 2318 (fallthrough)
475branch 2 taken 140
476call 3 returned 2318
477branch 4 taken 14 (fallthrough)
478branch 5 taken 2304
479 2444: 244: if ((v = get(kvs, n, "hi")) && !parse_real(v, &r->hi)) PERR("bad hi");
480call 0 returned 2444
481branch 1 taken 2304 (fallthrough)
482branch 2 taken 140
483call 3 returned 2304
484branch 4 taken 14 (fallthrough)
485branch 5 taken 2290
486 2430*: 245: if (r->lo > r->cap || r->hi < r->cap) PERR("need lo <= cap <= hi");
487branch 0 taken 2430 (fallthrough)
488branch 1 taken 0
489branch 2 taken 0 (fallthrough)
490branch 3 taken 2430
491 4552: 246: } else if (!strcmp(v, "capacity")) {
492branch 0 taken 2304 (fallthrough)
493branch 1 taken 2248
494 2304: 247: r->kind = DS_RES_CAPACITY;
495 2304: 248: if (!parse_real(get(kvs, n, "cap"), &r->cap) || r->cap <= 0) PERR("capacity resource needs cap>0");
496call 0 returned 2304
497call 1 returned 2304
498branch 2 taken 2283 (fallthrough)
499branch 3 taken 21
500branch 4 taken 0 (fallthrough)
501branch 5 taken 2283
502 2248: 249: } else if (!strcmp(v, "launch")) {
503branch 0 taken 2206 (fallthrough)
504branch 1 taken 42
505 2206: 250: r->kind = DS_RES_LAUNCH;
506 42: 251: } else PERR("resource kind=%s unknown", v);
507 10070: 252: int rc = parse_prov_src(kvs, n, &r->prov, r->src, sizeof r->src, 1, err, errcap, lineno); if (rc) return rc;
508call 0 returned 10070
509branch 1 taken 112 (fallthrough)
510branch 2 taken 9958
511 9958: 253: m->n_res++;
512 45153: 254: } else if (!strcmp(keyword, "op")) {
513branch 0 taken 10348 (fallthrough)
514branch 1 taken 34805
515 10348: 255: if (m->n_ops >= DS_MAX_OPS) PERR("too many ops (max %d)", DS_MAX_OPS);
516branch 0 taken 7 (fallthrough)
517branch 1 taken 10341
518 10341: 256: ds_op *o = &m->ops[m->n_ops];
519call 0 returned 10341
520 -: 257: memset(o, 0, sizeof *o);
521 10341: 258: o->engine = o->bw = o->launcher = -1;
522 -: 259: const char *v;
523 10341: 260: if (!(v = get(kvs, n, "id"))) PERR("op needs id=");
524call 0 returned 10341
525branch 1 taken 7 (fallthrough)
526branch 2 taken 10334
527 10334: 261: if (ds_find_op(m, v) >= 0) PERR("duplicate op %s", v);
528branch 0 taken 7 (fallthrough)
529branch 1 taken 10327
530 10327: 262: sset(o->id, sizeof o->id, v);
531call 0 returned 10327
532 10327: 263: if (!(v = get(kvs, n, "kind"))) PERR("op needs kind=");
533call 0 returned 10327
534branch 1 taken 7 (fallthrough)
535branch 2 taken 10320
536 10320: 264: if (!strcmp(v, "compute")) o->kind = DS_OP_COMPUTE;
537branch 0 taken 2549 (fallthrough)
538branch 1 taken 7771
539 7771: 265: else if (!strcmp(v, "copy")) o->kind = DS_OP_COPY;
540branch 0 taken 2220 (fallthrough)
541branch 1 taken 5551
542 5551: 266: else if (!strcmp(v, "matvec")) o->kind = DS_OP_MATVEC;
543branch 0 taken 112 (fallthrough)
544branch 1 taken 5439
545 5439: 267: else if (!strcmp(v, "barrier")) o->kind = DS_OP_BARRIER;
546branch 0 taken 5383 (fallthrough)
547branch 1 taken 56
548 56: 268: else if (!strcmp(v, "storage")) o->kind = DS_OP_STORAGE;
549branch 0 taken 14 (fallthrough)
550branch 1 taken 42
551 42: 269: else if (!strcmp(v, "persist")) o->kind = DS_OP_PERSIST;
552branch 0 taken 14 (fallthrough)
553branch 1 taken 28
554 28: 270: else PERR("op kind=%s unknown", v);
555 10292: 271: if ((v = get(kvs, n, "engine"))) {
556call 0 returned 10292
557branch 1 taken 4916 (fallthrough)
558branch 2 taken 5376
559 4916: 272: o->engine = ds_find_res(m, v);
560 4916: 273: if (o->engine < 0 || m->res[o->engine].kind != DS_RES_COMPUTE) PERR("engine=%s is not a compute resource defined above", v);
561branch 0 taken 4902 (fallthrough)
562branch 1 taken 14
563branch 2 taken 0 (fallthrough)
564branch 3 taken 4902
565 -: 274: }
566 10278: 275: if ((v = get(kvs, n, "t_ns"))) { if (!parse_real(v, &o->t_ns)) PERR("bad t_ns"); o->has_t = 1; o->lo = o->hi = o->t_ns; }
567call 0 returned 10278
568branch 1 taken 2556 (fallthrough)
569branch 2 taken 7722
570call 3 returned 2556
571branch 4 taken 14 (fallthrough)
572branch 5 taken 2542
573 10264: 276: if ((v = get(kvs, n, "lo"))) { if (!o->has_t || !parse_real(v, &o->lo) || o->lo > o->t_ns) PERR("lo needs t_ns and lo <= t_ns"); }
574call 0 returned 10264
575branch 1 taken 2500 (fallthrough)
576branch 2 taken 7764
577branch 3 taken 2493 (fallthrough)
578branch 4 taken 7
579call 5 returned 2493
580branch 6 taken 2479 (fallthrough)
581branch 7 taken 14
582branch 8 taken 0 (fallthrough)
583branch 9 taken 2479
584 10243: 277: if ((v = get(kvs, n, "hi"))) { if (!o->has_t || !parse_real(v, &o->hi) || o->hi < o->t_ns) PERR("hi needs t_ns and hi >= t_ns"); }
585call 0 returned 10243
586branch 1 taken 2479 (fallthrough)
587branch 2 taken 7764
588branch 3 taken 2479 (fallthrough)
589branch 4 taken 0
590call 5 returned 2479
591branch 6 taken 2465 (fallthrough)
592branch 7 taken 14
593branch 8 taken 0 (fallthrough)
594branch 9 taken 2465
595 10229: 278: if ((v = get(kvs, n, "bytes"))) {
596call 0 returned 10229
597branch 1 taken 2465 (fallthrough)
598branch 2 taken 7764
599 2465: 279: if (!parse_real(v, &o->bytes)) PERR("bad bytes");
600call 0 returned 2465
601branch 1 taken 14 (fallthrough)
602branch 2 taken 2451
603 2451: 280: const char *b = get(kvs, n, "bw");
604call 0 returned 2451
605 2451: 281: if (!b || (o->bw = ds_find_res(m, b)) < 0 || m->res[o->bw].kind != DS_RES_BANDWIDTH) PERR("bytes= needs bw=<bandwidth resource defined above>");
606branch 0 taken 2444 (fallthrough)
607branch 1 taken 7
608branch 2 taken 2430 (fallthrough)
609branch 3 taken 14
610branch 4 taken 0 (fallthrough)
611branch 5 taken 2430
612 -: 282: }
613 10194: 283: if ((v = get(kvs, n, "launch_ns"))) {
614call 0 returned 10194
615branch 1 taken 2430 (fallthrough)
616branch 2 taken 7764
617 2430: 284: if (!parse_real(v, &o->launch_ns)) PERR("bad launch_ns");
618call 0 returned 2430
619branch 1 taken 14 (fallthrough)
620branch 2 taken 2416
621 2416: 285: const char *l = get(kvs, n, "launcher");
622call 0 returned 2416
623 2416: 286: if (!l || (o->launcher = ds_find_res(m, l)) < 0 || m->res[o->launcher].kind != DS_RES_LAUNCH) PERR("launch_ns= needs launcher=<launch resource defined above>");
624branch 0 taken 2409 (fallthrough)
625branch 1 taken 7
626branch 2 taken 2395 (fallthrough)
627branch 3 taken 14
628branch 4 taken 0 (fallthrough)
629branch 5 taken 2395
630 -: 287: }
631 10159: 288: if ((v = get(kvs, n, "M"))) o->M = (uint32_t)strtoul(v, NULL, 10);
632call 0 returned 10159
633branch 1 taken 329 (fallthrough)
634branch 2 taken 9830
635call 3 returned 329
636 10159: 289: if ((v = get(kvs, n, "N"))) o->N = (uint32_t)strtoul(v, NULL, 10);
637call 0 returned 10159
638branch 1 taken 329 (fallthrough)
639branch 2 taken 9830
640call 3 returned 329
641 10159: 290: if ((v = get(kvs, n, "core"))) o->core = (uint32_t)strtoul(v, NULL, 10);
642call 0 returned 10159
643branch 1 taken 189 (fallthrough)
644branch 2 taken 9970
645call 3 returned 189
646 10159: 291: if ((v = get(kvs, n, "arm"))) o->arm = (uint32_t)strtoul(v, NULL, 10);
647call 0 returned 10159
648branch 1 taken 189 (fallthrough)
649branch 2 taken 9970
650call 3 returned 189
651 10159: 292: if (o->kind == DS_OP_MATVEC && !o->has_t && (o->M == 0 || o->N == 0)) PERR("matvec needs M= and N= (or t_ns=)");
652branch 0 taken 112 (fallthrough)
653branch 1 taken 10047
654branch 2 taken 105 (fallthrough)
655branch 3 taken 7
656branch 4 taken 77 (fallthrough)
657branch 5 taken 28
658branch 6 taken 0 (fallthrough)
659branch 7 taken 77
660 10131: 293: if (o->kind != DS_OP_BARRIER && o->engine < 0) PERR("op %s needs engine=", o->id);
661branch 0 taken 4748 (fallthrough)
662branch 1 taken 5383
663branch 2 taken 7 (fallthrough)
664branch 3 taken 4741
665 10124: 294: int required = o->has_t || o->bytes > 0 || o->launch_ns > 0 || o->kind == DS_OP_MATVEC;
666branch 0 taken 7687 (fallthrough)
667branch 1 taken 2437
668branch 2 taken 2206 (fallthrough)
669branch 3 taken 5481
670branch 4 taken 0
671branch 5 taken 5481 (fallthrough)
672branch 6 taken 77
673branch 7 taken 5404 (fallthrough)
674 10124: 295: int rc = parse_prov_src(kvs, n, &o->t_prov, o->src, sizeof o->src, required, err, errcap, lineno); if (rc) return rc;
675call 0 returned 10124
676branch 1 taken 105 (fallthrough)
677branch 2 taken 10019
678 10019: 296: if (o->t_prov < 0) o->t_prov = DS_PROV_SPECIFIED; /* a costless barrier: ordering only */
679branch 0 taken 5404 (fallthrough)
680branch 1 taken 4615
681 -: 297: if (!o->has_t && o->kind != DS_OP_MATVEC && o->t_prov == DS_PROV_UNKNOWN) { /* fine: explicitly unknown */ }
682 10019: 298: m->n_ops++;
683 34805: 299: } else if (!strcmp(keyword, "dep")) {
684branch 0 taken 21560 (fallthrough)
685branch 1 taken 13245
686 21560: 300: if (npos != 2 || n != 0) PERR("dep <from> <to>");
687branch 0 taken 21532 (fallthrough)
688branch 1 taken 28
689branch 2 taken 7 (fallthrough)
690branch 3 taken 21525
691 21525: 301: if (m->n_deps >= DS_MAX_DEPS) PERR("too many deps");
692branch 0 taken 7 (fallthrough)
693branch 1 taken 21518
694 21518: 302: int a = ds_find_op(m, pos[0]), b = ds_find_op(m, pos[1]);
695 21518: 303: if (a < 0 || b < 0) PERR("dep names an op not defined above: %s %s", pos[0], pos[1]);
696branch 0 taken 7 (fallthrough)
697branch 1 taken 21511
698 21511: 304: m->deps[m->n_deps].from = a; m->deps[m->n_deps].to = b; m->n_deps++;
699 13245: 305: } else if (!strcmp(keyword, "buffer")) {
700branch 0 taken 5747 (fallthrough)
701branch 1 taken 7498
702 5747: 306: if (m->n_buf >= DS_MAX_BUF) PERR("too many buffers");
703branch 0 taken 7 (fallthrough)
704branch 1 taken 5740
705 5740: 307: ds_buffer *b = &m->buf[m->n_buf];
706call 0 returned 5740
707 5740: 308: memset(b, 0, sizeof *b); b->first = b->last = -1;
708 -: 309: const char *v;
709 5740: 310: if (!(v = get(kvs, n, "id"))) PERR("buffer needs id=");
710call 0 returned 5740
711branch 1 taken 7 (fallthrough)
712branch 2 taken 5733
713 5733: 311: sset(b->id, sizeof b->id, v);
714call 0 returned 5733
715 5733: 312: if (!parse_real(get(kvs, n, "bytes"), &b->bytes) || !isfinite(b->bytes))
716call 0 returned 5733
717call 1 returned 5733
718branch 2 taken 5642 (fallthrough)
719branch 3 taken 91
720branch 4 taken 35 (fallthrough)
721branch 5 taken 5607
722 126: 313: PERR("buffer bytes must be a finite number >= 0");
723 5607: 314: if (!(v = get(kvs, n, "cap")) || (b->cap = ds_find_res(m, v)) < 0 || m->res[b->cap].kind != DS_RES_CAPACITY) PERR("buffer needs cap=<capacity resource>");
724call 0 returned 5607
725branch 1 taken 5600 (fallthrough)
726branch 2 taken 7
727branch 3 taken 5586 (fallthrough)
728branch 4 taken 14
729branch 5 taken 0 (fallthrough)
730branch 6 taken 5586
731 5586: 315: if ((v = get(kvs, n, "first")) && (b->first = ds_find_op(m, v)) < 0) PERR("first=%s not an op", v);
732call 0 returned 5586
733branch 1 taken 70 (fallthrough)
734branch 2 taken 5516
735branch 3 taken 14 (fallthrough)
736branch 4 taken 56
737 5572: 316: if ((v = get(kvs, n, "last")) && (b->last = ds_find_op(m, v)) < 0) PERR("last=%s not an op", v);
738call 0 returned 5572
739branch 1 taken 56 (fallthrough)
740branch 2 taken 5516
741branch 3 taken 14 (fallthrough)
742branch 4 taken 42
743 5558: 317: m->n_buf++;
744 7498: 318: } else if (!strcmp(keyword, "sync")) {
745branch 0 taken 84 (fallthrough)
746branch 1 taken 7414
747 -: 319: /* a barrier op that depends on every listed op */
748 119*: 320: if (m->n_ops >= DS_MAX_OPS) PERR("too many ops");
749branch 0 taken 0 (fallthrough)
750branch 1 taken 84
751 -: 321: const char *v, *list;
752 84: 322: if (!(v = get(kvs, n, "id"))) PERR("sync needs id=");
753call 0 returned 84
754branch 1 taken 7 (fallthrough)
755branch 2 taken 77
756 77: 323: if (ds_find_op(m, v) >= 0) PERR("duplicate op %s", v);
757branch 0 taken 7 (fallthrough)
758branch 1 taken 70
759 70: 324: if (!(list = get(kvs, n, "ops"))) PERR("sync needs ops=a,b,...");
760call 0 returned 70
761branch 1 taken 7 (fallthrough)
762branch 2 taken 63
763 63: 325: ds_op *o = &m->ops[m->n_ops];
764call 0 returned 63
765 -: 326: memset(o, 0, sizeof *o);
766 63: 327: o->engine = o->bw = o->launcher = -1; o->kind = DS_OP_BARRIER; o->t_prov = DS_PROV_SPECIFIED;
767 63: 328: sset(o->id, sizeof o->id, v);
768call 0 returned 63
769 63: 329: int self = m->n_ops++;
770 63: 330: char tmp[DS_SRC]; sset(tmp, sizeof tmp, list);
771call 0 returned 63
772 63: 331: char *save = NULL;
773 147: 332: for (char *t = strtok_r(tmp, ",", &save); t; t = strtok_r(NULL, ",", &save)) {
774call 0 returned 63
775branch 1 taken 98
776branch 2 taken 49 (fallthrough)
777 98: 333: int a = ds_find_op(m, t);
778 98: 334: if (a < 0 || a == self) PERR("sync lists unknown op %s", t);
779branch 0 taken 14 (fallthrough)
780branch 1 taken 84
781 84*: 335: if (m->n_deps >= DS_MAX_DEPS) PERR("too many deps");
782branch 0 taken 0 (fallthrough)
783branch 1 taken 84
784 84: 336: m->deps[m->n_deps].from = a; m->deps[m->n_deps].to = self; m->n_deps++;
785call 0 returned 84
786 -: 337: }
787 7414: 338: } else if (!strcmp(keyword, "energy")) {
788branch 0 taken 1835 (fallthrough)
789branch 1 taken 5579
790 -: 339: const char *v;
791 1947: 340: if (m->has_energy) PERR("one energy record only");
792branch 0 taken 7 (fallthrough)
793branch 1 taken 1828
794 1828: 341: if (!(v = get(kvs, n, "instrument"))) PERR("energy needs instrument=");
795call 0 returned 1828
796branch 1 taken 14 (fallthrough)
797branch 2 taken 1814
798 1814: 342: sset(m->instrument, sizeof m->instrument, v);
799call 0 returned 1814
800 1814: 343: if ((v = get(kvs, n, "boundary"))) sset(m->boundary, sizeof m->boundary, v);
801call 0 returned 1814
802branch 1 taken 224 (fallthrough)
803branch 2 taken 1590
804call 3 returned 224
805 1814: 344: const char *j = get(kvs, n, "joules"), *pw = get(kvs, n, "power_w");
806call 0 returned 1814
807call 1 returned 1814
808 1814: 345: int prov = -1; char src[DS_SRC];
809 1814: 346: int rc = parse_prov_src(kvs, n, &prov, src, sizeof src, j || pw ? 1 : 0, err, errcap, lineno); if (rc) return rc;
810call 0 returned 1814
811branch 1 taken 49 (fallthrough)
812branch 2 taken 1765
813 1765: 347: m->energy_prov = prov;
814 1765: 348: if (j) {
815branch 0 taken 84 (fallthrough)
816branch 1 taken 1681
817 84: 349: if (!strcmp(m->instrument, "none") || !m->boundary[0]) PERR("joules= needs a named instrument and boundary=");
818branch 0 taken 84 (fallthrough)
819branch 1 taken 0
820branch 2 taken 14 (fallthrough)
821branch 3 taken 70
822 70*: 350: if (prov != DS_PROV_MEASURED) PERR("joules= must be prov=measured with src=");
823branch 0 taken 0 (fallthrough)
824branch 1 taken 70
825 70: 351: if (!parse_real(j, &m->joules)) PERR("bad joules");
826call 0 returned 70
827branch 1 taken 14 (fallthrough)
828branch 2 taken 56
829 -: 352: }
830 1737: 353: if (pw) {
831branch 0 taken 91 (fallthrough)
832branch 1 taken 1646
833 91*: 354: if (prov != DS_PROV_SYNTHETIC) PERR("power_w= is allowed only as prov=synthetic (a sensitivity figure); measured power must be integrated into joules= by the instrument");
834branch 0 taken 0 (fallthrough)
835branch 1 taken 91
836 91: 355: if (!parse_real(pw, &m->power_w)) PERR("bad power_w");
837call 0 returned 91
838branch 1 taken 14 (fallthrough)
839branch 2 taken 77
840 -: 356: }
841 1723: 357: m->has_energy = 1;
842 5579: 358: } else if (!strcmp(keyword, "removed")) {
843branch 0 taken 5544 (fallthrough)
844branch 1 taken 35
845 5544: 359: if (m->n_removed >= DS_MAX_REMOVED) PERR("too many removed records");
846branch 0 taken 7 (fallthrough)
847branch 1 taken 5537
848 5537: 360: ds_removed *r = &m->removed[m->n_removed];
849call 0 returned 5537
850 -: 361: memset(r, 0, sizeof *r);
851 -: 362: const char *v;
852 5537: 363: if (!(v = get(kvs, n, "op"))) PERR("removed needs op=");
853call 0 returned 5537
854branch 1 taken 7 (fallthrough)
855branch 2 taken 5530
856 5530: 364: sset(r->op, sizeof r->op, v);
857call 0 returned 5530
858 5530: 365: if (ds_find_op(m, v) >= 0) PERR("removed op %s is still present in this DAG", v);
859branch 0 taken 7 (fallthrough)
860branch 1 taken 5523
861 5523: 366: if (!(v = get(kvs, n, "reason"))) PERR("removed needs reason=");
862call 0 returned 5523
863branch 1 taken 7 (fallthrough)
864branch 2 taken 5516
865 5516: 367: if (!strcmp(v, "eliminated")) r->reason = DS_RM_ELIMINATED;
866branch 0 taken 7 (fallthrough)
867branch 1 taken 5509
868 5509: 368: else if (!strcmp(v, "reused")) r->reason = DS_RM_REUSED;
869branch 0 taken 84 (fallthrough)
870branch 1 taken 5425
871 5425: 369: else if (!strcmp(v, "unchanged_dep")) r->reason = DS_RM_UNCHANGED_DEP;
872branch 0 taken 7 (fallthrough)
873branch 1 taken 5418
874 5418: 370: else if (!strcmp(v, "deferred")) r->reason = DS_RM_DEFERRED;
875branch 0 taken 7 (fallthrough)
876branch 1 taken 5411
877 5411: 371: else if (!strcmp(v, "moved")) r->reason = DS_RM_MOVED;
878branch 0 taken 7 (fallthrough)
879branch 1 taken 5404
880 5404: 372: else if (!strcmp(v, "shared")) r->reason = DS_RM_SHARED;
881branch 0 taken 7 (fallthrough)
882branch 1 taken 5397
883 5397: 373: else if (!strcmp(v, "lookup")) r->reason = DS_RM_LOOKUP;
884branch 0 taken 5376 (fallthrough)
885branch 1 taken 21
886 21: 374: else PERR("removed reason=%s unknown", v);
887 5495: 375: if ((v = get(kvs, n, "ref"))) sset(r->ref, sizeof r->ref, v);
888call 0 returned 5495
889branch 1 taken 119 (fallthrough)
890branch 2 taken 5376
891call 3 returned 119
892 5495: 376: if ((v = get(kvs, n, "proof"))) sset(r->proof, sizeof r->proof, v);
893call 0 returned 5495
894branch 1 taken 119 (fallthrough)
895branch 2 taken 5376
896call 3 returned 119
897 5495: 377: m->n_removed++;
898 35: 378: } else PERR("unknown record '%s'", keyword);
899 -: 379: char bad[32];
900 64389: 380: if (unused_key(kvs, n, bad, sizeof bad)) PERR("unknown field %s= on '%s'", bad, keyword);
901call 0 returned 64389
902branch 1 taken 238 (fallthrough)
903branch 2 taken 64151
904 -: 381: }
905 -: 382: lineno = 0;
906 1688: 383: if (!seen_oev) PERR("missing 'oev version=1'");
907branch 0 taken 147 (fallthrough)
908branch 1 taken 1541
909 1541: 384: if (!seen_machine) PERR("missing machine record");
910branch 0 taken 7 (fallthrough)
911branch 1 taken 1534
912 1534*: 385: if (!seen_build) PERR("missing build record");
913branch 0 taken 0 (fallthrough)
914branch 1 taken 1534
915 1534*: 386: if (!m->has_energy) PERR("missing energy record (use instrument=none for UNMEASURED)");
916branch 0 taken 0 (fallthrough)
917branch 1 taken 1534
918 -: 387: return DS_OK;
919 -: 388:}
920 -: 389:#else
921 -: 390:/* Copy only the already-bounded source spans selected by the Omega parser. */
922 -: 391:static void dp_copy(char *dst, const unsigned char *text, const uint64_t *w, size_t i) {
923 -: 392: memcpy(dst, text + w[i], (size_t)w[i + 1]);
924 -: 393: dst[w[i + 1]] = 0;
925 -: 394:}
926 -: 395:static double dp_double(const uint64_t *w, size_t i) {
927 -: 396: return ds_unbits(w[i]);
928 -: 397:}
929 -: 398:int ds_parse_text(const char *text, ds_model *m, char *err, size_t errcap) {
930 -: 399: memset(m, 0, sizeof *m);
931 -: 400: if (errcap) err[0] = 0;
932 -: 401: size_t n = strnlen(text, 1048576);
933 -: 402: if (n == 1048576) {
934 -: 403: if (errcap) snprintf(err, errcap, "file size out of range");
935 -: 404: return DS_PARSE_ERROR;
936 -: 405: }
937 -: 406: unsigned char *t = malloc(1048576);
938 -: 407: uint64_t *w = malloc(16384 * sizeof *w);
939 -: 408: if (!t || !w) {
940 -: 409: free(t); free(w);
941 -: 410: if (errcap) snprintf(err, errcap, "out of memory");
942 -: 411: return DS_PARSE_ERROR;
943 -: 412: }
944 -: 413: memcpy(t, text, n + 1);
945 -: 414: unsigned char error[256] = {0};
946 -: 415: uint64_t rc = 0;
947 -: 416: uint32_t trap = omega_dag_parse(&rc, t, 1048576, n, w, 16384, error, 256);
948 -: 417: if (trap || rc) {
949 -: 418: if (errcap) snprintf(err, errcap, "%s", trap ? "Omega parser trap" : (char *)error);
950 -: 419: free(t); free(w); return DS_PARSE_ERROR;
951 -: 420: }
952 -: 421: m->version = (int32_t)w[0]; m->cores = (int32_t)w[1];
953 -: 422: m->mem_bytes = dp_double(w, 2); m->has_calibration = (int32_t)w[3];
954 -: 423: m->cal_taken_day = (int32_t)w[4]; m->cal_valid_days = (int32_t)w[5];
955 -: 424: m->cal_load1 = dp_double(w, 6); m->has_energy = (int32_t)w[7];
956 -: 425: m->joules = dp_double(w, 8); m->power_w = dp_double(w, 9);
957 -: 426: m->energy_prov = (int32_t)w[10];
958 -: 427: m->n_res = (int32_t)w[11]; m->n_ops = (int32_t)w[12];
959 -: 428: m->n_buf = (int32_t)w[13]; m->n_deps = (int32_t)w[14]; m->n_removed = (int32_t)w[15];
960 -: 429: dp_copy(m->machine_id, t, w, 17); dp_copy(m->soc, t, w, 19);
961 -: 430: dp_copy(m->repo, t, w, 21); dp_copy(m->build_sha, t, w, 23);
962 -: 431: dp_copy(m->physics, t, w, 25); dp_copy(m->cal_id, t, w, 27);
963 -: 432: dp_copy(m->cal_src, t, w, 29); dp_copy(m->cal_model, t, w, 31);
964 -: 433: dp_copy(m->instrument, t, w, 33); dp_copy(m->boundary, t, w, 35);
965 -: 434: for (int i = 0; i < m->n_res; i++) {
966 -: 435: ds_resource *r = &m->res[i]; const uint64_t *p = w + 64 + i * 12;
967 -: 436: dp_copy(r->id, t, p, 0); r->kind = (int32_t)p[2]; r->slots = (int32_t)p[3];
968 -: 437: r->cap = dp_double(p, 4); r->lo = dp_double(p, 5); r->hi = dp_double(p, 6);
969 -: 438: r->prov = (int32_t)p[7]; dp_copy(r->src, t, p, 8);
970 -: 439: }
971 -: 440: for (int i = 0; i < m->n_ops; i++) {
972 -: 441: ds_op *o = &m->ops[i]; const uint64_t *p = w + 448 + i * 26;
973 -: 442: dp_copy(o->id, t, p, 0); o->kind = (int32_t)p[2]; o->engine = (int32_t)p[3];
974 -: 443: o->t_ns = dp_double(p, 4); o->lo = dp_double(p, 5); o->hi = dp_double(p, 6);
975 -: 444: o->t_prov = (int32_t)p[7]; o->has_t = (int32_t)p[8]; o->bytes = dp_double(p, 9);
976 -: 445: o->bw = (int32_t)p[10]; o->launch_ns = dp_double(p, 11); o->launcher = (int32_t)p[12];
977 -: 446: o->M = (uint32_t)p[13]; o->N = (uint32_t)p[14]; o->core = (uint32_t)p[15]; o->arm = (uint32_t)p[16];
978 -: 447: dp_copy(o->src, t, p, 17);
979 -: 448: }
980 -: 449: for (int i = 0; i < m->n_deps; i++) {
981 -: 450: m->deps[i].from = (int32_t)w[7104 + i * 2];
982 -: 451: m->deps[i].to = (int32_t)w[7105 + i * 2];
983 -: 452: }
984 -: 453: for (int i = 0; i < m->n_buf; i++) {
985 -: 454: ds_buffer *b = &m->buf[i]; const uint64_t *p = w + 9152 + i * 8;
986 -: 455: dp_copy(b->id, t, p, 0); b->bytes = dp_double(p, 2); b->cap = (int32_t)p[3];
987 -: 456: b->first = (int32_t)p[4]; b->last = (int32_t)p[5];
988 -: 457: }
989 -: 458: for (int i = 0; i < m->n_removed; i++) {
990 -: 459: ds_removed *r = &m->removed[i]; const uint64_t *p = w + 11200 + i * 8;
991 -: 460: dp_copy(r->op, t, p, 0); r->reason = (int32_t)p[2];
992 -: 461: dp_copy(r->ref, t, p, 3); dp_copy(r->proof, t, p, 5);
993 -: 462: }
994 -: 463: free(t); free(w);
995 -: 464: return DS_OK;
996 -: 465:}
997 -: 466:#endif
998 -: 467:
999function oracle_ds_parse_file called 0 returned 0% blocks executed 0%
1000 #####: 468:int ds_parse_file(const char *path, ds_model *m, char *err, size_t errcap) {
1001 #####: 469: FILE *fp = fopen(path, "r");
1002call 0 never executed
1003 #####: 470: if (!fp) { snprintf(err, errcap, "cannot open %s", path); return DS_PARSE_ERROR; }
1004branch 0 never executed (fallthrough)
1005branch 1 never executed
1006 #####: 471: fseek(fp, 0, SEEK_END); long n = ftell(fp); fseek(fp, 0, SEEK_SET);
1007call 0 never executed
1008call 1 never executed
1009call 2 never executed
1010 #####: 472: if (n < 0 || n > (1 << 20)) { fclose(fp); snprintf(err, errcap, "file size out of range"); return DS_PARSE_ERROR; }
1011branch 0 never executed (fallthrough)
1012branch 1 never executed
1013call 2 never executed
1014 #####: 473: char *buf = malloc((size_t)n + 1);
1015 #####: 474: if (!buf) { fclose(fp); snprintf(err, errcap, "out of memory"); return DS_PARSE_ERROR; }
1016branch 0 never executed (fallthrough)
1017branch 1 never executed
1018call 2 never executed
1019 #####: 475: size_t got = fread(buf, 1, (size_t)n, fp); buf[got] = 0; fclose(fp);
1020call 0 never executed
1021 #####: 476: int rc = ds_parse_text(buf, m, err, errcap);
1022call 0 never executed
1023 #####: 477: free(buf);
1024 #####: 478: return rc;
1025 -: 479:}
1026 -: 480:
1027 -: 481:/* ---------------------------------------------------------------- evaluate */
1028 -: 482:
1029 -: 483:/* resolved per-op numbers for one evaluation mode */
1030 -: 484:typedef struct { double t, launch, bytes, cap; int prov; } ds_num; /* cap in B/ns */
1031 -: 485:
1032 -: 486:static double res_cap(const ds_resource *r, int mode) {
1033 #####: 487: if (mode < 0) return r->lo;
1034 #####: 488: if (mode > 0) return r->hi;
1035branch 0 never executed (fallthrough)
1036branch 1 never executed
1037 #####: 489: return r->cap;
1038 -: 490:}
1039 -: 491:
1040function refuse called 0 returned 0% blocks executed 0%
1041 #####: 492:static int refuse(ds_result *r, int status, const char *fmt, const char *a, const char *b) {
1042branch 0 never executed (fallthrough)
1043branch 1 never executed
1044 -: 493: memset(r, 0, sizeof *r);
1045 #####: 494: r->status = status;
1046 #####: 495: snprintf(r->reason, sizeof r->reason, fmt, a ? a : "", b ? b : "");
1047branch 0 never executed (fallthrough)
1048branch 1 never executed
1049branch 2 never executed (fallthrough)
1050branch 3 never executed
1051 #####: 496: return status;
1052 -: 497:}
1053 -: 498:
1054function refuse_msg called 0 returned 0% blocks executed 0%
1055 #####: 499:static int refuse_msg(ds_result *r, int status, const char *msg) {
1056branch 0 never executed (fallthrough)
1057branch 1 never executed
1058 -: 500: memset(r, 0, sizeof *r);
1059 #####: 501: r->status = status;
1060 #####: 502: snprintf(r->reason, sizeof r->reason, "%s", msg ? msg : "");
1061branch 0 never executed (fallthrough)
1062branch 1 never executed
1063 #####: 503: return status;
1064 -: 504:}
1065 -: 505:
1066 -: 506:/* An unsupported operation and a refused prediction are the same as an
1067 -: 507: * unknown cell: no certificate. known alone is not enough. */
1068 -: 508:static int predict_unusable(int st, const RxCmPrediction *p) {
1069 #####: 509: return st == RX_CM_ERR_UNSUPPORTED || p->refused || !p->known || p->n == 0; /* PREDICT_REFUSAL_CHECK */
1070branch 0 never executed (fallthrough)
1071branch 1 never executed
1072branch 2 never executed (fallthrough)
1073branch 3 never executed
1074branch 4 never executed
1075branch 5 never executed (fallthrough)
1076branch 6 never executed
1077branch 7 never executed (fallthrough)
1078 -: 510:}
1079 -: 511:
1080function resolve called 0 returned 0% blocks executed 0%
1081 #####: 512:static int resolve(const ds_model *m, const ds_opts *o, ds_num *num, ds_result *r) {
1082 -: 513: int any_cal = 0;
1083 #####: 514: for (int i = 0; i < m->n_res; i++) {
1084branch 0 never executed
1085branch 1 never executed
1086 #####: 515: if (m->res[i].prov == DS_PROV_UNKNOWN) return refuse(r, DS_REFUSED_UNKNOWN, "resource %s has prov=unknown; unknown stays unknown%s", m->res[i].id, "");
1087branch 0 never executed (fallthrough)
1088branch 1 never executed
1089call 2 never executed
1090 #####: 516: if (m->res[i].prov == DS_PROV_MEASURED || m->res[i].prov == DS_PROV_FITTED) any_cal = 1;
1091branch 0 never executed (fallthrough)
1092branch 1 never executed
1093 -: 517: }
1094 #####: 518: for (int i = 0; i < m->n_ops; i++) {
1095branch 0 never executed
1096branch 1 never executed (fallthrough)
1097 -: 519: const ds_op *op = &m->ops[i];
1098 #####: 520: ds_num *x = &num[i];
1099branch 0 never executed (fallthrough)
1100branch 1 never executed
1101 -: 521: memset(x, 0, sizeof *x);
1102 #####: 522: x->prov = op->t_prov;
1103 #####: 523: x->launch = op->launch_ns;
1104 #####: 524: x->bytes = op->bytes;
1105 #####: 525: x->cap = op->bw >= 0 ? res_cap(&m->res[op->bw], o->mode) * 1e-9 : 0; /* B/s -> B/ns */
1106branch 0 never executed (fallthrough)
1107branch 1 never executed
1108branch 2 never executed (fallthrough)
1109branch 3 never executed
1110 #####: 526: if (op->kind == DS_OP_MATVEC && !op->has_t) {
1111branch 0 never executed (fallthrough)
1112branch 1 never executed
1113branch 2 never executed (fallthrough)
1114branch 3 never executed
1115 #####: 527: const RxCostModel *cm = (const RxCostModel *)o->costmodel;
1116 #####: 528: if (!cm) return refuse(r, DS_REFUSED_UNKNOWN, "op %s is a matvec with no rx_costmodel blob supplied (calibration model=)%s", op->id, "");
1117branch 0 never executed (fallthrough)
1118branch 1 never executed
1119call 2 never executed
1120 -: 529: RxCmFeatures f; memset(&f, 0, sizeof f);
1121 #####: 530: f.op = RX_CM_OP_MATVEC; f.M = op->M; f.N = op->N;
1122 #####: 531: f.state_bytes = ((uint64_t)op->M * op->N + op->M + op->N) * 8u;
1123 #####: 532: f.cache_bytes = 1u << 20; f.core = op->core; f.eligible = 1u << op->arm; f.current_arm = op->arm;
1124 -: 533: RxCmPrediction p;
1125 #####: 534: int st = rx_cm_predict(cm, &f, op->arm, &p);
1126call 0 never executed
1127 #####: 535: if (predict_unusable(st, &p)) return refuse(r, DS_REFUSED_UNKNOWN, "op %s: rx_costmodel has no known cell for this (op, core, pressure) and arm; measure it first%s", op->id, "");
1128call 0 never executed
1129 #####: 536: double q = o->interval_q > 0 && o->interval_q < 1 ? o->interval_q : 0.9;
1130branch 0 never executed (fallthrough)
1131branch 1 never executed
1132branch 2 never executed (fallthrough)
1133branch 3 never executed
1134 #####: 537: double k = rx_cm_t_quantile(q, p.dof);
1135call 0 never executed
1136 #####: 538: double l2 = p.mean_log2_ps + (o->mode < 0 ? k * p.sd_log2 : o->mode > 0 ? -k * p.sd_log2 : 0);
1137branch 0 never executed (fallthrough)
1138branch 1 never executed
1139branch 2 never executed (fallthrough)
1140branch 3 never executed
1141 #####: 539: x->t = pow(2.0, l2) / 1000.0; /* ps -> ns */
1142 #####: 540: x->prov = DS_PROV_FITTED;
1143 -: 541: any_cal = 1;
1144 -: 542: } else {
1145 #####: 543: if (op->t_prov == DS_PROV_UNKNOWN) return refuse(r, DS_REFUSED_UNKNOWN, "op %s has prov=unknown (%s); unknown stays unknown", op->id, op->src[0] ? op->src : "no source");
1146branch 0 never executed (fallthrough)
1147branch 1 never executed
1148branch 2 never executed (fallthrough)
1149branch 3 never executed
1150call 4 never executed
1151 #####: 544: x->t = o->mode < 0 ? op->hi : o->mode > 0 ? op->lo : op->t_ns;
1152branch 0 never executed (fallthrough)
1153branch 1 never executed
1154branch 2 never executed (fallthrough)
1155branch 3 never executed
1156 #####: 545: if (op->t_prov == DS_PROV_MEASURED || op->t_prov == DS_PROV_FITTED) any_cal = 1;
1157branch 0 never executed
1158branch 1 never executed (fallthrough)
1159 -: 546: }
1160 #####: 547: if (op->engine < 0 && op->kind != DS_OP_BARRIER) return refuse(r, DS_REFUSED_UNSUPPORTED, "op %s has no engine%s", op->id, "");
1161branch 0 never executed (fallthrough)
1162branch 1 never executed
1163branch 2 never executed (fallthrough)
1164branch 3 never executed
1165call 4 never executed
1166 #####: 548: if (op->launcher >= 0 && op->engine < 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "op %s: launch without an engine%s", op->id, "");
1167branch 0 never executed (fallthrough)
1168branch 1 never executed
1169branch 2 never executed (fallthrough)
1170branch 3 never executed
1171call 4 never executed
1172 -: 549: }
1173 #####: 550: if (any_cal) {
1174branch 0 never executed (fallthrough)
1175branch 1 never executed
1176 #####: 551: if (!m->has_calibration) return refuse(r, DS_REFUSED_NO_CALIBRATION, "measured or fitted values need a calibration record naming when and under what load they were taken%s%s", "", "");
1177branch 0 never executed (fallthrough)
1178branch 1 never executed
1179call 2 never executed
1180 #####: 552: int asof = o->asof_day;
1181 #####: 553: if (asof <= 0) asof = (int)(time(NULL) / 86400);
1182branch 0 never executed (fallthrough)
1183branch 1 never executed
1184call 2 never executed
1185 #####: 554: if (asof > m->cal_taken_day + m->cal_valid_days) {
1186branch 0 never executed (fallthrough)
1187branch 1 never executed
1188 #####: 555: char d[64]; snprintf(d, sizeof d, "asof is %d day(s) past the validity envelope", asof - m->cal_taken_day - m->cal_valid_days);
1189call 0 never executed
1190 #####: 556: return refuse(r, DS_REFUSED_STALE, "calibration %s is stale: %s", m->cal_id, d);
1191call 0 never executed
1192 -: 557: }
1193 -: 558: }
1194 -: 559: return DS_OK;
1195 -: 560:}
1196 -: 561:
1197 -: 562:static void pk_d(uint64_t *dst, double x) {
1198 -: 563: uint64_t b;
1199 -: 564: memcpy(&b, &x, 8);
1200 #####: 565: *dst = b;
1201 -: 566:}
1202 -: 567:
1203 -: 568:/* Pack post-resolve numbers for omega_dag_eval. Refusal strings stay in C. */
1204function oracle_ds_resolved_pack called 0 returned 0% blocks executed 0%
1205 #####: 569:int ds_resolved_pack(const ds_model *m, const ds_opts *o, uint64_t *model, ds_result *r) {
1206 #####: 570: if (m->n_ops == 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "empty DAG%s%s", "", "");
1207branch 0 never executed (fallthrough)
1208branch 1 never executed
1209call 2 never executed
1210 -: 571: ds_num num[DS_MAX_OPS];
1211 #####: 572: int rc = resolve(m, o, num, r);
1212call 0 never executed
1213 #####: 573: if (rc) return rc;
1214branch 0 never executed (fallthrough)
1215branch 1 never executed
1216 -: 574: memset(model, 0, 8192 * sizeof *model);
1217 #####: 575: model[0] = (uint64_t)m->n_ops;
1218 #####: 576: model[1] = (uint64_t)m->n_res;
1219 #####: 577: model[2] = (uint64_t)m->n_deps;
1220 #####: 578: model[3] = (uint64_t)m->n_buf;
1221 #####: 579: model[4] = m->has_energy ? 1u : 0u;
1222branch 0 never executed (fallthrough)
1223branch 1 never executed
1224 #####: 580: pk_d(&model[5], m->joules);
1225branch 0 never executed (fallthrough)
1226branch 1 never executed
1227 #####: 581: pk_d(&model[6], m->power_w);
1228 #####: 582: model[7] = (uint64_t)m->energy_prov;
1229 #####: 583: model[8] = strcmp(m->instrument, "none") == 0 ? 1u : 0u;
1230branch 0 never executed (fallthrough)
1231branch 1 never executed
1232 #####: 584: model[9] = 1u;
1233 #####: 585: for (int i = 0; i < m->n_ops; i++) {
1234branch 0 never executed
1235branch 1 never executed
1236 #####: 586: uint64_t *p = &model[32 + i * 10];
1237 #####: 587: pk_d(&p[0], num[i].t);
1238 #####: 588: pk_d(&p[1], num[i].bytes);
1239 #####: 589: pk_d(&p[2], num[i].launch);
1240 #####: 590: pk_d(&p[3], num[i].cap);
1241 #####: 591: p[4] = (uint64_t)(int64_t)m->ops[i].engine;
1242 #####: 592: p[5] = (uint64_t)(int64_t)m->ops[i].bw;
1243 #####: 593: p[6] = (uint64_t)(int64_t)m->ops[i].launcher;
1244 #####: 594: p[7] = (uint64_t)m->ops[i].kind;
1245 #####: 595: p[8] = (uint64_t)num[i].prov;
1246 -: 596: }
1247 #####: 597: for (int i = 0; i < m->n_res; i++) {
1248branch 0 never executed
1249branch 1 never executed
1250 #####: 598: uint64_t *p = &model[2592 + i * 4];
1251 #####: 599: p[0] = (uint64_t)m->res[i].kind;
1252 #####: 600: p[1] = (uint64_t)m->res[i].slots;
1253 #####: 601: pk_d(&p[2], m->res[i].cap);
1254 #####: 602: p[3] = (uint64_t)m->res[i].prov;
1255 -: 603: }
1256 #####: 604: for (int i = 0; i < m->n_deps; i++) {
1257branch 0 never executed
1258branch 1 never executed
1259 #####: 605: uint64_t *p = &model[2720 + i * 2];
1260 #####: 606: p[0] = (uint64_t)m->deps[i].from;
1261 #####: 607: p[1] = (uint64_t)m->deps[i].to;
1262 -: 608: }
1263 #####: 609: for (int i = 0; i < m->n_buf; i++) {
1264branch 0 never executed
1265branch 1 never executed (fallthrough)
1266 #####: 610: uint64_t *p = &model[4768 + i * 4];
1267 #####: 611: pk_d(&p[0], m->buf[i].bytes);
1268 #####: 612: p[1] = (uint64_t)m->buf[i].cap;
1269 #####: 613: p[2] = (uint64_t)(int64_t)m->buf[i].first;
1270 #####: 614: p[3] = (uint64_t)(int64_t)m->buf[i].last;
1271 -: 615: }
1272 -: 616: return DS_OK;
1273 -: 617:}
1274 -: 618:
1275 -: 619:/* Kahn topological order; returns 0 on a cycle */
1276function topo called 0 returned 0% blocks executed 0%
1277 #####: 620:static int topo(const ds_model *m, int *order) {
1278 #####: 621: int indeg[DS_MAX_OPS] = {0};
1279 #####: 622: for (int i = 0; i < m->n_deps; i++) indeg[m->deps[i].to]++;
1280branch 0 never executed
1281branch 1 never executed (fallthrough)
1282 -: 623: int n = 0, head = 0;
1283 #####: 624: for (int i = 0; i < m->n_ops; i++) if (indeg[i] == 0) order[n++] = i;
1284branch 0 never executed (fallthrough)
1285branch 1 never executed
1286branch 2 never executed
1287branch 3 never executed (fallthrough)
1288 #####: 625: while (head < n) {
1289branch 0 never executed
1290branch 1 never executed (fallthrough)
1291 #####: 626: int u = order[head++];
1292 #####: 627: for (int i = 0; i < m->n_deps; i++) if (m->deps[i].from == u && --indeg[m->deps[i].to] == 0) order[n++] = m->deps[i].to;
1293branch 0 never executed (fallthrough)
1294branch 1 never executed
1295branch 2 never executed
1296branch 3 never executed (fallthrough)
1297branch 4 never executed
1298branch 5 never executed (fallthrough)
1299 -: 628: }
1300 #####: 629: return n == m->n_ops;
1301 -: 630:}
1302 -: 631:
1303 -: 632:enum { ST_WAIT = 0, ST_READY, ST_LAUNCH, ST_RUN, ST_DONE };
1304 -: 633:enum { BLK_NONE = 0, BLK_SLOT, BLK_LAUNCHER };
1305 -: 634:
1306 -: 635:/* Half-open [start, end). Missing first -> 0; missing last -> makespan. */
1307 -: 636:static void buffer_window(const ds_model *m, const ds_result *r, int b, double *s, double *e) {
1308 #####: 637: *s = m->buf[b].first >= 0 ? r->start_ns[m->buf[b].first] : 0.0;
1309branch 0 never executed (fallthrough)
1310branch 1 never executed
1311branch 2 never executed (fallthrough)
1312branch 3 never executed
1313branch 4 never executed (fallthrough)
1314branch 5 never executed
1315 #####: 638: *e = m->buf[b].last >= 0 ? r->end_ns[m->buf[b].last] : r->makespan_ns;
1316branch 0 never executed (fallthrough)
1317branch 1 never executed
1318branch 2 never executed (fallthrough)
1319branch 3 never executed
1320branch 4 never executed (fallthrough)
1321branch 5 never executed
1322 -: 639:}
1323 -: 640:
1324 -: 641:static const char *endpoint_name(const ds_model *m, int op) {
1325 #####: 642: return op >= 0 ? m->ops[op].id : "omitted";
1326branch 0 never executed (fallthrough)
1327branch 1 never executed
1328 -: 643:}
1329 -: 644:
1330 -: 645:/* Resolved end earlier than start is not an interval. Refuse before the ledger. */
1331function reject_inverted_lifetimes called 0 returned 0% blocks executed 0%
1332 #####: 646:static int reject_inverted_lifetimes(const ds_model *m, ds_result *r) {
1333 #####: 647: for (int b = 0; b < m->n_buf; b++) {
1334branch 0 never executed
1335branch 1 never executed (fallthrough)
1336 -: 648: double s, e;
1337 -: 649: buffer_window(m, r, b, &s, &e);
1338 #####: 650: if (e + 1e-9 < s) {
1339branch 0 never executed (fallthrough)
1340branch 1 never executed
1341 -: 651: char msg[256];
1342 -: 652: snprintf(msg, sizeof msg,
1343 -: 653: "inverted lifetime for buffer %s: first=%s start_ns=%.9g last=%s end_ns=%.9g",
1344 #####: 654: m->buf[b].id, endpoint_name(m, m->buf[b].first), s,
1345branch 0 never executed (fallthrough)
1346branch 1 never executed
1347 -: 655: endpoint_name(m, m->buf[b].last), e);
1348 #####: 656: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
1349call 0 never executed
1350 -: 657: }
1351 -: 658: }
1352 -: 659: return DS_OK;
1353 -: 660:}
1354 -: 661:
1355function oracle_ds_eval_c called 0 returned 0% blocks executed 0%
1356 #####: 662:int ds_eval_c(const ds_model *m, const ds_opts *o, ds_result *r) {
1357branch 0 never executed (fallthrough)
1358branch 1 never executed
1359 -: 663: memset(r, 0, sizeof *r);
1360 #####: 664: if (m->n_ops == 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "empty DAG%s%s", "", "");
1361branch 0 never executed (fallthrough)
1362branch 1 never executed
1363call 2 never executed
1364 -: 665: ds_num num[DS_MAX_OPS];
1365 #####: 666: int rc = resolve(m, o, num, r);
1366call 0 never executed
1367 #####: 667: if (rc) return rc;
1368branch 0 never executed (fallthrough)
1369branch 1 never executed
1370 -: 668: int order[DS_MAX_OPS];
1371 #####: 669: if (!topo(m, order)) return refuse(r, DS_REFUSED_CYCLE, "dependency cycle%s%s", "", "");
1372call 0 never executed
1373branch 1 never executed (fallthrough)
1374branch 2 never executed
1375call 3 never executed
1376 -: 670: /* a buffer that never fits */
1377 #####: 671: for (int i = 0; i < m->n_buf; i++)
1378branch 0 never executed
1379branch 1 never executed (fallthrough)
1380 #####: 672: if (m->buf[i].bytes > m->res[m->buf[i].cap].cap)
1381branch 0 never executed (fallthrough)
1382branch 1 never executed
1383 #####: 673: return refuse(r, DS_REFUSED_CAPACITY, "buffer %s alone exceeds capacity %s", m->buf[i].id, m->res[m->buf[i].cap].id);
1384call 0 never executed
1385 -: 674:
1386 -: 675: /* provenance mask */
1387 #####: 676: for (int i = 0; i < m->n_ops; i++) r->prov_mask |= 1u << num[i].prov;
1388branch 0 never executed
1389branch 1 never executed (fallthrough)
1390 #####: 677: for (int i = 0; i < m->n_res; i++) {
1391branch 0 never executed
1392branch 1 never executed (fallthrough)
1393 -: 678: int used = 0;
1394 #####: 679: for (int j = 0; j < m->n_ops; j++) if (m->ops[j].engine == i || m->ops[j].bw == i || m->ops[j].launcher == i) used = 1;
1395branch 0 never executed (fallthrough)
1396branch 1 never executed
1397branch 2 never executed (fallthrough)
1398branch 3 never executed
1399branch 4 never executed (fallthrough)
1400branch 5 never executed
1401branch 6 never executed
1402branch 7 never executed
1403 #####: 680: for (int j = 0; j < m->n_buf; j++) if (m->buf[j].cap == i) used = 1;
1404branch 0 never executed (fallthrough)
1405branch 1 never executed
1406branch 2 never executed
1407branch 3 never executed (fallthrough)
1408 #####: 681: if (used) r->prov_mask |= 1u << m->res[i].prov;
1409branch 0 never executed (fallthrough)
1410branch 1 never executed
1411 -: 682: }
1412 -: 683:
1413 -: 684: /* ---- fluid simulation ---- */
1414 #####: 685: int state[DS_MAX_OPS] = {0}, blocked[DS_MAX_OPS] = {0}, npred[DS_MAX_OPS] = {0}, done_pred[DS_MAX_OPS] = {0};
1415 -: 686: double rem_t[DS_MAX_OPS], rem_b[DS_MAX_OPS], rem_l[DS_MAX_OPS], run_start[DS_MAX_OPS], bytes_end[DS_MAX_OPS];
1416 #####: 687: int free_slots[DS_MAX_RES], launcher_busy[DS_MAX_RES] = {0};
1417 #####: 688: for (int i = 0; i < m->n_res; i++) free_slots[i] = m->res[i].slots;
1418branch 0 never executed
1419branch 1 never executed
1420 #####: 689: for (int i = 0; i < m->n_deps; i++) npred[m->deps[i].to]++;
1421branch 0 never executed
1422branch 1 never executed (fallthrough)
1423 #####: 690: for (int i = 0; i < m->n_ops; i++) {
1424branch 0 never executed
1425branch 1 never executed
1426 #####: 691: rem_t[i] = num[i].t; rem_b[i] = num[i].bytes; rem_l[i] = num[i].launch;
1427 #####: 692: run_start[i] = bytes_end[i] = -1;
1428 #####: 693: r->n_ops++;
1429 #####: 694: r->total_bytes += num[i].bytes; r->total_busy_ns += num[i].t; r->total_launch_ns += num[i].launch;
1430 -: 695: }
1431 -: 696: double t = 0;
1432 -: 697: int remaining = m->n_ops, guard = 0;
1433 #####: 698: while (remaining > 0) {
1434branch 0 never executed
1435branch 1 never executed
1436 #####: 699: if (++guard > 8 * DS_MAX_OPS + 16) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", "");
1437branch 0 never executed (fallthrough)
1438branch 1 never executed
1439call 2 never executed
1440 -: 700: /* deps satisfied -> ready */
1441 #####: 701: for (int i = 0; i < m->n_ops; i++) if (state[i] == ST_WAIT && done_pred[i] == npred[i]) { state[i] = ST_READY; r->ready_ns[i] = t; }
1442branch 0 never executed (fallthrough)
1443branch 1 never executed
1444branch 2 never executed (fallthrough)
1445branch 3 never executed
1446branch 4 never executed
1447branch 5 never executed
1448 -: 702: /* dispatch in file order */
1449 #####: 703: for (int i = 0; i < m->n_ops; i++) {
1450branch 0 never executed
1451branch 1 never executed (fallthrough)
1452 #####: 704: if (state[i] != ST_READY) continue;
1453branch 0 never executed (fallthrough)
1454branch 1 never executed
1455 -: 705: const ds_op *op = &m->ops[i];
1456 #####: 706: if (op->engine >= 0 && free_slots[op->engine] <= 0) { blocked[i] = BLK_SLOT; continue; }
1457branch 0 never executed (fallthrough)
1458branch 1 never executed
1459branch 2 never executed (fallthrough)
1460branch 3 never executed
1461 #####: 707: if (op->launcher >= 0 && rem_l[i] > 0 && launcher_busy[op->launcher]) { blocked[i] = BLK_LAUNCHER; continue; }
1462branch 0 never executed (fallthrough)
1463branch 1 never executed
1464branch 2 never executed (fallthrough)
1465branch 3 never executed
1466branch 4 never executed (fallthrough)
1467branch 5 never executed
1468 #####: 708: if (op->engine >= 0) free_slots[op->engine]--;
1469branch 0 never executed (fallthrough)
1470branch 1 never executed
1471 #####: 709: r->start_ns[i] = t;
1472 #####: 710: if (op->launcher >= 0 && rem_l[i] > 0) { launcher_busy[op->launcher] = 1; state[i] = ST_LAUNCH; }
1473branch 0 never executed (fallthrough)
1474branch 1 never executed
1475branch 2 never executed (fallthrough)
1476branch 3 never executed
1477 #####: 711: else { state[i] = ST_RUN; run_start[i] = t; }
1478 -: 712: }
1479 -: 713: /* next event */
1480 #####: 714: int active[DS_MAX_RES] = {0};
1481 #####: 715: for (int i = 0; i < m->n_ops; i++) if (state[i] == ST_RUN && rem_b[i] > 0) active[m->ops[i].bw]++;
1482branch 0 never executed (fallthrough)
1483branch 1 never executed
1484branch 2 never executed (fallthrough)
1485branch 3 never executed
1486branch 4 never executed
1487branch 5 never executed
1488 -: 716: double dt = -1; int any = 0;
1489 #####: 717: for (int i = 0; i < m->n_ops; i++) {
1490branch 0 never executed
1491branch 1 never executed (fallthrough)
1492 #####: 718: if (state[i] == ST_LAUNCH) { any = 1; if (dt < 0 || rem_l[i] < dt) dt = rem_l[i]; }
1493branch 0 never executed (fallthrough)
1494branch 1 never executed
1495branch 2 never executed (fallthrough)
1496branch 3 never executed
1497branch 4 never executed (fallthrough)
1498branch 5 never executed
1499 #####: 719: else if (state[i] == ST_RUN) {
1500branch 0 never executed (fallthrough)
1501branch 1 never executed
1502 -: 720: any = 1;
1503 -: 721: /* next event for this op: the earlier of its two progress bars */
1504 -: 722: double d = -1;
1505 #####: 723: if (rem_t[i] > 0) d = rem_t[i];
1506branch 0 never executed (fallthrough)
1507branch 1 never executed
1508 #####: 724: if (rem_b[i] > 0) {
1509branch 0 never executed (fallthrough)
1510branch 1 never executed
1511 #####: 725: double share = num[i].cap / active[m->ops[i].bw];
1512 #####: 726: double db = rem_b[i] / share;
1513 #####: 727: if (d < 0 || db < d) d = db;
1514branch 0 never executed (fallthrough)
1515branch 1 never executed
1516branch 2 never executed
1517branch 3 never executed (fallthrough)
1518 -: 728: }
1519 #####: 729: if (d < 0) d = 0;
1520branch 0 never executed (fallthrough)
1521branch 1 never executed
1522 #####: 730: if (dt < 0 || d < dt) dt = d;
1523branch 0 never executed (fallthrough)
1524branch 1 never executed
1525branch 2 never executed (fallthrough)
1526branch 3 never executed
1527 -: 731: }
1528 -: 732: }
1529 #####: 733: if (!any) return refuse(r, DS_REFUSED_UNSUPPORTED, "no op can make progress (slots=0 or all blocked)%s%s", "", "");
1530branch 0 never executed (fallthrough)
1531branch 1 never executed
1532call 2 never executed
1533 #####: 734: if (dt < 0) dt = 0;
1534branch 0 never executed (fallthrough)
1535branch 1 never executed
1536 #####: 735: t += dt;
1537 -: 736: const double eps = 1e-9;
1538 #####: 737: for (int i = 0; i < m->n_ops; i++) {
1539branch 0 never executed
1540branch 1 never executed (fallthrough)
1541 #####: 738: if (state[i] == ST_LAUNCH) {
1542branch 0 never executed (fallthrough)
1543branch 1 never executed
1544 #####: 739: rem_l[i] -= dt;
1545 #####: 740: if (rem_l[i] <= eps) { rem_l[i] = 0; launcher_busy[m->ops[i].launcher] = 0; state[i] = ST_RUN; run_start[i] = t; }
1546branch 0 never executed (fallthrough)
1547branch 1 never executed
1548 #####: 741: } else if (state[i] == ST_RUN) {
1549branch 0 never executed
1550branch 1 never executed (fallthrough)
1551 #####: 742: if (rem_t[i] > 0) { rem_t[i] -= dt; if (rem_t[i] <= eps) rem_t[i] = 0; }
1552branch 0 never executed (fallthrough)
1553branch 1 never executed
1554branch 2 never executed (fallthrough)
1555branch 3 never executed
1556 #####: 743: if (rem_b[i] > 0) {
1557branch 0 never executed (fallthrough)
1558branch 1 never executed
1559 #####: 744: double share = num[i].cap / active[m->ops[i].bw];
1560 #####: 745: rem_b[i] -= share * dt;
1561 #####: 746: if (rem_b[i] <= eps * (num[i].bytes > 1 ? num[i].bytes : 1)) { rem_b[i] = 0; bytes_end[i] = t; }
1562branch 0 never executed (fallthrough)
1563branch 1 never executed
1564branch 2 never executed (fallthrough)
1565branch 3 never executed
1566 -: 747: }
1567 #####: 748: if (rem_t[i] <= 0 && rem_b[i] <= 0) {
1568branch 0 never executed
1569branch 1 never executed (fallthrough)
1570branch 2 never executed
1571branch 3 never executed (fallthrough)
1572 #####: 749: state[i] = ST_DONE; r->end_ns[i] = t; remaining--;
1573 #####: 750: if (m->ops[i].engine >= 0) free_slots[m->ops[i].engine]++;
1574branch 0 never executed (fallthrough)
1575branch 1 never executed
1576 #####: 751: for (int d = 0; d < m->n_deps; d++) if (m->deps[d].from == i) done_pred[m->deps[d].to]++;
1577branch 0 never executed (fallthrough)
1578branch 1 never executed
1579branch 2 never executed
1580branch 3 never executed (fallthrough)
1581 #####: 752: if (num[i].bytes > 0) {
1582branch 0 never executed (fallthrough)
1583branch 1 never executed
1584 #####: 753: double ideal = num[i].bytes / num[i].cap;
1585 #####: 754: double actual = (bytes_end[i] >= 0 ? bytes_end[i] : t) - run_start[i];
1586branch 0 never executed (fallthrough)
1587branch 1 never executed
1588 #####: 755: r->op_contention_ns[i] = actual - ideal > 0 ? actual - ideal : 0;
1589branch 0 never executed (fallthrough)
1590branch 1 never executed
1591 -: 756: }
1592 -: 757: }
1593 -: 758: }
1594 -: 759: }
1595 #####: 760: if (t > r->makespan_ns) r->makespan_ns = t;
1596branch 0 never executed (fallthrough)
1597branch 1 never executed
1598 -: 761: }
1599 -: 762:
1600 -: 763: /* ---- bounds ---- */
1601 -: 764: double cp[DS_MAX_OPS];
1602 #####: 765: for (int k = 0; k < m->n_ops; k++) {
1603branch 0 never executed
1604branch 1 never executed (fallthrough)
1605 #####: 766: int i = order[k];
1606 #####: 767: double floor_ = num[i].t;
1607 #####: 768: if (num[i].bytes > 0 && num[i].bytes / num[i].cap > floor_) floor_ = num[i].bytes / num[i].cap;
1608branch 0 never executed (fallthrough)
1609branch 1 never executed
1610branch 2 never executed
1611branch 3 never executed (fallthrough)
1612 #####: 769: floor_ += num[i].launch;
1613 #####: 770: r->op_floor_ns[i] = floor_;
1614 -: 771: double best = 0;
1615 #####: 772: for (int d = 0; d < m->n_deps; d++) if (m->deps[d].to == i && cp[m->deps[d].from] > best) best = cp[m->deps[d].from];
1616branch 0 never executed (fallthrough)
1617branch 1 never executed
1618branch 2 never executed
1619branch 3 never executed (fallthrough)
1620branch 4 never executed
1621branch 5 never executed (fallthrough)
1622 #####: 773: cp[i] = best + floor_;
1623 #####: 774: if (cp[i] > r->bound_critical_path_ns) r->bound_critical_path_ns = cp[i];
1624branch 0 never executed (fallthrough)
1625branch 1 never executed
1626 -: 775: }
1627 #####: 776: r->bound_ns = r->bound_critical_path_ns;
1628 #####: 777: for (int i = 0; i < m->n_res; i++) {
1629branch 0 never executed
1630branch 1 never executed (fallthrough)
1631 -: 778: double w = 0;
1632 #####: 779: for (int j = 0; j < m->n_ops; j++) {
1633branch 0 never executed
1634branch 1 never executed (fallthrough)
1635 #####: 780: if (m->res[i].kind == DS_RES_BANDWIDTH && m->ops[j].bw == i) w += num[j].bytes / num[j].cap;
1636branch 0 never executed (fallthrough)
1637branch 1 never executed
1638branch 2 never executed (fallthrough)
1639branch 3 never executed
1640 #####: 781: if (m->res[i].kind == DS_RES_COMPUTE && m->ops[j].engine == i) w += (num[j].t + num[j].launch) / m->res[i].slots;
1641branch 0 never executed (fallthrough)
1642branch 1 never executed
1643branch 2 never executed (fallthrough)
1644branch 3 never executed
1645 #####: 782: if (m->res[i].kind == DS_RES_LAUNCH && m->ops[j].launcher == i) w += num[j].launch;
1646branch 0 never executed (fallthrough)
1647branch 1 never executed
1648branch 2 never executed (fallthrough)
1649branch 3 never executed
1650 -: 783: }
1651 #####: 784: r->bound_resource_ns[i] = w;
1652 #####: 785: if (w > r->bound_ns) r->bound_ns = w;
1653branch 0 never executed (fallthrough)
1654branch 1 never executed
1655 -: 786: }
1656 -: 787:
1657 -: 788: /* Inverted lifetimes never enter the ledger (and never rank). */
1658 #####: 789: if ((rc = reject_inverted_lifetimes(m, r)) != DS_OK) return rc; /* LIFETIME_ORDER_CHECK */
1659call 0 never executed
1660branch 1 never executed
1661branch 2 never executed
1662 -: 790:
1663 -: 791: /* ---- capacity ledger: frees before allocations at the same instant ----
1664 -: 792: * Positive intervals only. A zero-duration [s, e) is empty and emits no
1665 -: 793: * event, so a same-time free cannot pull the ledger negative or offset
1666 -: 794: * another buffer. Frees of earlier intervals still precede allocs, which
1667 -: 795: * is the completion/allocation tie. */
1668 #####: 796: for (int c = 0; c < m->n_res; c++) {
1669branch 0 never executed
1670branch 1 never executed
1671 #####: 797: if (m->res[c].kind != DS_RES_CAPACITY) continue;
1672branch 0 never executed (fallthrough)
1673branch 1 never executed
1674 -: 798: double live = 0, peak = 0, peak_at = 0;
1675 -: 799: /* event list */
1676 -: 800: double et[2 * DS_MAX_BUF]; double ev[2 * DS_MAX_BUF]; int en = 0;
1677 #####: 801: for (int b = 0; b < m->n_buf; b++) {
1678branch 0 never executed
1679branch 1 never executed (fallthrough)
1680 #####: 802: if (m->buf[b].cap != c) continue;
1681branch 0 never executed (fallthrough)
1682branch 1 never executed
1683 -: 803: double s, e;
1684 -: 804: buffer_window(m, r, b, &s, &e);
1685 #####: 805: if (!(s + 1e-9 < e)) continue;
1686branch 0 never executed (fallthrough)
1687branch 1 never executed
1688 #####: 806: et[en] = s; ev[en] = m->buf[b].bytes; en++;
1689 #####: 807: et[en] = e; ev[en] = -m->buf[b].bytes; en++;
1690 -: 808: }
1691 -: 809: /* insertion sort by time, frees (negative) first on ties; stable */
1692 #####: 810: for (int i = 1; i < en; i++) {
1693branch 0 never executed
1694branch 1 never executed
1695 #####: 811: double kt = et[i], kv_ = ev[i]; int j = i - 1;
1696 #####: 812: while (j >= 0 && (et[j] > kt || (et[j] == kt && ev[j] > 0 && kv_ < 0))) { et[j + 1] = et[j]; ev[j + 1] = ev[j]; j--; }
1697branch 0 never executed (fallthrough)
1698branch 1 never executed
1699branch 2 never executed
1700branch 3 never executed (fallthrough)
1701branch 4 never executed (fallthrough)
1702branch 5 never executed
1703branch 6 never executed (fallthrough)
1704branch 7 never executed
1705branch 8 never executed
1706branch 9 never executed (fallthrough)
1707 #####: 813: et[j + 1] = kt; ev[j + 1] = kv_;
1708 -: 814: }
1709 #####: 815: for (int i = 0; i < en; i++) {
1710branch 0 never executed
1711branch 1 never executed (fallthrough)
1712 #####: 816: live += ev[i];
1713 -: 817: /* Reachable by rounding: 1e20 + 1 sums to 1e20, so the later
1714 -: 818: * frees overshoot (dagsim_unit rounding_drives_live_negative). */
1715 #####: 819: if (live < -1e-6) {
1716branch 0 never executed (fallthrough)
1717branch 1 never executed
1718 -: 820: char msg[256];
1719 #####: 821: snprintf(msg, sizeof msg,
1720 -: 822: "capacity %s live bytes went negative (%.9g at t=%.9g); refusing the certificate",
1721 #####: 823: m->res[c].id, live, et[i]);
1722call 0 never executed
1723 #####: 824: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
1724call 0 never executed
1725 -: 825: }
1726 #####: 826: if (live > peak) { peak = live; peak_at = et[i]; }
1727branch 0 never executed (fallthrough)
1728branch 1 never executed
1729 -: 827: }
1730 #####: 828: r->peak_live_bytes[c] = peak; r->peak_live_at_ns[c] = peak_at;
1731 #####: 829: if (peak > m->res[c].cap + 1e-9) {
1732branch 0 never executed (fallthrough)
1733branch 1 never executed
1734 #####: 830: char names[160] = ""; size_t L = 0;
1735 #####: 831: for (int b = 0; b < m->n_buf && L < sizeof names - 8; b++) {
1736branch 0 never executed (fallthrough)
1737branch 1 never executed
1738branch 2 never executed
1739branch 3 never executed (fallthrough)
1740 #####: 832: if (m->buf[b].cap != c) continue;
1741branch 0 never executed (fallthrough)
1742branch 1 never executed
1743 -: 833: double s, e;
1744 -: 834: buffer_window(m, r, b, &s, &e);
1745 #####: 835: if (s <= peak_at && e > peak_at) { snprintf(names + L, sizeof names - L, "%s%s", L ? "," : "", m->buf[b].id); L = strlen(names); }
1746branch 0 never executed (fallthrough)
1747branch 1 never executed
1748branch 2 never executed (fallthrough)
1749branch 3 never executed
1750branch 4 never executed (fallthrough)
1751branch 5 never executed
1752 -: 836: }
1753 -: 837: char what[200]; snprintf(what, sizeof what, "%.0f B live at t=%.0f ns (%s) exceeds", peak, peak_at, names);
1754 #####: 838: int st = refuse(r, DS_REFUSED_CAPACITY, "%s %s", what, m->res[c].id);
1755call 0 never executed
1756 -: 839: return st;
1757 -: 840: }
1758 -: 841: }
1759 -: 842:
1760 -: 843: /* ---- attribution along the schedule's critical chain ---- */
1761 -: 844: int cur = 0;
1762 #####: 845: for (int i = 1; i < m->n_ops; i++) if (r->end_ns[i] > r->end_ns[cur]) cur = i;
1763branch 0 never executed (fallthrough)
1764branch 1 never executed
1765branch 2 never executed
1766branch 3 never executed
1767 -: 846: double accounted = 0;
1768 -: 847: int chain[DS_MAX_OPS]; int nc = 0;
1769 #####: 848: while (cur >= 0 && nc < DS_MAX_OPS) {
1770branch 0 never executed
1771branch 1 never executed (fallthrough)
1772 #####: 849: chain[nc++] = cur;
1773 -: 850: const ds_op *op = &m->ops[cur];
1774 #####: 851: double runtime = r->end_ns[cur] - (run_start[cur] >= 0 ? run_start[cur] : r->start_ns[cur]);
1775branch 0 never executed (fallthrough)
1776branch 1 never executed
1777 #####: 852: r->attr_ns[DS_ATTR_LAUNCH] += num[cur].launch;
1778 #####: 853: accounted += num[cur].launch;
1779 #####: 854: if (op->kind == DS_OP_BARRIER) r->attr_ns[DS_ATTR_SYNC] += runtime;
1780branch 0 never executed (fallthrough)
1781branch 1 never executed
1782 #####: 855: else if (num[cur].bytes > 0) {
1783branch 0 never executed (fallthrough)
1784branch 1 never executed
1785 #####: 856: double ideal = num[cur].bytes / num[cur].cap;
1786 #####: 857: double actual = ideal + r->op_contention_ns[cur];
1787 #####: 858: if (num[cur].t >= actual) r->attr_ns[DS_ATTR_COMPUTE] += runtime;
1788branch 0 never executed (fallthrough)
1789branch 1 never executed
1790 #####: 859: else { r->attr_ns[DS_ATTR_BANDWIDTH] += ideal; r->attr_ns[DS_ATTR_CONTENTION] += r->op_contention_ns[cur]; if (runtime > actual) r->attr_ns[DS_ATTR_RESIDUAL] += runtime - actual; }
1791branch 0 never executed (fallthrough)
1792branch 1 never executed
1793 #####: 860: } else r->attr_ns[DS_ATTR_COMPUTE] += runtime;
1794 #####: 861: accounted += runtime;
1795 -: 862: /* predecessor: the dep that finished last */
1796 -: 863: int pred = -1;
1797 #####: 864: for (int d = 0; d < m->n_deps; d++) if (m->deps[d].to == cur && (pred < 0 || r->end_ns[m->deps[d].from] > r->end_ns[pred])) pred = m->deps[d].from;
1798branch 0 never executed (fallthrough)
1799branch 1 never executed
1800branch 2 never executed (fallthrough)
1801branch 3 never executed
1802branch 4 never executed (fallthrough)
1803branch 5 never executed
1804branch 6 never executed
1805branch 7 never executed (fallthrough)
1806 #####: 865: double gap = r->start_ns[cur] - (pred >= 0 ? r->end_ns[pred] : 0);
1807branch 0 never executed (fallthrough)
1808branch 1 never executed
1809 #####: 866: if (gap > 0) {
1810branch 0 never executed (fallthrough)
1811branch 1 never executed
1812 #####: 867: if (blocked[cur] == BLK_SLOT) r->attr_ns[DS_ATTR_SERIALIZATION] += gap;
1813branch 0 never executed (fallthrough)
1814branch 1 never executed
1815 #####: 868: else if (blocked[cur] == BLK_LAUNCHER) r->attr_ns[DS_ATTR_LAUNCH] += gap;
1816branch 0 never executed (fallthrough)
1817branch 1 never executed
1818 #####: 869: else r->attr_ns[DS_ATTR_RESIDUAL] += gap;
1819 #####: 870: accounted += gap;
1820 -: 871: }
1821 -: 872: cur = pred;
1822 -: 873: }
1823 #####: 874: for (int i = 0; i < nc; i++) r->critical_path[i] = chain[nc - 1 - i];
1824branch 0 never executed
1825branch 1 never executed (fallthrough)
1826 #####: 875: r->n_critical = nc;
1827 #####: 876: double leftover = r->makespan_ns - accounted;
1828 #####: 877: if (fabs(leftover) > 1e-6) r->attr_ns[DS_ATTR_RESIDUAL] += leftover;
1829branch 0 never executed (fallthrough)
1830branch 1 never executed
1831 -: 878:
1832 -: 879: /* ---- energy ---- */
1833 #####: 880: if (m->has_energy && m->joules > 0 && strcmp(m->instrument, "none")) { r->energy_measured = 1; r->energy_j = m->joules; }
1834branch 0 never executed (fallthrough)
1835branch 1 never executed
1836branch 2 never executed (fallthrough)
1837branch 3 never executed
1838branch 4 never executed (fallthrough)
1839branch 5 never executed
1840 #####: 881: else if (m->has_energy && m->power_w > 0 && m->energy_prov == DS_PROV_SYNTHETIC) { r->energy_synthetic = 1; r->energy_j = m->power_w * r->makespan_ns * 1e-9; r->prov_mask |= 1u << DS_PROV_SYNTHETIC; }
1841branch 0 never executed (fallthrough)
1842branch 1 never executed
1843branch 2 never executed (fallthrough)
1844branch 3 never executed
1845branch 4 never executed (fallthrough)
1846branch 5 never executed
1847 #####: 882: r->synthetic = (r->prov_mask & (1u << DS_PROV_SYNTHETIC)) ? 1 : 0;
1848 #####: 883: r->status = DS_OK;
1849 #####: 884: return DS_OK;
1850 -: 885:}
1851 -: 886:
1852 -: 887:#ifndef CUDAPP_MIGRATION_PENDING_C_TOOLS
1853 -: 888:extern uint32_t omega_dag_eval(uint64_t *result, const void *p0, uint64_t p0_n, void *p1, uint64_t p1_n) __attribute__((weak));
1854 -: 889:
1855 -: 890:static double om_f(const uint64_t *s, int i) {
1856 -: 891: double x;
1857 #####: 892: memcpy(&x, &s[i], 8);
1858 -: 893: return x;
1859 -: 894:}
1860 -: 895:
1861function om_names called 0 returned 0% blocks executed 0%
1862 #####: 896:static void om_names(const ds_model *m, const uint64_t *s, char *names, size_t cap) {
1863 #####: 897: names[0] = 0;
1864 -: 898: size_t L = 0;
1865 #####: 899: for (int b = 0; b < m->n_buf && L < cap - 8; b++) {
1866branch 0 never executed (fallthrough)
1867branch 1 never executed
1868branch 2 never executed
1869branch 3 never executed (fallthrough)
1870 #####: 900: if (!(s[6336 + b / 64] & (1ull << (b % 64)))) continue;
1871branch 0 never executed (fallthrough)
1872branch 1 never executed
1873 #####: 901: snprintf(names + L, cap - L, "%s%s", L ? "," : "", m->buf[b].id);
1874branch 0 never executed (fallthrough)
1875branch 1 never executed
1876 #####: 902: L = strlen(names);
1877 -: 903: }
1878 #####: 904:}
1879 -: 905:
1880function om_refuse called 0 returned 0% blocks executed 0%
1881 #####: 906:static int om_refuse(const ds_model *m, const uint64_t *s, ds_result *r) {
1882 #####: 907: int why = (int)s[5], a = (int)s[6], b = (int)s[7];
1883branch 0 never executed (fallthrough)
1884branch 1 never executed
1885 -: 908: double fa = om_f(s, 8), fb = om_f(s, 9);
1886 -: 909: char msg[256];
1887 #####: 910: if (why == 2) return refuse(r, DS_REFUSED_CYCLE, "dependency cycle%s%s", "", "");
1888branch 0 never executed (fallthrough)
1889branch 1 never executed
1890call 2 never executed
1891 #####: 911: if (why == 3 && a >= 0 && a < m->n_buf && b >= 0 && b < m->n_res)
1892branch 0 never executed (fallthrough)
1893branch 1 never executed
1894branch 2 never executed (fallthrough)
1895branch 3 never executed
1896branch 4 never executed (fallthrough)
1897branch 5 never executed
1898branch 6 never executed (fallthrough)
1899branch 7 never executed
1900 #####: 912: return refuse(r, DS_REFUSED_CAPACITY, "buffer %s alone exceeds capacity %s", m->buf[a].id, m->res[b].id);
1901call 0 never executed
1902 #####: 913: if (why == 4) return refuse(r, DS_REFUSED_UNSUPPORTED, "no op can make progress (slots=0 or all blocked)%s%s", "", "");
1903branch 0 never executed (fallthrough)
1904branch 1 never executed
1905call 2 never executed
1906 #####: 914: if (why == 5) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", "");
1907branch 0 never executed (fallthrough)
1908branch 1 never executed
1909call 2 never executed
1910 #####: 915: if (why == 6 && a >= 0 && a < m->n_buf) {
1911branch 0 never executed (fallthrough)
1912branch 1 never executed
1913branch 2 never executed (fallthrough)
1914branch 3 never executed
1915 -: 916: snprintf(msg, sizeof msg, "inverted lifetime for buffer %s: first=%s start_ns=%.9g last=%s end_ns=%.9g",
1916 #####: 917: m->buf[a].id, endpoint_name(m, m->buf[a].first), fa, endpoint_name(m, m->buf[a].last), fb);
1917branch 0 never executed (fallthrough)
1918branch 1 never executed
1919branch 2 never executed (fallthrough)
1920branch 3 never executed
1921 #####: 918: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
1922call 0 never executed
1923 -: 919: }
1924 #####: 920: if (why == 7 && a >= 0 && a < m->n_res) {
1925branch 0 never executed (fallthrough)
1926branch 1 never executed
1927branch 2 never executed (fallthrough)
1928branch 3 never executed
1929 -: 921: snprintf(msg, sizeof msg, "capacity %s live bytes went negative (%.9g at t=%.9g); refusing the certificate",
1930 #####: 922: m->res[a].id, fa, fb);
1931call 0 never executed
1932 #####: 923: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
1933call 0 never executed
1934 -: 924: }
1935 #####: 925: if (why == 8 && a >= 0 && a < m->n_res) {
1936branch 0 never executed (fallthrough)
1937branch 1 never executed
1938branch 2 never executed (fallthrough)
1939branch 3 never executed
1940 -: 926: char names[160], what[200];
1941 #####: 927: om_names(m, s, names, sizeof names);
1942call 0 never executed
1943 -: 928: snprintf(what, sizeof what, "%.0f B live at t=%.0f ns (%s) exceeds", fa, fb, names);
1944 #####: 929: return refuse(r, DS_REFUSED_CAPACITY, "%s %s", what, m->res[a].id);
1945call 0 never executed
1946 -: 930: }
1947 #####: 931: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega refusal %s%s", "", "");
1948call 0 never executed
1949 -: 932:}
1950 -: 933:
1951function om_fill called 0 returned 0% blocks executed 0%
1952 #####: 934:static int om_fill(const ds_model *m, const uint64_t *s, ds_result *r) {
1953 #####: 935: if ((int)s[4] != DS_OK) return om_refuse(m, s, r);
1954branch 0 never executed (fallthrough)
1955branch 1 never executed
1956call 2 never executed
1957 -: 936: memset(r, 0, sizeof *r);
1958 -: 937: r->status = DS_OK;
1959 #####: 938: r->makespan_ns = om_f(s, 3);
1960 #####: 939: r->total_bytes = om_f(s, 15);
1961 #####: 940: r->total_busy_ns = om_f(s, 16);
1962 #####: 941: r->total_launch_ns = om_f(s, 17);
1963 #####: 942: r->bound_ns = om_f(s, 19);
1964 #####: 943: r->bound_critical_path_ns = om_f(s, 20);
1965 #####: 944: r->n_critical = (int)s[21];
1966 #####: 945: r->prov_mask = (uint32_t)s[11];
1967 #####: 946: r->energy_measured = (int)s[22];
1968 #####: 947: r->energy_synthetic = (int)s[23];
1969 #####: 948: r->energy_j = om_f(s, 24);
1970 #####: 949: r->synthetic = (int)s[26];
1971 #####: 950: r->n_ops = m->n_ops;
1972 #####: 951: for (int i = 0; i < m->n_ops; i++) {
1973branch 0 never executed
1974branch 1 never executed
1975 #####: 952: r->start_ns[i] = om_f(s, 4512 + i);
1976branch 0 never executed (fallthrough)
1977branch 1 never executed
1978 #####: 953: r->end_ns[i] = om_f(s, 4768 + i);
1979 #####: 954: r->ready_ns[i] = om_f(s, 5024 + i);
1980 #####: 955: r->op_contention_ns[i] = om_f(s, 5536 + i);
1981 #####: 956: r->op_floor_ns[i] = om_f(s, 5280 + i);
1982 #####: 957: if (i < r->n_critical) r->critical_path[i] = (int)s[6080 + i];
1983branch 0 never executed (fallthrough)
1984branch 1 never executed
1985 -: 958: }
1986 #####: 959: for (int i = 0; i < DS_ATTR_N; i++) r->attr_ns[i] = om_f(s, 5824 + i);
1987branch 0 never executed
1988branch 1 never executed
1989 #####: 960: for (int i = 0; i < m->n_res; i++) {
1990branch 0 never executed
1991branch 1 never executed (fallthrough)
1992 #####: 961: r->bound_resource_ns[i] = om_f(s, 5792 + i);
1993 #####: 962: r->peak_live_bytes[i] = om_f(s, 6344 + i);
1994 #####: 963: r->peak_live_at_ns[i] = om_f(s, 6376 + i);
1995 -: 964: }
1996 -: 965: return DS_OK;
1997 -: 966:}
1998 -: 967:
1999 -: 968:#endif
2000function oracle_ds_eval called 0 returned 0% blocks executed 0%
2001 #####: 969:int ds_eval(const ds_model *m, const ds_opts *o, ds_result *r) {
2002 -: 970:#if defined(CUDAPP_MIGRATION_PENDING_C_TOOLS)
2003 -: 971: return ds_eval_c(m, o, r);
2004 -: 972:#else
2005 #####: 973: if (!omega_dag_eval) return ds_eval_c(m, o, r);
2006branch 0 never executed (fallthrough)
2007branch 1 never executed
2008call 2 never executed
2009 -: 974: memset(r, 0, sizeof *r);
2010 #####: 975: uint64_t model[8192], scratch[8192], result = 0;
2011 #####: 976: int rc = ds_resolved_pack(m, o, model, r);
2012call 0 never executed
2013 #####: 977: if (rc) return rc;
2014branch 0 never executed (fallthrough)
2015branch 1 never executed
2016 -: 978: memset(scratch, 0, sizeof scratch);
2017 #####: 979: if (omega_dag_eval(&result, model, 8192, scratch, 8192))
2018call 0 never executed
2019branch 1 never executed (fallthrough)
2020branch 2 never executed
2021 #####: 980: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega trap%s%s", "", "");
2022call 0 never executed
2023 #####: 981: return om_fill(m, scratch, r);
2024call 0 never executed
2025 -: 982:#endif
2026 -: 983:}
2027 -: 984:
2028function oracle_ds_eval_interval called 0 returned 0% blocks executed 0%
2029 #####: 985:int ds_eval_interval(const ds_model *m, const ds_opts *o, ds_result *nominal, double *lo_ns, double *hi_ns) {
2030 #####: 986: ds_opts x = *o; x.mode = 0;
2031 #####: 987: int rc = ds_eval(m, &x, nominal);
2032call 0 never executed
2033 #####: 988: *lo_ns = *hi_ns = 0;
2034 #####: 989: if (rc) return rc;
2035branch 0 never executed (fallthrough)
2036branch 1 never executed
2037 -: 990: ds_result tmp;
2038 #####: 991: x.mode = +1; if (ds_eval(m, &x, &tmp) == DS_OK) *lo_ns = tmp.makespan_ns;
2039call 0 never executed
2040branch 1 never executed (fallthrough)
2041branch 2 never executed
2042 #####: 992: x.mode = -1; if (ds_eval(m, &x, &tmp) == DS_OK) *hi_ns = tmp.makespan_ns;
2043call 0 never executed
2044branch 1 never executed (fallthrough)
2045branch 2 never executed
2046 -: 993: return rc;
2047 -: 994:}
2048 -: 995:
2049function oracle_ds_counterfactual called 0 returned 0% blocks executed 0%
2050 #####: 996:double ds_counterfactual(const ds_model *m, const ds_opts *o, int res_index) {
2051 #####: 997: if (res_index < 0 || res_index >= m->n_res) return -DS_REFUSED_UNSUPPORTED;
2052branch 0 never executed (fallthrough)
2053branch 1 never executed
2054branch 2 never executed (fallthrough)
2055branch 3 never executed
2056 #####: 998: ds_model *c = malloc(sizeof *c);
2057 #####: 999: if (!c) return -DS_REFUSED_UNSUPPORTED;
2058branch 0 never executed
2059branch 1 never executed (fallthrough)
2060 #####: 1000: *c = *m;
2061 -: 1001: ds_resource *r = &c->res[res_index];
2062 #####: 1002: switch (r->kind) {
2063branch 0 never executed
2064branch 1 never executed
2065branch 2 never executed
2066branch 3 never executed
2067branch 4 never executed
2068 #####: 1003: case DS_RES_BANDWIDTH: r->cap *= 2; r->lo *= 2; r->hi *= 2; break;
2069 #####: 1004: case DS_RES_COMPUTE: r->slots *= 2; break;
2070 #####: 1005: case DS_RES_LAUNCH: for (int i = 0; i < c->n_ops; i++) if (c->ops[i].launcher == res_index) c->ops[i].launch_ns = 0; break;
2071branch 0 never executed (fallthrough)
2072branch 1 never executed
2073branch 2 never executed
2074branch 3 never executed
2075 #####: 1006: case DS_RES_CAPACITY: r->cap *= 2; break;
2076 -: 1007: }
2077 #####: 1008: ds_result res; ds_opts x = *o; x.mode = 0;
2078 #####: 1009: int rc = ds_eval(c, &x, &res);
2079call 0 never executed
2080 #####: 1010: free(c);
2081 #####: 1011: return rc == DS_OK ? res.makespan_ns : -(double)rc;
2082branch 0 never executed (fallthrough)
2083branch 1 never executed
2084 -: 1012:}
2085 -: 1013:
2086 -: 1014:/* ---------------------------------------------------------------- diff */
2087 -: 1015:
2088function in_changed called 0 returned 0% blocks executed 0%
2089 #####: 1016:static int in_changed(const char *list, const char *id) {
2090 #####: 1017: if (!list) return 0;
2091branch 0 never executed (fallthrough)
2092branch 1 never executed
2093 #####: 1018: const char *p = list; size_t L = strlen(id);
2094 #####: 1019: while (*p) {
2095branch 0 never executed
2096branch 1 never executed (fallthrough)
2097 #####: 1020: const char *q = strchr(p, ','); size_t n = q ? (size_t)(q - p) : strlen(p);
2098branch 0 never executed (fallthrough)
2099branch 1 never executed
2100 #####: 1021: if (n == L && !strncmp(p, id, L)) return 1;
2101branch 0 never executed (fallthrough)
2102branch 1 never executed
2103branch 2 never executed (fallthrough)
2104branch 3 never executed
2105 #####: 1022: if (!q) break;
2106branch 0 never executed (fallthrough)
2107branch 1 never executed
2108 #####: 1023: p = q + 1;
2109 -: 1024: }
2110 -: 1025: return 0;
2111 -: 1026:}
2112 -: 1027:
2113function oracle_ds_diff_models called 0 returned 0% blocks executed 0%
2114 #####: 1028:int ds_diff_models(const ds_model *b, const ds_model *t, const ds_opts *o, ds_diff *d) {
2115 -: 1029: memset(d, 0, sizeof *d);
2116 #####: 1030: for (int i = 0; i < t->n_ops; i++) if (ds_find_op(b, t->ops[i].id) < 0) d->n_added++;
2117branch 0 never executed (fallthrough)
2118branch 1 never executed
2119branch 2 never executed
2120branch 3 never executed
2121 #####: 1031: for (int i = 0; i < b->n_ops; i++) {
2122branch 0 never executed
2123branch 1 never executed
2124 #####: 1032: int j = ds_find_op(t, b->ops[i].id);
2125 #####: 1033: if (j >= 0) {
2126branch 0 never executed (fallthrough)
2127branch 1 never executed
2128 #####: 1034: d->n_kept++;
2129 #####: 1035: if (b->ops[i].t_ns != t->ops[j].t_ns || b->ops[i].bytes != t->ops[j].bytes)
2130branch 0 never executed (fallthrough)
2131branch 1 never executed
2132branch 2 never executed (fallthrough)
2133branch 3 never executed
2134 #####: 1036: snprintf(d->reason, sizeof d->reason, "op %s kept but its demand changed; trace conservation broken", b->ops[i].id);
2135 #####: 1037: continue;
2136 -: 1038: }
2137 #####: 1039: d->n_removed++;
2138 -: 1040: /* find its removed record(s) */
2139 -: 1041: int found = 0; const ds_removed *rec = NULL;
2140 #####: 1042: for (int k = 0; k < t->n_removed; k++) if (!strcmp(t->removed[k].op, b->ops[i].id)) { found++; rec = &t->removed[k]; }
2141branch 0 never executed (fallthrough)
2142branch 1 never executed
2143branch 2 never executed
2144branch 3 never executed (fallthrough)
2145 #####: 1043: if (found == 0) { d->required_removed = 1; snprintf(d->reason, sizeof d->reason, "op %s vanished without a removed record", b->ops[i].id); return DS_REFUSED_REMOVED_REQUIRED; }
2146branch 0 never executed (fallthrough)
2147branch 1 never executed
2148 #####: 1044: if (found > 1) { d->double_counted = 1; snprintf(d->reason, sizeof d->reason, "op %s removed %d times (double counted)", b->ops[i].id, found); return DS_REFUSED_REMOVED_REQUIRED; }
2149branch 0 never executed (fallthrough)
2150branch 1 never executed
2151 -: 1045: /* consumers of the removed op in the baseline that still exist */
2152 -: 1046: int has_consumer = 0;
2153 #####: 1047: for (int k = 0; k < b->n_deps; k++) if (b->deps[k].from == i && ds_find_op(t, b->ops[b->deps[k].to].id) >= 0) has_consumer = 1;
2154branch 0 never executed (fallthrough)
2155branch 1 never executed
2156branch 2 never executed
2157branch 3 never executed (fallthrough)
2158branch 4 never executed
2159branch 5 never executed (fallthrough)
2160 -: 1048: int ok = 1;
2161 #####: 1049: switch (rec->reason) {
2162branch 0 never executed
2163branch 1 never executed
2164branch 2 never executed
2165branch 3 never executed
2166branch 4 never executed
2167branch 5 never executed
2168 #####: 1050: case DS_RM_ELIMINATED: if (has_consumer && !rec->proof[0]) ok = 0; break;
2169branch 0 never executed (fallthrough)
2170branch 1 never executed
2171branch 2 never executed
2172branch 3 never executed
2173 #####: 1051: case DS_RM_REUSED: case DS_RM_LOOKUP: case DS_RM_MOVED: if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0; break;
2174branch 0 never executed (fallthrough)
2175branch 1 never executed
2176branch 2 never executed
2177branch 3 never executed
2178 #####: 1052: case DS_RM_UNCHANGED_DEP: if (!rec->ref[0] || ds_find_op(b, rec->ref) < 0 || in_changed(o ? o->changed : NULL, rec->ref)) ok = 0; break;
2179branch 0 never executed (fallthrough)
2180branch 1 never executed
2181branch 2 never executed (fallthrough)
2182branch 3 never executed
2183branch 4 never executed (fallthrough)
2184branch 5 never executed
2185call 6 never executed
2186branch 7 never executed
2187branch 8 never executed
2188 #####: 1053: case DS_RM_DEFERRED: if (has_consumer) ok = 0; break;
2189branch 0 never executed
2190branch 1 never executed
2191 #####: 1054: case DS_RM_SHARED:
2192 #####: 1055: if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0;
2193branch 0 never executed (fallthrough)
2194branch 1 never executed
2195branch 2 never executed (fallthrough)
2196branch 3 never executed
2197 #####: 1056: for (int k = 0; k < t->n_removed; k++) if (!strcmp(t->removed[k].op, rec->ref)) { d->double_counted = 1; ok = 0; }
2198branch 0 never executed (fallthrough)
2199branch 1 never executed
2200branch 2 never executed
2201branch 3 never executed (fallthrough)
2202 -: 1057: break;
2203 -: 1058: }
2204 #####: 1059: if (!ok) {
2205branch 0 never executed (fallthrough)
2206branch 1 never executed
2207 #####: 1060: d->required_removed = 1;
2208 #####: 1061: snprintf(d->reason, sizeof d->reason, "op %s: removal reason %d not supported by its evidence (ref=%s proof=%s changed=%s)",
2209 #####: 1062: b->ops[i].id, rec->reason, rec->ref, rec->proof, o && o->changed ? o->changed : "");
2210branch 0 never executed (fallthrough)
2211branch 1 never executed
2212branch 2 never executed (fallthrough)
2213branch 3 never executed
2214 #####: 1063: return DS_REFUSED_REMOVED_REQUIRED;
2215 -: 1064: }
2216 #####: 1065: double w = b->ops[i].t_ns + b->ops[i].launch_ns;
2217 #####: 1066: if (b->ops[i].bytes > 0 && b->ops[i].bw >= 0) { double tb = b->ops[i].bytes / (b->res[b->ops[i].bw].cap * 1e-9); if (tb > b->ops[i].t_ns) w = tb + b->ops[i].launch_ns; }
2218branch 0 never executed (fallthrough)
2219branch 1 never executed
2220branch 2 never executed (fallthrough)
2221branch 3 never executed
2222branch 4 never executed (fallthrough)
2223branch 5 never executed
2224 #####: 1067: d->removed_ns[rec->reason] += w;
2225 -: 1068: }
2226 -: 1069: /* removed records that name ops never in the baseline are fabricated savings */
2227 #####: 1070: for (int k = 0; k < t->n_removed; k++) if (ds_find_op(b, t->removed[k].op) < 0) {
2228branch 0 never executed (fallthrough)
2229branch 1 never executed
2230branch 2 never executed
2231branch 3 never executed (fallthrough)
2232 #####: 1071: d->double_counted = 1;
2233 #####: 1072: snprintf(d->reason, sizeof d->reason, "removed record for %s, which was never in the baseline", t->removed[k].op);
2234 #####: 1073: return DS_REFUSED_REMOVED_REQUIRED;
2235 -: 1074: }
2236 -: 1075: return DS_OK;
2237 -: 1076:}
2238 -: 0:Source:/usr/include/aarch64-linux-gnu/bits/string_fortified.h
2239 -: 0:Graph:build/dagsim-parse/oracle.gcno
2240 -: 0:Data:build/dagsim-parse/oracle.gcda
2241 -: 0:Runs:9
2242 -: 1:/* Copyright (C) 2004-2024 Free Software Foundation, Inc.
2243 -: 2: This file is part of the GNU C Library.
2244 -: 3:
2245 -: 4: The GNU C Library is free software; you can redistribute it and/or
2246 -: 5: modify it under the terms of the GNU Lesser General Public
2247 -: 6: License as published by the Free Software Foundation; either
2248 -: 7: version 2.1 of the License, or (at your option) any later version.
2249 -: 8:
2250 -: 9: The GNU C Library is distributed in the hope that it will be useful,
2251 -: 10: but WITHOUT ANY WARRANTY; without even the implied warranty of
2252 -: 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2253 -: 12: Lesser General Public License for more details.
2254 -: 13:
2255 -: 14: You should have received a copy of the GNU Lesser General Public
2256 -: 15: License along with the GNU C Library; if not, see
2257 -: 16: <https://www.gnu.org/licenses/>. */
2258 -: 17:
2259 -: 18:#ifndef _BITS_STRING_FORTIFIED_H
2260 -: 19:#define _BITS_STRING_FORTIFIED_H 1
2261 -: 20:
2262 -: 21:#ifndef _STRING_H
2263 -: 22:# error "Never use <bits/string_fortified.h> directly; include <string.h> instead."
2264 -: 23:#endif
2265 -: 24:
2266 -: 25:__fortify_function void *
2267 -: 26:__NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
2268 -: 27: size_t __len))
2269 -: 28:{
2270 87433*: 29: return __builtin___memcpy_chk (__dest, __src, __len,
2271branch 0 never executed (fallthrough)
2272branch 1 never executed
2273branch 2 never executed (fallthrough)
2274branch 3 never executed
2275branch 4 never executed (fallthrough)
2276branch 5 never executed
2277branch 6 taken 87405 (fallthrough)
2278branch 7 taken 28
2279 -: 30: __glibc_objsize0 (__dest));
2280 -: 31:}
2281 -: 32:
2282 -: 33:__fortify_function void *
2283 -: 34:__NTH (memmove (void *__dest, const void *__src, size_t __len))
2284 -: 35:{
2285 -: 36: return __builtin___memmove_chk (__dest, __src, __len,
2286 -: 37: __glibc_objsize0 (__dest));
2287 -: 38:}
2288 -: 39:
2289 -: 40:#ifdef __USE_GNU
2290 -: 41:__fortify_function void *
2291 -: 42:__NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
2292 -: 43: size_t __len))
2293 -: 44:{
2294 -: 45: return __builtin___mempcpy_chk (__dest, __src, __len,
2295 -: 46: __glibc_objsize0 (__dest));
2296 -: 47:}
2297 -: 48:#endif
2298 -: 49:
2299 -: 50:
2300 -: 51:/* The first two tests here help to catch a somewhat common problem
2301 -: 52: where the second and third parameter are transposed. This is
2302 -: 53: especially problematic if the intended fill value is zero. In this
2303 -: 54: case no work is done at all. We detect these problems by referring
2304 -: 55: non-existing functions. */
2305 -: 56:__fortify_function void *
2306 -: 57:__NTH (memset (void *__dest, int __ch, size_t __len))
2307 -: 58:{
2308 35567*: 59: return __builtin___memset_chk (__dest, __ch, __len,
2309call 0 never executed
2310call 1 never executed
2311branch 2 never executed (fallthrough)
2312branch 3 never executed
2313branch 4 never executed (fallthrough)
2314branch 5 never executed
2315branch 6 never executed (fallthrough)
2316branch 7 never executed
2317call 8 never executed
2318branch 9 never executed (fallthrough)
2319branch 10 never executed
2320branch 11 never executed (fallthrough)
2321branch 12 never executed
2322call 13 returned 10441
2323call 14 returned 10341
2324call 15 returned 5740
2325call 16 returned 63
2326call 17 returned 5537
2327 -: 60: __glibc_objsize0 (__dest));
2328 -: 61:}
2329 -: 62:
2330 -: 63:#ifdef __USE_MISC
2331 -: 64:# include <bits/strings_fortified.h>
2332 -: 65:
2333 -: 66:void __explicit_bzero_chk (void *__dest, size_t __len, size_t __destlen)
2334 -: 67: __THROW __nonnull ((1)) __fortified_attr_access (__write_only__, 1, 2);
2335 -: 68:
2336 -: 69:__fortify_function void
2337 -: 70:__NTH (explicit_bzero (void *__dest, size_t __len))
2338 -: 71:{
2339 -: 72: __explicit_bzero_chk (__dest, __len, __glibc_objsize0 (__dest));
2340 -: 73:}
2341 -: 74:#endif
2342 -: 75:
2343 -: 76:__fortify_function char *
2344 -: 77:__NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
2345 -: 78:{
2346 -: 79: return __builtin___strcpy_chk (__dest, __src, __glibc_objsize (__dest));
2347 -: 80:}
2348 -: 81:
2349 -: 82:#ifdef __USE_XOPEN2K8
2350 -: 83:__fortify_function char *
2351 -: 84:__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src))
2352 -: 85:{
2353 -: 86: return __builtin___stpcpy_chk (__dest, __src, __glibc_objsize (__dest));
2354 -: 87:}
2355 -: 88:#endif
2356 -: 89:
2357 -: 90:
2358 -: 91:__fortify_function char *
2359 -: 92:__NTH (strncpy (char *__restrict __dest, const char *__restrict __src,
2360 -: 93: size_t __len))
2361 -: 94:{
2362 -: 95: return __builtin___strncpy_chk (__dest, __src, __len,
2363 -: 96: __glibc_objsize (__dest));
2364 -: 97:}
2365 -: 98:
2366 -: 99:#ifdef __USE_XOPEN2K8
2367 -: 100:# if __GNUC_PREREQ (4, 7) || __glibc_clang_prereq (2, 6)
2368 -: 101:__fortify_function char *
2369 -: 102:__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
2370 -: 103:{
2371 -: 104: return __builtin___stpncpy_chk (__dest, __src, __n,
2372 -: 105: __glibc_objsize (__dest));
2373 -: 106:}
2374 -: 107:# else
2375 -: 108:extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
2376 -: 109: size_t __destlen) __THROW
2377 -: 110: __fortified_attr_access (__write_only__, 1, 3)
2378 -: 111: __attr_access ((__read_only__, 2));
2379 -: 112:extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src,
2380 -: 113: size_t __n), stpncpy);
2381 -: 114:
2382 -: 115:__fortify_function char *
2383 -: 116:__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
2384 -: 117:{
2385 -: 118: if (__bos (__dest) != (size_t) -1
2386 -: 119: && (!__builtin_constant_p (__n) || __n > __bos (__dest)))
2387 -: 120: return __stpncpy_chk (__dest, __src, __n, __bos (__dest));
2388 -: 121: return __stpncpy_alias (__dest, __src, __n);
2389 -: 122:}
2390 -: 123:# endif
2391 -: 124:#endif
2392 -: 125:
2393 -: 126:
2394 -: 127:__fortify_function char *
2395 -: 128:__NTH (strcat (char *__restrict __dest, const char *__restrict __src))
2396 -: 129:{
2397 -: 130: return __builtin___strcat_chk (__dest, __src, __glibc_objsize (__dest));
2398 -: 131:}
2399 -: 132:
2400 -: 133:
2401 -: 134:__fortify_function char *
2402 -: 135:__NTH (strncat (char *__restrict __dest, const char *__restrict __src,
2403 -: 136: size_t __len))
2404 -: 137:{
2405 -: 138: return __builtin___strncat_chk (__dest, __src, __len,
2406 -: 139: __glibc_objsize (__dest));
2407 -: 140:}
2408 -: 141:
2409 -: 142:#ifdef __USE_MISC
2410 -: 143:extern size_t __strlcpy_chk (char *__dest, const char *__src, size_t __n,
2411 -: 144: size_t __destlen) __THROW;
2412 -: 145:extern size_t __REDIRECT_NTH (__strlcpy_alias,
2413 -: 146: (char *__dest, const char *__src, size_t __n),
2414 -: 147: strlcpy);
2415 -: 148:
2416 -: 149:__fortify_function size_t
2417 -: 150:__NTH (strlcpy (char *__restrict __dest, const char *__restrict __src,
2418 -: 151: size_t __n))
2419 -: 152:{
2420 -: 153: if (__glibc_objsize (__dest) != (size_t) -1
2421 -: 154: && (!__builtin_constant_p (__n > __glibc_objsize (__dest))
2422 -: 155: || __n > __glibc_objsize (__dest)))
2423 -: 156: return __strlcpy_chk (__dest, __src, __n, __glibc_objsize (__dest));
2424 -: 157: return __strlcpy_alias (__dest, __src, __n);
2425 -: 158:}
2426 -: 159:
2427 -: 160:extern size_t __strlcat_chk (char *__dest, const char *__src, size_t __n,
2428 -: 161: size_t __destlen) __THROW;
2429 -: 162:extern size_t __REDIRECT_NTH (__strlcat_alias,
2430 -: 163: (char *__dest, const char *__src, size_t __n),
2431 -: 164: strlcat);
2432 -: 165:
2433 -: 166:__fortify_function size_t
2434 -: 167:__NTH (strlcat (char *__restrict __dest, const char *__restrict __src,
2435 -: 168: size_t __n))
2436 -: 169:{
2437 -: 170: if (__glibc_objsize (__dest) != (size_t) -1
2438 -: 171: && (!__builtin_constant_p (__n > __glibc_objsize (__dest))
2439 -: 172: || __n > __glibc_objsize (__dest)))
2440 -: 173: return __strlcat_chk (__dest, __src, __n, __glibc_objsize (__dest));
2441 -: 174: return __strlcat_alias (__dest, __src, __n);
2442 -: 175:}
2443 -: 176:#endif /* __USE_MISC */
2444 -: 177:
2445 -: 178:#endif /* bits/string_fortified.h */
2446 -: 0:Source:/usr/include/aarch64-linux-gnu/bits/stdio2.h
2447 -: 0:Graph:build/dagsim-parse/oracle.gcno
2448 -: 0:Data:build/dagsim-parse/oracle.gcda
2449 -: 0:Runs:9
2450 -: 1:/* Checking macros for stdio functions.
2451 -: 2: Copyright (C) 2004-2024 Free Software Foundation, Inc.
2452 -: 3: This file is part of the GNU C Library.
2453 -: 4:
2454 -: 5: The GNU C Library is free software; you can redistribute it and/or
2455 -: 6: modify it under the terms of the GNU Lesser General Public
2456 -: 7: License as published by the Free Software Foundation; either
2457 -: 8: version 2.1 of the License, or (at your option) any later version.
2458 -: 9:
2459 -: 10: The GNU C Library is distributed in the hope that it will be useful,
2460 -: 11: but WITHOUT ANY WARRANTY; without even the implied warranty of
2461 -: 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2462 -: 13: Lesser General Public License for more details.
2463 -: 14:
2464 -: 15: You should have received a copy of the GNU Lesser General Public
2465 -: 16: License along with the GNU C Library; if not, see
2466 -: 17: <https://www.gnu.org/licenses/>. */
2467 -: 18:
2468 -: 19:#ifndef _BITS_STDIO2_H
2469 -: 20:#define _BITS_STDIO2_H 1
2470 -: 21:
2471 -: 22:#ifndef _STDIO_H
2472 -: 23:# error "Never include <bits/stdio2.h> directly; use <stdio.h> instead."
2473 -: 24:#endif
2474 -: 25:
2475 -: 26:#ifdef __va_arg_pack
2476 -: 27:__fortify_function int
2477 -: 28:__NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...))
2478 -: 29:{
2479 -: 30: return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
2480 -: 31: __glibc_objsize (__s), __fmt,
2481 -: 32: __va_arg_pack ());
2482 -: 33:}
2483 -: 34:#elif !defined __cplusplus
2484 -: 35:# define sprintf(str, ...) \
2485 -: 36: __builtin___sprintf_chk (str, __USE_FORTIFY_LEVEL - 1, \
2486 -: 37: __glibc_objsize (str), __VA_ARGS__)
2487 -: 38:#endif
2488 -: 39:
2489 -: 40:__fortify_function int
2490 -: 41:__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
2491 -: 42: __gnuc_va_list __ap))
2492 -: 43:{
2493 -: 44: return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
2494 -: 45: __glibc_objsize (__s), __fmt, __ap);
2495 -: 46:}
2496 -: 47:
2497 -: 48:#if defined __USE_ISOC99 || defined __USE_UNIX98
2498 -: 49:# ifdef __va_arg_pack
2499 -: 50:__fortify_function int
2500 -: 51:__NTH (snprintf (char *__restrict __s, size_t __n,
2501 -: 52: const char *__restrict __fmt, ...))
2502 -: 53:{
2503 86236*: 54: return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
2504call 0 never executed
2505call 1 never executed
2506call 2 never executed
2507call 3 never executed
2508call 4 never executed
2509call 5 never executed
2510call 6 never executed
2511 -: 55: __glibc_objsize (__s), __fmt,
2512 -: 56: __va_arg_pack ());
2513 -: 57:}
2514 -: 58:# elif !defined __cplusplus
2515 -: 59:# define snprintf(str, len, ...) \
2516 -: 60: __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, \
2517 -: 61: __glibc_objsize (str), __VA_ARGS__)
2518 -: 62:# endif
2519 -: 63:
2520 -: 64:__fortify_function int
2521 -: 65:__NTH (vsnprintf (char *__restrict __s, size_t __n,
2522 -: 66: const char *__restrict __fmt, __gnuc_va_list __ap))
2523 -: 67:{
2524 -: 68: return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
2525 -: 69: __glibc_objsize (__s), __fmt, __ap);
2526 -: 70:}
2527 -: 71:
2528 -: 72:#endif
2529 -: 73:
2530 -: 74:#if __USE_FORTIFY_LEVEL > 1
2531 -: 75:# ifdef __va_arg_pack
2532 -: 76:__fortify_function __nonnull ((1)) int
2533 -: 77:fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
2534 -: 78:{
2535 -: 79: return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
2536 -: 80: __va_arg_pack ());
2537 -: 81:}
2538 -: 82:
2539 -: 83:__fortify_function int
2540 -: 84:printf (const char *__restrict __fmt, ...)
2541 -: 85:{
2542 -: 86: return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
2543 -: 87:}
2544 -: 88:# elif !defined __cplusplus
2545 -: 89:# define printf(...) \
2546 -: 90: __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2547 -: 91:# define fprintf(stream, ...) \
2548 -: 92: __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2549 -: 93:# endif
2550 -: 94:
2551 -: 95:__fortify_function int
2552 -: 96:vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
2553 -: 97:{
2554 -: 98:#ifdef __USE_EXTERN_INLINES
2555 -: 99: return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2556 -: 100:#else
2557 -: 101: return __vprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2558 -: 102:#endif
2559 -: 103:}
2560 -: 104:
2561 -: 105:__fortify_function __nonnull ((1)) int
2562 -: 106:vfprintf (FILE *__restrict __stream,
2563 -: 107: const char *__restrict __fmt, __gnuc_va_list __ap)
2564 -: 108:{
2565 -: 109: return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2566 -: 110:}
2567 -: 111:
2568 -: 112:# ifdef __USE_XOPEN2K8
2569 -: 113:# ifdef __va_arg_pack
2570 -: 114:__fortify_function int
2571 -: 115:dprintf (int __fd, const char *__restrict __fmt, ...)
2572 -: 116:{
2573 -: 117: return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt,
2574 -: 118: __va_arg_pack ());
2575 -: 119:}
2576 -: 120:# elif !defined __cplusplus
2577 -: 121:# define dprintf(fd, ...) \
2578 -: 122: __dprintf_chk (fd, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2579 -: 123:# endif
2580 -: 124:
2581 -: 125:__fortify_function int
2582 -: 126:vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
2583 -: 127:{
2584 -: 128: return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2585 -: 129:}
2586 -: 130:# endif
2587 -: 131:
2588 -: 132:# ifdef __USE_GNU
2589 -: 133:# ifdef __va_arg_pack
2590 -: 134:__fortify_function int
2591 -: 135:__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...))
2592 -: 136:{
2593 -: 137: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
2594 -: 138: __va_arg_pack ());
2595 -: 139:}
2596 -: 140:
2597 -: 141:__fortify_function int
2598 -: 142:__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt,
2599 -: 143: ...))
2600 -: 144:{
2601 -: 145: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
2602 -: 146: __va_arg_pack ());
2603 -: 147:}
2604 -: 148:
2605 -: 149:__fortify_function int
2606 -: 150:__NTH (obstack_printf (struct obstack *__restrict __obstack,
2607 -: 151: const char *__restrict __fmt, ...))
2608 -: 152:{
2609 -: 153: return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
2610 -: 154: __va_arg_pack ());
2611 -: 155:}
2612 -: 156:# elif !defined __cplusplus
2613 -: 157:# define asprintf(ptr, ...) \
2614 -: 158: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2615 -: 159:# define __asprintf(ptr, ...) \
2616 -: 160: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2617 -: 161:# define obstack_printf(obstack, ...) \
2618 -: 162: __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2619 -: 163:# endif
2620 -: 164:
2621 -: 165:__fortify_function int
2622 -: 166:__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
2623 -: 167: __gnuc_va_list __ap))
2624 -: 168:{
2625 -: 169: return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2626 -: 170:}
2627 -: 171:
2628 -: 172:__fortify_function int
2629 -: 173:__NTH (obstack_vprintf (struct obstack *__restrict __obstack,
2630 -: 174: const char *__restrict __fmt, __gnuc_va_list __ap))
2631 -: 175:{
2632 -: 176: return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
2633 -: 177: __ap);
2634 -: 178:}
2635 -: 179:
2636 -: 180:# endif
2637 -: 181:
2638 -: 182:#endif
2639 -: 183:
2640 -: 184:#if __GLIBC_USE (DEPRECATED_GETS)
2641 -: 185:__fortify_function __wur char *
2642 -: 186:gets (char *__str)
2643 -: 187:{
2644 -: 188: if (__glibc_objsize (__str) != (size_t) -1)
2645 -: 189: return __gets_chk (__str, __glibc_objsize (__str));
2646 -: 190: return __gets_warn (__str);
2647 -: 191:}
2648 -: 192:#endif
2649 -: 193:
2650 -: 194:__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2)
2651 -: 195:__nonnull ((3)) char *
2652 -: 196:fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
2653 -: 197:{
2654 -: 198: size_t sz = __glibc_objsize (__s);
2655 -: 199: if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz))
2656 -: 200: return __fgets_alias (__s, __n, __stream);
2657 -: 201: if (__glibc_unsafe_len (__n, sizeof (char), sz))
2658 -: 202: return __fgets_chk_warn (__s, sz, __n, __stream);
2659 -: 203: return __fgets_chk (__s, sz, __n, __stream);
2660 -: 204:}
2661 -: 205:
2662 -: 206:__fortify_function __wur __nonnull ((4)) size_t
2663 -: 207:fread (void *__restrict __ptr, size_t __size, size_t __n,
2664 -: 208: FILE *__restrict __stream)
2665 -: 209:{
2666 #####: 210: size_t sz = __glibc_objsize0 (__ptr);
2667 #####: 211: if (__glibc_safe_or_unknown_len (__n, __size, sz))
2668branch 0 never executed (fallthrough)
2669branch 1 never executed
2670branch 2 never executed (fallthrough)
2671branch 3 never executed
2672branch 4 never executed (fallthrough)
2673branch 5 never executed
2674branch 6 never executed (fallthrough)
2675branch 7 never executed
2676 #####: 212: return __fread_alias (__ptr, __size, __n, __stream);
2677call 0 never executed
2678 -: 213: if (__glibc_unsafe_len (__n, __size, sz))
2679 #####: 214: return __fread_chk_warn (__ptr, sz, __size, __n, __stream);
2680call 0 never executed
2681 #####: 215: return __fread_chk (__ptr, sz, __size, __n, __stream);
2682call 0 never executed
2683 -: 216:}
2684 -: 217:
2685 -: 218:#ifdef __USE_GNU
2686 -: 219:__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2)
2687 -: 220:__nonnull ((3)) char *
2688 -: 221:fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
2689 -: 222:{
2690 -: 223: size_t sz = __glibc_objsize (__s);
2691 -: 224: if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz))
2692 -: 225: return __fgets_unlocked_alias (__s, __n, __stream);
2693 -: 226: if (__glibc_unsafe_len (__n, sizeof (char), sz))
2694 -: 227: return __fgets_unlocked_chk_warn (__s, sz, __n, __stream);
2695 -: 228: return __fgets_unlocked_chk (__s, sz, __n, __stream);
2696 -: 229:}
2697 -: 230:#endif
2698 -: 231:
2699 -: 232:#ifdef __USE_MISC
2700 -: 233:# undef fread_unlocked
2701 -: 234:__fortify_function __wur __nonnull ((4)) size_t
2702 -: 235:fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
2703 -: 236: FILE *__restrict __stream)
2704 -: 237:{
2705 -: 238: size_t sz = __glibc_objsize0 (__ptr);
2706 -: 239: if (__glibc_safe_or_unknown_len (__n, __size, sz))
2707 -: 240: {
2708 -: 241:# ifdef __USE_EXTERN_INLINES
2709 -: 242: if (__builtin_constant_p (__size)
2710 -: 243: && __builtin_constant_p (__n)
2711 -: 244: && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2))
2712 -: 245: && __size * __n <= 8)
2713 -: 246: {
2714 -: 247: size_t __cnt = __size * __n;
2715 -: 248: char *__cptr = (char *) __ptr;
2716 -: 249: if (__cnt == 0)
2717 -: 250: return 0;
2718 -: 251:
2719 -: 252: for (; __cnt > 0; --__cnt)
2720 -: 253: {
2721 -: 254: int __c = getc_unlocked (__stream);
2722 -: 255: if (__c == EOF)
2723 -: 256: break;
2724 -: 257: *__cptr++ = __c;
2725 -: 258: }
2726 -: 259: return (__cptr - (char *) __ptr) / __size;
2727 -: 260: }
2728 -: 261:# endif
2729 -: 262: return __fread_unlocked_alias (__ptr, __size, __n, __stream);
2730 -: 263: }
2731 -: 264: if (__glibc_unsafe_len (__n, __size, sz))
2732 -: 265: return __fread_unlocked_chk_warn (__ptr, sz, __size, __n, __stream);
2733 -: 266: return __fread_unlocked_chk (__ptr, sz, __size, __n, __stream);
2734 -: 267:
2735 -: 268:}
2736 -: 269:#endif
2737 -: 270:
2738 -: 271:#endif /* bits/stdio2.h. */
2739 -: 0:Source:/usr/include/stdlib.h
2740 -: 0:Graph:build/dagsim-parse/oracle.gcno
2741 -: 0:Data:build/dagsim-parse/oracle.gcda
2742 -: 0:Runs:9
2743 -: 1:/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
2744 -: 2: Copyright The GNU Toolchain Authors.
2745 -: 3: This file is part of the GNU C Library.
2746 -: 4:
2747 -: 5: The GNU C Library is free software; you can redistribute it and/or
2748 -: 6: modify it under the terms of the GNU Lesser General Public
2749 -: 7: License as published by the Free Software Foundation; either
2750 -: 8: version 2.1 of the License, or (at your option) any later version.
2751 -: 9:
2752 -: 10: The GNU C Library is distributed in the hope that it will be useful,
2753 -: 11: but WITHOUT ANY WARRANTY; without even the implied warranty of
2754 -: 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2755 -: 13: Lesser General Public License for more details.
2756 -: 14:
2757 -: 15: You should have received a copy of the GNU Lesser General Public
2758 -: 16: License along with the GNU C Library; if not, see
2759 -: 17: <https://www.gnu.org/licenses/>. */
2760 -: 18:
2761 -: 19:/*
2762 -: 20: * ISO C99 Standard: 7.20 General utilities <stdlib.h>
2763 -: 21: */
2764 -: 22:
2765 -: 23:#ifndef _STDLIB_H
2766 -: 24:
2767 -: 25:#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
2768 -: 26:#include <bits/libc-header-start.h>
2769 -: 27:
2770 -: 28:/* Get size_t, wchar_t and NULL from <stddef.h>. */
2771 -: 29:#define __need_size_t
2772 -: 30:#define __need_wchar_t
2773 -: 31:#define __need_NULL
2774 -: 32:#include <stddef.h>
2775 -: 33:
2776 -: 34:__BEGIN_DECLS
2777 -: 35:
2778 -: 36:#define _STDLIB_H 1
2779 -: 37:
2780 -: 38:#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
2781 -: 39:/* XPG requires a few symbols from <sys/wait.h> being defined. */
2782 -: 40:# include <bits/waitflags.h>
2783 -: 41:# include <bits/waitstatus.h>
2784 -: 42:
2785 -: 43:/* Define the macros <sys/wait.h> also would define this way. */
2786 -: 44:# define WEXITSTATUS(status) __WEXITSTATUS (status)
2787 -: 45:# define WTERMSIG(status) __WTERMSIG (status)
2788 -: 46:# define WSTOPSIG(status) __WSTOPSIG (status)
2789 -: 47:# define WIFEXITED(status) __WIFEXITED (status)
2790 -: 48:# define WIFSIGNALED(status) __WIFSIGNALED (status)
2791 -: 49:# define WIFSTOPPED(status) __WIFSTOPPED (status)
2792 -: 50:# ifdef __WIFCONTINUED
2793 -: 51:# define WIFCONTINUED(status) __WIFCONTINUED (status)
2794 -: 52:# endif
2795 -: 53:#endif /* X/Open or XPG7 and <sys/wait.h> not included. */
2796 -: 54:
2797 -: 55:/* _FloatN API tests for enablement. */
2798 -: 56:#include <bits/floatn.h>
2799 -: 57:
2800 -: 58:/* Returned by `div'. */
2801 -: 59:typedef struct
2802 -: 60: {
2803 -: 61: int quot; /* Quotient. */
2804 -: 62: int rem; /* Remainder. */
2805 -: 63: } div_t;
2806 -: 64:
2807 -: 65:/* Returned by `ldiv'. */
2808 -: 66:#ifndef __ldiv_t_defined
2809 -: 67:typedef struct
2810 -: 68: {
2811 -: 69: long int quot; /* Quotient. */
2812 -: 70: long int rem; /* Remainder. */
2813 -: 71: } ldiv_t;
2814 -: 72:# define __ldiv_t_defined 1
2815 -: 73:#endif
2816 -: 74:
2817 -: 75:#if defined __USE_ISOC99 && !defined __lldiv_t_defined
2818 -: 76:/* Returned by `lldiv'. */
2819 -: 77:__extension__ typedef struct
2820 -: 78: {
2821 -: 79: long long int quot; /* Quotient. */
2822 -: 80: long long int rem; /* Remainder. */
2823 -: 81: } lldiv_t;
2824 -: 82:# define __lldiv_t_defined 1
2825 -: 83:#endif
2826 -: 84:
2827 -: 85:
2828 -: 86:/* The largest number rand will return (same as INT_MAX). */
2829 -: 87:#define RAND_MAX 2147483647
2830 -: 88:
2831 -: 89:
2832 -: 90:/* We define these the same for all machines.
2833 -: 91: Changes from this to the outside world should be done in `_exit'. */
2834 -: 92:#define EXIT_FAILURE 1 /* Failing exit status. */
2835 -: 93:#define EXIT_SUCCESS 0 /* Successful exit status. */
2836 -: 94:
2837 -: 95:
2838 -: 96:/* Maximum length of a multibyte character in the current locale. */
2839 -: 97:#define MB_CUR_MAX (__ctype_get_mb_cur_max ())
2840 -: 98:extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
2841 -: 99:
2842 -: 100:
2843 -: 101:/* Convert a string to a floating-point number. */
2844 -: 102:extern double atof (const char *__nptr)
2845 -: 103: __THROW __attribute_pure__ __nonnull ((1)) __wur;
2846 -: 104:/* Convert a string to an integer. */
2847 -: 105:extern int atoi (const char *__nptr)
2848 -: 106: __THROW __attribute_pure__ __nonnull ((1)) __wur;
2849 -: 107:/* Convert a string to a long integer. */
2850 -: 108:extern long int atol (const char *__nptr)
2851 -: 109: __THROW __attribute_pure__ __nonnull ((1)) __wur;
2852 -: 110:
2853 -: 111:#ifdef __USE_ISOC99
2854 -: 112:/* Convert a string to a long long integer. */
2855 -: 113:__extension__ extern long long int atoll (const char *__nptr)
2856 -: 114: __THROW __attribute_pure__ __nonnull ((1)) __wur;
2857 -: 115:#endif
2858 -: 116:
2859 -: 117:/* Convert a string to a floating-point number. */
2860 -: 118:extern double strtod (const char *__restrict __nptr,
2861 -: 119: char **__restrict __endptr)
2862 -: 120: __THROW __nonnull ((1));
2863 -: 121:
2864 -: 122:#ifdef __USE_ISOC99
2865 -: 123:/* Likewise for `float' and `long double' sizes of floating-point numbers. */
2866 -: 124:extern float strtof (const char *__restrict __nptr,
2867 -: 125: char **__restrict __endptr) __THROW __nonnull ((1));
2868 -: 126:
2869 -: 127:extern long double strtold (const char *__restrict __nptr,
2870 -: 128: char **__restrict __endptr)
2871 -: 129: __THROW __nonnull ((1));
2872 -: 130:#endif
2873 -: 131:
2874 -: 132:/* Likewise for '_FloatN' and '_FloatNx'. */
2875 -: 133:
2876 -: 134:#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
2877 -: 135:extern _Float16 strtof16 (const char *__restrict __nptr,
2878 -: 136: char **__restrict __endptr)
2879 -: 137: __THROW __nonnull ((1));
2880 -: 138:#endif
2881 -: 139:
2882 -: 140:#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
2883 -: 141:extern _Float32 strtof32 (const char *__restrict __nptr,
2884 -: 142: char **__restrict __endptr)
2885 -: 143: __THROW __nonnull ((1));
2886 -: 144:#endif
2887 -: 145:
2888 -: 146:#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
2889 -: 147:extern _Float64 strtof64 (const char *__restrict __nptr,
2890 -: 148: char **__restrict __endptr)
2891 -: 149: __THROW __nonnull ((1));
2892 -: 150:#endif
2893 -: 151:
2894 -: 152:#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
2895 -: 153:extern _Float128 strtof128 (const char *__restrict __nptr,
2896 -: 154: char **__restrict __endptr)
2897 -: 155: __THROW __nonnull ((1));
2898 -: 156:#endif
2899 -: 157:
2900 -: 158:#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
2901 -: 159:extern _Float32x strtof32x (const char *__restrict __nptr,
2902 -: 160: char **__restrict __endptr)
2903 -: 161: __THROW __nonnull ((1));
2904 -: 162:#endif
2905 -: 163:
2906 -: 164:#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
2907 -: 165:extern _Float64x strtof64x (const char *__restrict __nptr,
2908 -: 166: char **__restrict __endptr)
2909 -: 167: __THROW __nonnull ((1));
2910 -: 168:#endif
2911 -: 169:
2912 -: 170:#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
2913 -: 171:extern _Float128x strtof128x (const char *__restrict __nptr,
2914 -: 172: char **__restrict __endptr)
2915 -: 173: __THROW __nonnull ((1));
2916 -: 174:#endif
2917 -: 175:
2918 -: 176:/* Convert a string to a long integer. */
2919 -: 177:extern long int strtol (const char *__restrict __nptr,
2920 -: 178: char **__restrict __endptr, int __base)
2921 -: 179: __THROW __nonnull ((1));
2922 -: 180:/* Convert a string to an unsigned long integer. */
2923 -: 181:extern unsigned long int strtoul (const char *__restrict __nptr,
2924 -: 182: char **__restrict __endptr, int __base)
2925 -: 183: __THROW __nonnull ((1));
2926 -: 184:
2927 -: 185:#ifdef __USE_MISC
2928 -: 186:/* Convert a string to a quadword integer. */
2929 -: 187:__extension__
2930 -: 188:extern long long int strtoq (const char *__restrict __nptr,
2931 -: 189: char **__restrict __endptr, int __base)
2932 -: 190: __THROW __nonnull ((1));
2933 -: 191:/* Convert a string to an unsigned quadword integer. */
2934 -: 192:__extension__
2935 -: 193:extern unsigned long long int strtouq (const char *__restrict __nptr,
2936 -: 194: char **__restrict __endptr, int __base)
2937 -: 195: __THROW __nonnull ((1));
2938 -: 196:#endif /* Use misc. */
2939 -: 197:
2940 -: 198:#ifdef __USE_ISOC99
2941 -: 199:/* Convert a string to a quadword integer. */
2942 -: 200:__extension__
2943 -: 201:extern long long int strtoll (const char *__restrict __nptr,
2944 -: 202: char **__restrict __endptr, int __base)
2945 -: 203: __THROW __nonnull ((1));
2946 -: 204:/* Convert a string to an unsigned quadword integer. */
2947 -: 205:__extension__
2948 -: 206:extern unsigned long long int strtoull (const char *__restrict __nptr,
2949 -: 207: char **__restrict __endptr, int __base)
2950 -: 208: __THROW __nonnull ((1));
2951 -: 209:#endif /* ISO C99 or use MISC. */
2952 -: 210:
2953 -: 211:/* Versions of the above functions that handle '0b' and '0B' prefixes
2954 -: 212: in base 0 or 2. */
2955 -: 213:#if __GLIBC_USE (C2X_STRTOL)
2956 -: 214:# ifdef __REDIRECT
2957 -: 215:extern long int __REDIRECT_NTH (strtol, (const char *__restrict __nptr,
2958 -: 216: char **__restrict __endptr,
2959 -: 217: int __base), __isoc23_strtol)
2960 -: 218: __nonnull ((1));
2961 -: 219:extern unsigned long int __REDIRECT_NTH (strtoul,
2962 -: 220: (const char *__restrict __nptr,
2963 -: 221: char **__restrict __endptr,
2964 -: 222: int __base), __isoc23_strtoul)
2965 -: 223: __nonnull ((1));
2966 -: 224:# ifdef __USE_MISC
2967 -: 225:__extension__
2968 -: 226:extern long long int __REDIRECT_NTH (strtoq, (const char *__restrict __nptr,
2969 -: 227: char **__restrict __endptr,
2970 -: 228: int __base), __isoc23_strtoll)
2971 -: 229: __nonnull ((1));
2972 -: 230:__extension__
2973 -: 231:extern unsigned long long int __REDIRECT_NTH (strtouq,
2974 -: 232: (const char *__restrict __nptr,
2975 -: 233: char **__restrict __endptr,
2976 -: 234: int __base), __isoc23_strtoull)
2977 -: 235: __nonnull ((1));
2978 -: 236:# endif
2979 -: 237:__extension__
2980 -: 238:extern long long int __REDIRECT_NTH (strtoll, (const char *__restrict __nptr,
2981 -: 239: char **__restrict __endptr,
2982 -: 240: int __base), __isoc23_strtoll)
2983 -: 241: __nonnull ((1));
2984 -: 242:__extension__
2985 -: 243:extern unsigned long long int __REDIRECT_NTH (strtoull,
2986 -: 244: (const char *__restrict __nptr,
2987 -: 245: char **__restrict __endptr,
2988 -: 246: int __base), __isoc23_strtoull)
2989 -: 247: __nonnull ((1));
2990 -: 248:# else
2991 -: 249:extern long int __isoc23_strtol (const char *__restrict __nptr,
2992 -: 250: char **__restrict __endptr, int __base)
2993 -: 251: __THROW __nonnull ((1));
2994 -: 252:extern unsigned long int __isoc23_strtoul (const char *__restrict __nptr,
2995 -: 253: char **__restrict __endptr,
2996 -: 254: int __base)
2997 -: 255: __THROW __nonnull ((1));
2998 -: 256:__extension__
2999 -: 257:extern long long int __isoc23_strtoll (const char *__restrict __nptr,
3000 -: 258: char **__restrict __endptr, int __base)
3001 -: 259: __THROW __nonnull ((1));
3002 -: 260:__extension__
3003 -: 261:extern unsigned long long int __isoc23_strtoull (const char *__restrict __nptr,
3004 -: 262: char **__restrict __endptr,
3005 -: 263: int __base)
3006 -: 264: __THROW __nonnull ((1));
3007 -: 265:# define strtol __isoc23_strtol
3008 -: 266:# define strtoul __isoc23_strtoul
3009 -: 267:# ifdef __USE_MISC
3010 -: 268:# define strtoq __isoc23_strtoll
3011 -: 269:# define strtouq __isoc23_strtoull
3012 -: 270:# endif
3013 -: 271:# define strtoll __isoc23_strtoll
3014 -: 272:# define strtoull __isoc23_strtoull
3015 -: 273:# endif
3016 -: 274:#endif
3017 -: 275:
3018 -: 276:/* Convert a floating-point number to a string. */
3019 -: 277:#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
3020 -: 278:extern int strfromd (char *__dest, size_t __size, const char *__format,
3021 -: 279: double __f)
3022 -: 280: __THROW __nonnull ((3));
3023 -: 281:
3024 -: 282:extern int strfromf (char *__dest, size_t __size, const char *__format,
3025 -: 283: float __f)
3026 -: 284: __THROW __nonnull ((3));
3027 -: 285:
3028 -: 286:extern int strfroml (char *__dest, size_t __size, const char *__format,
3029 -: 287: long double __f)
3030 -: 288: __THROW __nonnull ((3));
3031 -: 289:#endif
3032 -: 290:
3033 -: 291:#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
3034 -: 292:extern int strfromf16 (char *__dest, size_t __size, const char * __format,
3035 -: 293: _Float16 __f)
3036 -: 294: __THROW __nonnull ((3));
3037 -: 295:#endif
3038 -: 296:
3039 -: 297:#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
3040 -: 298:extern int strfromf32 (char *__dest, size_t __size, const char * __format,
3041 -: 299: _Float32 __f)
3042 -: 300: __THROW __nonnull ((3));
3043 -: 301:#endif
3044 -: 302:
3045 -: 303:#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
3046 -: 304:extern int strfromf64 (char *__dest, size_t __size, const char * __format,
3047 -: 305: _Float64 __f)
3048 -: 306: __THROW __nonnull ((3));
3049 -: 307:#endif
3050 -: 308:
3051 -: 309:#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
3052 -: 310:extern int strfromf128 (char *__dest, size_t __size, const char * __format,
3053 -: 311: _Float128 __f)
3054 -: 312: __THROW __nonnull ((3));
3055 -: 313:#endif
3056 -: 314:
3057 -: 315:#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
3058 -: 316:extern int strfromf32x (char *__dest, size_t __size, const char * __format,
3059 -: 317: _Float32x __f)
3060 -: 318: __THROW __nonnull ((3));
3061 -: 319:#endif
3062 -: 320:
3063 -: 321:#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
3064 -: 322:extern int strfromf64x (char *__dest, size_t __size, const char * __format,
3065 -: 323: _Float64x __f)
3066 -: 324: __THROW __nonnull ((3));
3067 -: 325:#endif
3068 -: 326:
3069 -: 327:#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
3070 -: 328:extern int strfromf128x (char *__dest, size_t __size, const char * __format,
3071 -: 329: _Float128x __f)
3072 -: 330: __THROW __nonnull ((3));
3073 -: 331:#endif
3074 -: 332:
3075 -: 333:
3076 -: 334:#ifdef __USE_GNU
3077 -: 335:/* Parallel versions of the functions above which take the locale to
3078 -: 336: use as an additional parameter. These are GNU extensions inspired
3079 -: 337: by the POSIX.1-2008 extended locale API. */
3080 -: 338:# include <bits/types/locale_t.h>
3081 -: 339:
3082 -: 340:extern long int strtol_l (const char *__restrict __nptr,
3083 -: 341: char **__restrict __endptr, int __base,
3084 -: 342: locale_t __loc) __THROW __nonnull ((1, 4));
3085 -: 343:
3086 -: 344:extern unsigned long int strtoul_l (const char *__restrict __nptr,
3087 -: 345: char **__restrict __endptr,
3088 -: 346: int __base, locale_t __loc)
3089 -: 347: __THROW __nonnull ((1, 4));
3090 -: 348:
3091 -: 349:__extension__
3092 -: 350:extern long long int strtoll_l (const char *__restrict __nptr,
3093 -: 351: char **__restrict __endptr, int __base,
3094 -: 352: locale_t __loc)
3095 -: 353: __THROW __nonnull ((1, 4));
3096 -: 354:
3097 -: 355:__extension__
3098 -: 356:extern unsigned long long int strtoull_l (const char *__restrict __nptr,
3099 -: 357: char **__restrict __endptr,
3100 -: 358: int __base, locale_t __loc)
3101 -: 359: __THROW __nonnull ((1, 4));
3102 -: 360:
3103 -: 361:/* Versions of the above functions that handle '0b' and '0B' prefixes
3104 -: 362: in base 0 or 2. */
3105 -: 363:# if __GLIBC_USE (C2X_STRTOL)
3106 -: 364:# ifdef __REDIRECT
3107 -: 365:extern long int __REDIRECT_NTH (strtol_l, (const char *__restrict __nptr,
3108 -: 366: char **__restrict __endptr,
3109 -: 367: int __base, locale_t __loc),
3110 -: 368: __isoc23_strtol_l)
3111 -: 369: __nonnull ((1, 4));
3112 -: 370:extern unsigned long int __REDIRECT_NTH (strtoul_l,
3113 -: 371: (const char *__restrict __nptr,
3114 -: 372: char **__restrict __endptr,
3115 -: 373: int __base, locale_t __loc),
3116 -: 374: __isoc23_strtoul_l)
3117 -: 375: __nonnull ((1, 4));
3118 -: 376:__extension__
3119 -: 377:extern long long int __REDIRECT_NTH (strtoll_l, (const char *__restrict __nptr,
3120 -: 378: char **__restrict __endptr,
3121 -: 379: int __base,
3122 -: 380: locale_t __loc),
3123 -: 381: __isoc23_strtoll_l)
3124 -: 382: __nonnull ((1, 4));
3125 -: 383:__extension__
3126 -: 384:extern unsigned long long int __REDIRECT_NTH (strtoull_l,
3127 -: 385: (const char *__restrict __nptr,
3128 -: 386: char **__restrict __endptr,
3129 -: 387: int __base, locale_t __loc),
3130 -: 388: __isoc23_strtoull_l)
3131 -: 389: __nonnull ((1, 4));
3132 -: 390:# else
3133 -: 391:extern long int __isoc23_strtol_l (const char *__restrict __nptr,
3134 -: 392: char **__restrict __endptr, int __base,
3135 -: 393: locale_t __loc) __THROW __nonnull ((1, 4));
3136 -: 394:extern unsigned long int __isoc23_strtoul_l (const char *__restrict __nptr,
3137 -: 395: char **__restrict __endptr,
3138 -: 396: int __base, locale_t __loc)
3139 -: 397: __THROW __nonnull ((1, 4));
3140 -: 398:__extension__
3141 -: 399:extern long long int __isoc23_strtoll_l (const char *__restrict __nptr,
3142 -: 400: char **__restrict __endptr,
3143 -: 401: int __base, locale_t __loc)
3144 -: 402: __THROW __nonnull ((1, 4));
3145 -: 403:__extension__
3146 -: 404:extern unsigned long long int __isoc23_strtoull_l (const char *__restrict __nptr,
3147 -: 405: char **__restrict __endptr,
3148 -: 406: int __base, locale_t __loc)
3149 -: 407: __THROW __nonnull ((1, 4));
3150 -: 408:# define strtol_l __isoc23_strtol_l
3151 -: 409:# define strtoul_l __isoc23_strtoul_l
3152 -: 410:# define strtoll_l __isoc23_strtoll_l
3153 -: 411:# define strtoull_l __isoc23_strtoull_l
3154 -: 412:# endif
3155 -: 413:# endif
3156 -: 414:
3157 -: 415:extern double strtod_l (const char *__restrict __nptr,
3158 -: 416: char **__restrict __endptr, locale_t __loc)
3159 -: 417: __THROW __nonnull ((1, 3));
3160 -: 418:
3161 -: 419:extern float strtof_l (const char *__restrict __nptr,
3162 -: 420: char **__restrict __endptr, locale_t __loc)
3163 -: 421: __THROW __nonnull ((1, 3));
3164 -: 422:
3165 -: 423:extern long double strtold_l (const char *__restrict __nptr,
3166 -: 424: char **__restrict __endptr,
3167 -: 425: locale_t __loc)
3168 -: 426: __THROW __nonnull ((1, 3));
3169 -: 427:
3170 -: 428:# if __HAVE_FLOAT16
3171 -: 429:extern _Float16 strtof16_l (const char *__restrict __nptr,
3172 -: 430: char **__restrict __endptr,
3173 -: 431: locale_t __loc)
3174 -: 432: __THROW __nonnull ((1, 3));
3175 -: 433:# endif
3176 -: 434:
3177 -: 435:# if __HAVE_FLOAT32
3178 -: 436:extern _Float32 strtof32_l (const char *__restrict __nptr,
3179 -: 437: char **__restrict __endptr,
3180 -: 438: locale_t __loc)
3181 -: 439: __THROW __nonnull ((1, 3));
3182 -: 440:# endif
3183 -: 441:
3184 -: 442:# if __HAVE_FLOAT64
3185 -: 443:extern _Float64 strtof64_l (const char *__restrict __nptr,
3186 -: 444: char **__restrict __endptr,
3187 -: 445: locale_t __loc)
3188 -: 446: __THROW __nonnull ((1, 3));
3189 -: 447:# endif
3190 -: 448:
3191 -: 449:# if __HAVE_FLOAT128
3192 -: 450:extern _Float128 strtof128_l (const char *__restrict __nptr,
3193 -: 451: char **__restrict __endptr,
3194 -: 452: locale_t __loc)
3195 -: 453: __THROW __nonnull ((1, 3));
3196 -: 454:# endif
3197 -: 455:
3198 -: 456:# if __HAVE_FLOAT32X
3199 -: 457:extern _Float32x strtof32x_l (const char *__restrict __nptr,
3200 -: 458: char **__restrict __endptr,
3201 -: 459: locale_t __loc)
3202 -: 460: __THROW __nonnull ((1, 3));
3203 -: 461:# endif
3204 -: 462:
3205 -: 463:# if __HAVE_FLOAT64X
3206 -: 464:extern _Float64x strtof64x_l (const char *__restrict __nptr,
3207 -: 465: char **__restrict __endptr,
3208 -: 466: locale_t __loc)
3209 -: 467: __THROW __nonnull ((1, 3));
3210 -: 468:# endif
3211 -: 469:
3212 -: 470:# if __HAVE_FLOAT128X
3213 -: 471:extern _Float128x strtof128x_l (const char *__restrict __nptr,
3214 -: 472: char **__restrict __endptr,
3215 -: 473: locale_t __loc)
3216 -: 474: __THROW __nonnull ((1, 3));
3217 -: 475:# endif
3218 -: 476:#endif /* GNU */
3219 -: 477:
3220 -: 478:
3221 -: 479:#ifdef __USE_EXTERN_INLINES
3222 -: 480:__extern_inline int
3223 -: 481:__NTH (atoi (const char *__nptr))
3224 -: 482:{
3225 6750: 483: return (int) strtol (__nptr, (char **) NULL, 10);
3226call 0 returned 3312
3227call 1 returned 203
3228call 2 returned 203
3229call 3 returned 3235
3230branch 4 taken 84 (fallthrough)
3231branch 5 taken 3151
3232 -: 484:}
3233 -: 485:__extern_inline long int
3234 -: 486:__NTH (atol (const char *__nptr))
3235 -: 487:{
3236 -: 488: return strtol (__nptr, (char **) NULL, 10);
3237 -: 489:}
3238 -: 490:
3239 -: 491:# ifdef __USE_ISOC99
3240 -: 492:__extension__ __extern_inline long long int
3241 -: 493:__NTH (atoll (const char *__nptr))
3242 -: 494:{
3243 -: 495: return strtoll (__nptr, (char **) NULL, 10);
3244 -: 496:}
3245 -: 497:# endif
3246 -: 498:#endif /* Optimizing and Inlining. */
3247 -: 499:
3248 -: 500:
3249 -: 501:#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
3250 -: 502:/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
3251 -: 503: digit first. Returns a pointer to static storage overwritten by the
3252 -: 504: next call. */
3253 -: 505:extern char *l64a (long int __n) __THROW __wur;
3254 -: 506:
3255 -: 507:/* Read a number from a string S in base 64 as above. */
3256 -: 508:extern long int a64l (const char *__s)
3257 -: 509: __THROW __attribute_pure__ __nonnull ((1)) __wur;
3258 -: 510:
3259 -: 511:#endif /* Use misc || extended X/Open. */
3260 -: 512:
3261 -: 513:#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
3262 -: 514:# include <sys/types.h> /* we need int32_t... */
3263 -: 515:
3264 -: 516:/* These are the functions that actually do things. The `random', `srandom',
3265 -: 517: `initstate' and `setstate' functions are those from BSD Unices.
3266 -: 518: The `rand' and `srand' functions are required by the ANSI standard.
3267 -: 519: We provide both interfaces to the same random number generator. */
3268 -: 520:/* Return a random long integer between 0 and 2^31-1 inclusive. */
3269 -: 521:extern long int random (void) __THROW;
3270 -: 522:
3271 -: 523:/* Seed the random number generator with the given number. */
3272 -: 524:extern void srandom (unsigned int __seed) __THROW;
3273 -: 525:
3274 -: 526:/* Initialize the random number generator to use state buffer STATEBUF,
3275 -: 527: of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
3276 -: 528: 32, 64, 128 and 256, the bigger the better; values less than 8 will
3277 -: 529: cause an error and values greater than 256 will be rounded down. */
3278 -: 530:extern char *initstate (unsigned int __seed, char *__statebuf,
3279 -: 531: size_t __statelen) __THROW __nonnull ((2));
3280 -: 532:
3281 -: 533:/* Switch the random number generator to state buffer STATEBUF,
3282 -: 534: which should have been previously initialized by `initstate'. */
3283 -: 535:extern char *setstate (char *__statebuf) __THROW __nonnull ((1));
3284 -: 536:
3285 -: 537:
3286 -: 538:# ifdef __USE_MISC
3287 -: 539:/* Reentrant versions of the `random' family of functions.
3288 -: 540: These functions all use the following data structure to contain
3289 -: 541: state, rather than global state variables. */
3290 -: 542:
3291 -: 543:struct random_data
3292 -: 544: {
3293 -: 545: int32_t *fptr; /* Front pointer. */
3294 -: 546: int32_t *rptr; /* Rear pointer. */
3295 -: 547: int32_t *state; /* Array of state values. */
3296 -: 548: int rand_type; /* Type of random number generator. */
3297 -: 549: int rand_deg; /* Degree of random number generator. */
3298 -: 550: int rand_sep; /* Distance between front and rear. */
3299 -: 551: int32_t *end_ptr; /* Pointer behind state table. */
3300 -: 552: };
3301 -: 553:
3302 -: 554:extern int random_r (struct random_data *__restrict __buf,
3303 -: 555: int32_t *__restrict __result) __THROW __nonnull ((1, 2));
3304 -: 556:
3305 -: 557:extern int srandom_r (unsigned int __seed, struct random_data *__buf)
3306 -: 558: __THROW __nonnull ((2));
3307 -: 559:
3308 -: 560:extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
3309 -: 561: size_t __statelen,
3310 -: 562: struct random_data *__restrict __buf)
3311 -: 563: __THROW __nonnull ((2, 4));
3312 -: 564:
3313 -: 565:extern int setstate_r (char *__restrict __statebuf,
3314 -: 566: struct random_data *__restrict __buf)
3315 -: 567: __THROW __nonnull ((1, 2));
3316 -: 568:# endif /* Use misc. */
3317 -: 569:#endif /* Use extended X/Open || misc. */
3318 -: 570:
3319 -: 571:
3320 -: 572:/* Return a random integer between 0 and RAND_MAX inclusive. */
3321 -: 573:extern int rand (void) __THROW;
3322 -: 574:/* Seed the random number generator with the given number. */
3323 -: 575:extern void srand (unsigned int __seed) __THROW;
3324 -: 576:
3325 -: 577:#ifdef __USE_POSIX199506
3326 -: 578:/* Reentrant interface according to POSIX.1. */
3327 -: 579:extern int rand_r (unsigned int *__seed) __THROW;
3328 -: 580:#endif
3329 -: 581:
3330 -: 582:
3331 -: 583:#if defined __USE_MISC || defined __USE_XOPEN
3332 -: 584:/* System V style 48-bit random number generator functions. */
3333 -: 585:
3334 -: 586:/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
3335 -: 587:extern double drand48 (void) __THROW;
3336 -: 588:extern double erand48 (unsigned short int __xsubi[3]) __THROW __nonnull ((1));
3337 -: 589:
3338 -: 590:/* Return non-negative, long integer in [0,2^31). */
3339 -: 591:extern long int lrand48 (void) __THROW;
3340 -: 592:extern long int nrand48 (unsigned short int __xsubi[3])
3341 -: 593: __THROW __nonnull ((1));
3342 -: 594:
3343 -: 595:/* Return signed, long integers in [-2^31,2^31). */
3344 -: 596:extern long int mrand48 (void) __THROW;
3345 -: 597:extern long int jrand48 (unsigned short int __xsubi[3])
3346 -: 598: __THROW __nonnull ((1));
3347 -: 599:
3348 -: 600:/* Seed random number generator. */
3349 -: 601:extern void srand48 (long int __seedval) __THROW;
3350 -: 602:extern unsigned short int *seed48 (unsigned short int __seed16v[3])
3351 -: 603: __THROW __nonnull ((1));
3352 -: 604:extern void lcong48 (unsigned short int __param[7]) __THROW __nonnull ((1));
3353 -: 605:
3354 -: 606:# ifdef __USE_MISC
3355 -: 607:/* Data structure for communication with thread safe versions. This
3356 -: 608: type is to be regarded as opaque. It's only exported because users
3357 -: 609: have to allocate objects of this type. */
3358 -: 610:struct drand48_data
3359 -: 611: {
3360 -: 612: unsigned short int __x[3]; /* Current state. */
3361 -: 613: unsigned short int __old_x[3]; /* Old state. */
3362 -: 614: unsigned short int __c; /* Additive const. in congruential formula. */
3363 -: 615: unsigned short int __init; /* Flag for initializing. */
3364 -: 616: __extension__ unsigned long long int __a; /* Factor in congruential
3365 -: 617: formula. */
3366 -: 618: };
3367 -: 619:
3368 -: 620:/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
3369 -: 621:extern int drand48_r (struct drand48_data *__restrict __buffer,
3370 -: 622: double *__restrict __result) __THROW __nonnull ((1, 2));
3371 -: 623:extern int erand48_r (unsigned short int __xsubi[3],
3372 -: 624: struct drand48_data *__restrict __buffer,
3373 -: 625: double *__restrict __result) __THROW __nonnull ((1, 2));
3374 -: 626:
3375 -: 627:/* Return non-negative, long integer in [0,2^31). */
3376 -: 628:extern int lrand48_r (struct drand48_data *__restrict __buffer,
3377 -: 629: long int *__restrict __result)
3378 -: 630: __THROW __nonnull ((1, 2));
3379 -: 631:extern int nrand48_r (unsigned short int __xsubi[3],
3380 -: 632: struct drand48_data *__restrict __buffer,
3381 -: 633: long int *__restrict __result)
3382 -: 634: __THROW __nonnull ((1, 2));
3383 -: 635:
3384 -: 636:/* Return signed, long integers in [-2^31,2^31). */
3385 -: 637:extern int mrand48_r (struct drand48_data *__restrict __buffer,
3386 -: 638: long int *__restrict __result)
3387 -: 639: __THROW __nonnull ((1, 2));
3388 -: 640:extern int jrand48_r (unsigned short int __xsubi[3],
3389 -: 641: struct drand48_data *__restrict __buffer,
3390 -: 642: long int *__restrict __result)
3391 -: 643: __THROW __nonnull ((1, 2));
3392 -: 644:
3393 -: 645:/* Seed random number generator. */
3394 -: 646:extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
3395 -: 647: __THROW __nonnull ((2));
3396 -: 648:
3397 -: 649:extern int seed48_r (unsigned short int __seed16v[3],
3398 -: 650: struct drand48_data *__buffer) __THROW __nonnull ((1, 2));
3399 -: 651:
3400 -: 652:extern int lcong48_r (unsigned short int __param[7],
3401 -: 653: struct drand48_data *__buffer)
3402 -: 654: __THROW __nonnull ((1, 2));
3403 -: 655:
3404 -: 656:/* Return a random integer between zero and 2**32-1 (inclusive). */
3405 -: 657:extern __uint32_t arc4random (void)
3406 -: 658: __THROW __wur;
3407 -: 659:
3408 -: 660:/* Fill the buffer with random data. */
3409 -: 661:extern void arc4random_buf (void *__buf, size_t __size)
3410 -: 662: __THROW __nonnull ((1));
3411 -: 663:
3412 -: 664:/* Return a random number between zero (inclusive) and the specified
3413 -: 665: limit (exclusive). */
3414 -: 666:extern __uint32_t arc4random_uniform (__uint32_t __upper_bound)
3415 -: 667: __THROW __wur;
3416 -: 668:# endif /* Use misc. */
3417 -: 669:#endif /* Use misc or X/Open. */
3418 -: 670:
3419 -: 671:/* Allocate SIZE bytes of memory. */
3420 -: 672:extern void *malloc (size_t __size) __THROW __attribute_malloc__
3421 -: 673: __attribute_alloc_size__ ((1)) __wur;
3422 -: 674:/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
3423 -: 675:extern void *calloc (size_t __nmemb, size_t __size)
3424 -: 676: __THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur;
3425 -: 677:
3426 -: 678:/* Re-allocate the previously allocated block
3427 -: 679: in PTR, making the new block SIZE bytes long. */
3428 -: 680:/* __attribute_malloc__ is not used, because if realloc returns
3429 -: 681: the same pointer that was passed to it, aliasing needs to be allowed
3430 -: 682: between objects pointed by the old and new pointers. */
3431 -: 683:extern void *realloc (void *__ptr, size_t __size)
3432 -: 684: __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
3433 -: 685:
3434 -: 686:/* Free a block allocated by `malloc', `realloc' or `calloc'. */
3435 -: 687:extern void free (void *__ptr) __THROW;
3436 -: 688:
3437 -: 689:#ifdef __USE_MISC
3438 -: 690:/* Re-allocate the previously allocated block in PTR, making the new
3439 -: 691: block large enough for NMEMB elements of SIZE bytes each. */
3440 -: 692:/* __attribute_malloc__ is not used, because if reallocarray returns
3441 -: 693: the same pointer that was passed to it, aliasing needs to be allowed
3442 -: 694: between objects pointed by the old and new pointers. */
3443 -: 695:extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
3444 -: 696: __THROW __attribute_warn_unused_result__
3445 -: 697: __attribute_alloc_size__ ((2, 3))
3446 -: 698: __attr_dealloc_free;
3447 -: 699:
3448 -: 700:/* Add reallocarray as its own deallocator. */
3449 -: 701:extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
3450 -: 702: __THROW __attr_dealloc (reallocarray, 1);
3451 -: 703:#endif
3452 -: 704:
3453 -: 705:#ifdef __USE_MISC
3454 -: 706:# include <alloca.h>
3455 -: 707:#endif /* Use misc. */
3456 -: 708:
3457 -: 709:#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
3458 -: 710: || defined __USE_MISC
3459 -: 711:/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
3460 -: 712:extern void *valloc (size_t __size) __THROW __attribute_malloc__
3461 -: 713: __attribute_alloc_size__ ((1)) __wur;
3462 -: 714:#endif
3463 -: 715:
3464 -: 716:#ifdef __USE_XOPEN2K
3465 -: 717:/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
3466 -: 718:extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
3467 -: 719: __THROW __nonnull ((1)) __wur;
3468 -: 720:#endif
3469 -: 721:
3470 -: 722:#ifdef __USE_ISOC11
3471 -: 723:/* ISO C variant of aligned allocation. */
3472 -: 724:extern void *aligned_alloc (size_t __alignment, size_t __size)
3473 -: 725: __THROW __attribute_malloc__ __attribute_alloc_align__ ((1))
3474 -: 726: __attribute_alloc_size__ ((2)) __wur;
3475 -: 727:#endif
3476 -: 728:
3477 -: 729:/* Abort execution and generate a core-dump. */
3478 -: 730:extern void abort (void) __THROW __attribute__ ((__noreturn__));
3479 -: 731:
3480 -: 732:
3481 -: 733:/* Register a function to be called when `exit' is called. */
3482 -: 734:extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
3483 -: 735:
3484 -: 736:#if defined __USE_ISOC11 || defined __USE_ISOCXX11
3485 -: 737:/* Register a function to be called when `quick_exit' is called. */
3486 -: 738:# ifdef __cplusplus
3487 -: 739:extern "C++" int at_quick_exit (void (*__func) (void))
3488 -: 740: __THROW __asm ("at_quick_exit") __nonnull ((1));
3489 -: 741:# else
3490 -: 742:extern int at_quick_exit (void (*__func) (void)) __THROW __nonnull ((1));
3491 -: 743:# endif
3492 -: 744:#endif
3493 -: 745:
3494 -: 746:#ifdef __USE_MISC
3495 -: 747:/* Register a function to be called with the status
3496 -: 748: given to `exit' and the given argument. */
3497 -: 749:extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
3498 -: 750: __THROW __nonnull ((1));
3499 -: 751:#endif
3500 -: 752:
3501 -: 753:/* Call all functions registered with `atexit' and `on_exit',
3502 -: 754: in the reverse of the order in which they were registered,
3503 -: 755: perform stdio cleanup, and terminate program execution with STATUS. */
3504 -: 756:extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
3505 -: 757:
3506 -: 758:#if defined __USE_ISOC11 || defined __USE_ISOCXX11
3507 -: 759:/* Call all functions registered with `at_quick_exit' in the reverse
3508 -: 760: of the order in which they were registered and terminate program
3509 -: 761: execution with STATUS. */
3510 -: 762:extern void quick_exit (int __status) __THROW __attribute__ ((__noreturn__));
3511 -: 763:#endif
3512 -: 764:
3513 -: 765:#ifdef __USE_ISOC99
3514 -: 766:/* Terminate the program with STATUS without calling any of the
3515 -: 767: functions registered with `atexit' or `on_exit'. */
3516 -: 768:extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__));
3517 -: 769:#endif
3518 -: 770:
3519 -: 771:
3520 -: 772:/* Return the value of envariable NAME, or NULL if it doesn't exist. */
3521 -: 773:extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
3522 -: 774:
3523 -: 775:#ifdef __USE_GNU
3524 -: 776:/* This function is similar to the above but returns NULL if the
3525 -: 777: programs is running with SUID or SGID enabled. */
3526 -: 778:extern char *secure_getenv (const char *__name)
3527 -: 779: __THROW __nonnull ((1)) __wur;
3528 -: 780:#endif
3529 -: 781:
3530 -: 782:#if defined __USE_MISC || defined __USE_XOPEN
3531 -: 783:/* The SVID says this is in <stdio.h>, but this seems a better place. */
3532 -: 784:/* Put STRING, which is of the form "NAME=VALUE", in the environment.
3533 -: 785: If there is no `=', remove NAME from the environment. */
3534 -: 786:extern int putenv (char *__string) __THROW __nonnull ((1));
3535 -: 787:#endif
3536 -: 788:
3537 -: 789:#ifdef __USE_XOPEN2K
3538 -: 790:/* Set NAME to VALUE in the environment.
3539 -: 791: If REPLACE is nonzero, overwrite an existing value. */
3540 -: 792:extern int setenv (const char *__name, const char *__value, int __replace)
3541 -: 793: __THROW __nonnull ((2));
3542 -: 794:
3543 -: 795:/* Remove the variable NAME from the environment. */
3544 -: 796:extern int unsetenv (const char *__name) __THROW __nonnull ((1));
3545 -: 797:#endif
3546 -: 798:
3547 -: 799:#ifdef __USE_MISC
3548 -: 800:/* The `clearenv' was planned to be added to POSIX.1 but probably
3549 -: 801: never made it. Nevertheless the POSIX.9 standard (POSIX bindings
3550 -: 802: for Fortran 77) requires this function. */
3551 -: 803:extern int clearenv (void) __THROW;
3552 -: 804:#endif
3553 -: 805:
3554 -: 806:
3555 -: 807:#if defined __USE_MISC \
3556 -: 808: || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)
3557 -: 809:/* Generate a unique temporary file name from TEMPLATE.
3558 -: 810: The last six characters of TEMPLATE must be "XXXXXX";
3559 -: 811: they are replaced with a string that makes the file name unique.
3560 -: 812: Always returns TEMPLATE, it's either a temporary file name or a null
3561 -: 813: string if it cannot get a unique file name. */
3562 -: 814:extern char *mktemp (char *__template) __THROW __nonnull ((1));
3563 -: 815:#endif
3564 -: 816:
3565 -: 817:#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
3566 -: 818:/* Generate a unique temporary file name from TEMPLATE.
3567 -: 819: The last six characters of TEMPLATE must be "XXXXXX";
3568 -: 820: they are replaced with a string that makes the filename unique.
3569 -: 821: Returns a file descriptor open on the file for reading and writing,
3570 -: 822: or -1 if it cannot create a uniquely-named file.
3571 -: 823:
3572 -: 824: This function is a possible cancellation point and therefore not
3573 -: 825: marked with __THROW. */
3574 -: 826:# ifndef __USE_FILE_OFFSET64
3575 -: 827:extern int mkstemp (char *__template) __nonnull ((1)) __wur;
3576 -: 828:# else
3577 -: 829:# ifdef __REDIRECT
3578 -: 830:extern int __REDIRECT (mkstemp, (char *__template), mkstemp64)
3579 -: 831: __nonnull ((1)) __wur;
3580 -: 832:# else
3581 -: 833:# define mkstemp mkstemp64
3582 -: 834:# endif
3583 -: 835:# endif
3584 -: 836:# ifdef __USE_LARGEFILE64
3585 -: 837:extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
3586 -: 838:# endif
3587 -: 839:#endif
3588 -: 840:
3589 -: 841:#ifdef __USE_MISC
3590 -: 842:/* Similar to mkstemp, but the template can have a suffix after the
3591 -: 843: XXXXXX. The length of the suffix is specified in the second
3592 -: 844: parameter.
3593 -: 845:
3594 -: 846: This function is a possible cancellation point and therefore not
3595 -: 847: marked with __THROW. */
3596 -: 848:# ifndef __USE_FILE_OFFSET64
3597 -: 849:extern int mkstemps (char *__template, int __suffixlen) __nonnull ((1)) __wur;
3598 -: 850:# else
3599 -: 851:# ifdef __REDIRECT
3600 -: 852:extern int __REDIRECT (mkstemps, (char *__template, int __suffixlen),
3601 -: 853: mkstemps64) __nonnull ((1)) __wur;
3602 -: 854:# else
3603 -: 855:# define mkstemps mkstemps64
3604 -: 856:# endif
3605 -: 857:# endif
3606 -: 858:# ifdef __USE_LARGEFILE64
3607 -: 859:extern int mkstemps64 (char *__template, int __suffixlen)
3608 -: 860: __nonnull ((1)) __wur;
3609 -: 861:# endif
3610 -: 862:#endif
3611 -: 863:
3612 -: 864:#ifdef __USE_XOPEN2K8
3613 -: 865:/* Create a unique temporary directory from TEMPLATE.
3614 -: 866: The last six characters of TEMPLATE must be "XXXXXX";
3615 -: 867: they are replaced with a string that makes the directory name unique.
3616 -: 868: Returns TEMPLATE, or a null pointer if it cannot get a unique name.
3617 -: 869: The directory is created mode 700. */
3618 -: 870:extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur;
3619 -: 871:#endif
3620 -: 872:
3621 -: 873:#ifdef __USE_GNU
3622 -: 874:/* Generate a unique temporary file name from TEMPLATE similar to
3623 -: 875: mkstemp. But allow the caller to pass additional flags which are
3624 -: 876: used in the open call to create the file..
3625 -: 877:
3626 -: 878: This function is a possible cancellation point and therefore not
3627 -: 879: marked with __THROW. */
3628 -: 880:# ifndef __USE_FILE_OFFSET64
3629 -: 881:extern int mkostemp (char *__template, int __flags) __nonnull ((1)) __wur;
3630 -: 882:# else
3631 -: 883:# ifdef __REDIRECT
3632 -: 884:extern int __REDIRECT (mkostemp, (char *__template, int __flags), mkostemp64)
3633 -: 885: __nonnull ((1)) __wur;
3634 -: 886:# else
3635 -: 887:# define mkostemp mkostemp64
3636 -: 888:# endif
3637 -: 889:# endif
3638 -: 890:# ifdef __USE_LARGEFILE64
3639 -: 891:extern int mkostemp64 (char *__template, int __flags) __nonnull ((1)) __wur;
3640 -: 892:# endif
3641 -: 893:
3642 -: 894:/* Similar to mkostemp, but the template can have a suffix after the
3643 -: 895: XXXXXX. The length of the suffix is specified in the second
3644 -: 896: parameter.
3645 -: 897:
3646 -: 898: This function is a possible cancellation point and therefore not
3647 -: 899: marked with __THROW. */
3648 -: 900:# ifndef __USE_FILE_OFFSET64
3649 -: 901:extern int mkostemps (char *__template, int __suffixlen, int __flags)
3650 -: 902: __nonnull ((1)) __wur;
3651 -: 903:# else
3652 -: 904:# ifdef __REDIRECT
3653 -: 905:extern int __REDIRECT (mkostemps, (char *__template, int __suffixlen,
3654 -: 906: int __flags), mkostemps64)
3655 -: 907: __nonnull ((1)) __wur;
3656 -: 908:# else
3657 -: 909:# define mkostemps mkostemps64
3658 -: 910:# endif
3659 -: 911:# endif
3660 -: 912:# ifdef __USE_LARGEFILE64
3661 -: 913:extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
3662 -: 914: __nonnull ((1)) __wur;
3663 -: 915:# endif
3664 -: 916:#endif
3665 -: 917:
3666 -: 918:
3667 -: 919:/* Execute the given line as a shell command.
3668 -: 920:
3669 -: 921: This function is a cancellation point and therefore not marked with
3670 -: 922: __THROW. */
3671 -: 923:extern int system (const char *__command) __wur;
3672 -: 924:
3673 -: 925:
3674 -: 926:#ifdef __USE_GNU
3675 -: 927:/* Return a malloc'd string containing the canonical absolute name of the
3676 -: 928: existing named file. */
3677 -: 929:extern char *canonicalize_file_name (const char *__name)
3678 -: 930: __THROW __nonnull ((1)) __attribute_malloc__
3679 -: 931: __attr_dealloc_free __wur;
3680 -: 932:#endif
3681 -: 933:
3682 -: 934:#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
3683 -: 935:/* Return the canonical absolute name of file NAME. If RESOLVED is
3684 -: 936: null, the result is malloc'd; otherwise, if the canonical name is
3685 -: 937: PATH_MAX chars or more, returns null with `errno' set to
3686 -: 938: ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
3687 -: 939: returns the name in RESOLVED. */
3688 -: 940:extern char *realpath (const char *__restrict __name,
3689 -: 941: char *__restrict __resolved) __THROW __wur;
3690 -: 942:#endif
3691 -: 943:
3692 -: 944:
3693 -: 945:/* Shorthand for type of comparison functions. */
3694 -: 946:#ifndef __COMPAR_FN_T
3695 -: 947:# define __COMPAR_FN_T
3696 -: 948:typedef int (*__compar_fn_t) (const void *, const void *);
3697 -: 949:
3698 -: 950:# ifdef __USE_GNU
3699 -: 951:typedef __compar_fn_t comparison_fn_t;
3700 -: 952:# endif
3701 -: 953:#endif
3702 -: 954:#ifdef __USE_GNU
3703 -: 955:typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
3704 -: 956:#endif
3705 -: 957:
3706 -: 958:/* Do a binary search for KEY in BASE, which consists of NMEMB elements
3707 -: 959: of SIZE bytes each, using COMPAR to perform the comparisons. */
3708 -: 960:extern void *bsearch (const void *__key, const void *__base,
3709 -: 961: size_t __nmemb, size_t __size, __compar_fn_t __compar)
3710 -: 962: __nonnull ((1, 2, 5)) __wur;
3711 -: 963:
3712 -: 964:#ifdef __USE_EXTERN_INLINES
3713 -: 965:# include <bits/stdlib-bsearch.h>
3714 -: 966:#endif
3715 -: 967:
3716 -: 968:/* Sort NMEMB elements of BASE, of SIZE bytes each,
3717 -: 969: using COMPAR to perform the comparisons. */
3718 -: 970:extern void qsort (void *__base, size_t __nmemb, size_t __size,
3719 -: 971: __compar_fn_t __compar) __nonnull ((1, 4));
3720 -: 972:#ifdef __USE_GNU
3721 -: 973:extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
3722 -: 974: __compar_d_fn_t __compar, void *__arg)
3723 -: 975: __nonnull ((1, 4));
3724 -: 976:#endif
3725 -: 977:
3726 -: 978:
3727 -: 979:/* Return the absolute value of X. */
3728 -: 980:extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
3729 -: 981:extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
3730 -: 982:
3731 -: 983:#ifdef __USE_ISOC99
3732 -: 984:__extension__ extern long long int llabs (long long int __x)
3733 -: 985: __THROW __attribute__ ((__const__)) __wur;
3734 -: 986:#endif
3735 -: 987:
3736 -: 988:
3737 -: 989:/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
3738 -: 990: of the value of NUMER over DENOM. */
3739 -: 991:/* GCC may have built-ins for these someday. */
3740 -: 992:extern div_t div (int __numer, int __denom)
3741 -: 993: __THROW __attribute__ ((__const__)) __wur;
3742 -: 994:extern ldiv_t ldiv (long int __numer, long int __denom)
3743 -: 995: __THROW __attribute__ ((__const__)) __wur;
3744 -: 996:
3745 -: 997:#ifdef __USE_ISOC99
3746 -: 998:__extension__ extern lldiv_t lldiv (long long int __numer,
3747 -: 999: long long int __denom)
3748 -: 1000: __THROW __attribute__ ((__const__)) __wur;
3749 -: 1001:#endif
3750 -: 1002:
3751 -: 1003:
3752 -: 1004:#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
3753 -: 1005: || defined __USE_MISC
3754 -: 1006:/* Convert floating point numbers to strings. The returned values are
3755 -: 1007: valid only until another call to the same function. */
3756 -: 1008:
3757 -: 1009:/* Convert VALUE to a string with NDIGIT digits and return a pointer to
3758 -: 1010: this. Set *DECPT with the position of the decimal character and *SIGN
3759 -: 1011: with the sign of the number. */
3760 -: 1012:extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
3761 -: 1013: int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
3762 -: 1014:
3763 -: 1015:/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
3764 -: 1016: with the position of the decimal character and *SIGN with the sign of
3765 -: 1017: the number. */
3766 -: 1018:extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
3767 -: 1019: int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
3768 -: 1020:
3769 -: 1021:/* If possible convert VALUE to a string with NDIGIT significant digits.
3770 -: 1022: Otherwise use exponential representation. The resulting string will
3771 -: 1023: be written to BUF. */
3772 -: 1024:extern char *gcvt (double __value, int __ndigit, char *__buf)
3773 -: 1025: __THROW __nonnull ((3)) __wur;
3774 -: 1026:#endif
3775 -: 1027:
3776 -: 1028:#ifdef __USE_MISC
3777 -: 1029:/* Long double versions of above functions. */
3778 -: 1030:extern char *qecvt (long double __value, int __ndigit,
3779 -: 1031: int *__restrict __decpt, int *__restrict __sign)
3780 -: 1032: __THROW __nonnull ((3, 4)) __wur;
3781 -: 1033:extern char *qfcvt (long double __value, int __ndigit,
3782 -: 1034: int *__restrict __decpt, int *__restrict __sign)
3783 -: 1035: __THROW __nonnull ((3, 4)) __wur;
3784 -: 1036:extern char *qgcvt (long double __value, int __ndigit, char *__buf)
3785 -: 1037: __THROW __nonnull ((3)) __wur;
3786 -: 1038:
3787 -: 1039:
3788 -: 1040:/* Reentrant version of the functions above which provide their own
3789 -: 1041: buffers. */
3790 -: 1042:extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
3791 -: 1043: int *__restrict __sign, char *__restrict __buf,
3792 -: 1044: size_t __len) __THROW __nonnull ((3, 4, 5));
3793 -: 1045:extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
3794 -: 1046: int *__restrict __sign, char *__restrict __buf,
3795 -: 1047: size_t __len) __THROW __nonnull ((3, 4, 5));
3796 -: 1048:
3797 -: 1049:extern int qecvt_r (long double __value, int __ndigit,
3798 -: 1050: int *__restrict __decpt, int *__restrict __sign,
3799 -: 1051: char *__restrict __buf, size_t __len)
3800 -: 1052: __THROW __nonnull ((3, 4, 5));
3801 -: 1053:extern int qfcvt_r (long double __value, int __ndigit,
3802 -: 1054: int *__restrict __decpt, int *__restrict __sign,
3803 -: 1055: char *__restrict __buf, size_t __len)
3804 -: 1056: __THROW __nonnull ((3, 4, 5));
3805 -: 1057:#endif /* misc */
3806 -: 1058:
3807 -: 1059:
3808 -: 1060:/* Return the length of the multibyte character
3809 -: 1061: in S, which is no longer than N. */
3810 -: 1062:extern int mblen (const char *__s, size_t __n) __THROW;
3811 -: 1063:/* Return the length of the given multibyte character,
3812 -: 1064: putting its `wchar_t' representation in *PWC. */
3813 -: 1065:extern int mbtowc (wchar_t *__restrict __pwc,
3814 -: 1066: const char *__restrict __s, size_t __n) __THROW;
3815 -: 1067:/* Put the multibyte character represented
3816 -: 1068: by WCHAR in S, returning its length. */
3817 -: 1069:extern int wctomb (char *__s, wchar_t __wchar) __THROW;
3818 -: 1070:
3819 -: 1071:
3820 -: 1072:/* Convert a multibyte string to a wide char string. */
3821 -: 1073:extern size_t mbstowcs (wchar_t *__restrict __pwcs,
3822 -: 1074: const char *__restrict __s, size_t __n) __THROW
3823 -: 1075: __attr_access ((__read_only__, 2));
3824 -: 1076:/* Convert a wide char string to multibyte string. */
3825 -: 1077:extern size_t wcstombs (char *__restrict __s,
3826 -: 1078: const wchar_t *__restrict __pwcs, size_t __n)
3827 -: 1079: __THROW
3828 -: 1080: __fortified_attr_access (__write_only__, 1, 3)
3829 -: 1081: __attr_access ((__read_only__, 2));
3830 -: 1082:
3831 -: 1083:#ifdef __USE_MISC
3832 -: 1084:/* Determine whether the string value of RESPONSE matches the affirmation
3833 -: 1085: or negative response expression as specified by the LC_MESSAGES category
3834 -: 1086: in the program's current locale. Returns 1 if affirmative, 0 if
3835 -: 1087: negative, and -1 if not matching. */
3836 -: 1088:extern int rpmatch (const char *__response) __THROW __nonnull ((1)) __wur;
3837 -: 1089:#endif
3838 -: 1090:
3839 -: 1091:
3840 -: 1092:#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
3841 -: 1093:/* Parse comma separated suboption from *OPTIONP and match against
3842 -: 1094: strings in TOKENS. If found return index and set *VALUEP to
3843 -: 1095: optional value introduced by an equal sign. If the suboption is
3844 -: 1096: not part of TOKENS return in *VALUEP beginning of unknown
3845 -: 1097: suboption. On exit *OPTIONP is set to the beginning of the next
3846 -: 1098: token or at the terminating NUL character. */
3847 -: 1099:extern int getsubopt (char **__restrict __optionp,
3848 -: 1100: char *const *__restrict __tokens,
3849 -: 1101: char **__restrict __valuep)
3850 -: 1102: __THROW __nonnull ((1, 2, 3)) __wur;
3851 -: 1103:#endif
3852 -: 1104:
3853 -: 1105:
3854 -: 1106:/* X/Open pseudo terminal handling. */
3855 -: 1107:
3856 -: 1108:#ifdef __USE_XOPEN2KXSI
3857 -: 1109:/* Return a master pseudo-terminal handle. */
3858 -: 1110:extern int posix_openpt (int __oflag) __wur;
3859 -: 1111:#endif
3860 -: 1112:
3861 -: 1113:#ifdef __USE_XOPEN_EXTENDED
3862 -: 1114:/* The next four functions all take a master pseudo-tty fd and
3863 -: 1115: perform an operation on the associated slave: */
3864 -: 1116:
3865 -: 1117:/* Chown the slave to the calling user. */
3866 -: 1118:extern int grantpt (int __fd) __THROW;
3867 -: 1119:
3868 -: 1120:/* Release an internal lock so the slave can be opened.
3869 -: 1121: Call after grantpt(). */
3870 -: 1122:extern int unlockpt (int __fd) __THROW;
3871 -: 1123:
3872 -: 1124:/* Return the pathname of the pseudo terminal slave associated with
3873 -: 1125: the master FD is open on, or NULL on errors.
3874 -: 1126: The returned storage is good until the next call to this function. */
3875 -: 1127:extern char *ptsname (int __fd) __THROW __wur;
3876 -: 1128:#endif
3877 -: 1129:
3878 -: 1130:#ifdef __USE_GNU
3879 -: 1131:/* Store at most BUFLEN characters of the pathname of the slave pseudo
3880 -: 1132: terminal associated with the master FD is open on in BUF.
3881 -: 1133: Return 0 on success, otherwise an error number. */
3882 -: 1134:extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
3883 -: 1135: __THROW __nonnull ((2)) __fortified_attr_access (__write_only__, 2, 3);
3884 -: 1136:
3885 -: 1137:/* Open a master pseudo terminal and return its file descriptor. */
3886 -: 1138:extern int getpt (void);
3887 -: 1139:#endif
3888 -: 1140:
3889 -: 1141:#ifdef __USE_MISC
3890 -: 1142:/* Put the 1 minute, 5 minute and 15 minute load averages into the first
3891 -: 1143: NELEM elements of LOADAVG. Return the number written (never more than
3892 -: 1144: three, but may be less than NELEM), or -1 if an error occurred. */
3893 -: 1145:extern int getloadavg (double __loadavg[], int __nelem)
3894 -: 1146: __THROW __nonnull ((1));
3895 -: 1147:#endif
3896 -: 1148:
3897 -: 1149:#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K
3898 -: 1150:/* Return the index into the active-logins file (utmp) for
3899 -: 1151: the controlling terminal. */
3900 -: 1152:extern int ttyslot (void) __THROW;
3901 -: 1153:#endif
3902 -: 1154:
3903 -: 1155:#include <bits/stdlib-float.h>
3904 -: 1156:
3905 -: 1157:/* Define some macros helping to catch buffer overflows. */
3906 -: 1158:#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
3907 -: 1159:# include <bits/stdlib.h>
3908 -: 1160:#endif
3909 -: 1161:
3910 -: 1162:#include <bits/floatn.h>
3911 -: 1163:#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
3912 -: 1164:# include <bits/stdlib-ldbl.h>
3913 -: 1165:#endif
3914 -: 1166:
3915 -: 1167:__END_DECLS
3916 -: 1168:
3917 -: 1169:#endif /* stdlib.h */