]> git.ipfire.org Git - thirdparty/glibc.git/blob - libio/Makefile
libio: do not attempt to free wide buffers of legacy streams [BZ #24228]
[thirdparty/glibc.git] / libio / Makefile
1 # Copyright (C) 1995-2019 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 # <http://www.gnu.org/licenses/>.
17
18 #
19 # Specific makefile for libio.
20 #
21 subdir := libio
22
23 include ../Makeconfig
24
25 headers := stdio.h \
26 bits/stdio.h bits/stdio2.h bits/sys_errlist.h bits/stdio-ldbl.h \
27 bits/types/FILE.h bits/types/__FILE.h bits/types/struct_FILE.h \
28 bits/types/__fpos_t.h bits/types/__fpos64_t.h \
29 bits/types/cookie_io_functions_t.h
30
31 routines := \
32 filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \
33 iofopncook iofputs iofread iofsetpos ioftell wfiledoalloc \
34 iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs \
35 ioseekoff ioseekpos iosetbuffer iosetvbuf ioungetc \
36 iovsprintf iovsscanf \
37 iofgetpos64 iofopen64 iofsetpos64 \
38 fputwc fputwc_u getwc getwc_u getwchar getwchar_u iofgetws iofgetws_u \
39 iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \
40 putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf \
41 wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops \
42 wstrops wfileops iofwide fwide wmemstream \
43 \
44 clearerr feof ferror fileno fputc freopen fseek getc getchar \
45 memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \
46 iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello \
47 freopen64 fseeko64 ftello64 \
48 \
49 __fbufsize __freading __fwriting __freadable __fwritable __flbf \
50 __fpurge __fpending __fsetlocking \
51 \
52 libc_fatal fmemopen oldfmemopen vtables readline
53
54 tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
55 tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-ext2 \
56 tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \
57 tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \
58 tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
59 tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \
60 tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \
61 bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \
62 tst-memstream1 tst-memstream2 tst-memstream3 tst-memstream4 \
63 tst-wmemstream1 tst-wmemstream2 tst-wmemstream3 tst-wmemstream4 \
64 bug-memstream1 bug-wmemstream1 \
65 tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \
66 tst-fwrite-error tst-ftell-partial-wide tst-ftell-active-handler \
67 tst-ftell-append tst-fputws tst-bz22415 tst-fgetc-after-eof \
68 tst-sprintf-ub tst-sprintf-chk-ub tst-bz24051 tst-bz24153 \
69 tst-wfile-sync tst-wfile-gconv
70
71 # This test tests interaction with the gconv cache. Setting
72 # GCONV_CACHE during out-of-container testing disables the cache.
73 tests-container += tst-wfile-ascii
74
75 tests-internal = tst-vtables tst-vtables-interposed tst-readline
76
77 ifeq (yes,$(build-shared))
78 # Add test-fopenloc only if shared library is enabled since it depends on
79 # shared localedata objects.
80 tests += tst-fopenloc
81 # Add tst-bz24228 only if shared library is enabled since it can never meet its
82 # objective with static linking because the relevant code just is not there.
83 tests += tst-bz24228
84 endif
85 test-srcs = test-freopen
86
87 ifeq ($(build-shared),yes)
88 routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
89 oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos \
90 oldiofsetpos64
91 endif
92
93 ifeq (yes,$(libc-reentrant))
94 routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \
95 iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u \
96 iofputs_u
97 endif
98
99 CPPFLAGS += $(libio-mtsafe)
100
101 # Support for exception handling.
102 CFLAGS-fileops.c += -fexceptions
103 CFLAGS-fputc.c += -fexceptions
104 CFLAGS-fputwc.c += -fexceptions
105 CFLAGS-freopen64.c += -fexceptions
106 CFLAGS-freopen.c += -fexceptions
107 CFLAGS-fseek.c += -fexceptions
108 CFLAGS-fseeko64.c += -fexceptions
109 CFLAGS-fseeko.c += -fexceptions
110 CFLAGS-ftello64.c += -fexceptions
111 CFLAGS-ftello.c += -fexceptions
112 CFLAGS-fwide.c += -fexceptions
113 CFLAGS-genops.c += -fexceptions
114 CFLAGS-getc.c += -fexceptions
115 CFLAGS-getchar.c += -fexceptions
116 CFLAGS-getwc.c += -fexceptions
117 CFLAGS-getwchar.c += -fexceptions
118 CFLAGS-iofclose.c += -fexceptions
119 CFLAGS-iofflush.c += -fexceptions
120 CFLAGS-iofgetpos64.c += -fexceptions
121 CFLAGS-iofgetpos.c += -fexceptions
122 CFLAGS-iofgets.c += -fexceptions
123 CFLAGS-iofgetws.c += -fexceptions
124 CFLAGS-iofputs.c += -fexceptions
125 CFLAGS-iofputws.c += -fexceptions
126 CFLAGS-iofread.c += -fexceptions
127 CFLAGS-iofsetpos64.c += -fexceptions
128 CFLAGS-iofsetpos.c += -fexceptions
129 CFLAGS-ioftell.c += -fexceptions
130 CFLAGS-iofwrite.c += -fexceptions
131 CFLAGS-iogetdelim.c += -fexceptions
132 CFLAGS-iogetline.c += -fexceptions
133 CFLAGS-iogets.c += -fexceptions
134 CFLAGS-iogetwline.c += -fexceptions
135 CFLAGS-ioputs.c += -fexceptions
136 CFLAGS-ioseekoff.c += -fexceptions
137 CFLAGS-ioseekpos.c += -fexceptions
138 CFLAGS-iosetbuffer.c += -fexceptions
139 CFLAGS-iosetvbuf.c += -fexceptions
140 CFLAGS-ioungetc.c += -fexceptions
141 CFLAGS-ioungetwc.c += -fexceptions
142 CFLAGS-oldfileops.c += -fexceptions
143 CFLAGS-oldiofclose.c += -fexceptions
144 CFLAGS-oldiofgetpos64.c += -fexceptions
145 CFLAGS-oldiofgetpos.c += -fexceptions
146 CFLAGS-oldiofsetpos64.c += -fexceptions
147 CFLAGS-oldiofsetpos.c += -fexceptions
148 CFLAGS-peekc.c += -fexceptions
149 CFLAGS-putc.c += -fexceptions
150 CFLAGS-putchar.c += -fexceptions
151 CFLAGS-putwc.c += -fexceptions
152 CFLAGS-putwchar.c += -fexceptions
153 CFLAGS-rewind.c += -fexceptions
154 CFLAGS-wfileops.c += -fexceptions
155 CFLAGS-wgenops.c += -fexceptions
156 CFLAGS-oldiofopen.c += -fexceptions
157 CFLAGS-iofopen.c += -fexceptions
158 CFLAGS-iofopen64.c += -fexceptions
159 CFLAGS-oldtmpfile.c += -fexceptions
160 # XXX Do we need filedoalloc and wfiledoalloc? Others?
161
162 CFLAGS-tst_putwc.c += -DOBJPFX=\"$(objpfx)\"
163
164 # These test cases intentionally use overlapping arguments
165 CFLAGS-tst-sprintf-ub.c += -Wno-restrict
166 CFLAGS-tst-sprintf-chk-ub.c += -Wno-restrict
167
168 LDFLAGS-tst-bz24228 = -Wl,--version-script=tst-bz24228.map
169
170 tst_wprintf2-ARGS = "Some Text"
171
172 test-fmemopen-ENV = MALLOC_TRACE=$(objpfx)test-fmemopen.mtrace
173 tst-fopenloc-ENV = MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace
174 tst-bz22415-ENV = MALLOC_TRACE=$(objpfx)tst-bz22415.mtrace
175 tst-bz24228-ENV = MALLOC_TRACE=$(objpfx)tst-bz24228.mtrace
176 tst-wfile-gconv-ENV = MALLOC_TRACE=$(objpfx)tst-wfile-gconv.mtrace
177
178 generated += test-fmemopen.mtrace test-fmemopen.check
179 generated += tst-fopenloc.mtrace tst-fopenloc.check
180 generated += tst-bz22415.mtrace tst-bz22415.check
181 generated += tst-wfile-gconv.mtrace tst-wfile-gconv.check
182
183 aux := fileops genops stdfiles stdio strops
184
185 ifeq ($(build-shared),yes)
186 generated += tst-bz24228.mtrace tst-bz24228.check
187 aux += oldfileops oldstdfiles
188 endif
189
190 shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \
191 oldstdfiles oldiopopen oldpclose oldtmpfile \
192 oldiofgetpos oldiofgetpos64 oldiofsetpos \
193 oldiofsetpos64
194
195 ifeq ($(run-built-tests),yes)
196 tests-special += $(objpfx)test-freopen.out $(objpfx)test-fmemopen-mem.out \
197 $(objpfx)tst-bz22415-mem.out \
198 $(objpfx)tst-wfile-gconv-mem.out
199 ifeq (yes,$(build-shared))
200 # Run tst-fopenloc-cmp.out and tst-openloc-mem.out only if shared
201 # library is enabled since they depend on tst-fopenloc.out.
202 tests-special += $(objpfx)tst-fopenloc-cmp.out $(objpfx)tst-fopenloc-mem.out \
203 $(objpfx)tst-bz24228-mem.out
204 endif
205 endif
206
207 include ../Rules
208
209 ifeq ($(run-built-tests),yes)
210 LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \
211 ja_JP.EUC-JP ja_JP.UTF-8
212 include ../gen-locales.mk
213
214 $(objpfx)bug-ftell.out: $(gen-locales)
215 $(objpfx)bug-ungetwc1.out: $(gen-locales)
216 $(objpfx)bug-ungetwc2.out: $(gen-locales)
217 $(objpfx)tst-fgetwc.out: $(gen-locales)
218 $(objpfx)tst-fgetws.out: $(gen-locales)
219 $(objpfx)tst-fopenloc.out: $(gen-locales)
220 $(objpfx)tst-fputws.out: $(gen-locales)
221 $(objpfx)tst-fseek.out: $(gen-locales)
222 $(objpfx)tst-ftell-active-handler.out: $(gen-locales)
223 $(objpfx)tst-ftell-append.out: $(gen-locales)
224 $(objpfx)tst-ftell-partial-wide.out: $(gen-locales)
225 $(objpfx)tst-setvbuf1.out: $(gen-locales)
226 $(objpfx)tst-swscanf.out: $(gen-locales)
227 $(objpfx)tst-ungetwc1.out: $(gen-locales)
228 $(objpfx)tst-ungetwc2.out: $(gen-locales)
229 $(objpfx)tst-widetext.out: $(gen-locales)
230 $(objpfx)tst_wprintf2.out: $(gen-locales)
231 $(objpfx)tst-wfile-sync.out: $(gen-locales)
232 $(objpfx)tst-wfile-gconv.out: $(gen-locales)
233 endif
234
235 $(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen
236 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' \
237 $(common-objpfx)libio/ > $@; \
238 $(evaluate-test)
239
240 $(objpfx)tst-fopenloc-cmp.out: ../iconvdata/testdata/ISO-8859-1..UTF8 \
241 $(objpfx)tst-fopenloc.out
242 cmp $^ > $@; \
243 $(evaluate-test)
244
245 $(objpfx)test-fmemopen-mem.out: $(objpfx)test-fmemopen.out
246 $(common-objpfx)malloc/mtrace $(objpfx)test-fmemopen.mtrace > $@; \
247 $(evaluate-test)
248
249 $(objpfx)tst-fopenloc-mem.out: $(objpfx)tst-fopenloc.out
250 $(common-objpfx)malloc/mtrace $(objpfx)tst-fopenloc.mtrace > $@; \
251 $(evaluate-test)
252
253 $(objpfx)tst-bz22415-mem.out: $(objpfx)tst-bz22415.out
254 $(common-objpfx)malloc/mtrace $(objpfx)tst-bz22415.mtrace > $@; \
255 $(evaluate-test)
256
257 $(objpfx)tst-bz24228-mem.out: $(objpfx)tst-bz24228.out
258 $(common-objpfx)malloc/mtrace $(objpfx)tst-bz24228.mtrace > $@; \
259 $(evaluate-test)
260
261 $(objpfx)tst-wfile-gconv-mem.out: $(objpfx)tst-wfile-gconv.out
262 $(common-objpfx)malloc/mtrace $(objpfx)tst-wfile-gconv.mtrace > $@; \
263 $(evaluate-test)