1# 2# SPDX-License-Identifier: BSD-3-Clause 3# 4# Copyright © 2019 Keith Packard 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 13# 2. Redistributions in binary form must reproduce the above 14# copyright notice, this list of conditions and the following 15# disclaimer in the documentation and/or other materials provided 16# with the distribution. 17# 18# 3. Neither the name of the copyright holder nor the names of its 19# contributors may be used to endorse or promote products derived 20# from this software without specific prior written permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33# OF THE POSSIBILITY OF SUCH DAMAGE. 34# 35srcs_tinystdio = [ 36 'asprintf.c', 37 'atold_engine.c', 38 'bufio.c', 39 'clearerr.c', 40 'dtox_engine.c', 41 'ecvt.c', 42 'ecvtf.c', 43 'ecvtf_r.c', 44 'ecvtl.c', 45 'ecvtl_r.c', 46 'ecvt_r.c', 47 'fclose.c', 48 'fcvt.c', 49 'fcvtf.c', 50 'fcvtf_r.c', 51 'fcvtl.c', 52 'fcvtl_r.c', 53 'fcvt_r.c', 54 'fdevopen.c', 55 'feof.c', 56 'ferror.c', 57 'fflush.c', 58 'fgetc.c', 59 'fgets.c', 60 'fgetwc.c', 61 'fgetws.c', 62 'fileno.c', 63 'filestrget.c', 64 'filestrputalloc.c', 65 'filestrput.c', 66 'filewstrget.c', 67 'fmemopen.c', 68 'fprintf.c', 69 'fputc.c', 70 'fputs.c', 71 'fputwc.c', 72 'fputws.c', 73 'fread.c', 74 'fscanf.c', 75 'fseek.c', 76 'fseeko.c', 77 'ftell.c', 78 'ftello.c', 79 'ftox_engine.c', 80 'fwide.c', 81 'fwprintf.c', 82 'fwrite.c', 83 'fwscanf.c', 84 'gcvt.c', 85 'gcvtf.c', 86 'gcvtl.c', 87 'getchar.c', 88 'getdelim.c', 89 'getline.c', 90 'gets.c', 91 'getwchar.c', 92 'ldtoa_engine.c', 93 'ldtox_engine.c', 94 'matchcaseprefix.c', 95 'mktemp.c', 96 'perror.c', 97 'printf.c', 98 'putchar.c', 99 'puts.c', 100 'putwchar.c', 101 'remove.c', 102 'rewind.c', 103 'scanf.c', 104 'setbuf.c', 105 'setbuffer.c', 106 'setlinebuf.c', 107 'setvbuf.c', 108 'sflags.c', 109 'snprintf.c', 110 'snprintfd.c', 111 'snprintff.c', 112 'sprintf.c', 113 'sprintfd.c', 114 'sprintff.c', 115 'sscanf.c', 116 'strfromd.c', 117 'strfromf.c', 118 'strfroml.c', 119 'strtod.c', 120 'strtod_l.c', 121 'strtof.c', 122 'strtof_l.c', 123 'strtoimax.c', 124 'strtol.c', 125 'strtold.c', 126 'strtold_l.c', 127 'strtol_l.c', 128 'strtoll.c', 129 'strtoll_l.c', 130 'strtoul.c', 131 'strtoul_l.c', 132 'strtoull.c', 133 'strtoull_l.c', 134 'strtoumax.c', 135 'swprintf.c', 136 'swscanf.c', 137 'tmpfile.c', 138 'tmpnam.c', 139 'ungetc.c', 140 'ungetwc.c', 141 'vasprintf.c', 142 'vffprintf.c', 143 'vffscanf.c', 144 'vfiprintf.c', 145 'vfiscanf.c', 146 'vflprintf.c', 147 'vflscanf.c', 148 'vfmprintf.c', 149 'vfmscanf.c', 150 'vfprintf.c', 151 'vfscanf.c', 152 'vfwprintf.c', 153 'vfwscanf.c', 154 'vprintf.c', 155 'vscanf.c', 156 'vsnprintf.c', 157 'vsprintf.c', 158 'vsscanf.c', 159 'vswprintf.c', 160 'vswscanf.c', 161 'vwprintf.c', 162 'vwscanf.c', 163 'wprintf.c', 164 'wscanf.c', 165] 166 167# exact float/string conversion code 168srcs_dtoa_ryu = [ 169 'atod_ryu.c', 170 'atof_ryu.c', 171 'dtoa_ryu.c', 172 'ftoa_ryu.c', 173 'ryu_divpow2.c', 174 'ryu_log10.c', 175 'ryu_log2pow5.c', 176 'ryu_pow5bits.c', 177 'ryu_table.c', 178 'ryu_umul128.c', 179] 180 181# smaller float/string conversion code 182srcs_dtoa_float = [ 183 'atod_engine.c', 184 'atof_engine.c', 185 'dtoa_engine.c', 186 'ftoa_engine.c', 187] 188 189if io_float_exact 190 srcs_tinystdio += srcs_dtoa_ryu 191else 192 srcs_tinystdio += srcs_dtoa_float 193endif 194 195# atomic support for ungetc 196srcs_tinystdio_atomic = [ 197 'compare_exchange.c', 198 'exchange.c', 199] 200 201if atomic_ungetc 202 srcs_tinystdio += srcs_tinystdio_atomic 203endif 204 205# code using POSIX APIs 206srcs_tinystdio_posix = [ 207 'fdopen.c', 208 'fopen.c', 209 'freopen.c', 210] 211 212if posix_io 213 srcs_tinystdio += srcs_tinystdio_posix 214endif 215 216# stdin/stdout/stderr using POSIX APIs 217srcs_tinystdio_posix_console = [ 218 'posixiob_stdin.c', 219 'posixiob_stdout.c', 220 'posixiob_stderr.c', 221] 222 223if posix_console 224 srcs_tinystdio += srcs_tinystdio_posix_console 225endif 226 227install_headers(['stdio.h', 'stdio-bufio.h'], 228 install_dir: include_dir 229 ) 230 231srcs_tinystdio_use = [] 232foreach file : srcs_tinystdio 233 s_file = fs.replace_suffix(file, '.S') 234 if file in srcs_machine 235 message('libc/tinystdio/' + file + ': machine overrides generic') 236 elif s_file in srcs_machine 237 message('libc/tinystdio/' + s_file + ': machine overrides generic') 238 else 239 srcs_tinystdio_use += file 240 endif 241endforeach 242 243src_tinystdio = files(srcs_tinystdio_use) 244