7.3 リエントラント性

標準ライブラリ構築ツールで-reent オプションを指定して作成したライブラリは、rand、srand関数およびEC++ライブラリを除いてすべてリエントラントに実行できます。

-reent オプションを指定していない場合について、表 7.4および表 7.5にリエントラントライブラリ一覧を示します。表中、△で示した関数は、errno変数を設定しますので、プログラム中でerrnoを参照していなければリエントラントに実行できます。

 

リエントラント欄 ◯:リエントラント ×:ノンリエントラント △:errnoを設定

表 7.4

C(C89)リエントラントライブラリ関数一覧

標準インクルード
ファイル

関数名

リエントラント

 

標準インクルード
ファイル

関数名

リエントラント

stddef.h

offsetof

 

math.h

frexp

assert.h

assert

×

 

ldexp

ctype.h

isalnum

 

log

isalpha

 

log10

iscntrl

 

modf

isdigit

 

pow

isgraph

 

sqrt

△*1

islower

 

ceil

isprint

 

fabs

△*1

ispunct

 

floor

isspace

 

fmod

isupper

 

mathf.h

acosf

isxdigit

 

asinf

tolower

 

atanf

toupper

 

atan2f

math.h

acos

 

cosf

asin

 

sinf

atan

 

tanf

atan2

 

coshf

cos

 

sinhf

sin

 

tanhf

tan

 

expf

cosh

 

frexpf

sinh

 

ldexpf

tanh

 

logf

exp

 

log10f

mathf.h

modff

 

stdio.h

gets

×

powf

 

putc

×

sqrtf

△*1

 

putchar

×

ceilf

 

puts

×

fabsf

△*1

 

ungetc

×

floorf

 

fread

×

fmodf

 

fwirte

×

setjmp.h

setjmp

 

fseek

×

longjmp

 

ftell

×

stdarg.h

va_start

 

rewind

×

va_arg

 

clearerr

×

va_end

 

feof

×

stdio.h

fclose

×

 

ferror

×

fflush

×

 

perror

×

fopen

×

 

stdlib.h

atof

freopen

×

 

atoi

setbuf

×

 

atol

setvbuf

×

 

atoll

fprintf

×

 

strtod

fscanf

×

 

strtol

printf

×

 

strtoul

scanf

×

 

strtoll

sprintf

×

 

strtoull

sscanf

 

rand

×

vfprintf

×

 

srand

×

vprintf

×

 

calloc

×

vsprintf

×

 

free

×

fgetc

×

 

malloc

×

fgets

×

 

realloc

×

fputc

×

 

bsearch

fputs

×

 

qsort

getc

×

 

abs

getchar

×

 

div

stdlib.h

labs

 

string.h

memchr

llabs

 

strchr

ldiv

 

strcspn

lldiv

 

strpbrk

string.h

memcpy

 

strrchr

strcpy

 

strspn

strncpy

 

strstr

strcat

 

strtok

×

strncat

 

memset

memcmp

 

strerror

strcmp

 

strlen

strncmp

 

memmove

注 1.

関数呼び出しが命令に置き換わる場合は errno変数を更新しないため ○ になります。
命令に置き換わる条件は、コンパイルオプションの-libraryの項目を参照ください。

表 7.5

C99リエントラントライブラリ関数一覧

標準インクルード
ファイル

関数名

リエントラント

 

標準インクルード
ファイル

関数名

リエントラント

stddef.h

isblank

 

math.h

sqrtl

math.h

acosl

 

ceill

atanl

 

fabsl

atan2l

 

floorl

cosl

 

fmodl

sinl

 

fpclassify

tanl

 

isfinite

coshl

 

isinf

sinhl

 

isnan

tanhl

 

isnormal

expl

 

signbit

frexpl

 

isgreater

ldexpl

 

isgreaterequal

logl

 

isless

log10l

 

islessequal

modfl

 

islessgreater

powl

 

isunordered

math.h

acosh

×

 

math.h

cbrt

acoshf

×

 

cbrtf

acoshl

×

 

cbrtl

asinh

×

 

hypot

×

asinhf

×

 

hypotf

×

asinhl

×

 

hypotl

×

atanh

×

 

erf

×

atanhf

×

 

erff

×

atanhl

×

 

erfl

×

exp2

