Everything
7.3 Reentrant Library

Functions of libraries created by using the standard library generator with the -reent option specified can be executed as reentrant except for the rand and srand functions and the functions of the EC++ library.

Table 7.4 and Table 7.5 indicate which functions of libraries are reentrant even when the -reent option is not specified.

In the tables, functions for which "D" is indicated set the errno variable, so execution as reentrant is only possible as long as the program does not refer to the errno variable.

 

Reentrant column O: Reentrant X: Non-reentrant D: Sets the errno variable.

Table 7.4

C(C89) Reentrant Library Function List

Standard Include File

Function Name

Reentrant

 

Standard Include File

Function Name

Reentrant

stddef.h

offsetof

O

 

math.h

frexp

D

assert.h

assert

X

 

ldexp

D

ctype.h

isalnum

O

 

log

D

isalpha

O

 

log10

D

iscntrl

O

 

modf

D

isdigit

O

 

pow

D

isgraph

O

 

sqrt

D *1

islower

O

 

ceil

D

isprint

O

 

fabs

D *1

ispunct

O

 

floor

D

isspace

O

 

fmod

D

isupper

O

 

mathf.h

acosf

D

isxdigit

O

 

asinf

D

tolower

O

 

atanf

D

toupper

O

 

atan2f

D *2

math.h

acos

D

 

cosf

D *2

asin

D

 

sinf

D *2

atan

D

 

tanf

D

atan2

D *2

 

coshf

D

cos

D *2

 

sinhf

D

sin

D *2

 

tanhf

D

tan

D

 

expf

D

cosh

D

 

frexpf

D

sinh

D

 

ldexpf

D

tanh

D

 

logf

D

exp

D

 

log10f

D

mathf.h

modff

D

 

stdio.h

fputs

X

powf

D

 

getc

X

sqrtf

D *1

 

getchar

X

ceilf

D

 

gets

X

fabsf

O

 

putc

X

fabsl

D *1

 

putchar

X

floorf

D

 

puts

X

fmodf

D

 

ungetc

X

setjmp.h

setjmp

O

 

fread

X

longjmp

O

 

fwrite

X

stdarg.h

va_start

O

 

fseek

X

va_arg

O

 

ftell

X

va_end

O

 

rewind

X

stdio.h

fclose

X

 

clearerr

X

fflush

X

 

feof

X

fopen

X

 

ferror

X

freopen

X

 

perror

X

setbuf

X

 

stdlib.h

atof

D

setvbuf

X

 

atoi

D

fprintf

X

 

atol

D

fscanf

X

 

atoll

D

printf

X

 

strtod

D

scanf

X

 

strtol

D

sprintf

X

 

strtoul

D

sscanf

D

 

strtoll

D

vfprintf

X

 

strtoull

D

vprintf

X

 

rand

X

vsprintf

X

 

srand

X

fgetc

X

 

calloc

X

fgets

X

 

free

X

fputc

X

 

malloc

X

stdlib.h

realloc

X

 

string.h

strcmp

O

bsearch

O

 

strncmp

O

qsort

O

 

memchr

O

abs

O

 

strchr

O

div

O

 

strcspn

O

labs

O

 

strpbrk

O

llabs

O

 

strrchr

O

ldiv

O

 

strspn

O

lldiv

O

 

strstr

O

string.h

memcpy

O

 

strtok

X

strcpy

O

 

memset

O

strncpy

O

 

strerror

O

strcat

O

 

strlen

O

strncat

O

 

memmove

O

memcmp

O

 

Notes 1.

If the function call is replaced by an instruction, the entry in the column for "Reentrant" in the table would become O (i.e. reentrance is possible) since the instruction does not update the errno variable. Refer to the item on -library in the section on compiler options for the conditions under which calls are replaced by instructions.

Notes 2.

If the function call is replaced by code that uses a trigonometric function unit, the entry in the column for "Reentrant" in the table might become X (i.e. non-reentrant). For details, refer to the item about -tfu in the section on compile options.

 

Table 7.5

C99 Reentrant Library Functions List

Standard Include File

Function Name

Reentrant

 

Standard Include File

Function Name

Reentrant

stddef.h

isblank

O

 

math.h

frexpl

D

math.h

acosl

D

 

ldexpl

D

atanl

D

 

logl

D

atan2l

D *2

 

log10l

D

cosl

D *2

 

modfl

D

sinl

D *2

 

powl

D

tanl

D

 

sqrtl

D *1

coshl

D

 

ceill

D

sinhl

D

 

fabsl

D *1

tanhl

D

 

floorl

D

expl

D

 

fmodl

D

math.h

fpclassify

O

 

math.h

log2

X

isfinite

O

 

log2f

X

isinf

O

 

log2l

X

isnan

O

 

logb

X

isnormal

O

 

logbf

X

signbit

O

 

logbl

X

isgreater

O

 

scalbn

X

isgreaterequal

O

 

scalbnf

X

isless

O

 

scalbnl

X

islessequal

O

 

scalbln

X

islessgreater

O

 

scalblnf

X

isunordered

O

 

scalblnl

X

acosh

X

 

cbrt

O

acoshf

X

 

cbrtf

O

acoshl

X

 

