Japanese Automotive C

Japanese Automotive C is a set of extensions to ANSI C used by Japanese automobile manufacturers. For complete specifications, refer to the C-Language Specification for Automotive Control (Proposal) by Toyota Motor Corp., July 29, 1993.

Japanese Automotive C generally conforms to the principles of ISO 9899, equivalent to the ANSI X3.159-1989 standard, with the exception of the "Implementation-defined Behavior" specification of Annex G.3 in ISO 9899. Japanese Automotive C modifies, or extends, this specification to support portability. The method by which it extends the "Implementation-defined Behavior" conforms to the "Common Extension" section of ISO 9899, found in Annex G.5.

To select this version of C, click the Japanese Automotive C box in the C options window of the MULTI Builder window. Alternately, enter the -japanese_automotive_c command line option.

Selecting Japanese Automotive C enables the following command line options:

-pragma_asm_inline

Enables #pragma asm, #pragma endasm, #pragma inline.

-unsignedchar

Specifies type char as unsigned.

-unsignedfield

Specifies that a bit field whose type is char, short, int, or long has an unsigned value.

-noshortenum

Specifies that enumerated types are integers.

-asmwarn Prints a warning for each _ _asm() statement.

-noasm Prevents the compiler from recognizing asm as a keyword in other modes, allowing a variable or function named asm to be declared.

Normally, in strict ANSI C mode, it is a fatal error to declare a bit field with basetype other than int, signed int, or unsigned int. Japanese Automotive C makes this legal, even though it is a minor violation of the ANSI standard.

For example,

struct {
char b:3;
char c:5;
) s;

When the above code is compiled with -ANSI, the following error occurs:

"x.c", line 3: Illegal type for bit field
"x.c", line 4: Illegal type for bit field

When the code is compiled with -ANSI -japanese_automotive_c, no error or warning occurs.

Interrupt Functions

A function may be declared to be an interrupt function by prepending the __interrupt keyword to the function definition. The compiler will generate code for this function that will save all the registers this function uses, including the registers that are normally destroyable across function calls. These functions are intended to be used to handle hardware interrupt and exception conditions; since these events are not part of the normal program flow using a non-interrupt function may modify registers, resulting in incorrect behavior of the interrupted routine. These functions should be of void type and should take no arguments.

Example:

__interrupt void handle_clock_interrupt(void)
{
clock_ticks = clock_ticks + 1;
}

#pragma ghs interrupt

Putting #pragma ghs interrupt before a function definition is equivalent to declaring the function with the __interrupt keyword.

#pragma intvect

For all CPU processors, selecting Japanese Automotive C also enables:

#pragma intvect function integer_constant

The purpose of this pragma is to establish interrupt vectors. The compiler arranges for the address of the named function to be placed in memory at the address specified by integer_constant using a .org directive to the assembler.

This feature is only supported when using a Green Hills assembler and is not available in binary code generation mode.

The compiler does not check to see if function has been declared in the file, or if it is a legal function of any kind. The compiler also does not verify that integer_constant is a legal or unique address.

Selecting Japanese Automotive C also results in the following caveat: in the case of a pointer being cast to an integer, if the pointer and the integer are the same size, no data is lost. If the pointer is cast to a smaller integer, then the data is reduced from the upper bit.

Also, for some CPU processors, selecting Japanese Automotive C enables several built-in functions to control interrupts:

void _ _DI(void);

Disables all interrupts.

void _ _EI(void);

Enables all interrupts.

void _set_il(int n);

Sets interrupt level to n.


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.