Preface

This document contains useful information for embedded software developers who wish to migrate their code from Renesas tools to CyberTHOR Studios GNU tools (and vice versa) for RX target. At present, this guide contains the following:


   Compiler Options
   Compiler Macros
   Compiler Directives
   Assembler Directives.
   Intrinsic Functions.
   Build-in Functions
   Linker Section Mapping
   C/Math Library Functions.
   Inline Assembly

Revision History:

Version Number

Date

Overview of changes

1.0 01-July-2010 Document created.
2.0 17-September-2014 Updated to GNURX v14.03
3.0 20-October-2016 Added new responsive template

Please note that this is an intermediate guide, which will be improved and enhanced periodically.

Please do not hesitate to send any of your suggestions or ideas. You may log in your suggestions on our web site https://gcc-renesas.com/.

You will need to register first, after which you can either add a new support query at the following link: https://gcc-renesas.com/my-support-requests/tickettrackingsystem/addticket, or ask a question here: https://gcc-renesas.com/forum/ask/.

Please note that in order to be able to add a new support query or ask a question you must be logged in.

Compiler Options


Renesas Compiler Options

Equivalent GCC compiler options
 

-include = <path name>[,…]
Include paths.

-I<path>
 

-preinclude = <file name>[,...]
Includes the specified files at the head of compiled files.

-include <file>
 

-define = <sub> [,…]
<sub>: <macro name> [ = <string literal>]

Defines <string literal> as <macro name>

-D<macro>
 

-undefine = <sub>[,…]
<sub>:< macro name >

Disables the predefined macro of <macro name>

-U <macro>

-nomessage [ = <error number> [- <error number>] [,…] ]
Specifies whether to output information-level messages.

-w
 

-preprocessor [= <file name>]
Preprocessor to named file.

-E -o filename
 

-output={prep | src | obj | abs | hex | sty }[=filename]
Specifies the output file type and output filename
prep = Outputs a source file after preprocessed.
src = Outputs an assembly language file.
obj = Outputs a relocatable file.
abs = Outputs an absolute file.
hex = Outputs an Intel hex type file.
sty = Outputs a Motorola S type file.

filename = Name of output file

-o filename
filename = Name of output file

Use following compiler options for specifying the output file type.
-E = Outputs a source file after preprocessed.
-S = Outputs an assembly language file.
-c = Outputs a relocatable file
no option = Outputs an absolute file

Use following linker options for specifying the output file type.
--oformat=hex : Outputs an Intel hex type file.
--oformat=srec : Outputs a Motorola S type file.

-debug
Outputs debugging information.

-g[level]
 

-listfile[=<file name>]
Outputs a source list file
-nolistfile
Does not output a source list file.

-Wa,-al=file
Outputs a source list file
No Option
Does not output a source list file.
show = <sub>[,…]
<sub>: {source | conditionals | definitions | expansions }

Specifies the contents of the source list file.
source = Outputs the C/C++ source file.
conditionals = Outputs the statements unsatisfied in conditional assembly.
definitions = Outputs the information before .DEFINE replacement.
expansions = Outputs the assembler macro
expansion statements.

-a[sub-option...]

Sub-options [default hls]:
c  = omit false conditionals
d  = omit debugging directives
h  = include high-level source
l  = include assembly
m = include macro expansions
n = omit forms processing
s  = include symbols
=FILE list to FILE (must be last sub-option)
 

-optimize = { 0 | 1 | 2 | max }

Specifies the optimization level.

optimize=0: the compiler does not optimize the program
optimize=1: the compiler partially optimizes the program for code size
optimize=2: the compiler performs overall optimization
optimize=max: the compiler performs optimization as much as possible; the optimization scope is expanded to its maximum extent, and if the speed option is specified, loop expansion is possible on a large scale.

-O0 : the compiler does not optimize the program
-O1: the compiler partially optimizes the program for code size
-O2: the compiler performs overall optimization
-Os or -O3: the compiler performs optimization as much as possible; the optimization scope is expanded to its maximum extent, and if the speed option is specified, loop expansion is possible on a large scale.
-speed

