title: Why are sem_init(), sem_getvalue(), sem_destroy() deprecated on Mac OS X — and what replaces them?
body: <p>When I compile a program using the POSIX <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html" rel="noreferrer"><code>sem_init()</code></a> function, I get a compilation warning (error because I normally use <code>-Werror</code>) that the function has been deprecated when I compile on Mac OS X 10.10.1 (Yosemite) with GCC 4.9.1 or the version of Clang (<code>Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)</code>) from XCode 6.1.1.  A quick look at <code>/usr/include/sys/semaphore.h</code> shows that the function does indeed have a <code>__deprecated</code> tag after its declaration, as do
  <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_getvalue.html" rel="noreferrer"><code>sem_getvalue()</code></a> and
  <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_destroy.html" rel="noreferrer"><code>sem_destroy()</code></a>.</p>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>Given that there is no hint of deprecation in the POSIX specification, why are these three functions singled out as deprecated on Mac OS X?</p></li>
  <li><p>Given that they are deprecated, what is the replacement, and why is the replacement preferred?</p></li>
  </ol>
  
  <p>(<em>I did check <a href="https://apple.stackexchange.com/">Ask Different</a> first; there are no questions tagged <a href="/questions/tagged/c" class="post-tag" title="show questions tagged &#39;c&#39;" rel="tag">c</a> and no questions that ask about deprecated system calls — only programs.</em>)</p>