×

 

erfc

×

exp2f

×

 

erfcf

×

exp2l

×

 

erfcl

×

expm1

 

lgamma

×

expm1f

 

lgammaf

×

expm1l

 

lgammal

×

ilogb

 

tgamma

×

ilogbf

 

tgammaf

×

ilogbl

 

tgammal

×

log1p

×

 

nearbyint

log1pf

×

 

nearbyintf

log1pl

×

 

nearbyintl

log2

×

 

rint

×

log2f

×

 

rintf

×

log2l

×

 

rintl

×

logb

×

 

lrint

×

logbf

×

 

lrintf

×

logbl

×

 

lrintl

×

scalbn

×

 

llrint

×

scalbnf

×

 

llrintf

×

scalbnl

×

 

llrintl

×

scalbln

×

 

round

scalblnf

×

 

roundf

scalblnl

×

 

roundl

math.h

lround

×

 

math.h

fmin

lroundf

×

 

fminf

lroundl

×

 

fminl

llround

×

 

fma

×

llroundf

×

 

fmaf

×

llroundl

×

 

fmal

×

trunc

 

stdarg.h

va_copy

truncf

 

stdio.h

snprintf

×

truncl

 

vsnprintf

×

remainder

×

 

vfscanf

×

remainderf

×

 

vscanf

×

remainderl

×

 

vsscanf

×

remquo

×

 

complex.h

cacos

×

remquof

×

 

cacosf

×

remquol

×

 

cacosl

×

copysign

 

casin

×

copysignf

 

casinf

×

copysignl

 

casinl

×

nan

 

catan

×

nanf

 

catanf

×

nanl

 

catanl

×

nextafter

×

 

ccos

×

nextafterf

×

 

ccosf

×

nextafterl

×

 

ccosl

×

nexttoward

×

 

csin

×

nexttowardf

×

 

csinf

×

nexttowardl

×

 

csinl

×

fdim

 

ctan

fdimf

 

ctanf

fdiml

 

ctanl

fmax

 

cacosh

×

fmaxf

 

cacoshf

×

fmaxl

 

cacoshl

×

complex.h

casinh

×

 

complex.h

cimag

casinhf

×

 

cimagf

casinhl

×

 

cimagl

catanh

×

 

conj

catanhf

×

 

conjf

catanhl

×

 

conjl

ccosh

×

 

cproj

ccoshf

×

 

cprojf

ccoshl

×

 

cprojl

csinh

×

 

creal

csinhf

×

 

crealf

csinhl

×

 

creall

ctanh

 

fenv.h

feclearexcept

×

ctanhf

 

fegetexceptflag

ctanhl

 

feraiseexcept

×

cexp

×

 

fesetexceptflag

×

cexpf

×

 

fetestexcept

cexpl

×

 

fegetround

clog

×

 

fesetround

×

clogf

×

 

fegetenv

clogl

×

 

feholdexcept

×

cabs

×

 

fesetenv

×

cabsf

×

 

feupdateenv

×

cabsl

×

 

nttypes.h

imaxabs

cpow

×

 

imaxdiv

cpowf

 

strtoimax

cpowl

 

strtoumax

csqrt

 

wcstoimax

csqrtf

 

wcstoumax

csqrtl

 

wchar.h

fwprintf

×

carg

 

vfwprintf

×

cargf

 

swprintf

×

cargl

 

vswprintf

×

wchar.h

wprintf

×

 

wchar.h

wcstoul

vwprintf

×

 

wcstoull

fwscanf

×

 

wcscpy

vfwscanf

×

 

wcsncpy

swscanf

×

 

wmemcpy

vswscanf

×

 

wmemmove

wscanf

×

 

wcscat

vwscanf

×

 

wcsncat

fgetwc

×

 

wcscmp

fgetws

×

 

wcsncmp

fputwc

×

 

wmemcmp

fputws

×

 

wcschr

fwide

 

wcscspn

getwc

×

 

wcspbrk

getwchar

×

 

wcsrchr

putwc

×

 

wcsspn

putwchar

×

 

wcsstr

ungetwc

×

 

wcstok

wcstod

×

 

wmemchr

wcstof

×

 

wcslen

wcstold

×

 

wmemset

wcstol

 

mbsinit

wcstoll

 

mbrlen

×