• Keine Ergebnisse gefunden

ANSI Library Function List

Chapter 8 ANSI Library

8.2 ANSI Library Function List

The following explains the meaning of the entries in the Reentrant field:

d The function is reentrant.

˜ The function is not reentrant.

Ù Dummy function.(You need to modify it for your system.)

L The function is QRW reentrant. ÔThis refers to the global parameters, and it calls the dummy function. It can be used as a reentrant function if there is no change in the global parameters and your created read(),write()wrote are reentrant functions.Õ

8.2.1 Input/Output Functions (io.lib)

The table below lists the input/output functions included in io.lib.

Table 8.2.1.1 Input/output functions Header file: stdio.h

Function Functionality Reentrant Notes

FILE *fopen(char *filename, char *mode); Dummy Ù FILE *freopen(char *filename, char

*mode, FILE *stream);

Dummy

Ù

int fclose(FILE *stream); Dummy Ù

int fflush(FILE *stream); Dummy Ù

int fseek(FILE *stream, long int offset, int orign);

Dummy

Ù

long int ftell(FILE *stream); Dummy Ù

void rewind(FILE *stream); Dummy Ù

int fgetpos(FILE *stream, fpos_t *ptr); Dummy Ù int fsetpos(FILE *stream, fpos_t *ptr); Dummy Ù size_t fread(void *ptr, size_t size, size_t

count, FILE *stream);

Input array element from

stdin. L Refer to global parameter stdin,_iob, call read function.

size_t fwrite(void *ptr, size_t size, size_t count, FILE *stream);

Output array element to stdout.

L Refer to global parameter

stdout,stderr,_iob, call write function.

int fgetc(FILE *stream); Input one character from stdin.

L Refer to global parameter stdin,_iob, call read function.

int getc(FILE *stream); Input one character from

stdin. L Refer to global parameter stdin,_iob, call read function.

int getchar( ); Input one

character from stdin.

L Refer to global parameter stdin,_iob, call read function.

int ungetc(int c, FILE *stream); Push one character back to

input buffer. ˜

Refer to global parameter stdin,stdout,stderr,_iob, returned value overwrite.

char *fgets(char *s, int n, FILE *stream); Input character

string from stdin. L Refer to global parameter stdin,_iob, call read function.

char *gets(char *s); Input character

string from stdin. L Refer to global parameter stdin,_iob, call read function.

int fputc(int c, FILE *stream); Output one character to stdout.

L Refer to global parameter

stdout,stderr,_iob, call write function.

int putc(int c, FILE *stream); Output one character to

stdout. L Refer to global parameter

stdout,stderr,_iob, call write function.

CHAPTER 8: ANSI LIBRARY

E0C33 FAMILY EPSON 99

int putchar(int c); Output one

character to stdout.

L Refer to global parameter

stdout,stderr,_iob, call write function.

int fputs(char *s, FILE *stream); Output character

string to stdout. L Refer to global parameter

stdout,stderr,_iob, call write function.

int puts(char *s); Output character

string to stdout. L Refer to global parameter

stdout,stderr,_iob, call write function.

int remove(char *filename); Dummy Ù

int rename(char *oldname, char

*newname);

Dummy

Ù void setbuf(FILE *stream, char *buf); Dummy Ù int setvbuf(FILE *stream, char *buf, int

type, size_t size);

Dummy

Ù

FILE *tmpfile( ); Dummy Ù

char *tmpnam(char *buf); Dummy Ù

int feof(FILE *stream); Dummy Ù

int ferror(FILE *stream); Dummy Ù

void clearerr(FILE *stream); Dummy Ù

void perror(char *s); Output error information to

stdout. ˜

Refer to global parameter stdout,stderr,_iob, change errno call write function.

int fscanf(FILE *stream, char *format, ...); Input from stdin with format specified.

˜ Refer to global parameter stdout,_iob, change errno call read function.

int scanf(char *format, ...); Input from stdin with format specified.

˜ Refer to global parameter stdout,_iob, change errno call read function.

int sscanf(char *s, char *format, ...); Input from character string with format specified.

˜

Change global parameter errno.

int fprintf(FILE *stream, char *format, ...); Output to stdout with format

specified. L Refer to global parameter

stdout,stderr,_iob, call write function.

int printf(char *format, ...); Output to stdout with format specified.

L Refer to global parameter

stdout,stderr,_iob, call write function.

int sprintf(char *s, char *format, ...); Output to array with format specified.

d int vfprintf(FILE *stream, char *format,

va_list arg);

Output conversion result

to stdout. L Refer to global parameter

stdout,stderr,_iob, call write function.

int vprintf(FILE *stream, char *format, va_list arg);

Output conversion result to stdout.

L Refer to global parameter

stdout,stderr,_iob, call write function.

int vsprintf(char *s, char *format, va_list arg);

Output conversion result to array.

d

Note: The file system is disabled; stdin and stdout are enabled.

