- Reindented code such that it uses three spaces for indentation instead
  of two. The indentation of the DRD source code is now consistent with
  the other Valgrind source files.
- Added emacs mode line with indentation settings.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9496 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/drd/drd_cond.c b/drd/drd_cond.c
index afee311..a698e1c 100644
--- a/drd/drd_cond.c
+++ b/drd/drd_cond.c
@@ -1,3 +1,4 @@
+/* -*- mode: C; c-basic-offset: 3; -*- */
 /*
   This file is part of drd, a thread error detector.
 
@@ -50,25 +51,25 @@
 
 void DRD_(cond_set_report_signal_unlocked)(const Bool r)
 {
-  DRD_(s_report_signal_unlocked) = r;
+   DRD_(s_report_signal_unlocked) = r;
 }
 
 void DRD_(cond_set_trace)(const Bool trace_cond)
 {
-  DRD_(s_trace_cond) = trace_cond;
+   DRD_(s_trace_cond) = trace_cond;
 }
 
 static
 void DRD_(cond_initialize)(struct cond_info* const p, const Addr cond)
 {
-  tl_assert(cond != 0);
-  tl_assert(p->a1         == cond);
-  tl_assert(p->type       == ClientCondvar);
+   tl_assert(cond != 0);
+   tl_assert(p->a1         == cond);
+   tl_assert(p->type       == ClientCondvar);
 
-  p->cleanup       = (void(*)(DrdClientobj*))(DRD_(cond_cleanup));
-  p->delete_thread = 0;
-  p->waiter_count  = 0;
-  p->mutex         = 0;
+   p->cleanup       = (void(*)(DrdClientobj*))(DRD_(cond_cleanup));
+   p->delete_thread = 0;
+   p->waiter_count  = 0;
+   p->mutex         = 0;
 }
 
 /**
@@ -77,111 +78,111 @@
  */
 static void DRD_(cond_cleanup)(struct cond_info* p)
 {
-  tl_assert(p);
-  if (p->mutex)
-  {
-    struct mutex_info* q;
-    q = &(DRD_(clientobj_get)(p->mutex, ClientMutex)->mutex);
-    tl_assert(q);
-    {
-      CondDestrErrInfo cde = { p->a1, q->a1, q->owner };
-      VG_(maybe_record_error)(VG_(get_running_tid)(),
-                              CondDestrErr,
-                              VG_(get_IP)(VG_(get_running_tid)()),
-                              "Destroying condition variable that is being"
-                              " waited upon",
-                              &cde);
-    }
-  }
+   tl_assert(p);
+   if (p->mutex)
+   {
+      struct mutex_info* q;
+      q = &(DRD_(clientobj_get)(p->mutex, ClientMutex)->mutex);
+      tl_assert(q);
+      {
+         CondDestrErrInfo cde = { p->a1, q->a1, q->owner };
+         VG_(maybe_record_error)(VG_(get_running_tid)(),
+                                 CondDestrErr,
+                                 VG_(get_IP)(VG_(get_running_tid)()),
+                                 "Destroying condition variable that is being"
+                                 " waited upon",
+                                 &cde);
+      }
+   }
 }
 
 static struct cond_info* DRD_(cond_get_or_allocate)(const Addr cond)
 {
-  struct cond_info *p;
+   struct cond_info *p;
 
-  tl_assert(offsetof(DrdClientobj, cond) == 0);
-  p = &(DRD_(clientobj_get)(cond, ClientCondvar)->cond);
-  if (p == 0)
-  {
-    p = &(DRD_(clientobj_add)(cond, ClientCondvar)->cond);
-    DRD_(cond_initialize)(p, cond);
-  }
-  return p;
+   tl_assert(offsetof(DrdClientobj, cond) == 0);
+   p = &(DRD_(clientobj_get)(cond, ClientCondvar)->cond);
+   if (p == 0)
+   {
+      p = &(DRD_(clientobj_add)(cond, ClientCondvar)->cond);
+      DRD_(cond_initialize)(p, cond);
+   }
+   return p;
 }
 
 static struct cond_info* DRD_(cond_get)(const Addr cond)
 {
-  tl_assert(offsetof(DrdClientobj, cond) == 0);
-  return &(DRD_(clientobj_get)(cond, ClientCondvar)->cond);
+   tl_assert(offsetof(DrdClientobj, cond) == 0);
+   return &(DRD_(clientobj_get)(cond, ClientCondvar)->cond);
 }
 
 /** Called before pthread_cond_init(). */
 void DRD_(cond_pre_init)(const Addr cond)
 {
-  struct cond_info* p;
+   struct cond_info* p;
 
-  if (DRD_(s_trace_cond))
-  {
-    VG_(message)(Vg_UserMsg,
-                 "[%d/%d] cond_init       cond 0x%lx",
-                 VG_(get_running_tid)(),
-                 DRD_(thread_get_running_tid)(),
-                 cond);
-  }
+   if (DRD_(s_trace_cond))
+   {
+      VG_(message)(Vg_UserMsg,
+                   "[%d/%d] cond_init       cond 0x%lx",
+                   VG_(get_running_tid)(),
+                   DRD_(thread_get_running_tid)(),
+                   cond);
+   }
 
-  p = DRD_(cond_get)(cond);
+   p = DRD_(cond_get)(cond);
 
-  if (p)
-  {
-    CondErrInfo cei = { .cond = cond };
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            CondErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "initialized twice",
-                            &cei);
-  }
+   if (p)
+   {
+      CondErrInfo cei = { .cond = cond };
+      VG_(maybe_record_error)(VG_(get_running_tid)(),
+                              CondErr,
+                              VG_(get_IP)(VG_(get_running_tid)()),
+                              "initialized twice",
+                              &cei);
+   }
 
