Download TR0130 Nios II Embedded Tools Reference

Transcript
Nios II Embedded Tools Reference
Numeric conversions
The following functions convert the intial portion of a string *s to a double, int, long int and long long int value
respectively.
double
int
long
long long
atof(*s)
atoi(*s)
atol(*s)
atoll(*s)
The following functions convert the initial portion of the string *s to a float, double and long double value respectively. *endp will
point to the first character not used by the conversion.
stdlib.h
wchar.h
float
strtof(*s,**endp)
double
strtod(*s,**endp)
long double strtold(*s,**endp)
float
wcstof(*s,**endp)
double
wcstod(*s,**endp)
long double wcstold(*s,**endp)
The following functions convert the initial portion of the string *s to a long, long long, unsigned long and unsigned
long long respectively. Base specifies the radix. *endp will point to the first character not used by the conversion.
stdlib.h
long
long long
unsigned long
unsigned long
wchar.h
strtol(*s,**endp,base)
strtoll(*s,**endp,base)
strtoul(*s,**endp,base)
long
strtoull(*s,**endp,base)
long
long long
unsigned long
unsigned long
wcstol(*s,**endp,base)
wcstoll(*s,**endp,base)
wcstoul(*s,**endp,base)
long
wcstoull(*s,**endp,base)
Random number generation
rand
Returns a pseudo random integer in the range 0 to RAND_MAX.
srand(seed)
Same as rand but uses seed for a new sequence of pseudo random numbers.
Memory management
malloc(size)
Allocates space for an object with size size. The allocated space is not initialized. Returns a
pointer to the allocated space.
calloc(nobj,size)
Allocates space for n objects with size size. The allocated space is initialized with zeros. Returns
a pointer to the allocated space.
free(*ptr)
Deallocates the memory space pointed to by ptr which should be a pointer earlier returned by the
malloc or calloc function.
realloc(*ptr,size)
Deallocates the old object pointed to by ptr and returns a pointer to a new object with size size,
while preserving its contents. If the new size is smaller than the old size, some contents at the
end of the old region will be discarded. If the new size is larger than the old size, all of the old
contents are preserved and any bytes in the new object beyond the size of the old object will have
indeterminate values.
Environment communication
abort()
Causes abnormal program termination. If the signal SIGABRTis caught, the signal handler may
take over control. (See section 3.2.17, signal.h).
atexit(*func)
Func points to a function that is called (without arguments) when the program normally
terminates.
exit(status)
Causes normal program termination. Acts as if main() returns with status as the return value.
Status can also be specified with the predefined macros EXIT_SUCCES or EXIT_FAILURE.
_Exit(status)
Same as exit, but no registered by the atexit function or signal handlers registerd by the
signal function are called.
3−18