| 552 | } |
| 553 | |
| 554 | static 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 "); |
no test coverage detected