cbrtl

O

asinh

X

 

hypot

X

asinhf

X

 

hypotf

X

asinhl

X

 

hypotl

X

atanh

X

 

erf

X

atanhf

X

 

erff

X

atanhl

X

 

erfl

X

exp2

X

 

erfc

X

exp2f

X

 

erfcf

X

exp2l

X

 

erfcl

X

expm1

D

 

lgamma

X

expm1f

D

 

lgammaf

X

expm1l

D

 

lgammal

X

ilogb

O

 

tgamma

X

ilogbf

O

 

tgammaf

X

ilogbl

O

 

tgammal

X

log1p

X

 

nearbyint

O

log1pf

X

 

nearbyintf

O

log1pl

X

 

nearbyintl

O

math.h

rint

X

 

math.h

nextafter

X

rintf

X

 

nextafterf

X

rintl

X

 

nextafterl

X

lrint

X

 

nexttoward

X

lrintf

X

 

nexttowardf

X

lrintl

X

 

nexttowardl

X

llrint

X

 

fdim

O

llrintf

X

 

fdimf

O

llrintl

X

 

fdiml

O

round

O

 

fmax

O

roundf

O

 

fmaxf

O

roundl

O

 

fmaxl

O

lround

X

 

fmin

O

lroundf

X

 

fminf

O

lroundl

X

 

fminl

O

llround

X

 

fma

X

llroundf

X

 

fmaf

X

llroundl

X

 

fmal

X

trunc

O

 

stdarg.h

va_copy

O

truncf

O

 

stdio.h

snprintf

X

truncl

O

 

vsnprintf

X

remainder

X

 

vfscanf

X

remainderf

X

 

vscanf

X

remainderl

X

 

vsscanf

D

remquo

X

 

complex.h

cacos

X

remquof

X

 

cacosf

X

remquol

X

 

cacosl

X

copysign

O

 

casin

X

copysignf

O

 

casinf

X

copysignl

O

 

casinl

X

nan

O

 

catan

X

nanf

O

 

catanf

X

nanl

O

 

catanl

X

complex.h

ccos

X

 

complex.h

cabsf

X

ccosf

X

 

cabsl

X

ccosl

X

 

cpow

X

csin

X

 

cpowf

X

csinf

X

 

cpowl

X

csinl

X

 

csqrt

D

ctan

D

 

csqrtf

D

ctanf

D

 

csqrtl

D

ctanl

D

 

carg

D

cacosh

X

 

cargf

D

cacoshf

X

 

cargl

D

cacoshl

X

 

cimag

O

casinh

X

 

cimagf

O

casinhf

X

 

cimagl

O

casinhl

X

 

conj

O

catanh

X

 

conjf

O

catanhf

X

 

conjl

O

catanhl

X

 

cproj

O

ccosh

X

 

cprojf

O

ccoshf

X

 

cprojl

O

ccoshl

X

 

creal

O

csinh

X

 

crealf

O

csinhf

X

 

creall

O

csinhl

X

 

fenv.h

feclearexcept

X

ctanh

D

 

fegetexceptflag

O

ctanhf

D

 

feraiseexcept

X

ctanhl

D

 

fesetexceptflag

X

cexp

X

 

fetestexcept

O

cexpf

X

 

fegetround

O

cexpl

X

 

fesetround

X

clog

X

 

fegetenv

O

clogf

X

 

feholdexcept

X

clogl

X

 

fesetenv

X

cabs

X

 

feupdateenv

X

inttypes.h

imaxabs

O

 

wchar.h

wcstod

D

imaxdiv

O

 

wcstof

D

strtoimax

D

 

wcstold

D

strtoumax

D

 

wcstol

D

wcstoimax

D

 

wcstoll

D

wcstoumax

D

 

wcstoul

D

wchar.h

fwprintf

X

 

wcstoull

D

vfwprintf

X

 

wcscpy

O

swprintf

X

 

wcsncpy

O

vswprintf

X

 

wmemcpy

O

wprintf

X

 

wmemmove

O

vwprintf

X

 

wcscat

O

fwscanf

X

 

wcsncat

O

vfwscanf

X

 

wcscmp

O

swscanf

D

 

wcsncmp

O

vswscanf

D

 

wmemcmp

O

wscanf

X

 

wcschr

O

vwscanf

X

 

wcscspn

O

fgetwc

X

 

wcspbrk

O

fgetws

X

 

wcsrchr

O

fputwc

X

 

wcsspn

O

fputws

X

 

wcsstr

O

fwide

X

 

wcstok

O

getwc

X

 

wmemchr

O

getwchar

X

 

wcslen

O

putwc

X

 

wmemset

O

putwchar

X

 

mbsinit

O

ungetwc

X

 

mbrlen

X

Notes 1.

If the function call is replaced by an instruction, the entry in the column for "Reentrant" in the table would become O (i.e. reentrance is possible) since the instruction does not update the errno variable. Refer to the item on -library in the section on compiler options for the conditions under which calls are replaced by instructions.

Notes 2.

If the function call is replaced by code that uses a trigonometric function unit, the entry in the column for "Reentrant" in the table might become X (i.e. non-reentrant). For details, refer to the item about -tfu in the section on compile options.