-  p = DRD_(cond_get_or_allocate)(cond);
+   p = DRD_(cond_get_or_allocate)(cond);
 }
 
 /** Called after pthread_cond_destroy(). */
 void DRD_(cond_post_destroy)(const Addr cond)
 {
-  struct cond_info* p;
+   struct cond_info* p;
 
-  if (DRD_(s_trace_cond))
-  {
-    VG_(message)(Vg_UserMsg,
-                 "[%d/%d] cond_destroy    cond 0x%lx",
-                 VG_(get_running_tid)(),
-                 DRD_(thread_get_running_tid)(),
-                 cond);
-  }
+   if (DRD_(s_trace_cond))
+   {
+      VG_(message)(Vg_UserMsg,
+                   "[%d/%d] cond_destroy    cond 0x%lx",
+                   VG_(get_running_tid)(),
+                   DRD_(thread_get_running_tid)(),
+                   cond);
+   }
 
-  p = DRD_(cond_get)(cond);
-  if (p == 0)
-  {
-    CondErrInfo cei = { .cond = cond };
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            CondErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "not a condition variable",
-                            &cei);
-    return;
-  }
+   p = DRD_(cond_get)(cond);
+   if (p == 0)
+   {
+      CondErrInfo cei = { .cond = cond };
+      VG_(maybe_record_error)(VG_(get_running_tid)(),
+                              CondErr,
+                              VG_(get_IP)(VG_(get_running_tid)()),
+                              "not a condition variable",
+                              &cei);
+      return;
+   }
 
-  if (p->waiter_count != 0)
-  {
-    CondErrInfo cei = { .cond = cond };
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            CondErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "destruction of condition variable being waited"
-                            " upon",
-                            &cei);
-  }
+   if (p->waiter_count != 0)
+   {
+      CondErrInfo cei = { .cond = cond };
+      VG_(maybe_record_error)(VG_(get_running_tid)(),
+                              CondErr,
+                              VG_(get_IP)(VG_(get_running_tid)()),
+                              "destruction of condition variable being waited"
+                              " upon",
+                              &cei);
+   }
 