When using stdin, you need the read function. When using stdout, you need the write function.

Refer to 8.4 for more information.

CHAPTER 8: ANSI LIBRARY

8.2.2 Utility Functions (lib.lib)

The table below lists the utility functions included in lib.lib.

Table 8.2.2.1 Utility functions Header file: stdlib.h

Function Functionality Reentrant Notes

void *malloc(size_t size); Allocate area.

˜ Change global parameter errno, ucNxtAlcP,ucBefAlcP,end_alloc.

void *calloc(size_t elt_count, size_t elt_size);

Allocate array area.

˜ Invalid for call from memory allocate.

void free(void *ptr); Clear area. ˜ Invalid for call from memory allocate.

void *realloc(void *ptr, size_t size); Change area size. ˜ Invalid for call from memory allocate.

int system(char *command); Dummy Ù Invalid for call from memory allocate.

void exit(int status); Terminate program

normally. d Refer to exit, terminates on the side of called later.

void abort( ); Terminate program

abnormally. d Refer to exit, terminates on the side of called later.

int atexit(void (*func)(void)); Dummy Ù

char *getenv(char *str); Dummy Ù

void *bsearch(void *key, void *base, size_t count, size_t size, int (*compare)(void *, void *));

Binary search.

d void qsort(void *base, size_t count,

size_t size, int (*compare)(void *, void *));

Quick sort.

d int abs(int x); Return absolute value

(int type). d

long int labs(long int x); Return absolute value

(long type). d

div_t div(int n, int d); Divide int type. ˜ Change global parameter errno.

ldiv_t ldiv(int n, int d); Divide long type. ˜ Change global parameter errno.

int rand( ); Return pseudo-random

number. ˜ Change global parameter seed.

void srand(unsigned int seed); Set seed of

pseudo-random number. ˜ Change global parameter seed.

long int atol(char *str); Convert character string

into long type. ˜ Change global parameter errno.

int atoi(char *str); Convert character string

into int type. ˜ Change global parameter errno.

double atof(char *str); Convert character string

into double type. ˜ Change global parameter errno.

double strtod(char *str, char **ptr); Convert character string

into double type. ˜ Change global parameter errno.

long int strtol(char *str, char **ptr, int base)

Convert character string

into long type. ˜ Change global parameter errno.

unsigned long int strtoul(char *str, char **ptr, int base);

Convert character string

into unsigned long type. ˜ Change global parameter errno.

Note: Memory allocation and release are simply implemented as follows:

If you perform memory allocation, it takes the necessary size in ucNxtAlcp.

If the area is same as the one taken before, the memory is freed; otherwise, nothing is performed.

If it reaches end_alloc, no more allocation is performed.

Refer to "cc33\utility\lib_src\" for more information, and modify them if needed.

CHAPTER 8: ANSI LIBRARY

E0C33 FAMILY EPSON 101

8.2.3 Date and Time Functions (lib.lib)

The table below lists the date and time functions included in lib.lib.

Table 8.2.3.1 Date and time functions Header file: time.h

Function Functionality Reentrant Notes

clock_t clock( ); Dummy

char *asctime(struct tm *ts); Dummy

char *ctime(time_t *timeptr); Dummy

double difftime(time_t ti, time_t t2); Dummy struct tm *gmtime(time_t *t); Convert calendar

time to standard time.

˜ Change static parameter.

struct tm *localtime(time_t *t); Dummy

time_t mktime(struct tm *tmptr); Convert standard time to calendar time.

˜ Change static parameter.

time_t time(time_t *tptr); Return current

calendar time. L Refer to global parameter gm_sec

CHAPTER 8: ANSI LIBRARY

8.2.4 Mathematical Functions (math.lib)

The table below lists the mathematical functions included in math.lib.

Table 8.2.4.1 Mathematical functions Header files: math.h, errno.h, float.h, limits.h

Function Functionality Reentrant Notes

double fabs(double x); Return absolute value (double type). d double ceil(double x); Round up double-type decimal part.

˜ Change global parameter errno, destruct ALR,AHR.

double floor(double x); Round down double-type decimal

part. ˜ Change global parameter errno,

destruct ALR,AHR.

double fmod(double x, double y);

Calculate double-type remainder.

˜ Change global parameter errno, destruct ALR,AHR.

double exp(double x); Exponentiate (ex).

˜ Change global parameter errno, destruct ALR,AHR.

double log(double x); Calculate natural logarithm.

˜ Change global parameter errno, destruct ALR,AHR.

double log10(double x); Calculate common logarithm.

˜ Change global parameter errno, destruct ALR,AHR.

double frexp(double x, int

*nptr);

Return mantissa and exponent of

floating-point number. ˜ Change global parameter errno, destruct ALR,AHR.

double ldexp(double x, int n); Return floating-point number from

mantissa and exponent. ˜ Change global parameter errno, destruct ALR,AHR.

double modf(double x, double *nptr);

Return integer and decimal parts of

