mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
7fe1fde499
The gilbc manual has some documentation in llio.texi of requirements for moving between I/O on FILE * streams and file descriptors on the same open file description. The documentation of what must be done on a FILE * stream to move from it to either a file descriptor or another FILE * for the same open file description seems to match POSIX. However, there is an additional requirement in POSIX on the *second* of the two handles being moved between, which is not mentioned in the glibc manual: "If any previous active handle has been used by a function that explicitly changed the file offset, except as required above for the first handle, the application shall perform an lseek() or fseek() (as appropriate to the type of handle) to an appropriate location.". Document this requirement on seeking in the glibc manual, limited to the case that seems relevant to glibc (the new channel is a previously active stream, on which the seeking previously occurred). Note that I'm not sure what the "except as required above for the first handle" is meant to be about, so I haven't documented anything for it. As far as I can tell, nothing specified for moving from the first handle actually list calling a seek function as one of the steps to be done. (Current POSIX doesn't seem to have any relevant rationale for this section. The rationale in the 1996 edition says "In requiring the seek to an appropriate location for the new handle, the application is required to know what it is doing if it is passing streams with seeks involved. If the required seek is not done, the results are undefined (and in fact the program probably will not work on many common implementations)." - which also doesn't help in understanding the purpose of "except as required above for the first handle".) Tested with "make info" and "make pdf". |
||
---|---|---|
.. | ||
examples | ||
argp.texi | ||
arith.texi | ||
charset.texi | ||
check-deftype.sh | ||
check-safety.sh | ||
conf.texi | ||
contrib.texi | ||
creature.texi | ||
crypt.texi | ||
ctype.texi | ||
debug.texi | ||
dir | ||
dynlink.texi | ||
errno.texi | ||
fdl-1.3.texi | ||
filesys.texi | ||
freemanuals.texi | ||
getopt.texi | ||
header.texi | ||
install-plain.texi | ||
install.texi | ||
intro.texi | ||
io.texi | ||
ipc.texi | ||
job.texi | ||
lang.texi | ||
lgpl-2.1.texi | ||
libc-texinfo.sh | ||
libc.texinfo | ||
libcbook.texi | ||
llio.texi | ||
locale.texi | ||
macros.texi | ||
maint.texi | ||
Makefile | ||
math.texi | ||
memory.texi | ||
message.texi | ||
nss.texi | ||
nsswitch.texi | ||
pattern.texi | ||
pipe.texi | ||
platform.texi | ||
probes.texi | ||
process.texi | ||
README.pretty-printers | ||
README.tunables | ||
resource.texi | ||
search.texi | ||
setjmp.texi | ||
signal.texi | ||
socket.texi | ||
startup.texi | ||
stdbit.texi | ||
stdio-fp.c | ||
stdio.texi | ||
string.texi | ||
summary.pl | ||
sysinfo.texi | ||
syslog.texi | ||
terminal.texi | ||
texinfo.tex | ||
texis.awk | ||
threads.texi | ||
time.texi | ||
tsort.awk | ||
tunables.texi | ||
users.texi | ||
xtract-typefun.awk |
TUNABLE FRAMEWORK ================= Tunables is a feature in the GNU C Library that allows application authors and distribution maintainers to alter the runtime library behaviour to match their workload. The tunable framework allows modules within glibc to register variables that may be tweaked through an environment variable. It aims to enforce a strict namespace rule to bring consistency to naming of these tunable environment variables across the project. This document is a guide for glibc developers to add tunables to the framework. ADDING A NEW TUNABLE -------------------- The TOP_NAMESPACE macro is defined by default as 'glibc'. If distributions intend to add their own tunables, they should do so in a different top namespace by overriding the TOP_NAMESPACE macro for that tunable. Downstream implementations are discouraged from using the 'glibc' top namespace for tunables they don't already have consensus to push upstream. There are three steps to adding a tunable: 1. Add a tunable to the list and fully specify its properties: For each tunable you want to add, make an entry in elf/dl-tunables.list. The format of the file is as follows: TOP_NAMESPACE { NAMESPACE1 { TUNABLE1 { # tunable attributes, one per line } # A tunable with default attributes, i.e. string variable. TUNABLE2 TUNABLE3 { # its attributes } } NAMESPACE2 { ... } } The list of allowed attributes are: - type: Data type. Defaults to STRING. Allowed types are: INT_32, UINT_64, SIZE_T and STRING. Numeric types may be in octal or hexadecimal format too. - minval: Optional minimum acceptable value. For a string type this is the minimum length of the value. - maxval: Optional maximum acceptable value. For a string type this is the maximum length of the value. - default: Specify an optional default value for the tunable. - env_alias: An alias environment variable 2. Use TUNABLE_GET/TUNABLE_SET/TUNABLE_SET_WITH_BOUNDS to get and set tunables. 3. OPTIONAL: If tunables in a namespace are being used multiple times within a specific module, set the TUNABLE_NAMESPACE macro to reduce the amount of typing. GETTING AND SETTING TUNABLES ---------------------------- When the TUNABLE_NAMESPACE macro is defined, one may get tunables in that module using the TUNABLE_GET macro as follows: val = TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (check_callback)) where 'check' is the tunable name, 'int32_t' is the C type of the tunable and 'check_callback' is the function to call if the tunable got initialized to a non-default value. The macro returns the value as type 'int32_t'. The callback function should be defined as follows: void TUNABLE_CALLBACK (check_callback) (int32_t *valp) { ... } where it can expect the tunable value to be passed in VALP. Tunables in the module can be updated using: TUNABLE_SET (check, val) where 'check' is the tunable name and 'val' is a value of same type. To get and set tunables in a different namespace from that module, use the full form of the macros as follows: val = TUNABLE_GET_FULL (glibc, malloc, mmap_max, int32_t, NULL) TUNABLE_SET_FULL (glibc, malloc, mmap_max, val) where 'glibc' is the top namespace, 'malloc' is the tunable namespace and the remaining arguments are the same as the short form macros. The minimum and maximum values can updated together with the tunable value using: TUNABLE_SET_WITH_BOUNDS (check, val, min, max) where 'check' is the tunable name, 'val' is a value of same type, 'min' and 'max' are the minimum and maximum values of the tunable. To set the minimum and maximum values of tunables in a different namespace from that module, use the full form of the macros as follows: val = TUNABLE_GET_FULL (glibc, malloc, mmap_max, int32_t, NULL) TUNABLE_SET_WITH_BOUNDS_FULL (glibc, malloc, mmap_max, val, min, max) where 'glibc' is the top namespace, 'malloc' is the tunable namespace and the remaining arguments are the same as the short form macros. When TUNABLE_NAMESPACE is not defined in a module, TUNABLE_GET is equivalent to TUNABLE_GET_FULL, so you will need to provide full namespace information for both macros. Likewise for TUNABLE_SET, TUNABLE_SET_FULL, TUNABLE_SET_WITH_BOUNDS and TUNABLE_SET_WITH_BOUNDS_FULL. ** IMPORTANT NOTE ** The tunable list is set as read-only after the dynamic linker relocates itself, so setting tunable values must be limited only to tunables within the dynamic linker, that too before relocation. FUTURE WORK ----------- The framework currently only allows a one-time initialization of variables through environment variables and in some cases, modification of variables via an API call. A future goals for this project include: - Setting system-wide and user-wide defaults for tunables through some mechanism like a configuration file. - Allow tweaking of some tunables at runtime