1# Copyright (C) 1991-2021 Free Software Foundation, Inc. 2# This file is part of the GNU C Library. 3 4# The GNU C Library is free software; you can redistribute it and/or 5# modify it under the terms of the GNU Lesser General Public 6# License as published by the Free Software Foundation; either 7# version 2.1 of the License, or (at your option) any later version. 8 9# The GNU C Library is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# Lesser General Public License for more details. 13 14# You should have received a copy of the GNU Lesser General Public 15# License along with the GNU C Library; if not, see 16# <https://www.gnu.org/licenses/>. 17 18# 19# Makefile for stdlib routines 20# 21subdir := stdlib 22 23include ../Makeconfig 24 25headers := stdlib.h bits/stdlib.h bits/stdlib-ldbl.h bits/stdlib-float.h \ 26 monetary.h bits/monetary-ldbl.h \ 27 inttypes.h stdint.h bits/wordsize.h bits/timesize.h \ 28 errno.h sys/errno.h bits/errno.h bits/types/error_t.h \ 29 ucontext.h sys/ucontext.h bits/indirect-return.h \ 30 alloca.h fmtmsg.h \ 31 bits/stdlib-bsearch.h sys/random.h bits/stdint-intn.h \ 32 bits/stdint-uintn.h bits/time64.h \ 33 34routines := \ 35 atof atoi atol atoll \ 36 abort \ 37 bsearch qsort msort \ 38 getenv putenv setenv secure-getenv \ 39 exit on_exit atexit cxa_atexit cxa_finalize old_atexit \ 40 quick_exit at_quick_exit cxa_at_quick_exit cxa_thread_atexit_impl \ 41 abs labs llabs \ 42 div ldiv lldiv \ 43 mblen mbstowcs mbtowc wcstombs wctomb \ 44 random random_r rand rand_r \ 45 drand48 erand48 lrand48 nrand48 mrand48 jrand48 \ 46 srand48 seed48 lcong48 \ 47 drand48_r erand48_r lrand48_r nrand48_r mrand48_r jrand48_r \ 48 srand48_r seed48_r lcong48_r \ 49 drand48-iter getrandom getentropy \ 50 strfromf strfromd strfroml \ 51 strtol strtoul strtoll strtoull \ 52 strtol_l strtoul_l strtoll_l strtoull_l \ 53 strtof strtod strtold \ 54 strtof_l strtod_l strtold_l \ 55 strtof_nan strtod_nan strtold_nan \ 56 system canonicalize \ 57 a64l l64a \ 58 rpmatch strfmon strfmon_l getsubopt xpg_basename fmtmsg \ 59 getcontext setcontext makecontext swapcontext 60aux = grouping groupingwc tens_in_limb 61 62# These routines will be omitted from the libc shared object. 63# Instead the static object files will be included in a special archive 64# linked against when the shared library will be used. 65static-only-routines = atexit at_quick_exit 66 67test-srcs := tst-fmtmsg 68tests := tst-strtol tst-strtod testmb testrand testsort testdiv \ 69 test-canon test-canon2 tst-strtoll tst-environ \ 70 tst-xpg-basename tst-random tst-random2 tst-bsearch \ 71 tst-limits tst-rand48 bug-strtod tst-setcontext \ 72 tst-setcontext2 test-a64l tst-qsort testmb2 \ 73 bug-strtod2 tst-atof1 tst-atof2 tst-strtod2 \ 74 tst-rand48-2 tst-makecontext tst-strtod5 \ 75 tst-qsort2 tst-makecontext2 tst-strtod6 tst-unsetenv1 \ 76 tst-makecontext3 bug-getcontext bug-fmtmsg1 \ 77 tst-secure-getenv tst-strtod-overflow tst-strtod-round \ 78 tst-tininess tst-strtod-underflow tst-setcontext3 \ 79 tst-strtol-locale tst-strtod-nan-locale tst-strfmon_l \ 80 tst-quick_exit tst-thread-quick_exit tst-width \ 81 tst-width-stdint tst-strfrom tst-strfrom-locale \ 82 tst-getrandom tst-atexit tst-at_quick_exit \ 83 tst-cxa_atexit tst-on_exit test-atexit-race \ 84 test-at_quick_exit-race test-cxa_atexit-race \ 85 test-cxa_atexit-race2 \ 86 test-on_exit-race test-dlclose-exit-race \ 87 tst-makecontext-align test-bz22786 tst-strtod-nan-sign \ 88 tst-swapcontext1 tst-setcontext4 tst-setcontext5 \ 89 tst-setcontext6 tst-setcontext7 tst-setcontext8 \ 90 tst-setcontext9 tst-bz20544 tst-canon-bz26341 \ 91 tst-realpath 92 93tests-internal := tst-strtod1i tst-strtod3 tst-strtod4 tst-strtod5i \ 94 tst-tls-atexit tst-tls-atexit-nodelete 95tests-static := tst-secure-getenv 96tests-container := tst-system 97 98ifeq ($(build-hardcoded-path-in-tests),yes) 99tests += tst-empty-env 100endif 101 102LDLIBS-test-atexit-race = $(shared-thread-library) 103LDLIBS-test-at_quick_exit-race = $(shared-thread-library) 104LDLIBS-test-cxa_atexit-race = $(shared-thread-library) 105LDLIBS-test-cxa_atexit-race2 = $(shared-thread-library) 106LDLIBS-test-on_exit-race = $(shared-thread-library) 107LDLIBS-tst-canon-bz26341 = $(shared-thread-library) 108 109LDLIBS-test-dlclose-exit-race = $(shared-thread-library) 110LDFLAGS-test-dlclose-exit-race = $(LDFLAGS-rdynamic) 111LDLIBS-test-dlclose-exit-race-helper.so = $(libsupport) $(shared-thread-library) 112 113ifeq ($(have-cxx-thread_local),yes) 114CFLAGS-tst-quick_exit.o = -std=c++11 115LDLIBS-tst-quick_exit = -lstdc++ 116CFLAGS-tst-thread-quick_exit.o = -std=c++11 117LDLIBS-tst-thread-quick_exit = -lstdc++ 118$(objpfx)tst-thread-quick_exit: $(shared-thread-library) 119else 120tests-unsupported += tst-quick_exit tst-thread-quick_exit 121endif 122 123modules-names = tst-tls-atexit-lib test-dlclose-exit-race-helper 124extra-test-objs += $(addsuffix .os, $(modules-names)) 125 126ifeq ($(build-shared),yes) 127tests += tst-putenv 128endif 129 130# Several mpn functions from GNU MP are used by the strtod function. 131mpn-routines := inlines add_n addmul_1 cmp divmod_1 divrem udiv_qrnnd \ 132 lshift rshift mod_1 mul mul_1 mul_n sub_n submul_1 133mpn-headers = longlong.h gmp.h gmp-impl.h gmp-mparam.h asm-syntax.h 134 135routines := $(strip $(routines) $(mpn-routines)) \ 136 dbl2mpn ldbl2mpn \ 137 mpn2flt mpn2dbl mpn2ldbl 138aux += fpioconst mp_clz_tab 139 140tests-extras += tst-putenvmod 141extra-test-objs += tst-putenvmod.os 142 143generated += isomac isomac.out tst-putenvmod.so 144 145CFLAGS-bsearch.c += $(uses-callbacks) 146CFLAGS-msort.c += $(uses-callbacks) 147CFLAGS-qsort.c += $(uses-callbacks) 148CFLAGS-system.c += -fexceptions 149CFLAGS-system.os = -fomit-frame-pointer 150CFLAGS-fmtmsg.c += -fexceptions 151 152CFLAGS-strfmon.c += $(libio-mtsafe) 153CFLAGS-strfmon_l.c += $(libio-mtsafe) 154 155# The strfrom class of functions call __printf_fp in order to convert the 156# floating-point value to characters. This requires the value of IO_MTSAFE_IO. 157CFLAGS-strfromd.c += $(libio-mtsafe) 158CFLAGS-strfromf.c += $(libio-mtsafe) 159CFLAGS-strfroml.c += $(libio-mtsafe) 160 161CFLAGS-tst-bsearch.c += $(stack-align-test-flags) 162CFLAGS-tst-qsort.c += $(stack-align-test-flags) 163CFLAGS-tst-makecontext.c += -funwind-tables 164CFLAGS-tst-makecontext2.c += $(stack-align-test-flags) 165 166# Run a test on the header files we use. 167tests-special += $(objpfx)isomac.out 168 169ifeq ($(run-built-tests),yes) 170tests-special += $(objpfx)tst-fmtmsg.out 171endif 172 173include ../Rules 174 175ifeq ($(run-built-tests),yes) 176LOCALES := cs_CZ.UTF-8 de_DE.UTF-8 en_US.ISO-8859-1 tr_TR.UTF-8 \ 177 tr_TR.ISO-8859-9 tg_TJ.UTF-8 hr_HR.UTF-8 hi_IN.UTF-8 \ 178 el_GR.UTF-8 179include ../gen-locales.mk 180 181$(objpfx)bug-strtod2.out: $(gen-locales) 182$(objpfx)testmb2.out: $(gen-locales) 183$(objpfx)tst-strtod.out: $(gen-locales) 184$(objpfx)tst-strtod1i.out: $(gen-locales) 185$(objpfx)tst-strtod3.out: $(gen-locales) 186$(objpfx)tst-strtod4.out: $(gen-locales) 187$(objpfx)tst-strtod5.out: $(gen-locales) 188$(objpfx)tst-strtod5i.out: $(gen-locales) 189$(objpfx)tst-strtol-locale.out: $(gen-locales) 190$(objpfx)tst-strtod-nan-locale.out: $(gen-locales) 191$(objpfx)tst-strfmon_l.out: $(gen-locales) 192$(objpfx)tst-strfrom.out: $(gen-locales) 193$(objpfx)tst-strfrom-locale.out: $(gen-locales) 194$(objpfx)test-dlclose-exit-race.out: $(objpfx)test-dlclose-exit-race-helper.so 195endif 196 197# Testdir has to be named stdlib and needs to be writable 198test-canon-ARGS = --test-dir=${common-objpfx}stdlib 199 200bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev 201 202$(objpfx)isomac.out: $(objpfx)isomac 203 $(dir $<)$(notdir $<) '$(CC)' \ 204 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \ 205 $(evaluate-test) 206 207isomac-CFLAGS = -O 208$(objpfx)isomac: isomac.c 209 $(native-compile) 210 211$(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg 212 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \ 213 '$(run-program-env)' '$(test-program-prefix-after-env)' \ 214 $(common-objpfx)stdlib/; \ 215 $(evaluate-test) 216 217$(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so 218LDFLAGS-tst-putenv = -Wl,--no-as-needed 219 220$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps) 221 $(build-module) 222libof-tst-putenvmod = extramodules 223 224$(objpfx)bug-getcontext: $(libm) 225$(objpfx)bug-strtod2: $(libm) 226$(objpfx)tst-strtod-round: $(libm) 227$(objpfx)tst-tininess: $(libm) 228$(objpfx)tst-strtod-underflow: $(libm) 229$(objpfx)tst-strtod6: $(libm) 230$(objpfx)tst-strtod-nan-locale: $(libm) 231$(objpfx)tst-strtod-nan-sign: $(libm) 232 233tst-tls-atexit-lib.so-no-z-defs = yes 234test-dlclose-exit-race-helper.so-no-z-defs = yes 235 236$(objpfx)tst-tls-atexit: $(shared-thread-library) 237$(objpfx)tst-tls-atexit.out: $(objpfx)tst-tls-atexit-lib.so 238 239$(objpfx)tst-tls-atexit-nodelete: $(shared-thread-library) 240$(objpfx)tst-tls-atexit-nodelete.out: $(objpfx)tst-tls-atexit-lib.so 241 242$(objpfx)tst-setcontext3.out: tst-setcontext3.sh $(objpfx)tst-setcontext3 243 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \ 244 '$(run-program-env)' '$(test-program-prefix-after-env)' \ 245 $(common-objpfx)stdlib/; \ 246 $(evaluate-test) 247