floating-point number. ˜ Change global parameter errno, destruct ALR,AHR.

double pow(double x, double y);

Calculate xy.

˜ Change global parameter errno, destruct ALR,AHR.

double sqrt(double x); Calculate square root.

˜ Change global parameter errno, destruct ALR,AHR.

double sin(double x); Calculate sine.

˜ Change global parameter errno, destruct ALR,AHR.

double cos(double x); Calculate cosine.

˜ Change global parameter errno, destruct ALR,AHR.

double tan(double x); Calculate tangent.

˜ Change global parameter errno, destruct ALR,AHR.

double asin(double x); Calculate arcsine.

˜ Change global parameter errno, destruct ALR,AHR.

double acos(double x); Calculate arccosine.

˜ Change global parameter errno, destruct ALR,AHR.

double atan(double x); Calculate arctangent. ˜ Destruct ALR,AHR.

double atan2(double y, double x);

Calculate arctangent of y/x.

˜ Change global parameter errno, destruct ALR,AHR.

double sinh(double x); Calculate hyperbolic sine.

˜ Change global parameter errno, destruct ALR,AHR.

double cosh(double x); Calculate hyperbolic cosine.

˜ Change global parameter errno, destruct ALR,AHR.

double tanh(double x); Calculate hyperbolic tangent. ˜ Destruct ALR,AHR.

Note: The operation is faster in Ver.3 than in Ver.1 and Ver.2.

CHAPTER 8: ANSI LIBRARY

E0C33 FAMILY EPSON 103

8.2.5 Character Functions (string.lib)

The table below lists the character functions included in string.lib.

Table 8.2.5.1 Character functions Header file: string.h

Function Functionality Reentrant Notes

char *memchr(char *s, int c, int n); Return specified character position in the storage

area. d

int memcmp(char *s1, char *s2, int n); Compare storage areas. d char *memcpy(char *s1, char *s2, int n); Copy the storage area. d char *memmove(char *s1, char *s2, int n); Copy the storage area (overlapping allowed). d char *memset(char *s, int c, int n); Set character in the storage area. d char *strcat(char *s1, char *s2); Concatenate character strings. d char *strchr(char *s, int c); Return specified character position found first in

the character string. d

int strcmp(char *s1, char *s2); Compare character strings. d

char *strcpy(char *s1, char *s2); Copy character string. d

size_t *strcspn(char *s1, char *s2); Return number of characters from the beginning of the character string until the specified character

appears (multiple choices). d

char *strerror(int code); Return error message character string. d

size_t strlen(char *s); Return length of character string. d

size_t strncat(char *s1, char *s2, int n); Concatenate character strings (number of

characters specified). d

int strncmp(char *s1, char *s2, int n); Compare character strings (number of characters

specified). d

char *strncpy(char *s1, char *s2, int n); Copy the character string (number of characters

specified). d

char *strpbrk(char *s1, char *s2); Return specified character position (multiple

choices) found first in the character string. d char *strrchr(char *s, int c); Return specified character position found last in

the character string. d

size_t strspn(char *s1, char *s2); Return number of characters from the beginning of the character string until the non-specified character appears (multiple choices).

d char *strstr(char *s1, char *s2); Return position where the specified character

string appeared first. d

char *strtok(char *s1, char *s2); Divide the character string into tokens.

˜ Change static parameter.

∗ All functions except strerror have been created and tuned by an assembly source.

CHAPTER 8: ANSI LIBRARY

8.2.6 Character Type Determination/Conversion Functions (ctype.lib)

The table below lists the character functions included in ctype.lib.

Table 8.2.6.1 Character type determination/conversion functions Header file: ctype.h

Function Functionality Reentrant

int isalnum(char c); Determine character type (decimal or alphabet). d

int isalpha(char c); Determine character type (alphabet). d

int iscntrl(char c); Determine character type (control character). d

int isdigit(char c); Determine character type (decimal). d

int isgraph(char c); Determine character type (graphic character). d int islower(char c); Determine character type (lowercase alphabet). d int isprint(char c); Determine character type (printable character). d

int ispunct(char c); Determine character type (delimiter). d

int isspace(char c); Determine character type (null character). d

int isupper(char c); Determine character type (uppercase alphabet). d

int isxdigit(char c); Determine character type (hexadecimal). d

int tolower(char c); Convert character type (uppercase alphabet → lowercase). d int toupper(char c); Convert character type (lowercase alphabet → uppercase). d

8.2.7 Variable Argument Macros (stdarg.h)

The table below lists the variable argument macros defined in stdarg.h.

Table 8.2.7.1 Variable argument macros Header file: stdarg.h

Functionality Initialize the variable argument group.

Return the actual argument.

Return normally from the variable argument function.

Macro

void va_start(va_list ap, type lastarg);

type va_arg(va_list ap, type);

void va_end(va_list ap);

CHAPTER 8: ANSI LIBRARY

E0C33 FAMILY EPSON 105