Commit 85eda648 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Import of changes for defmod 6.01 from OSLib.

Admin:
  Tested against ToolAction.

Version 6.01. Tagged as 'defmod-6_01'
parent f4b50277
...@@ -82,7 +82,10 @@ LIBS=${CLIB} ...@@ -82,7 +82,10 @@ LIBS=${CLIB}
.SUFFIXES: .o .c .y .s .SUFFIXES: .o .c .y .s
.c.o:; ${CC} ${CCFLAGS} -o $@ $< .c.o:; ${CC} ${CCFLAGS} -o $@ $<
.s.o:; ${AS} ${ASFLAGS} -o $@ $< .s.o:; ${AS} ${ASFLAGS} -o $@ $<
.y.c:; ${YACC} ${YACCFLAGS} -o $@ $<
c.defmod: sources.y.defmod
${YACC} ${YACCFLAGS} -o $@ sources.y.defmod
o.defmod: c.defmod o.defmod: c.defmod
${CC} ${CCFLAGS} ${YACCDEFS} -o $@ c.defmod ${CC} ${CCFLAGS} ${YACCDEFS} -o $@ c.defmod
......
/* (5.50) /* (6.01)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* *
*/ */
#define Module_MajorVersion_CMHG 5.50 #define Module_MajorVersion_CMHG 6.01
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Nov 1999 #define Module_Date_CMHG 18 Apr 2000
#define Module_MajorVersion "5.50" #define Module_MajorVersion "6.01"
#define Module_Version 550 #define Module_Version 601
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "29 Nov 1999" #define Module_Date "18 Apr 2000"
#define Module_FullVersion "5.50" #define Module_FullVersion "6.01"
/*asmhelp.c - output a help file given a module defn*/ /*asmhelp.c - output a help file given a module defn*/
/*OSLib---efficient, type-safe, transparent, extensible, /*OSLib---efficient, type-safe, transparent, extensible,\n"
register-safe A P I coverage of RISC O S*/ register-safe A P I coverage of RISC O S*/
/*Copyright 1994 Jonathan Coxhead*/ /*Copyright 1994 Jonathan Coxhead*/
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <kernel.h> /* TV 980115 */
#include "os.h" #include "os.h"
...@@ -120,6 +121,6 @@ os_error *asmhelp_output ...@@ -120,6 +121,6 @@ os_error *asmhelp_output
} } } }
finish: finish:
if (rc < 0) error = _kernel_last_oserror (); if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 980115 */
return error; return error;
} }
/*cheader.c - output a cheader file given a module defn*/ /*cheader.c - output a cheader file given a module defn*/
/*OSLib---efficient, type-safe, transparent, extensible, /*OSLib---efficient, type-safe, transparent, extensible,\n"
register-safe A P I coverage of RISC O S*/ register-safe A P I coverage of RISC O S*/
/*Copyright 1994 Jonathan Coxhead*/ /*Copyright 1994 Jonathan Coxhead*/
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <kernel.h> /* TV 980115 */
#include "macros.h" #include "macros.h"
#include "os.h" #include "os.h"
...@@ -35,10 +36,10 @@ ...@@ -35,10 +36,10 @@
static int strsplen static int strsplen
( (
const char *s char *s
) )
{ {
const char *p = s; char *p = s;
while (*p != '\0' && *p != ' ') p++; while (*p != '\0' && *p != ' ') p++;
...@@ -204,6 +205,14 @@ static int Print_Decl ...@@ -204,6 +205,14 @@ static int Print_Decl
) )
goto finish; goto finish;
if (t->tag == def_TYPE_STRUCT && t->data AS list.base)
{
char base [def_ID_LIMIT + 1];
def_as_macro (base, t->data AS list.base->data AS id);
if ((rc = fprintf (file, "%s_MEMBERS%s\n%*s ",
base, var? " \\": "", 3*(nest + 1), "")) < 0)
goto finish;
}
for (i = 0; i < t->data AS list.count; i++) for (i = 0; i < t->data AS list.count; i++)
{ {
if (i == t->data AS list.count - 1 && if (i == t->data AS list.count - 1 &&
...@@ -725,9 +734,46 @@ os_error *cheader_output ...@@ -725,9 +734,46 @@ os_error *cheader_output
} }
} }
if ((rc = Print_Decl (file, t, c_name, NULL, FALSE, 0)) < 0) if (t->tag == def_TYPE_STRUCT && t->data AS list.ellipsis &&
goto finish; t->data AS list.count > 1)
{
char macro_name [def_ID_LIMIT + 1];
int i;
def_as_macro (macro_name, type);
if ((rc = fprintf (file, "#define %s_MEMBERS",
macro_name)) < 0)
goto finish;
if (t->data AS list.base)
{
char base [def_ID_LIMIT + 1];
def_as_macro (base, t->data AS list.base->data AS id);
if ((rc = fprintf (file, " \\\n %s_MEMBERS", base)) < 0)
goto finish;
}
for (i = 0; i < t->data AS list.count - 1; i++)
{
if ((rc = fprintf (file, " \\\n ")) < 0)
goto finish;
if ((rc = Print_Decl (file, t->data AS list.members [i],
NULL, t->data AS list.members [i]->name, TRUE, 0)) < 0)
goto finish;
if ((rc = fprintf (file, ";")) < 0)
goto finish;
}
if ((rc = fprintf (file,
"\n\nstruct %s\n { %s_MEMBERS\n ",
c_name, macro_name)) < 0)
goto finish;
if ((rc = Print_Decl (file, t->data AS list.members [i],
NULL, t->data AS list.members [i]->name, TRUE, 0)) < 0)
goto finish;
if ((rc = fprintf (file, " [UNKNOWN];\n }")) < 0)
goto finish;
}
else
if ((rc = Print_Decl (file, t, c_name, NULL, FALSE, 0)) < 0)
goto finish;
if ((rc = fprintf (file, ";\n\n")) < 0) if ((rc = fprintf (file, ";\n\n")) < 0)
goto finish; goto finish;
...@@ -738,39 +784,46 @@ os_error *cheader_output ...@@ -738,39 +784,46 @@ os_error *cheader_output
t->data AS list.members t->data AS list.members
[t->data AS list.count - 1]->value != def_VALUE_VARIABLE) [t->data AS list.count - 1]->value != def_VALUE_VARIABLE)
{ {
int i; char macro_name [def_ID_LIMIT + 1];
int i = t->data AS list.count - 1;
char *suffix; char *suffix;
def_as_macro (c_name, type); def_as_macro (macro_name, type);
if ((rc = fprintf (file, "#define %s(N) \\\n ", if ((rc = fprintf (file, "#define %s(N) \\\n ",
c_name)) < 0) macro_name)) < 0)
goto finish; goto finish;
if ((rc = Print_Decl (file, t, NULL, NULL, TRUE, 1)) < 0) if ((rc = fprintf (file, "struct \\\n { ")) < 0)
goto finish;
if (t->data AS list.count > 1)
if ((rc = fprintf (file, "%s_MEMBERS \\\n ",
macro_name)) < 0)
goto finish;
if ((rc = Print_Decl (file, t->data AS list.members [i],
NULL, t->data AS list.members [i]->name, TRUE, 0)) < 0)
goto finish;
if ((rc = fprintf (file, " [N]; \\\n }")) < 0)
goto finish; goto finish;
if ((rc = fprintf (file, "\n\n")) < 0) if ((rc = fprintf (file, "\n\n")) < 0)
goto finish; goto finish;
/*Also emit a macro to calculate the size of such a type.*/ /*Also emit a macro to calculate the size of such a type.*/
if ((suffix = strchr (c_name, '_')) != NULL) if ((suffix = strchr (macro_name, '_')) != NULL)
{ {
if ((rc = fprintf (file, if ((rc = fprintf (file,
"#define %.*s_SIZEOF%s(N) \\\n (", "#define %.*s_SIZEOF%s(N) \\\n (",
suffix - c_name, c_name, suffix)) < 0) suffix - macro_name, macro_name, suffix)) < 0)
goto finish; goto finish;
} }
else else
{ {
if ((rc = fprintf (file, "#define %s_SIZEOF(N) (", if ((rc = fprintf (file, "#define %s_SIZEOF(N) (",
c_name)) < 0) macro_name)) < 0)
goto finish; goto finish;
} }
/*We need the extern form for the rest.*/
def_as_extern (c_name, type);
/*This calculates an offset (using |offsetof|).*/ /*This calculates an offset (using |offsetof|).*/
if ((i = t->data AS list.count) > 1) if ((i = t->data AS list.count) > 1)
{ {
...@@ -876,23 +929,13 @@ os_error *cheader_output ...@@ -876,23 +929,13 @@ os_error *cheader_output
break; break;
case def_TYPE_BITS: case def_TYPE_BITS:
#if 1 /* RS Thursday, 1st April 1999 */
if ((rc = fprintf (file, "0x%X", c->value)) < 0)
goto finish;
#else /* JRC -- originally... */
if ((rc = fprintf (file, "0x%Xu", c->value)) < 0) if ((rc = fprintf (file, "0x%Xu", c->value)) < 0)
goto finish; goto finish;
#endif
break; break;
case def_TYPE_BYTES: case def_TYPE_BYTES:
#if 1 /* RS Thursday, 1st April 1999 */
if ((rc = fprintf (file, "((bytes) 0x%X)", c->value)) < 0)
goto finish;
#else /* JRC -- originally... */
if ((rc = fprintf (file, "((bytes) 0x%Xu)", c->value)) < 0) if ((rc = fprintf (file, "((bytes) 0x%Xu)", c->value)) < 0)
goto finish; goto finish;
#endif
break; break;
case def_TYPE_BOOL: case def_TYPE_BOOL:
...@@ -908,13 +951,8 @@ os_error *cheader_output ...@@ -908,13 +951,8 @@ os_error *cheader_output
0)) < 0) 0)) < 0)
goto finish; goto finish;
#if 1 /* RS Thursday, 1st April 1999 */
if ((rc = fprintf (file, ") 0x%x)", c->value)) < 0)
/*was %d in either case 19th Apr 1995*/
#else /* JRC -- originally... */
if ((rc = fprintf (file, ") 0x%Xu)", c->value)) < 0) if ((rc = fprintf (file, ") 0x%Xu)", c->value)) < 0)
/*was %d in either case 19th Apr 1995*/ /*was %d in either case 19th Apr 1995*/
#endif
goto finish; goto finish;
break; break;
} }
...@@ -1551,6 +1589,6 @@ os_error *cheader_output ...@@ -1551,6 +1589,6 @@ os_error *cheader_output
goto finish; goto finish;
finish: finish:
if (rc < 0) error = _kernel_last_oserror (); if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 980115 */
return error; return error;
} }
/*chelp.c - output an help file given a module defn*/ /*chelp.c - output an help file given a module defn*/
/*OSLib---efficient, type-safe, transparent, extensible, /*OSLib---efficient, type-safe, transparent, extensible,\n"
register-safe A P I coverage of RISC O S*/ register-safe A P I coverage of RISC O S*/
/*Copyright 1994 Jonathan Coxhead*/ /*Copyright 1994 Jonathan Coxhead*/
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <kernel.h> /* TV 980115 */
#include "macros.h" #include "macros.h"
#include "os.h" #include "os.h"
...@@ -586,6 +587,6 @@ os_error *chelp_output ...@@ -586,6 +587,6 @@ os_error *chelp_output
} }
finish: finish:
if (rc < 0) error = _kernel_last_oserror (); if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 980115 */
return error; return error;
} }
/*cstrong.c - output an help file given a module defn*/ /*cstrong.c - output an help file given a module defn*/
/*OSLib---efficient, type-safe, transparent, extensible, /*OSLib---efficient, type-safe, transparent, extensible,\n"
register-safe A P I coverage of RISC O S*/ register-safe A P I coverage of RISC O S*/
/*Copyright 1994 Jonathan Coxhead*/ /*Copyright 1994 Jonathan Coxhead*/
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <kernel.h> /* TV 990127 */
/*From OSLib*/ /*From OSLib*/
#include "macros.h" #include "macros.h"
...@@ -40,9 +41,7 @@ ...@@ -40,9 +41,7 @@
#include "def.h" #include "def.h"
#include "cstrong.h" #include "cstrong.h"
/*
#define TRUNCATION_LIMIT 19 #define TRUNCATION_LIMIT 19
*/
typedef typedef
struct cstrong_entry struct cstrong_entry
...@@ -244,6 +243,17 @@ static int Print_Decl ...@@ -244,6 +243,17 @@ static int Print_Decl
) )
goto finish; goto finish;
if (t->tag == def_TYPE_STRUCT && t->data AS list.base)
{
char base [def_ID_LIMIT + 1];
def_as_macro (base, t->data AS list.base->data AS id);
if ((rc = fprintf (file, "%s_MEMBERS\n%*s ",
base, 21 + 3*nest, " ")) < 0)
goto finish;
}
for (i = 0; i < t->data AS list.count; i++) for (i = 0; i < t->data AS list.count; i++)
{ {
if (i == t->data AS list.count - 1 && if (i == t->data AS list.count - 1 &&
...@@ -411,47 +421,24 @@ os_error *cstrong_output ...@@ -411,47 +421,24 @@ os_error *cstrong_output
if (t == NULL || t->tag == def_TYPE_ABSTRACT) if (t == NULL || t->tag == def_TYPE_ABSTRACT)
{ {
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf (help_data, if ((rc = fprintf (help_data,
"%s\n" "%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n" "Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: typedef struct {...} *%s;", "Declaration: typedef struct {...} *%s;",
c_name, c_title, c_title, c_name)) < 0) c_name, c_title, c_title, c_name)) < 0)
goto finish;
#else
if ((rc = fprintf (help_data,
"%s\n"
"Defined in: <%s>.h\n"
"Declaration: typedef struct {...} *%s;",
c_name, c_title, c_name)) < 0)
goto finish; goto finish;
#endif
} }
else else
{ {
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf (help_data, if ((rc = fprintf (help_data,
"%s\n" "%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n" "Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: typedef%s", "Declaration: typedef%s",
c_name, c_name,
c_title, c_title, c_title, c_title,
t->tag == def_TYPE_STRUCT || t->tag == def_TYPE_UNION? t->tag == def_TYPE_STRUCT || t->tag == def_TYPE_UNION?
"\n ": " ")) < 0) "\n ": " ")) < 0)
goto finish; goto finish;
#else
if ((rc = fprintf (help_data,
"%s\n"
"Defined in: <%s>.h\n"
"Declaration: typedef%s",
c_name,
c_title,
t->tag == def_TYPE_STRUCT || t->tag == def_TYPE_UNION?
"\n ": " ")) < 0)
goto finish;
#endif
if ((rc = Print_Decl (c_title, help_data, t, NULL, c_name, FALSE, if ((rc = Print_Decl (c_title, help_data, t, NULL, c_name, FALSE,
0)) < 0) 0)) < 0)
...@@ -536,25 +523,14 @@ os_error *cstrong_output ...@@ -536,25 +523,14 @@ os_error *cstrong_output
def_as_macro (c_name, cnst); def_as_macro (c_name, cnst);
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf if ((rc = fprintf
( help_data, ( help_data,
"%s\n" "%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n" "Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: #define %s ", "Declaration: #define %s ",
c_name, c_title, c_title, c_name c_name, c_title, c_title, c_name
)) < 0) )) < 0)
goto finish; goto finish;
#else
if ((rc = fprintf
( help_data,
"%s\n"
"Defined in: <%s>.h\n"
"Declaration: #define %s ",
c_name, c_title, c_name
)) < 0)
goto finish;
#endif
switch (c->type->tag) switch (c->type->tag)
{ {
...@@ -670,22 +646,12 @@ os_error *cstrong_output ...@@ -670,22 +646,12 @@ os_error *cstrong_output
first = TRUE; first = TRUE;
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf (help_data, if ((rc = fprintf (help_data,
"%s\n" "%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n" "Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: extern ", "Declaration: extern ",
c_name, c_title, c_title)) < 0) c_name, c_title, c_title)) < 0)
goto finish; goto finish;
#else
if ((rc = fprintf (help_data,
"%s\n"
"Defined in: <%s>.h\n"
"Declaration: extern ",
c_name, c_title)) < 0)
goto finish;
#endif
if (!nonx) if (!nonx)
{ {
...@@ -968,13 +934,15 @@ os_error *cstrong_output ...@@ -968,13 +934,15 @@ os_error *cstrong_output
goto finish; goto finish;
finish: finish:
if (help_data != NULL && fclose (help_data) != 0) rc = -1; if (help_data != NULL)
fclose (help_data);
if (index != NULL && fclose (index) != 0) rc = -1; if (index != NULL)
fclose (index);
for (i = 0; i < Entry_Count; i++) for (i = 0; i < Entry_Count; i++)
free (Strings [i]); free (Strings [i]);
if (rc < 0) error = _kernel_last_oserror (); if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 990127 */
return error; return error;
} }
/*def.c - support routines*/ /*def.c - support routines*/
/*OSLib---efficient, type-safe, transparent, extensible, /*OSLib---efficient, type-safe, transparent, extensible,\n"
register-safe A P I coverage of RISC O S*/ register-safe A P I coverage of RISC O S*/
/*Copyright 1994 Jonathan Coxhead*/ /*Copyright 1994 Jonathan Coxhead*/
...@@ -56,7 +56,7 @@ typedef struct String {char s [def_ID_LIMIT + 1];} String; ...@@ -56,7 +56,7 @@ typedef struct String {char s [def_ID_LIMIT + 1];} String;
void def_as_extern void def_as_extern
( (
char *s0, char *s0,
const char *s1 char *s1
) )
{ {
enum {MODULE, NAME} state = MODULE; enum {MODULE, NAME} state = MODULE;
...@@ -106,7 +106,7 @@ void def_as_extern ...@@ -106,7 +106,7 @@ void def_as_extern
void def_as_macro void def_as_macro
( (
char *s0,