Skip to content

Commit

Permalink
separate gcc stuff from general cpp stuff
Browse files Browse the repository at this point in the history
xml control char fix
  • Loading branch information
idgay committed Jan 22, 2008
1 parent 905d1aa commit fc3500e
Show file tree
Hide file tree
Showing 17 changed files with 496 additions and 380 deletions.
6 changes: 4 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ libparser_a_SOURCES = \
nesc-decls.h \
nesc-dfilter.c \
nesc-dfilter.h \
nesc-doc.c \
nesc-doc.h \
nesc-dspec.h \
nesc-dspec-int.h \
nesc-dspec.tab.c \
Expand All @@ -134,12 +136,12 @@ libparser_a_SOURCES = \
nesc-dump.h \
nesc-env.c \
nesc-env.h \
nesc-gcc.c \
nesc-gcc.h \
nesc-generate.c \
nesc-generate.h \
nesc-inline.c \
nesc-inline.h \
nesc-doc.c \
nesc-doc.h \
nesc-interface.c \
nesc-interface.h \
nesc-keywords.h \
Expand Down
8 changes: 6 additions & 2 deletions src/c-lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static void lex_string(const cpp_token *tok, struct yystype *lvalp)
string_array_length(string_sequence),
&istr, wide))
{
cstr = make_cstring(parse_region, (char *)istr.text, istr.len);
cstr = make_cstring(parse_region, (char *)istr.text, istr.len - 1);
free((char *)istr.text);
}
else
Expand Down Expand Up @@ -408,7 +408,11 @@ static lexical_cst interpret_integer(const cpp_token *token, unsigned int flags)
integer = cpp_interpret_integer(current_reader(), token, flags);
integer = cpp_num_sign_extend(integer, options->precision);

if (flags & CPP_N_UNSIGNED)
if (flags & CPP_N_UNSIGNED ||
/* what earlier nesC versions did, not correct as per C89/C99:
In both C89 and C99, octal and hex constants may be signed or
unsigned, whichever fits tighter. */
(flags & CPP_N_RADIX) != CPP_N_DECIMAL)
if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
t = unsigned_int_type;
else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
Expand Down
2 changes: 1 addition & 1 deletion src/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Boston, MA 02111-1307, USA. */
#undef yystype
#include "c-parse.h"
#include "semantics.h"
#include "nesc-cpp.h"
#include "nesc-gcc.h"

#include "machine/avr.c"
#include "machine/self.c"
Expand Down
3 changes: 2 additions & 1 deletion src/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ typedef struct {
bool (*field_attribute)(gcc_attribute attr, field_declaration fdecl);
bool (*type_attribute)(gcc_attribute attr, type *t);

void (*init)(void);
void (*preinit)(void); /* Immediately after target selection */
void (*init)(void); /* After everything else is setup */
int (*token)(const char *word, int length, struct yystype *lvalp);

/* A Keil C for 8051 special... */
Expand Down
5 changes: 3 additions & 2 deletions src/machine/avr.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ static bool avr_decl_attribute(gcc_attribute attr, data_declaration ddecl)

/* Basic pointer sizes and alignments for the AVR */
static machine_spec avr_machine = {
"avr", NULL,
"avr",
gcc_save_machine_options,
FALSE, /* big_endian */
FALSE, /* pcc_bitfield_type_matters */
8, /* empty field boundary - in bits */
Expand All @@ -41,7 +42,7 @@ static machine_spec avr_machine = {

avr_decl_attribute, /* Attribute handling: declarations */
NULL, NULL, NULL, /* Attribute handling: tag, field, type */
NULL, /* init */
NULL, NULL, /* preint, init */
NULL, /* token */
NULL, /* keil special */
gcc_global_cpp_init, /* global cpp support */
Expand Down
5 changes: 3 additions & 2 deletions src/machine/env_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Boston, MA 02111-1307, USA. */
#include <string.h>

static machine_spec env_machine = {
"env", NULL,
"env",
gcc_save_machine_options,
/* [default] */ /* [keyname] */
FALSE, /* big_endian */
FALSE, /* pcc_bitfield_type_matters */
Expand All @@ -52,7 +53,7 @@ static machine_spec env_machine = {
NULL, /* adjust_field_align */

NULL, NULL, NULL, NULL, /* Attributes: need some way to specify this */
NULL, /* init */
NULL, NULL, /* preint, init */
NULL, /* token */
NULL, /* keil special */
gcc_global_cpp_init, /* global cpp support */
Expand Down
2 changes: 1 addition & 1 deletion src/machine/keil.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static machine_spec keil_machine = {

NULL, /* adjust_field_align function */
NULL, NULL, NULL, NULL, /* attribute handling functions */
keil_init,
NULL, keil_init,
keil_token,
keil_special, /* Keil C special */
NULL, /* global cpp support */
Expand Down
5 changes: 3 additions & 2 deletions src/machine/msp430.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ static bool msp430_decl_attribute(gcc_attribute attr, data_declaration ddecl)

/* Basic pointer sizes and alignments for the TI MSP430 */
static machine_spec msp430_machine = {
"msp430", NULL,
"msp430",
gcc_save_machine_options,
FALSE, /* big_endian */
FALSE, /* pcc_bitfield_type_matters */
16, /* empty field boundary - in bits */
Expand All @@ -43,7 +44,7 @@ static machine_spec msp430_machine = {

msp430_decl_attribute, /* Attribute handling: declarations */
NULL, NULL, NULL, /* Attribute handling: tag, field, type */
NULL, /* init */
NULL, NULL, /* preint, init */
NULL, /* token */
NULL, /* keil special */
gcc_global_cpp_init, /* global cpp support */
Expand Down
2 changes: 1 addition & 1 deletion src/machine/sdcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static machine_spec sdcc_machine = {

NULL, /* adjust_field_align function */
NULL, NULL, NULL, NULL, /* attribute handling functions */
sdcc_init,
NULL, sdcc_init,
sdcc_token,
NULL, /* Keil C special */
NULL, /* global cpp support */
Expand Down
18 changes: 16 additions & 2 deletions src/machine/self.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct self_pcc2 {
char x : 1;
};

static void self_preinit(void);

#ifdef __i386__
#define SELF_ADJUST_FIELD_ALIGN self_adjust_field_align
#define SELF_HANDLE_OPTION self_handle_option
Expand All @@ -48,11 +50,12 @@ static void self_handle_option(const char *arg)
align_double = TRUE;
else if (!strcmp(arg, "-mnoalign-double"))
align_double = FALSE;
gcc_save_machine_options(arg);
}

#else
#define SELF_ADJUST_FIELD_ALIGN NULL
#define SELF_HANDLE_OPTION NULL
#define SELF_HANDLE_OPTION gcc_save_machine_options

#endif

Expand Down Expand Up @@ -87,9 +90,20 @@ static machine_spec self_machine = {
SELF_ADJUST_FIELD_ALIGN, /* adjust_field_align */

NULL, NULL, NULL, NULL, /* No special attributes */
NULL, /* init */
self_preinit, NULL, /* init */
NULL, /* token */
NULL, /* keil special */
gcc_global_cpp_init, /* global cpp support */
NULL /* per-file cpp support */
};

static void self_preinit(void)
{
union {
uint8_t a;
uint16_t b;
} endian;

endian.b = 1;
self_machine.big_endian = endian.a != 1;
}
Loading

0 comments on commit fc3500e

Please sign in to comment.