mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
Fix nxstyle to mksyscall.c
This commit is contained in:
committed by
Xiang Xiao
parent
bdf871a214
commit
d9472bb625
+40
-14
@@ -67,7 +67,8 @@ static bool is_vararg(const char *type, int ndx, int nparms)
|
||||
{
|
||||
if (ndx != (nparms - 1))
|
||||
{
|
||||
fprintf(stderr, "%d: ... is not the last in the argument list\n", g_lineno);
|
||||
fprintf(stderr, "%d: ... is not the last in the argument list\n",
|
||||
g_lineno);
|
||||
exit(11);
|
||||
}
|
||||
else if (nparms < 2)
|
||||
@@ -114,7 +115,9 @@ static void print_formalparm(FILE *stream, const char *argtype, int parmno)
|
||||
const char *part2;
|
||||
int len;
|
||||
|
||||
/* Function pointers and array formal parameter types are a little more work */
|
||||
/* Function pointers and array formal parameter types are a little more
|
||||
* work
|
||||
*/
|
||||
|
||||
if ((part2 = check_funcptr(argtype)) != NULL ||
|
||||
(part2 = check_array(argtype)) != NULL)
|
||||
@@ -139,6 +142,7 @@ static void get_formalparmtype(const char *arg, char *formal)
|
||||
{
|
||||
*formal++ = *arg++;
|
||||
}
|
||||
|
||||
*formal = '\0';
|
||||
}
|
||||
|
||||
@@ -168,6 +172,7 @@ static void get_actualparmtype(const char *arg, char *actual)
|
||||
{
|
||||
*actual++ = *pstart++;
|
||||
}
|
||||
|
||||
*actual = '\0';
|
||||
}
|
||||
|
||||
@@ -184,7 +189,9 @@ static void get_fieldname(const char *arg, char *fieldname)
|
||||
pstart = strchr(pactual, '|');
|
||||
if (pstart)
|
||||
{
|
||||
/* The fieldname is everything past the second '|' to the end of the string */
|
||||
/* The fieldname is everything past the second '|' to the end of
|
||||
* the string
|
||||
*/
|
||||
|
||||
pstart++;
|
||||
strncpy(fieldname, pstart, MAX_PARMSIZE);
|
||||
@@ -210,6 +217,7 @@ static FILE *open_proxy(void)
|
||||
fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno));
|
||||
exit(10);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
@@ -225,7 +233,8 @@ static void generate_proxy(int nparms)
|
||||
|
||||
/* Generate "up-front" information, include correct header files */
|
||||
|
||||
fprintf(stream, "/* Auto-generated %s proxy file -- do not edit */\n\n", g_parm[NAME_INDEX]);
|
||||
fprintf(stream, "/* Auto-generated %s proxy file -- do not edit */\n\n",
|
||||
g_parm[NAME_INDEX]);
|
||||
fprintf(stream, "#include <nuttx/config.h>\n");
|
||||
|
||||
/* Suppress "'noreturn' function does return" warnings. */
|
||||
@@ -261,7 +270,9 @@ static void generate_proxy(int nparms)
|
||||
fprintf(stream, "#if %s\n\n", g_parm[COND_INDEX]);
|
||||
}
|
||||
|
||||
/* Generate the function definition that matches standard function prototype */
|
||||
/* Generate the function definition that matches standard function
|
||||
* prototype
|
||||
*/
|
||||
|
||||
fprintf(stream, "%s %s(", g_parm[RETTYPE_INDEX], g_parm[NAME_INDEX]);
|
||||
|
||||
@@ -307,16 +318,19 @@ static void generate_proxy(int nparms)
|
||||
if (nparms < 7)
|
||||
{
|
||||
fprintf(stream, " va_list ap;\n");
|
||||
|
||||
for (i = nparms; i < 7; i++)
|
||||
{
|
||||
fprintf(stream, " uintptr_t parm%d;\n", i);
|
||||
}
|
||||
|
||||
fprintf(stream, "\n va_start(ap, parm%d);\n", nparms - 1);
|
||||
|
||||
for (i = nparms; i < 7; i++)
|
||||
{
|
||||
fprintf(stream, " parm%d = va_arg(ap, uintptr_t);\n", i);
|
||||
}
|
||||
|
||||
fprintf(stream, " va_end(ap);\n\n");
|
||||
}
|
||||
}
|
||||
@@ -336,7 +350,8 @@ static void generate_proxy(int nparms)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stream, " return (%s)sys_call%d(", g_parm[RETTYPE_INDEX], nactual);
|
||||
fprintf(stream, " return (%s)sys_call%d(", g_parm[RETTYPE_INDEX],
|
||||
nactual);
|
||||
}
|
||||
|
||||
/* Create the parameter list with the matching types. The first parameter
|
||||
@@ -385,9 +400,11 @@ static FILE *open_stub(void)
|
||||
g_stubstream = fopen("STUB.h", "w");
|
||||
if (g_stubstream == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to open STUB.h: %s\n", strerror(errno));
|
||||
fprintf(stderr, "Failed to open STUB.h: %s\n",
|
||||
strerror(errno));
|
||||
exit(9);
|
||||
}
|
||||
|
||||
fprintf(g_stubstream, "/* Autogenerated STUB header file */\n\n");
|
||||
fprintf(g_stubstream, "#ifndef __STUB_H\n");
|
||||
fprintf(g_stubstream, "#define __STUB_H\n\n");
|
||||
@@ -404,11 +421,14 @@ static FILE *open_stub(void)
|
||||
filename[MAX_PARMSIZE + 7] = '\0';
|
||||
|
||||
stream = fopen(filename, "w");
|
||||
|
||||
if (stream == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno));
|
||||
fprintf(stderr, "Failed to open %s: %s\n", filename,
|
||||
strerror(errno));
|
||||
exit(9);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +451,8 @@ static void generate_stub(int nparms)
|
||||
|
||||
/* Generate "up-front" information, include correct header files */
|
||||
|
||||
fprintf(stream, "/* Auto-generated %s stub file -- do not edit */\n\n", g_parm[0]);
|
||||
fprintf(stream, "/* Auto-generated %s stub file -- do not edit */\n\n",
|
||||
g_parm[0]);
|
||||
fprintf(stream, "#include <nuttx/config.h>\n");
|
||||
fprintf(stream, "#include <stdint.h>\n");
|
||||
|
||||
@@ -447,7 +468,9 @@ static void generate_stub(int nparms)
|
||||
fprintf(stream, "#if %s\n\n", g_parm[COND_INDEX]);
|
||||
}
|
||||
|
||||
/* Generate the function definition that matches standard function prototype */
|
||||
/* Generate the function definition that matches standard function
|
||||
* prototype
|
||||
*/
|
||||
|
||||
if (g_inline)
|
||||
{
|
||||
@@ -499,9 +522,10 @@ static void generate_stub(int nparms)
|
||||
for (i = 0; i < nparms; i++)
|
||||
{
|
||||
/* Get the formal type of the parameter, and get the type that we
|
||||
* actually have to cast to. For example for a formal type like 'int parm[]'
|
||||
* we have to cast the actual parameter to 'int*'. The worst is a union
|
||||
* type like 'union sigval' where we have to cast to (union sigval)((FAR void *)parm)
|
||||
* actually have to cast to. For example for a formal type like
|
||||
* 'int parm[]' we have to cast the actual parameter to 'int*'.
|
||||
* The worst is a union type like 'union sigval' where we have to
|
||||
* cast to (union sigval)((FAR void *)parm)
|
||||
* -- Yech.
|
||||
*/
|
||||
|
||||
@@ -529,7 +553,8 @@ static void generate_stub(int nparms)
|
||||
{
|
||||
if (is_union(formal))
|
||||
{
|
||||
fprintf(stream, ", (%s)((%s)parm%d)", formal, actual, i+1);
|
||||
fprintf(stream, ", (%s)((%s)parm%d)", formal, actual,
|
||||
i + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -567,6 +592,7 @@ static void generate_stub(int nparms)
|
||||
{
|
||||
fprintf(stream, "#endif /* %s */\n", g_parm[COND_INDEX]);
|
||||
}
|
||||
|
||||
stub_close(stream);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user