+/* **************************** Public C interface *************************** */
+/** @brief creates a semaphore object of the given initial capacity */
+sg_sem_t sg_sem_init(int initial_value)
+{
+ return new simgrid::s4u::Semaphore(initial_value);
+}
+
+/** @brief locks on a semaphore object */
+void sg_sem_acquire(sg_sem_t sem)
+{
+ sem->acquire();
+}
+
+/** @brief locks on a semaphore object up until the provided timeout expires */
+int sg_sem_acquire_timeout(sg_sem_t sem, double timeout)
+{
+ return sem->acquire_timeout(timeout);
+}
+
+/** @brief releases the semaphore object */
+void sg_sem_release(sg_sem_t sem)
+{
+ sem->release();
+}
+
+int sg_sem_get_capacity(sg_sem_t sem)
+{
+ return sem->get_capacity();
+}
+
+void sg_sem_destroy(sg_sem_t sem)
+{
+ delete sem;
+}
+
+/** @brief returns a boolean indicating if this semaphore would block at this very specific time
+ *
+ * Note that the returned value may be wrong right after the function call, when you try to use it...
+ * But that's a classical semaphore issue, and SimGrid's semaphore are not different to usual ones here.
+ */
+int sg_sem_would_block(sg_sem_t sem)
+{
+ return sem->would_block();
+}