Optimizes with emphasis on execution performance

-O3
-size

Optimizes with emphasis on code size.

-Os
-loop[=<numeric value>]

Expands a loop under the condition of loop expansion maximum number =
<numeric value>.

-funroll-loops
-inline[=<numeric value>]

Performs inline expansion automatically.

-finline-functions
-finline-small-functions
-finline-functions-called-once
-finline-limit=n
-volatile

Handles external variables as if they are volatile qualified.
Not supported.

However, keyword volatile is supported

-const_copy

Enables constant propagation of const qualified external variables.
-fgcse
-schedule

Schedules instructions
-fschedule-insns
-fschedule-insns2
-fpu
Outputs an object that uses floating-point operation instructions.

-nofpu
Outputs an object that does not use floating-point operation instructions.
-fpu
Outputs an object that uses floating-point operation instructions.

-nofpu
Outputs an object that does not use floating-point operation instructions.
-cpu = { rx600 }

Generates an instruction code for RX600 Series.

-mcpu={ rx600 }
-endian = { big | little }

Specifies the endian type for data.

-mbig-endian-data
 
-mlittle-endian-data
-dbl_size = { 4 | 8 }

4: Handles the double type and long double  type in single precision.
8: Handles the double type and long double type in double precision.

-m32bit-doubles : Handles the double type and long double

-m64bit-doubles : Handles the double type and long double type in double precision.

-pack

Assumes the boundary alignment value for structure members is 1.
-fpack-struct
-fint_register = { 0 | 1 | 2 | 3 | 4 }

0: No registers are used only for fast interrupts.
1: R13 is used only for fast interrupts.
2: R13 and R12 are used only for fast interrupts.
3: R13 to R11 are used only for fast interrupts.
4: R13 to R10 are used only for fast interrupts.

-mint-register=N

N=1 : Register r13 will be reserved for the exclusive use of fast interrupt handlers
N=2 : Reserves registers r13 and r12
N=3 : Reserves r13, r12 and r11
N=4 : Reserves r13 through r10
N=0 : Default option. This does not reserve any registers

-patch = { rx610 }

Avoids a problem specific to the CPU type.
The MVTIPL instruction should not be generated (for RX610 Group).
-patch={ rx610 }
Alias for option "-mcpu"

-comment = { nest | nonest }
Enables nested comments to be written.

By default enabled. To generate warning for nested comments use option.
-Wcomment

-rtti = { on | off }

Enables dynamic_cast and typeid.

-fno-rtti
 

-exception
Enables the C++ exception processing (try, catch, throw).

-fexceptions
 

-lang = { c | cpp | ecpp | c99 }
Specifies the language of the source program.

-x <language>
 

-asmcmd=<file name>

Specifies the asrx options with a subcommand file.
No direct support.

However, -Wa option can be used to pass assembler options.

-lnkcmd=<file name>

Specifies the optlnk options with a subcommand file.
@file

Read command-line options from file. The options read are inserted in place of the original @file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed.

-asmopt=["]<assembler option> [?<assembler option>…]["]

Specifies the asrx options.
-Wa,<assembler option> can be used to pass assembler options.
-lnkopt=["]<linkage option> [?<linkage option>…]["]

Specifies the optlnk options
-Wl,<linker option> can be used to pass assembler options.

For more information on the above compiler command line options, please refer to the gcc manual.

Compiler Macros


Renesas macro

Equivalent GCC macro

_DATE_, _FILE_, _LINE_, _STDC_, _STDC_HOSTED_, _STDC_VERSION_, _cplusplus, _TIME_

__DATE__, __FILE__, __LINE__, __STDC__, __STDC_HOSTED__, __STDC_VERSION__, __cplusplus, __TIME__

__RX600, __RX200

__RX600__, __RX200__

__BIG, __LIT

__RX_BIG_ENDIAN__, __RX_LITTLE_ENDIAN__