-  DRD_(clientobj_remove)(p->a1, ClientCondvar);
+   DRD_(clientobj_remove)(p->a1, ClientCondvar);
 }
 
 /** Called before pthread_cond_wait(). Note: before this function is called,
@@ -189,143 +190,143 @@
  */
 int DRD_(cond_pre_wait)(const Addr cond, const Addr mutex)
 {
-  struct cond_info* p;
-  struct mutex_info* q;
+   struct cond_info* p;
+   struct mutex_info* q;
 
-  if (DRD_(s_trace_cond))
-  {
-    VG_(message)(Vg_UserMsg,
-                 "[%d/%d] cond_pre_wait   cond 0x%lx",
-                 VG_(get_running_tid)(),
-                 DRD_(thread_get_running_tid)(),
-                 cond);
-  }
+   if (DRD_(s_trace_cond))
+   {
+      VG_(message)(Vg_UserMsg,
+                   "[%d/%d] cond_pre_wait   cond 0x%lx",
+                   VG_(get_running_tid)(),
+                   DRD_(thread_get_running_tid)(),
+                   cond);
+   }
 
-  p = DRD_(cond_get_or_allocate)(cond);
-  tl_assert(p);
+   p = DRD_(cond_get_or_allocate)(cond);
+   tl_assert(p);
 
-  if (p->waiter_count == 0)
-  {
-    p->mutex = mutex;
-  }
-  else if (p->mutex != mutex)
-  {
-    CondWaitErrInfo cwei
-      = { .cond = cond, .mutex1 = p->mutex, .mutex2 = mutex };
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            CondWaitErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "Inconsistent association of condition variable"
-                            " and mutex",
-                            &cwei);
-  }
-  tl_assert(p->mutex);
-  q = DRD_(mutex_get)(p->mutex);
-  if (q
-      && q->owner == DRD_(thread_get_running_tid)() && q->recursion_count > 0)
-  {
-    const ThreadId vg_tid = VG_(get_running_tid)();
-    MutexErrInfo MEI = { q->a1, q->recursion_count, q->owner };
-    VG_(maybe_record_error)(vg_tid,
-                            MutexErr,
-                            VG_(get_IP)(vg_tid),
-                            "Mutex locked recursively",
-                            &MEI);
-  }
-  else if (q == 0)
-  {
-    DRD_(not_a_mutex)(p->mutex);
-  }
+   if (p->waiter_count == 0)
+   {
+      p->mutex = mutex;
+   }
+   else if (p->mutex != mutex)
+   {
+      CondWaitErrInfo cwei
+         = { .cond = cond, .mutex1 = p->mutex, .mutex2 = mutex };
+      VG_(maybe_record_error)(VG_(get_running_tid)(),
+                              CondWaitErr,
+                              VG_(get_IP)(VG_(get_running_tid)()),
+                              "Inconsistent association of condition variable"
+                              " and mutex",
+                              &cwei);
+   }
+   tl_assert(p->mutex);
+   q = DRD_(mutex_get)(p->mutex);
+   if (q
+       && q->owner == DRD_(thread_get_running_tid)() && q->recursion_count > 0)
+   {
+      const ThreadId vg_tid = VG_(get_running_tid)();
+      MutexErrInfo MEI = { q->a1, q->recursion_count, q->owner };
+      VG_(maybe_record_error)(vg_tid,
+                              MutexErr,
+                              VG_(get_IP)(vg_tid),
+                              "Mutex locked recursively",
+                              &MEI);
+   }
+   else if (q == 0)
+   {
+      DRD_(not_a_mutex)(p->mutex);
+   }
 
