blob: 9667994e8a0a9b636eea5b595ca1f48344fd2820 [file] [log] [blame]
//===-- Printf Configuration Handler ----------------------------*- C++ -*-===//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// The index array buffer is always initialized when printf is called. In cases
// where index mode is necessary but memory is limited, or when index mode
// performance is important and memory is available, this compile option
// provides a knob to adjust memory usage to an appropriate level. 128 is picked
// as the default size since that's big enough to handle even extreme cases and
// the runtime penalty for not having enough space is severe.
// When an index mode argument is requested, if its index is before the most
// recently read index, then the arg list must be restarted from the beginning,
// and all of the arguments before the new index must be requested with the
// correct types. The index array caches the types of the values in the arg
// list. For every number between the last index cached in the array and the
// requested index, the format string must be parsed again to find the
// type of that index. As an example, if the format string has 20 indexes, and
// the index array is 10, then when the 20th index is requested the first 10
// types can be found immediately, and then the format string must be parsed 10
// times to find the types of the next 10 arguments.
// TODO(michaelrj): Move the other printf configuration options into this file.