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}
.SUFFIXES: .o .c .y .s
.c.o:; ${CC} ${CCFLAGS} -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
${CC} ${CCFLAGS} ${YACCDEFS} -o $@ c.defmod
......
/* (5.50)
/* (6.01)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 5.50
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Nov 1999
#define Module_MajorVersion_CMHG 6.01
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Apr 2000
#define Module_MajorVersion "5.50"
#define Module_Version 550
#define Module_MinorVersion ""
#define Module_Date "29 Nov 1999"
#define Module_MajorVersion "6.01"
#define Module_Version 601
#define Module_MinorVersion ""
#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*/
/*OSLib---efficient, type-safe, transparent, extensible,
/*OSLib---efficient, type-safe, transparent, extensible,\n"
register-safe A P I coverage of RISC O S*/
/*Copyright 1994 Jonathan Coxhead*/
......@@ -23,6 +23,7 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <kernel.h> /* TV 980115 */
#include "os.h"
......@@ -120,6 +121,6 @@ os_error *asmhelp_output
} }
finish:
if (rc < 0) error = _kernel_last_oserror ();
if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 980115 */
return error;
}
/*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*/
/*Copyright 1994 Jonathan Coxhead*/
......@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <kernel.h> /* TV 980115 */
#include "macros.h"
#include "os.h"
......@@ -35,10 +36,10 @@
static int strsplen
(
const char *s
char *s
)
{
const char *p = s;
char *p = s;
while (*p != '\0' && *p != ' ') p++;
......@@ -204,6 +205,14 @@ static int Print_Decl
)
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++)
{
if (i == t->data AS list.count - 1 &&
......@@ -725,9 +734,46 @@ os_error *cheader_output
}
}
if ((rc = Print_Decl (file, t, c_name, NULL, FALSE, 0)) < 0)
goto finish;
if (t->tag == def_TYPE_STRUCT && t->data AS list.ellipsis &&
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)
goto finish;
......@@ -738,39 +784,46 @@ os_error *cheader_output
t->data AS list.members
[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;
def_as_macro (c_name, type);
def_as_macro (macro_name, type);
if ((rc = fprintf (file, "#define %s(N) \\\n ",
c_name)) < 0)
macro_name)) < 0)
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;
if ((rc = fprintf (file, "\n\n")) < 0)
goto finish;
/*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,
"#define %.*s_SIZEOF%s(N) \\\n (",
suffix - c_name, c_name, suffix)) < 0)
suffix - macro_name, macro_name, suffix)) < 0)
goto finish;
}
else
{
if ((rc = fprintf (file, "#define %s_SIZEOF(N) (",
c_name)) < 0)
macro_name)) < 0)
goto finish;
}
/*We need the extern form for the rest.*/
def_as_extern (c_name, type);
/*This calculates an offset (using |offsetof|).*/
if ((i = t->data AS list.count) > 1)
{
......@@ -876,23 +929,13 @@ os_error *cheader_output
break;
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)
goto finish;
#endif
break;
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)
goto finish;
#endif
break;
case def_TYPE_BOOL:
......@@ -908,13 +951,8 @@ os_error *cheader_output
0)) < 0)
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)
/*was %d in either case 19th Apr 1995*/
#endif
goto finish;
break;
}
......@@ -1551,6 +1589,6 @@ os_error *cheader_output
goto finish;
finish:
if (rc < 0) error = _kernel_last_oserror ();
if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 980115 */
return error;
}
/*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*/
/*Copyright 1994 Jonathan Coxhead*/
......@@ -23,6 +23,7 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <kernel.h> /* TV 980115 */
#include "macros.h"
#include "os.h"
......@@ -586,6 +587,6 @@ os_error *chelp_output
}
finish:
if (rc < 0) error = _kernel_last_oserror ();
if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 980115 */
return error;
}
/*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*/
/*Copyright 1994 Jonathan Coxhead*/
......@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <kernel.h> /* TV 990127 */
/*From OSLib*/
#include "macros.h"
......@@ -40,9 +41,7 @@
#include "def.h"
#include "cstrong.h"
/*
#define TRUNCATION_LIMIT 19
*/
typedef
struct cstrong_entry
......@@ -244,6 +243,17 @@ static int Print_Decl
)
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++)
{
if (i == t->data AS list.count - 1 &&
......@@ -411,47 +421,24 @@ os_error *cstrong_output
if (t == NULL || t->tag == def_TYPE_ABSTRACT)
{
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf (help_data,
"%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: typedef struct {...} *%s;",
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;
#endif
}
else
{
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf (help_data,
"%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: typedef%s",
c_name,
c_title, c_title,
t->tag == def_TYPE_STRUCT || t->tag == def_TYPE_UNION?
"\n ": " ")) < 0)
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,
0)) < 0)
......@@ -536,25 +523,14 @@ os_error *cstrong_output
def_as_macro (c_name, cnst);
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf
( help_data,
"%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: #define %s ",
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: #define %s ",
c_name, c_title, c_name
)) < 0)
goto finish;
#endif
switch (c->type->tag)
{
......@@ -670,22 +646,12 @@ os_error *cstrong_output
first = TRUE;
#ifdef TRUNCATION_LIMIT
if ((rc = fprintf (help_data,
"%s\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s>.h\n"
"Defined in: <%s=>%." STR (TRUNCATION_LIMIT) "s.$>.h\n"
"Declaration: extern ",
c_name, c_title, c_title)) < 0)
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)
{
......@@ -968,13 +934,15 @@ os_error *cstrong_output
goto 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++)
free (Strings [i]);
if (rc < 0) error = _kernel_last_oserror ();
if (rc < 0) error = (os_error*)_kernel_last_oserror (); /* TV 990127 */
return error;
}
/*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*/
/*Copyright 1994 Jonathan Coxhead*/
......@@ -56,7 +56,7 @@ typedef struct String {char s [def_ID_LIMIT + 1];} String;
void def_as_extern
(
char *s0,
const char *s1
char *s1
)
{
enum {MODULE, NAME} state = MODULE;
......@@ -106,7 +106,7 @@ void def_as_extern
void def_as_macro
(
char *s0,
const char *s1
char *s1
)
{
enum {MODULE, NAME} state = MODULE;
......@@ -239,7 +239,7 @@ static String Name_Code
void def_as_c_plus_plus
(
char *c_plus_plus_name,
const char *swi_name,
char *swi_name,
def_s s
)
{
......
/*hdr.c - output an assembler header 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*/
/*Copyright 1994 Jonathan Coxhead*/
......@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "kernel.h" /* TV 980115 */
#include "macros.h"
#include "os.h"
......@@ -40,7 +41,7 @@
#define UNLABELLED_INST_COL 1
#define UNLABELLED_ARG_COL 2
static const char *Op [] = {":OR:", ":AND:", "+", ":EOR:"};
static char *Op [] = {":OR:", ":AND:", "+", ":EOR:"};
static int Emit
(
......@@ -436,7 +437,11 @@ static int Emit_Get (FILE *file, char *name)
if ((rc = Emit (file, NULL, "]")) < 0)
goto finish;
#if 0 // Amended to reflect change of include path name *** TV 20000305 ***
if ((rc = sprintf (s, "\"GET OS:Hdr.%s\"", name)) < 0)
#else
if ((rc = sprintf (s, "\"GET OSLibInclude:Hdr.%s\"", name)) < 0)
#endif
goto finish;
if ((rc = EmitSS (file, NULL, "[", ":LNOT: :DEF: ", hdr)) < 0)
......@@ -763,12 +768,10 @@ os_error *hdr_output
if ((rc = Emit (file, NULL, "]")) < 0)
goto finish;
if ((rc = fprintf (file, "\n")) < 0)
goto finish;
if ((rc = Emit (file, NULL, "END")) < 0)
goto finish;
finish:
if (rc < 0) error = _kernel_last_oserror ();
if (rc < 0) error = (os_error *)_kernel_last_oserror (); /* TV 980115 */
return error;
}
/*objasm.c - output an objasm 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*/
/*Copyright 1994 Jonathan Coxhead*/
......@@ -42,11 +42,11 @@
#include "main.h"
#include "objasm.h"
/* #define MEM_FOR_OBJASM (1024*1024) */
#define MEM_FOR_OBJASM (1024*1024)
static const char *Local;
static char *Local;
static const char
static char
*APCS_Names [] =
/*names of registers as seen by A P C S*/
{ /*arguments*/
......@@ -69,7 +69,7 @@ static const char
};
/*-----------------------------------------------------------------------*/
static const char *Op
static char *Op
(
def_op op
)
......@@ -163,8 +163,8 @@ static bool Byte_Wide
static int Emit_Header
(
FILE *file,
const char *title,
const char *author
char *title,
char *author
)
{
time_t now;
......@@ -219,7 +219,7 @@ static int Emit_Header
static int Emit0
(
FILE *file,
const char *s0
char *s0
)
{
int rc = 0;
......@@ -233,8 +233,8 @@ static int Emit0
static int Emit1
(
FILE *file,
const char *s0,
const char *s1
char *s0,
char *s1
)
{
int rc = 0;
......@@ -249,9 +249,9 @@ static int Emit1
static int Emit2
(
FILE *file,
const char *s0,
const char *s1,
const char *s2
char *s0,
char *s1,
char *s2
)
{
int rc = 0;
......@@ -266,10 +266,10 @@ static int Emit2
static int Emit3
(
FILE *file,
const char *s0,
const char *s1,
const char *s2,
const char *s3
char *s0,
char *s1,
char *s2,
char *s3
)
{
int rc = 0;
......@@ -284,7 +284,7 @@ static int Emit3
static int Emit_Label
(
FILE *file,
const char *s0
char *s0
)
{
return fprintf (file, "%s ROUT\n", s0);
......@@ -294,7 +294,7 @@ static int Emit_Label
static int Emit_Local
(
FILE *file,
const char *s0
char *s0
)
{
file = file;
......@@ -374,11 +374,11 @@ static int Format_SWI_List
static int Emit_Code
(
FILE *file,
const char *swi,
char *swi,
def_s s,
bool nonx,
lookup_t types,
bool apcs32
bool apcs32,
lookup_t types
)