__DBL4, __DBL8

__RX_32BIT_DOUBLES__, __RX_64BIT_DOUBLES__

__INT_SHORT

No corresponding GCC macro

__SCHAR, __UCHAR

No corresponding GCC macro

__SBIT, __UBIT

No corresponding GCC macro

__ROZ, __RON

No corresponding GCC macro

__DOFF, __DON

No corresponding GCC macro

__BITLEFT, __BITRIGHT

No corresponding GCC macro

__AUTO_ENUM

No corresponding GCC macro

__FUNCTION_LIB, __INTRINSIC_LIB

No corresponding GCC macro

__FPU

__RX_FPU_INSNS__

__RENESAS__

No corresponding GCC macro

__RENESAS_VERSION__

No corresponding GCC macro, should be defined inside the file

__RX

__RX__

__PIC

No corresponding GCC macro

__PID

No corresponding GCC macro


For more information on the above compiler predefined macros, please refer to the gcc manual.

Compiler directives


Renesas Directives Equivalent GNU directive or method
#pragma interrupt [(]<function name>
[(<interrupt specification>[,...])][,...][)]
This extension declares an interrupt function.
#pragma interrupt func
void func(){ .... }
void __attribute__ ((interrupt)) func ();
 
#pragma interrupt function_name(fint)

Fast interrupt
void function_name(void) __attribute__ ((fast_interrupt));
#pragma section [<section type>] [<new section name>]

This extension changes the section name to be output by the compiler.

Pragma is not available but the functionality can be achieved using __attribute__ ((section(“<section name>”)))
For e.g:
extern void foobar (void) __attribute__ ((section ("bar")));

Alternatively, this can be achieved using the linker script. In section definition, the contents of an output section can be specified by listing particular input files, listing particular input-file sections, or combination of the two.
#pragma stacksize {si=<constant> | su=<constant>}

When si=<constant> is specified, a data section is created to be used as the stack
of size <constant> with section name SI.
When su=<constant> is specified, a data section is created to be used as the stack
of size <constant> with section name SU.

char stack[100] __attribute__ ((section ("STACK"))) = { 0 };
 
main()
{
      /* Initialize stack pointer */
      init_sp (stack + sizeof (stack));
}
#pragma inline [(]<function name>[,...][)]
#pragma noinline [(]<function name>[,...][)]

#pragma inline declares a function for which inline expansion is performed.

inline void foo (const char) __attribute__((always_inline));

#pragma inline_asm[(]<function name>[,...][)]

This extension declares an assembly-language function for which inline expansion is performed

Asm(<assembly-language instruction string>);

#pragma entry[(]<function name>[)]

This specifies that the function specified as <function name> is handled as an entry function.

#pragma stacksize su=100
#pragma entry INIT
void INIT() {
:
}

Achieved through linker script.

#pragma option [<option string>]

This extension applies the options specified in <option string>.

