title: What exactly is a reentrant function?
body: <p><a href="https://stackoverflow.com/questions/1435541/is-this-function-reentrant/1435561#1435561">Most</a> <a href="https://stackoverflow.com/questions/856823/threadsafe-vs-re-entrant/856856#856856">of</a> <a href="https://stackoverflow.com/questions/1435541/is-this-function-reentrant/1435577#1435577">the</a> <a href="https://stackoverflow.com/questions/2441351/what-is-a-re-entrant-parser/2441401#2441401">times</a>, the definition of reentrance is quoted from <a href="http://en.wikipedia.org/wiki/Reentrant_%28subroutine%29" rel="noreferrer">Wikipedia</a>:</p>
  <blockquote>
  <p>A computer program or routine is
  described as reentrant if it can be
  <em><strong>safely</strong></em> called again before its
  previous invocation has been completed
  (i.e it can be safely executed
  concurrently). To be reentrant, a
  computer program or routine:</p>
  <ol>
  <li>Must hold no static (or global)
  non-constant data.</li>
  <li>Must not return the address to
  static (or global) non-constant
  data.</li>
  <li>Must work only on the data provided
  to it by the caller.</li>
  <li>Must not rely on locks to singleton
  resources.</li>
  <li>Must not modify its own code (unless
  executing in its own unique thread
  storage)</li>
  <li>Must not call non-reentrant computer
  programs or routines.</li>
  </ol>
  </blockquote>
  <p>How is <em><strong>safely</strong></em> defined?</p>
  <p>If a program can be <em><strong>safely executed concurrently</strong></em>, does it always mean that it is reentrant?</p>
  <p>What exactly is the common thread between the six points mentioned that I should keep in mind while checking my code for reentrant capabilities?</p>
  <p>Also,</p>
  <ol>
  <li>Are all recursive functions reentrant?</li>
  <li>Are all thread-safe functions reentrant?</li>
  <li>Are all recursive and thread-safe functions reentrant?</li>
  </ol>
  <hr />
  <p>While writing this question, one thing comes to mind:
  Are the terms like <strong>reentrance</strong> and <strong>thread safety</strong> absolute at all i.e. do they have fixed concrete definitions? For, if they are not, this question is not very meaningful.</p>