• Home
  • Raw
  • Download

Lines Matching +full:n +full:-

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
44 if (str[n1 - i - 1] != suffix[n2 - i - 1]) in str_has_suffix()
54 strncpy(name, basename(file), MAX_OBJ_NAME_LEN - 1); in get_obj_name()
55 name[MAX_OBJ_NAME_LEN - 1] = '\0'; in get_obj_name()
57 name[strlen(name) - 2] = '\0'; in get_obj_name()
100 const char *sec_name = btf__name_by_offset(btf, sec->name_off); in codegen_datasec_def()
120 printf(" struct %s__%s {\n", obj_name, sec_ident); in codegen_datasec_def()
122 const struct btf_type *var = btf__type_by_id(btf, sec_var->type); in codegen_datasec_def()
123 const char *var_name = btf__name_by_offset(btf, var->name_off); in codegen_datasec_def()
129 int need_off = sec_var->offset, align_off, align; in codegen_datasec_def()
130 __u32 var_type_id = var->type; in codegen_datasec_def()
133 p_err("Something is wrong for %s's variable #%d: need offset %d, already at %d.\n", in codegen_datasec_def()
135 return -EINVAL; in codegen_datasec_def()
138 align = btf__align_of(btf, var->type); in codegen_datasec_def()
142 return -EINVAL; in codegen_datasec_def()
144 /* Assume 32-bit architectures when generating data section in codegen_datasec_def()
147 * conservative and assume 32-bit one to ensure enough padding in codegen_datasec_def()
149 * still work correctly for 64-bit architectures, because in in codegen_datasec_def()
151 * which on 64-bit architectures is not strictly necessary and in codegen_datasec_def()
152 * would be handled by natural 8-byte alignment. But it still in codegen_datasec_def()
159 align_off = (off + align - 1) / align * align; in codegen_datasec_def()
161 printf("\t\tchar __pad%d[%d];\n", in codegen_datasec_def()
162 pad_cnt, need_off - off); in codegen_datasec_def()
171 strncat(var_ident, var_name, sizeof(var_ident) - 1); in codegen_datasec_def()
178 printf(";\n"); in codegen_datasec_def()
180 off = sec_var->offset + sec_var->size; in codegen_datasec_def()
182 printf(" } *%s;\n", sec_ident); in codegen_datasec_def()
189 int n = btf__get_nr_types(btf); in codegen_datasecs() local
197 for (i = 1; i <= n; i++) { in codegen_datasecs()
215 int skip_tabs = 0, n; in codegen() local
220 n = strlen(template); in codegen()
221 s = malloc(n + 1); in codegen()
223 exit(-1); in codegen()
231 } else if (c == '\n') { in codegen()
235 src - template - 1, template); in codegen()
237 exit(-1); in codegen()
243 for (n = skip_tabs; n > 0; n--, src++) { in codegen()
246 src - template - 1, template); in codegen()
248 exit(-1); in codegen()
252 end = strchrnul(src, '\n'); in codegen()
253 for (n = end - src; n > 0 && isspace(src[n - 1]); n--) in codegen()
255 memcpy(dst, src, n); in codegen()
256 dst += n; in codegen()
258 *dst++ = '\n'; in codegen()
265 n = vprintf(s, args); in codegen()
280 int fd, len, err = -1; in do_skeleton()
287 return -1; in do_skeleton()
293 return -1; in do_skeleton()
298 return -1; in do_skeleton()
305 return -1; in do_skeleton()
340 \n\ in do_skeleton()
341 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ \n\ in do_skeleton()
342 \n\ in do_skeleton()
343 /* THIS FILE IS AUTOGENERATED! */ \n\ in do_skeleton()
344 #ifndef %2$s \n\ in do_skeleton()
345 #define %2$s \n\ in do_skeleton()
346 \n\ in do_skeleton()
347 #include <stdlib.h> \n\ in do_skeleton()
348 #include <bpf/libbpf.h> \n\ in do_skeleton()
349 \n\ in do_skeleton()
350 struct %1$s { \n\ in do_skeleton()
351 struct bpf_object_skeleton *skeleton; \n\ in do_skeleton()
352 struct bpf_object *obj; \n\ in do_skeleton()
358 printf("\tstruct {\n"); in do_skeleton()
363 printf("\t\tstruct bpf_map *%s;\n", ident); in do_skeleton()
365 printf("\t} maps;\n"); in do_skeleton()
369 printf("\tstruct {\n"); in do_skeleton()
371 printf("\t\tstruct bpf_program *%s;\n", in do_skeleton()
374 printf("\t} progs;\n"); in do_skeleton()
375 printf("\tstruct {\n"); in do_skeleton()
377 printf("\t\tstruct bpf_link *%s;\n", in do_skeleton()
380 printf("\t} links;\n"); in do_skeleton()
391 \n\ in do_skeleton()
392 }; \n\ in do_skeleton()
393 \n\ in do_skeleton()
394 static void \n\ in do_skeleton()
395 %1$s__destroy(struct %1$s *obj) \n\ in do_skeleton()
396 { \n\ in do_skeleton()
397 if (!obj) \n\ in do_skeleton()
398 return; \n\ in do_skeleton()
399 if (obj->skeleton) \n\ in do_skeleton()
400 bpf_object__destroy_skeleton(obj->skeleton);\n\ in do_skeleton()
401 free(obj); \n\ in do_skeleton()
402 } \n\ in do_skeleton()
403 \n\ in do_skeleton()
404 static inline int \n\ in do_skeleton()
405 %1$s__create_skeleton(struct %1$s *obj); \n\ in do_skeleton()
406 \n\ in do_skeleton()
407 static inline struct %1$s * \n\ in do_skeleton()
408 %1$s__open_opts(const struct bpf_object_open_opts *opts) \n\ in do_skeleton()
409 { \n\ in do_skeleton()
410 struct %1$s *obj; \n\ in do_skeleton()
411 \n\ in do_skeleton()
412 obj = (struct %1$s *)calloc(1, sizeof(*obj)); \n\ in do_skeleton()
413 if (!obj) \n\ in do_skeleton()
414 return NULL; \n\ in do_skeleton()
415 if (%1$s__create_skeleton(obj)) \n\ in do_skeleton()
416 goto err; \n\ in do_skeleton()
417 if (bpf_object__open_skeleton(obj->skeleton, opts)) \n\ in do_skeleton()
418 goto err; \n\ in do_skeleton()
419 \n\ in do_skeleton()
420 return obj; \n\ in do_skeleton()
421 err: \n\ in do_skeleton()
422 %1$s__destroy(obj); \n\ in do_skeleton()
423 return NULL; \n\ in do_skeleton()
424 } \n\ in do_skeleton()
425 \n\ in do_skeleton()
426 static inline struct %1$s * \n\ in do_skeleton()
427 %1$s__open(void) \n\ in do_skeleton()
428 { \n\ in do_skeleton()
429 return %1$s__open_opts(NULL); \n\ in do_skeleton()
430 } \n\ in do_skeleton()
431 \n\ in do_skeleton()
432 static inline int \n\ in do_skeleton()
433 %1$s__load(struct %1$s *obj) \n\ in do_skeleton()
434 { \n\ in do_skeleton()
435 return bpf_object__load_skeleton(obj->skeleton); \n\ in do_skeleton()
436 } \n\ in do_skeleton()
437 \n\ in do_skeleton()
438 static inline struct %1$s * \n\ in do_skeleton()
439 %1$s__open_and_load(void) \n\ in do_skeleton()
440 { \n\ in do_skeleton()
441 struct %1$s *obj; \n\ in do_skeleton()
442 \n\ in do_skeleton()
443 obj = %1$s__open(); \n\ in do_skeleton()
444 if (!obj) \n\ in do_skeleton()
445 return NULL; \n\ in do_skeleton()
446 if (%1$s__load(obj)) { \n\ in do_skeleton()
447 %1$s__destroy(obj); \n\ in do_skeleton()
448 return NULL; \n\ in do_skeleton()
449 } \n\ in do_skeleton()
450 return obj; \n\ in do_skeleton()
451 } \n\ in do_skeleton()
452 \n\ in do_skeleton()
453 static inline int \n\ in do_skeleton()
454 %1$s__attach(struct %1$s *obj) \n\ in do_skeleton()
455 { \n\ in do_skeleton()
456 return bpf_object__attach_skeleton(obj->skeleton); \n\ in do_skeleton()
457 } \n\ in do_skeleton()
458 \n\ in do_skeleton()
459 static inline void \n\ in do_skeleton()
460 %1$s__detach(struct %1$s *obj) \n\ in do_skeleton()
461 { \n\ in do_skeleton()
462 return bpf_object__detach_skeleton(obj->skeleton); \n\ in do_skeleton()
463 } \n\ in do_skeleton()
469 \n\ in do_skeleton()
470 \n\ in do_skeleton()
471 static inline int \n\ in do_skeleton()
472 %1$s__create_skeleton(struct %1$s *obj) \n\ in do_skeleton()
473 { \n\ in do_skeleton()
474 struct bpf_object_skeleton *s; \n\ in do_skeleton()
475 \n\ in do_skeleton()
476 s = (struct bpf_object_skeleton *)calloc(1, sizeof(*s));\n\ in do_skeleton()
477 if (!s) \n\ in do_skeleton()
478 return -1; \n\ in do_skeleton()
479 obj->skeleton = s; \n\ in do_skeleton()
480 \n\ in do_skeleton()
481 s->sz = sizeof(*s); \n\ in do_skeleton()
482 s->name = \"%1$s\"; \n\ in do_skeleton()
483 s->obj = &obj->obj; \n\ in do_skeleton()
489 \n\ in do_skeleton()
490 \n\ in do_skeleton()
491 /* maps */ \n\ in do_skeleton()
492 s->map_cnt = %zu; \n\ in do_skeleton()
493 s->map_skel_sz = sizeof(*s->maps); \n\ in do_skeleton()
494 s->maps = (struct bpf_map_skeleton *)calloc(s->map_cnt, s->map_skel_sz);\n\ in do_skeleton()
495 if (!s->maps) \n\ in do_skeleton()
496 goto err; \n\ in do_skeleton()
508 \n\ in do_skeleton()
509 \n\ in do_skeleton()
510 s->maps[%zu].name = \"%s\"; \n\ in do_skeleton()
511 s->maps[%zu].map = &obj->maps.%s; \n\ in do_skeleton()
514 /* memory-mapped internal maps */ in do_skeleton()
516 (bpf_map__def(map)->map_flags & BPF_F_MMAPABLE)) { in do_skeleton()
517 printf("\ts->maps[%zu].mmaped = (void **)&obj->%s;\n", in do_skeleton()
525 \n\ in do_skeleton()
526 \n\ in do_skeleton()
527 /* programs */ \n\ in do_skeleton()
528 s->prog_cnt = %zu; \n\ in do_skeleton()
529 s->prog_skel_sz = sizeof(*s->progs); \n\ in do_skeleton()
530 s->progs = (struct bpf_prog_skeleton *)calloc(s->prog_cnt, s->prog_skel_sz);\n\ in do_skeleton()
531 if (!s->progs) \n\ in do_skeleton()
532 goto err; \n\ in do_skeleton()
539 \n\ in do_skeleton()
540 \n\ in do_skeleton()
541 s->progs[%1$zu].name = \"%2$s\"; \n\ in do_skeleton()
542 s->progs[%1$zu].prog = &obj->progs.%2$s;\n\ in do_skeleton()
543 s->progs[%1$zu].link = &obj->links.%2$s;\n\ in do_skeleton()
550 \n\ in do_skeleton()
551 \n\ in do_skeleton()
552 s->data_sz = %d; \n\ in do_skeleton()
553 s->data = (void *)\"\\ \n\ in do_skeleton()
563 printf("\\\n"); in do_skeleton()
573 \n\ in do_skeleton()
574 \"; \n\ in do_skeleton()
575 \n\ in do_skeleton()
576 return 0; \n\ in do_skeleton()
577 err: \n\ in do_skeleton()
578 bpf_object__destroy_skeleton(s); \n\ in do_skeleton()
579 return -1; \n\ in do_skeleton()
580 } \n\ in do_skeleton()
581 \n\ in do_skeleton()
582 #endif /* %s */ \n\ in do_skeleton()
602 "Usage: %1$s %2$s skeleton FILE\n" in do_help()
603 " %1$s %2$s help\n" in do_help()
604 "\n" in do_help()
605 " " HELP_SPEC_OPTIONS "\n" in do_help()