-  return ++p->waiter_count;
+   return ++p->waiter_count;
 }
 
 /** Called after pthread_cond_wait(). */
 int DRD_(cond_post_wait)(const Addr cond)
 {
-  struct cond_info* p;
+   struct cond_info* p;
 
-  if (DRD_(s_trace_cond))
-  {
-    VG_(message)(Vg_UserMsg,
-                 "[%d/%d] cond_post_wait  cond 0x%lx",
-                 VG_(get_running_tid)(),
-                 DRD_(thread_get_running_tid)(),
-                 cond);
-  }
+   if (DRD_(s_trace_cond))
+   {
+      VG_(message)(Vg_UserMsg,
+                   "[%d/%d] cond_post_wait  cond 0x%lx",
+                   VG_(get_running_tid)(),
+                   DRD_(thread_get_running_tid)(),
+                   cond);
+   }
 
-  p = DRD_(cond_get)(cond);
-  if (p)
-  {
-    if (p->waiter_count > 0)
-    {
-      --p->waiter_count;
-      if (p->waiter_count == 0)
+   p = DRD_(cond_get)(cond);
+   if (p)
+   {
+      if (p->waiter_count > 0)
       {
-        p->mutex = 0;
+         --p->waiter_count;
+         if (p->waiter_count == 0)
+         {
+            p->mutex = 0;
+         }
       }
-    }
-    return p->waiter_count;
-  }
-  return 0;
+      return p->waiter_count;
+   }
+   return 0;
 }
 
 static void DRD_(cond_signal)(Addr const cond)
 {
-  const ThreadId vg_tid = VG_(get_running_tid)();
-  const DrdThreadId drd_tid = DRD_(VgThreadIdToDrdThreadId)(vg_tid);
-  struct cond_info* const cond_p = DRD_(cond_get)(cond);
+   const ThreadId vg_tid = VG_(get_running_tid)();
+   const DrdThreadId drd_tid = DRD_(VgThreadIdToDrdThreadId)(vg_tid);
+   struct cond_info* const cond_p = DRD_(cond_get)(cond);
 
-  if (cond_p && cond_p->waiter_count > 0)
-  {
-    if (DRD_(s_report_signal_unlocked)
-        && ! DRD_(mutex_is_locked_by)(cond_p->mutex, drd_tid))
-    {
-      /* A signal is sent while the associated mutex has not been locked. */
-      /* This can indicate but is not necessarily a race condition.       */
-      CondRaceErrInfo cei;
-      cei.cond  = cond;
-      cei.mutex = cond_p->mutex;
-      VG_(maybe_record_error)(vg_tid,
-                              CondRaceErr,
-                              VG_(get_IP)(vg_tid),
-                              "CondErr",
-                              &cei);
-    }
-  }
-  else
-  {
-    /* No other thread is waiting for the signal, hence the signal will be */
-    /* lost. This is normal in a POSIX threads application.                */
-  }
+   if (cond_p && cond_p->waiter_count > 0)
+   {
+      if (DRD_(s_report_signal_unlocked)
+          && ! DRD_(mutex_is_locked_by)(cond_p->mutex, drd_tid))
+      {
+         /* A signal is sent while the associated mutex has not been locked. */
+         /* This can indicate but is not necessarily a race condition.       */
+         CondRaceErrInfo cei;
+         cei.cond  = cond;
+         cei.mutex = cond_p->mutex;
+         VG_(maybe_record_error)(vg_tid,
+                                 CondRaceErr,
+                                 VG_(get_IP)(vg_tid),
+                                 "CondErr",
+                                 &cei);
+      }
+   }
+   else
+   {
+      /* No other thread is waiting for the signal, hence the signal will be */
+      /* lost. This is normal in a POSIX threads application.                */
+   }
 }
 
 /** Called before pthread_cond_signal(). */
 void DRD_(cond_pre_signal)(Addr const cond)
 {
-  if (DRD_(s_trace_cond))
-  {
-    VG_(message)(Vg_UserMsg,
-                 "[%d/%d] cond_signal     cond 0x%lx",
-                 VG_(get_running_tid)(),
-                 DRD_(thread_get_running_tid)(),
-                 cond);
-  }
+   if (DRD_(s_trace_cond))
+   {
+      VG_(message)(Vg_UserMsg,
+                   "[%d/%d] cond_signal     cond 0x%lx",
+                   VG_(get_running_tid)(),
+                   DRD_(thread_get_running_tid)(),
+                   cond);
+   }
 
-  DRD_(cond_signal)(cond);
+   DRD_(cond_signal)(cond);
 }
 
 /** Called before pthread_cond_broadcast(). */
 void DRD_(cond_pre_broadcast)(Addr const cond)
 {
-  if (DRD_(s_trace_cond))
-  {
-    VG_(message)(Vg_UserMsg,
-                 "[%d/%d] cond_broadcast  cond 0x%lx",
-                 VG_(get_running_tid)(),
-                 DRD_(thread_get_running_tid)(),
-                 cond);
-  }
+   if (DRD_(s_trace_cond))
+   {
+      VG_(message)(Vg_UserMsg,
+                   "[%d/%d] cond_broadcast  cond 0x%lx",
+                   VG_(get_running_tid)(),
+                   DRD_(thread_get_running_tid)(),
+                   cond);
+   }
 
-  DRD_(cond_signal)(cond);
+   DRD_(cond_signal)(cond);
 }