B
Bill Cunningham
What is a reentrant function? Are there any of these in c89 or c99?
B
B
What is a reentrant function? Are there any of these in c89 or c99?
In said:What is a reentrant function? Are there any of these in c89 or c99?
What is a reentrant function? Are there any of these in c89 or c99?
What is a reentrant function? Are there any of these in c89 or c99?
one that can be re-entered. ...
... This really applies to threading or interupts neither of which the older C standards address.
So we don't know if any function is re. But in fact most of them could fairly easily be made reentrant (eg. sin, strcpy etc.). Functions that hold internal state or have side effects (change the environment) likely aren't- strtok(), malloc(), rand(), anything to do with i/o
James said:A definition that uses another version of the same word being defined
is generally not very helpful.
A re-entrant function is one that can be safely be called while
execution of another call to that function is still in progress. One
of the most common barriers to re-entrancy is writing to memory with
static storage duration (in C2011, thread storage duration poses
similar problems) which is shared between the two copies of the
function; however, any other resource shared between them (such as
files) could also be a source of problems.
Reentrancy can also be an issue for directly or indirectly recursive
function calls, or for signal handlers, which were issues that could
come up even in C90. For instance, the fact that strtok() is not
re-entrant caused problems for some utility library code which I did
not write, but for which I was responsible. The calling function was
in the middle of a strtok() loop when it called my library routine
which contained it's own strtok() loop. I changed my function to use
an alternative approach to tokenizing the string it was parsing.
7.1.4p4: "The functions in the standard library are not guaranteed to
be reentrant and may modify objects with static or thread storage
duration."
However, many of the optional functions described in Annex K, which
are new in C2011, are intended to address re-entrancy issues
associated with the older versions of those functions.
Kaz said:Something that keeps going back into a newsgroup, without being aware
of any previous state.
Google didn't help me much on this. I was looking at posix functions.
Some reentrant some evidently not. These reentrant functions usually end in
*_r. I thought maybe the same thing existed in C and could help me
understand.
Barry said:Any function which limits the objects it updates to ones that have
automatic duration bounded by the life of the function and which calls
only functions which also observe this limitation is potentially
reentrent. The fact that most functions don't call themselves
recursively doesn't mean they couldn't.
So you must be looking for something else. Did you perhaps mean
thread-safe?
The man page. man (de)crypt did say anything about threads. But it did
mean static storage and non static storage and provided a struct to use if
one wanted reentrant. This is on my linux system but does seem to show on
linix.die.com.
jacob said:Le 27/04/12 00:30, Bill Cunningham a écrit :
WOW! What a sentence Bill. That's quite a show.
"The man page. man (de)crypt did say anything about threads."
Maybe
"The man page. man (de)crypt didn't say anything about threads."
http://www.kernel.org/doc/man-pages/online/pages/man3/encrypt.3.htmlBill said:jacob said:Le 27/04/12 00:30, Bill Cunningham a écrit :
WOW! What a sentence Bill. That's quite a show.
"The man page. man (de)crypt did say anything about threads."
Maybe
"The man page. man (de)crypt didn't say anything about threads."
The above was correct.
[snip]
I have looked at decrypt and crypt both. I shall recheck for those
interested.
B
What is a reentrant function? Are there any of these in c89 or c99?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.