OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [reent/] [reent.tex] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
@node Reentrancy
2
@chapter Reentrancy
3
 
4
@cindex reentrancy
5
Reentrancy is a characteristic of library functions which allows multiple
6
processes to use the same address space with assurance that the values stored
7
in those spaces will remain constant between calls. Cygnus's implementation
8
of the library functions ensures that
9
whenever possible, these library functions are reentrant.  However,
10
there are some functions that can not be trivially made reentrant.
11
Hooks have been provided to allow you to use these functions in a fully
12
reentrant fashion.
13
 
14
@findex _reent
15
@findex reent.h
16
@cindex reentrancy structure
17
These hooks use the structure @code{_reent} defined in @file{reent.h}.
18
A variable defined as @samp{struct _reent} is called a @dfn{reentrancy
19
structure}.  All functions which must manipulate global information are
20
available in two versions.  The first version has the usual name, and
21
uses a single global instance of the reentrancy structure.  The second
22
has a different name, normally formed by prepending @samp{_} and
23
appending @samp{_r}, and takes a pointer to the particular reentrancy
24
structure to use.
25
 
26
For example, the function @code{fopen} takes two arguments, @var{file}
27
and @var{mode}, and uses the global reentrancy structure.  The function
28
@code{_fopen_r} takes the arguments, @var{struct_reent}, which is a
29
pointer to an instance of the reentrancy structure, @var{file}
30
and @var{mode}.
31
 
32
@cindex global reentrancy structure
33
@findex _impure_ptr
34
Each function which uses the global reentrancy structure uses the global
35
variable @code{_impure_ptr}, which points to a reentrancy structure.
36
 
37
This means that you have two ways to achieve reentrancy.  Both require
38
that each thread of execution control initialize a unique global
39
variable of type @samp{struct _reent}:
40
 
41
@enumerate
42
@item
43
@cindex extra argument, reentrant fns
44
Use the reentrant versions of the library functions, after initializing
45
a global reentrancy structure for each process.  Use the pointer to this
46
structure as the extra argument for all library functions.
47
 
48
@item
49
Ensure that each thread of execution control has a pointer to its own
50
unique reentrancy structure in the global variable @code{_impure_ptr},
51
and call the standard library subroutines.
52
@end enumerate
53
 
54
@cindex list of reentrant functions
55
@cindex reentrant function list
56
The following functions are provided in both reentrant
57
and non-reentrant versions.
58
 
59
@example
60
@exdent @emph{Equivalent for errno variable:}
61
_errno_r
62
 
63
@exdent @emph{Locale functions:}
64
_localeconv_r  _setlocale_r
65
 
66
@exdent @emph{Equivalents for stdio variables:}
67
_stdin_r        _stdout_r       _stderr_r
68
 
69
@page
70
@exdent @emph{Stdio functions:}
71
_fdopen_r       _perror_r       _tempnam_r
72
_fopen_r        _putchar_r      _tmpnam_r
73
_getchar_r      _puts_r         _tmpfile_r
74
_gets_r         _remove_r       _vfprintf_r
75
_iprintf_r      _rename_r       _vsnprintf_r
76
_mkstemp_r      _snprintf_r     _vsprintf_r
77
_mktemp_t       _sprintf_r
78
 
79
@exdent @emph{Signal functions:}
80
_init_signal_r  _signal_r
81
_kill_r         __sigtramp_r
82
_raise_r
83
 
84
@exdent @emph{Stdlib functions:}
85
_calloc_r       _mblen_r        _setenv_r
86
_dtoa_r         _mbstowcs_r     _srand_r
87
_free_r         _mbtowc_r       _strtod_r
88
_getenv_r       _memalign_r     _strtol_r
89
_mallinfo_r     _mstats_r       _strtoul_r
90
_malloc_r       _putenv_r       _system_r
91
_malloc_r       _rand_r         _wcstombs_r
92
_malloc_stats_r _realloc_r      _wctomb_r
93
 
94
@exdent @emph{String functions:}
95
_strdup_r       _strtok_r
96
 
97
@exdent @emph{System functions:}
98
_close_r        _link_r         _unlink_r
99
_execve_r       _lseek_r        _wait_r
100
_fcntl_r        _open_r         _write_r
101
_fork_r         _read_r
102
_fstat_r        _sbrk_r
103
_gettimeofday_r _stat_r
104
_getpid_r       _times_r
105
 
106
@exdent @emph{Time function:}
107
_asctime_r
108
@end example

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.