MCPcopy Create free account
hub / github.com/apache/nuttx / generate_wrapper

Function generate_wrapper

tools/mksyscall.c:554–845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554static void generate_wrapper(int nfixed, int nparms)
555{
556 FILE *stream = open_wrapper();
557 char formal[MAX_PARMSIZE];
558 char actual[MAX_PARMSIZE];
559 char fieldname[MAX_PARMSIZE];
560 int i = 0;
561
562 /* Generate "up-front" information, include correct header files */
563
564 fprintf(stream, "/* Auto-generated %s wrap file -- do not edit */\n\n",
565 g_parm[NAME_INDEX]);
566 fprintf(stream, "#include <nuttx/config.h>\n");
567 fprintf(stream, "#include <nuttx/sched_note.h>\n");
568 fprintf(stream, "#include <stdint.h>\n");
569
570 /* Suppress "'noreturn' function does return" warnings. */
571
572 fprintf(stream, "#include <nuttx/compiler.h>\n");
573 fprintf(stream, "#undef noreturn_function\n");
574 fprintf(stream, "#define noreturn_function\n");
575
576 /* CONFIG_LIB_SYSCALL must be defined to get syscall number */
577
578 fprintf(stream, "#undef CONFIG_LIB_SYSCALL\n");
579 fprintf(stream, "#define CONFIG_LIB_SYSCALL\n");
580 fprintf(stream, "#include <syscall.h>\n");
581
582 /* Does this function have a variable number of parameters? If so then the
583 * final parameter type will be encoded as "..."
584 */
585
586 if (nfixed != nparms)
587 {
588 fprintf(stream, "#include <stdarg.h>\n");
589 }
590
591 if (strlen(g_parm[HEADER_INDEX]) > 0)
592 {
593 fprintf(stream, "#include <%s>\n", g_parm[HEADER_INDEX]);
594 }
595
596 /* Define macros to get wrapper symbol */
597
598 fprintf(stream, "#include <nuttx/arch.h>\n\n");
599
600 if (g_parm[COND_INDEX][0] != '\0')
601 {
602 fprintf(stream, "#if %s\n\n", g_parm[COND_INDEX]);
603 }
604
605 /* Generate the wrapper function definition that matches standard function
606 * prototype
607 */
608
609 if (strcmp(g_parm[RETTYPE_INDEX], "noreturn") == 0)
610 {
611 fprintf(stream, "void ");

Callers 1

mainFunction · 0.85

Calls 10

open_wrapperFunction · 0.85
fprintfFunction · 0.85
get_formalparmtypeFunction · 0.85
print_formalparmFunction · 0.85
get_actualparmtypeFunction · 0.85
is_unionFunction · 0.85
get_fieldnameFunction · 0.85
fcloseFunction · 0.85
strlenFunction · 0.50
strcmpFunction · 0.50

Tested by

no test coverage detected