#pragma option speed
void func1(){ ... } /* Default + -speed are applied

#pragma GCC optimize ("string"...)

OR

attribute optimize can be used as below,

void  func1 () __attribute__((optimize("-O3")));

#pragma pack
#pragma unpack
#pragma packoption

#pragma pack specifies the boundary alignment value for structure members and class members after the #pragma pack written in the source program.

__attribute__ ((packed));

struct foo
{
char a;
int x[2] __attribute__ ((packed));
};

 

#pragma endian [{big | little}]

This extension specifies the endian for the area that stores static objects.

This is not supported in GNU toolchains.

In GNU toolchains, command line options should be used to specify the endianness.

#pragma bit_order [{left | right}]

Switches the order of bit assignment.

This is not supported in GNU toolchains.
#pragma instalign4

#pragma instalign8

#pragma noinstalign

Specifies the function in which instructions at branch destinations are aligned for execution.

This is not supported in GNU toolchains.

For more information on the above compiler directives, please refer to the gcc manual.

Assembler Directives


Renesas Assembler Directives GNU Assembler Directives
.ORG

Declares the start address. The section including this directive becomes an absolute-addressing section.

.org
.ENDIAN

Specifies the endian for the section.

Following command line options for GNU assembler can be used;

-mbig-endian
-mlittle-endian

.BYTE

Stores 1-byte data in a ROM area.

.byte
.WORD

Stores 2-byte data in a ROM area.

.word
.LWORD

Stores 4-byte data in a ROM area.

.long
.FLOAT

Stores floating-point data represented by four bytes in a ROM area.

.float
.DOUBLE

Stores floating-point data represented by eight bytes in a ROM area.

.double
.ALIGN
Corrects a location counter to a multiple of the boundary alignment value.

.align <boundary alignment value>
(for details on more options of aligning like filling specific values,etc, please see link below)

.END .end
.INCLUDE .include
.SECTION name, attribute .section “ name” , “attributes”

(for details on the possible attributes, please refer the GNU linker manual)

.GLB .global
.EQU value .equ sym_name , value
.IF .if
.ELSE .else
.ELIF .elseif
.ENDIF .endif
.MACRO .macro
.ENDM .endm
.OFFSET .align
.BLKB .fill
.BLKW .fill
.BLKL .fill
.BLKD .fill
.EXITM .exitm
.MREPEAT .rept
.ENDR .endr
.LIST .list/.nolist
.LINE .line/.file
.DEFINE .set

For more information on the above assembler directives, please refer to the as manual.

Intrinsic Functions


Renesas Intrinsic functions Equivalent GCC inline code
unsigned long get_psw(void);
unsigned long get_usp(void);
unsigned long get_fpsw(void);
unsigned long get_isp(void);
unsigned long get_intb(void);
unsigned long get_bpsw(void);
unsigned long get_bpc(void);
unsigned long get_fintv(void);
 
int __builtin_rx_mvfc (int)
Generates the mvfc machine instruction which reads the control register specified in its argument and returns its value. The integer parameter corresponds to control registers as follows:
`0x0 psw'
`0x2 usp'
`0x3 fpsw'
`0x4 cpen'
`0x8 bpsw'
`0x9 bpc'
`0xA isp'
`0xB fintv'
`0xc intb'
Any other values will result in a warning message from the compiler. 

As an example, in order to read the contents of the fpsw register the following code can be used:

int a = __builtin_rx_mvfc (3);

void set_psw(unsigned long data) void __builtin_rx_setpsw (int)
Generates the setpsw machine instruction to set the specified bit in the processor status word.
signed long max(signed long data1, signed long data2) N/A
signed long min(signed long data1, signed long data2) N/A
unsigned long revl(unsigned long data) uint32_t __builtin_bswap32(uint32_t x)
Returns x with the order of the bytes reversed
unsigned long revw(unsigned long data) int __builtin_rx_revw(int)
Generates the revw machine instruction which swaps the bytes in the argument so that bits 0--7 now occupy bits 8--15 and vice versa, and also bits 16--23 occupy bits 24--31 and vice versa.
void xchg(signed long *data1, signed long *data2) void __builtin_rx_xchg (int *, int *)
Generates the xchg machine instruction.
long long rmpab(long long init, unsigned long count, signed char *addr1, signed char *addr2) N/A
long long rmpaw(long long init, unsigned long count, short *addr1, short *addr2) N/A
long long rmpal(long long init, unsigned long count, long *addr1, long *addr2) N/A
unsigned long rolc(unsigned long data) N/A
unsigned long rorc(unsigned long data) N/A
unsigned long rotl(unsigned long data, unsigned long num) N/A
unsigned long rotr(unsigned long data, unsigned long num) N/A
void brk(void) void __builtin_rx_brk (void) Generates the brk machine instruction.
void int_exception(signed long num) void __builtin_rx_int (int) Generates the int machine instruction to generate an interrupt with the specified value.
void wait(void) void __builtin_rx_wait (void) Generates the wait machine instruction.
void nop(void) __asm("nop")
void set_ipl(signed long level) N/A
unsigned char get_ipl(void) N/A
void set_fpsw(unsigned long data) void __builtin_rx_mvtc (int reg, int val) Generates the mvtc machine instruction which sets control register number reg to val.
void set_usp(void * data) void __builtin_rx_mvtc (int reg, int val) Generates the mvtc machine instruction which sets control register number reg to val.
void set_isp(void * data) void __builtin_rx_mvtc (int reg, int val) Generates the mvtc machine instruction which sets control register number reg to val.
void set_intb(void * data) void __builtin_rx_mvtc (int reg, int val) Generates the mvtc machine instruction which sets control register number reg to val.
void set_bpsw(unsigned long data) void __builtin_rx_mvtc (int reg, int val) Generates the mvtc machine instruction which sets control register number reg to val.
void set_bpc(void * data) void __builtin_rx_mvtc (int reg, int val) Generates the mvtc machine instruction which sets control register number reg to val.
void set_fintv(void * data) void __builtin_rx_mvtc (int reg, int val) Generates the mvtc machine instruction which sets control register number reg to val.
signed long long emul(signed long data1, signed long data2) N/A
unsigned long long emulu(unsigned long data1, unsigned long data2) N/A
void chg_pmusr(void) N/A
void set_acc(signed long long data) N/A
signed long long get_acc(void) N/A
void setpsw_i(void) N/A
void clrpsw_i(void) N/A
long macl(short* data1, short* data2, unsigned long count) N/A
short macw1(short* data1, short* data2, unsigned long count) N/A
short macw2(short* data1, short* data2, unsigned long count) N/A
void _CALL_INIT(void); N/A
void _CALL_END(void); N/A
void _INITSCT(void); N/A

Build-in Functions


GNU RX Built-in Functions Description
void __builtin_rx_clrpsw (int) Generates the clrpsw machine instruction to clear the specified bit in the processor status.
void __builtin_rx_machi (int, int) Generates the machi machine instruction to add the result of multiplying the top 16-bits of the two arguments into the accumulator.
void __builtin_rx_maclo (int, int) " Generates the maclo machine instruction to add the result of multiplying the bottom 16-bits of the two arguments into the accumulator.
void __builtin_rx_mulhi (int, int) Generates the mulhi machine instruction to place the result of multiplying the top 16-bits of the two arguments into the accumulator.
void __builtin_rx_mullo (int, int) Generates the mullo machine instruction to place the result of multiplying the bottom 16-bits of the two arguments into the accumulator.
int __builtin_rx_mvfachi (void) Generates the mvfachi machine instruction to read the top 32-bits of the accumulator.
int __builtin_rx_mvfacmi (void) Generates the mvfacmi machine instruction to read the middle 32-bits of the accumulator.
void __builtin_rx_mvtachi (int) Generates the mvtachi machine instruction to set the top 32-bits of the accumulator.
void __builtin_rx_mvtaclo (int) Generates the mvtaclo machine instruction to set the bottom 32-bits of the accumulator.
void __builtin_rx_mvtipl (int) Generates the mvtipl machine instruction set the interrupt priority level.
void __builtin_rx_racw (int) Generates the racw machine instruction to round the accumulator according to the specified mode.
void __builtin_rx_rmpa (void) Generates the rmpa machine instruction which initiates a repeated multiply and accumulate sequence.
void __builtin_rx_round (float) Generates the round machine instruction which returns the floating point argument rounded according to the current rounding mode set in the floating point status word register.
int __builtin_rx_sat (int) Generates the sat machine instruction which returns the saturated value of the argument.
void __builtin_rx_setpsw (int) Generates the setpsw machine instruction to set the specified bit in the processor status word.
void __builtin_rx_wait (void) Generates the wait machine instruction.
int __builtin_rx_bset (int, int) Generates the bset machine instruction.
int __builtin_rx_bclr (int, int) Generates the bclr machine instruction.
int __builtin_rx_bnot (int, int) Generates the bnot machine instruction.
void __builtin_rx_xchg (int *, int *) Generates the xchg machine instruction.

Linker Section Mapping


Renesas Section Equivalent GCC Section
CCRX Section GNURX Section
D .data
D_2 .data
D_1 .data
SI Istack
SU .ustack
B .bss
B_2 .bss
B_1 .bss
R .bss
R_2 .bss
R_1 .bss
P .text
FIXEDVECT .fvectors
C, C_2, C_1, C*,C$*,L,W* .rodata

For more information on assembler constraints, please refer to the gcc manual.

For more information on assembler command line options, please refer to the as manual.

C/Math Library Functions


GNU C library namely Newlib is under free software license. The Newlib supports various processors and architectures.

1.    Complete set of Standard input/output functions.
2.    Float parameters support for Math library.
3.    The library can be built with integer only support. This in turn reduces the load.
4.    Option is available to build the libraries with floating point support.
5.    A customizable math error handler matherr() is available.
6.    All the functions are reentrant.

Drawbacks Involved:

1.   malloc() is used in every stdio routine.
2.   There is no support for low-level routines to connect to the target.

C library Math Functions only in Renesas:

No. Function
General Utilities (stddef.h)
1 offsetof

C library Math Functions only in GNU:

No. Function Description

Character type handling routines (ctype.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC35 for more information on these routines.

1 Isascii ASCII character predicate
2 Toascii Control character predicate
3 Iswalnum Alphanumeric wide character test
4 Iswalpha Alphabetic wide character test
5 Iswcntrla Wide character cntrl test
6 Iswdigit Decimal digit wide character test
7 Iswgraph Graphic wide character test
8 Iswlower Lowercase wide character test
9 Iswprint Printable wide character test
10 Iswpunct Punctuation wide character test
11 Iswspace Wide character space test
12 Iswupper Uppercase wide character test
13 Iswxdigit Hexadecimal digit wide character test
14 Iswctype Extensible wide character test
15 Wctype Get wide character classification type
16 *Towlower Translate wide characters to lower case
17 *Towupper Translate wide characters to upper case
18 Towctrans Extensible wide character case mapping
19 Wctrans Get wide character translation type

No. Function Description

Mathematics Functions (math.h)

Please refer the http://sources.redhat.com/newlib/libm.html#SEC1 for more information on these routines.

1 acosh, acoshf Inverse hyperbolic cosine
2 asinh, asinhf Inverse hyperbolic sine
3 atanh, atanhf Inverse hyperbolic tangent
4 jN,jNf,yN,yNf Bessel functions
5 erf, erff, erfc, erfcf Error function
6 gamma, gammaf, lgamma, lgammaf, gamma_r, hypot, hypotf Distance from origin
7 isnan, isnanf, isinf, isinff, finite, finitef Test for exceptional numbers
8 remainder, remainderf Round and remainder
9 cbrt, cbrtf Cube root
10 copysign, copysignf Sign of y, magnitude of x
11 expm, expmf Exponential minus 1
12 ilogb, ilogbf Get exponent of floating point number
13 infinity, infinityf Representation of infinity
14 logp, logpf Log of 1 + x
15 Matherr Modifiable math error handler
16 nan, nanf Representation of infinity
17 nextafter, nextafterf Get next number
18 scalbn, scalbnf Scale by integer

No. Function Description

General Utilities (stdlib.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC1 for more information on these routines.

1 Atexit Request execution of functions at program exit
2 Atoff String to double or float
3 Ecvt, ecvtf, fcvt, fcvtf Double or float to string
4 Gvcvt, gcvtf Format double or float as string
5 Ecvtbuf, fcvtbuf Double or float to string
6 __env_lock, __env_unlock Lock environ variable
7 Getenv Look up environment variable
8 Mallinfo, malloc_stats, mallopt Malloc support
9 __malloc_lock, __malloc_unlock Lock malloc pool
10 Mblen Minimal multibyte length function
11 Mbstowcs Minimal multibyte string to wide char converter
12 Mbtowc Minimal multibyte to wide char converter
13 Rand48, drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 Pseudo random number generators and initialization routines
14 Strtof String to double or float
15 System Execute command string
16 Wcstombs Minimal wide char string to multibyte string converter
17 Wctomb Minimal wide char to multibyte converter

No. Function Description

String and Memory routines (string.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC109 for more information on these routines.

1 Bcmp Compare two memory areas
2 Bcopy Copy memory regions
3 Bzero Initialize memory to zero
4 Index Search for character in string
5 Memccpy Copy memory regions with end token check
6 Mempcpy Copy memory regions and return end pointer
7 Rindex Reverse search for character in string
8 Strcasecmp Case insensitive character string compare
9 Strlwr Force string to lower case
10 Strncasecmp Case insensitive character string compare
11 strtok_r,strsep Get next token from a string
12 Strupr Force string to uppercase
13 Swab Swap adjacent bytes

No. Function Description

Input/output routines (stdio.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC67 for more information on these routines.

1 Fgetpos Record position in a stream or file
2 Fiprintf Format output to file (integer only)
3 Fdopen Turn open file into a stream
4 Freopen Open a file using an existing file descriptor
5 fseeko Set file position
6 Fsetpos Restore position of a stream or file
7 ftello Return position in a stream or file
8 Getw Read a word (int)
9 Iprintf Write formatted output (integer only)
10 mktemp, mkstemp Generate unused file name
11 Putw Write a word (int)
12 Remove Delete a file's name
13 Rename Rename a file
14 Setbuf Specify full buffering for a file or stream
15 Siprintf Write formatted output (integer only)
16 asprintf, snprintf Format output
17 Tmpfile Create a temporary file
18 Tmpnam, Name for a temporary file
Large file input / output:
19 Fopen64 Open a large file
20 Freopen64 Open a large file using an existing file descriptor
21 Ftello64 Return position in a stream or file
22 Fseeko64 Set file position for large file
23 Fgetpos64 Record position in a large stream or file
24 Fsetpos64 Restore position of a large stream or file
25 Tmpfile64 Create a large temporary file

 

Along with all the above, following set of routines are provided in the newlib library:

1.    Wide character strings (wchar.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC144

2.    Signal handling (signal.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC169

3.    Time functions (time.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC172

4.    Locale specific routines (locale.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC183

Useful Links:

http://sources.redhat.com/newlib/libc.html
http://sources.redhat.com/newlib/libm.html

Inline Assembly


We can instruct the compiler to insert the code of a function into the code of its callers, to the point where actually the call is to be made. Such functions are inline functions. This method of inlining reduces the function-call overhead. And if any of the actual argument values are constant, their known values may permit simplifications at compile time so that not all of the inline function’s code needs to be included. The effect on code size is less predictable, it depends on the particular case. To declare an inline function, we’ve to use the keyword inline in its declaration. Inline assembly is important primarily because of its ability to operate and make its output visible on C variables. Because of this capability, "asm" works as an interface between the assembly instructions and the "C" program that contains it.

 

Syntax

GCC, the GNU C Compiler for Linux, uses AT&T UNIX assembly syntax.

a) Source-Destination Ordering

The first operand is the source and the second operand is the destination. ie, "Op-code src dst".

This is similar to the syntax followed in Renesas.

b) Register Naming

Register names are prefixed by % i.e., if r0 is to be used, write %r0.

c) Immediate Operand

Immediate operands are preceded by ’#’. For hexadecimal constants a ’0x’ is suffixed to the constant.

d) Operand Size

Size of memory operands is determined from the last character of the op-code name.

Op-code suffixes of ’b’, ’w’, and ’l’ specify byte(8-bit), word(16-bit), and long (32-bit) memory references.

e) Memory Operands

Base register is enclosed in ‘(’ and ’)’ and indirect memory reference is like

“section&colon;disp(base, index, scale)”. When a constant is used for disp and sol; scale, ’#’ shouldn’t be prefixed