| 186 | } |
| 187 | |
| 188 | static void generate_proxy(int nfixed, int nparms) |
| 189 | { |
| 190 | FILE *stream = open_proxy(); |
| 191 | char formal[MAX_PARMSIZE]; |
| 192 | char actual[MAX_PARMSIZE]; |
| 193 | char fieldname[MAX_PARMSIZE]; |
| 194 | int i = 0; |
| 195 | |
| 196 | /* Generate "up-front" information, include correct header files */ |
| 197 | |
| 198 | fprintf(stream, "/* Auto-generated %s proxy file -- do not edit */\n\n", |
| 199 | g_parm[NAME_INDEX]); |
| 200 | fprintf(stream, "#include <nuttx/config.h>\n"); |
| 201 | |
| 202 | /* Does this function have a variable number of parameters? If so then the |
| 203 | * final parameter type will be encoded as "..." |
| 204 | */ |
| 205 | |
| 206 | if (nfixed != nparms) |
| 207 | { |
| 208 | fprintf(stream, "#include <stdarg.h>\n"); |
| 209 | } |
| 210 | |
| 211 | if (strlen(g_parm[HEADER_INDEX]) > 0) |
| 212 | { |
| 213 | fprintf(stream, "#include <%s>\n", g_parm[HEADER_INDEX]); |
| 214 | } |
| 215 | |
| 216 | fprintf(stream, "#include <syscall.h>\n\n"); |
| 217 | |
| 218 | if (g_parm[COND_INDEX][0] != '\0') |
| 219 | { |
| 220 | fprintf(stream, "#if %s\n\n", g_parm[COND_INDEX]); |
| 221 | } |
| 222 | |
| 223 | /* Generate the function definition that matches standard function |
| 224 | * prototype |
| 225 | */ |
| 226 | |
| 227 | if (strcmp(g_parm[RETTYPE_INDEX], "noreturn") == 0) |
| 228 | { |
| 229 | fprintf(stream, "void "); |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | fprintf(stream, "%s ", g_parm[RETTYPE_INDEX]); |
| 234 | } |
| 235 | |
| 236 | fprintf(stream, "%s(", g_parm[NAME_INDEX]); |
| 237 | |
| 238 | /* Generate the formal parameter list */ |
| 239 | |
| 240 | if (nparms <= 0) |
| 241 | { |
| 242 | fprintf(stream, "void"); |
| 243 | } |
| 244 | else |
| 245 | { |
no test coverage detected