]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Removed trailing whitespace in C source and header files.
authorBart Van Assche <bvanassche@acm.org>
Sun, 21 Feb 2010 14:52:59 +0000 (14:52 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 21 Feb 2010 14:52:59 +0000 (14:52 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11052

33 files changed:
drd/drd.h
drd/drd_bitmap.c
drd/drd_bitmap.h
drd/drd_bitmap2_node.c
drd/drd_clientobj.c
drd/drd_clientreq.c
drd/drd_error.c
drd/drd_error.h
drd/drd_load_store.c
drd/drd_load_store.h
drd/drd_main.c
drd/drd_malloc_wrappers.c
drd/drd_pthread_intercepts.c
drd/drd_qtcore_intercepts.c
drd/drd_segment.h
drd/drd_semaphore.c
drd/drd_strmem_intercepts.c
drd/drd_suppression.c
drd/drd_thread.c
drd/drd_thread.h
drd/drd_vc.h
drd/tests/annotate_ignore_rw.c
drd/tests/annotate_ignore_write.c
drd/tests/custom_alloc.c
drd/tests/fp_race.c
drd/tests/matinv.c
drd/tests/omp_matinv.c
drd/tests/pth_broadcast.c
drd/tests/pth_detached.c
drd/tests/pth_detached_sem.c
drd/tests/sem_as_mutex.c
drd/tests/sem_open.c
drd/tests/tsan_thread_wrappers_pthread.h

index 83720e6580fa0076fb3427b5dd277a2c6bc7f311..62db36c925452068ea5ec204b7880d3e4af6d8cb 100644 (file)
--- a/drd/drd.h
+++ b/drd/drd.h
@@ -82,7 +82,7 @@
 #define DRD_STOP_IGNORING_VAR(x) DRDCL_(ignore_range)(&(x), sizeof(x))
 
 /**
- * Tell DRD to trace all memory accesses on the specified variable. 
+ * Tell DRD to trace all memory accesses on the specified variable.
  * until the memory that was allocated for the variable is freed.
  */
 #define DRD_TRACE_VAR(x) DRDCL_(trace_range)(&(x), sizeof(x))
index 82b6a0648616f75367d45e3998a058192d1cb235..7cdf87865fe539505ee8003803927123d0b274fd 100644 (file)
@@ -368,7 +368,7 @@ DRD_(bm_has_any_load)(struct bitmap* const bm, const Addr a1, const Addr a2)
          tl_assert(a1 <= b_end && b_end <= a2);
          tl_assert(b_start < b_end);
          tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
-      
+
          for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
          {
             if (bm0_is_set(p1->bm0_r, b0))
@@ -421,7 +421,7 @@ Bool DRD_(bm_has_any_store)(struct bitmap* const bm,
          tl_assert(a1 <= b_end && b_end <= a2);
          tl_assert(b_start < b_end);
          tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
-      
+
          for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
          {
             if (bm0_is_set(p1->bm0_w, b0))
@@ -476,7 +476,7 @@ Bool DRD_(bm_has_any_access)(struct bitmap* const bm,
          tl_assert(a1 <= b_end && b_end <= a2);
          tl_assert(b_start < b_end);
          tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
-      
+
          for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
          {
             /*
@@ -809,7 +809,7 @@ Bool DRD_(bm_has_conflict_with)(struct bitmap* const bm,
          tl_assert(a1 <= b_end && b_end <= a2);
          tl_assert(b_start < b_end);
          tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
-      
+
          for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
          {
             if (access_type == eLoad)
index 1bfde4560bba3644771b801487db7fd2bccfda64..bb04053e59d5abcd658a5f1f47aa61766f2268b4 100644 (file)
@@ -41,7 +41,7 @@
 
 /* Client addresses are split into bitfields as follows:
  * ------------------------------------------------------
- * | Address MSB |      Address LSB      | Ignored bits | 
+ * | Address MSB |      Address LSB      | Ignored bits |
  * ------------------------------------------------------
  * | Address MSB | UWord MSB | UWord LSB | Ignored bits |
  * ------------------------------------------------------
@@ -281,7 +281,7 @@ static __inline__ void bm0_clear_range(UWord* bm0,
    tl_assert(size == 0 || uword_msb(a) == uword_msb(a + size - 1));
 #endif
    /*
-    * Note: although the expression below yields a correct result even if 
+    * Note: although the expression below yields a correct result even if
     * size == 0, do not touch bm0[] if size == 0 because this might otherwise
     * cause an access of memory just past the end of the bm0[] array.
     */
index 6d016da99f0d19b080505a7998a23a12d61a554f..300fb416136e13ba6374c1c448ca2fd2f5546b38 100644 (file)
@@ -118,7 +118,7 @@ void* DRD_(bm2_alloc_node)(HChar* const ec, const SizeT szB)
    /*
     * If szB < sizeof(struct bitmap2) then this function has been called to
     * allocate an AVL tree root node. Otherwise it has been called to allocate
-    * an AVL tree branch or leaf node. 
+    * an AVL tree branch or leaf node.
     */
    if (szB < sizeof(struct bitmap2))
       return VG_(malloc)(ec, szB);
index d3f55f02950a7ef33f3ec06ea2b7032ccb7b499a..4f305cb1ffa1ddeb1fe0764f4f0e049ae0004330 100644 (file)
@@ -113,7 +113,7 @@ Bool DRD_(clientobj_present)(const Addr a1, const Addr a2)
    {
       if (a1 <= p->any.a1 && p->any.a1 < a2)
       {
-         return True;  
+         return True;
       }
    }
    return False;
index 8aa89ff3bfd653ba150e1a4bd24b45927fcc3e7e..0363a3fec0e820289eb2d4948fead419734813ad 100644 (file)
@@ -487,7 +487,7 @@ static Bool handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
       if (DRD_(thread_enter_synchr)(drd_tid) == 0)
          DRD_(rwlock_pre_unlock)(arg[1], pthread_rwlock);
       break;
-      
+
    case VG_USERREQ__POST_RWLOCK_UNLOCK:
       DRD_(thread_leave_synchr)(drd_tid);
       break;
index b46fc7f6701ea2f7ba25315b0ac3465950a4f23b..2c10703b39c7bad46d4cc3fb95c980e038e8c091 100644 (file)
@@ -190,7 +190,7 @@ void drd_report_data_race(Error* const err, const DataRaceErrInfo* const dri)
 /**
  * Compare two error contexts. The core function VG_(maybe_record_error)()
  * calls this function to compare error contexts such that errors that occur
- * repeatedly are only printed once. This function is only called by the core 
+ * repeatedly are only printed once. This function is only called by the core
  * if the error kind of e1 and e2 matches and if the ExeContext's of e1 and
  * e2 also match.
  */
index 6af6cdd0f91fcd9f46bd750aff52e73d165396a8..c8e582a716da75a573f45fab87de7208cb27d7de 100644 (file)
@@ -66,13 +66,13 @@ typedef enum {
 } DrdErrorKind;
 
 /* The classification of a faulting address. */
-typedef 
-enum { 
+typedef
+enum {
    //Undescribed,   // as-yet unclassified
-   eStack, 
+   eStack,
    eUnknown,       // classification yielded nothing useful
    //Freed,
-   eMallocd, 
+   eMallocd,
    eSegment,       // in a segment (as defined in pub_tool_debuginfo.h)
    //UserG,         // in a user-defined block
    //Mempool,       // in a mempool
index 01086d963944015f877b924ead48b5334c545dc5..c3f1011f05b3a1feda9efe68b62a3908897a1e25 100644 (file)
@@ -442,7 +442,7 @@ static void instrument_store(IRSB* const bb,
 IRSB* DRD_(instrument)(VgCallbackClosure* const closure,
                        IRSB* const bb_in,
                        VexGuestLayout* const layout,
-                       VexGuestExtents* const vge, 
+                       VexGuestExtents* const vge,
                        IRType const gWordTy,
                        IRType const hWordTy)
 {
index 974defcfe5005216c147e86b8ec89e7f02b01870..8619fa915273dd4772bb488ee7f7251e87734ebf 100644 (file)
@@ -43,7 +43,7 @@ void DRD_(set_first_race_only)(const Bool fro);
 IRSB* DRD_(instrument)(VgCallbackClosure* const closure,
                        IRSB* const bb_in,
                        VexGuestLayout* const layout,
-                       VexGuestExtents* const vge, 
+                       VexGuestExtents* const vge,
                        IRType const gWordTy,
                        IRType const hWordTy);
 void DRD_(trace_mem_access)(const Addr addr, const SizeT size,
index 2a1a7153551e1b46e37e00f8d7b08cdb58f415cb..ee2076001e8f0b06016cf12769865a466f18cee8 100644 (file)
@@ -214,7 +214,7 @@ DRD_(thread_get_segment_merge_interval)()
 }
 
 static void DRD_(print_debug_usage)(void)
-{  
+{
    VG_(printf)(
 "    --drd-stats=yes|no        Print statistics about DRD activity [no].\n"
 "    --trace-clientobj=yes|no  Trace all client object activity [no].\n"
@@ -287,7 +287,7 @@ void drd_start_using_mem(const Addr a1, const SizeT len)
    {
       DRD_(trace_mem_access)(a1, len, eStart);
    }
-   
+
    if (UNLIKELY(DRD_(running_thread_inside_pthread_create)()))
    {
       DRD_(start_suppression)(a1, a1 + len, "pthread_create()");
@@ -414,7 +414,7 @@ void drd_start_using_mem_stack(const Addr a, const SizeT len)
 {
    DRD_(thread_set_stack_min)(DRD_(thread_get_running_tid)(),
                               a - VG_STACK_REDZONE_SZB);
-   drd_start_using_mem(a - VG_STACK_REDZONE_SZB, 
+   drd_start_using_mem(a - VG_STACK_REDZONE_SZB,
                        len + VG_STACK_REDZONE_SZB);
 }
 
@@ -567,7 +567,7 @@ static void DRD_(fini)(Int exitcode)
 {
    // thread_print_all();
    if (VG_(clo_verbosity) == 1 && !VG_(clo_xml)) {
-      VG_(message)(Vg_UserMsg, 
+      VG_(message)(Vg_UserMsg,
                    "For counts of detected and suppressed errors, "
                    "rerun with: -v\n");
    }
index d380ecc52f58287879605efa7a78a0ed9252658f..13988eee8d4a76d1c598786dbefd899e824f2fea 100644 (file)
@@ -225,7 +225,7 @@ static void* drd_realloc(ThreadId tid, void* p_old, SizeT new_size)
       {
          /* Copy from old to new. */
          VG_(memcpy)(p_new, p_old, mc->size);
-         
+
          /* Free old memory. */
          VG_(cli_free)(p_old);
          if (mc->size > 0)
@@ -243,7 +243,7 @@ static void* drd_realloc(ThreadId tid, void* p_old, SizeT new_size)
       {
          /* Allocation failed -- leave original block untouched. */
       }
-   }  
+   }
 
    return p_new;
 }
@@ -346,7 +346,7 @@ void DRD_(print_malloc_stats)(void)
    DRD_Chunk* mc;
    SizeT     nblocks = 0;
    SizeT     nbytes  = 0;
-   
+
    if (VG_(clo_verbosity) == 0)
       return;
    if (VG_(clo_xml))
@@ -360,10 +360,10 @@ void DRD_(print_malloc_stats)(void)
       nbytes += mc->size;
    }
 
-   VG_(message)(Vg_DebugMsg, 
+   VG_(message)(Vg_DebugMsg,
                 "malloc/free: in use at exit: %lu bytes in %lu blocks.\n",
                 nbytes, nblocks);
-   VG_(message)(Vg_DebugMsg, 
+   VG_(message)(Vg_DebugMsg,
                 "malloc/free: %lu allocs, %lu frees, %lu bytes allocated.\n",
                 s_cmalloc_n_mallocs,
                 s_cmalloc_n_frees, s_cmalloc_bs_mallocd);
index 2193ed7e540a842eed0e014718d1d7141effba16..c494db1bccd59345b4f4a11d32902307de19de68 100644 (file)
@@ -28,7 +28,7 @@
 */
 
 /* ---------------------------------------------------------------------
-   ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU. 
+   ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU.
 
    These functions are not called directly - they're the targets of code
    redirection or load notifications (see pub_core_redir.h for info).
index cddfef9cdd91e9efd5b99a106b01df0eb3c5df2b..fbb88c3295a79109d6aa33537d71e33d02af3319 100644 (file)
@@ -28,7 +28,7 @@
 */
 
 /* ---------------------------------------------------------------------
-   ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU. 
+   ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU.
 
    These functions are not called directly - they're the targets of code
    redirection or load notifications (see pub_core_redir.h for info).
index 09f248ccd512ab9ccde74259eb1e3daaf28421b5..8167551777613d4ad959b565d3eff2edf0e68ecb 100644 (file)
@@ -28,7 +28,7 @@
 
 
 /*
- * Segments and segment lists. A segment represents information about 
+ * Segments and segment lists. A segment represents information about
  * a contiguous group of statements of a specific thread. There is a vector
  * clock associated with each segment.
  */
index d7a9ebf60fd06e39a0124b7b26a0abdce6a0ee7a..65b4ad695bd83250581d49451f878b435fde0ed9 100644 (file)
@@ -445,12 +445,12 @@ void DRD_(semaphore_post_post)(const DrdThreadId tid, const Addr semaphore,
                                const Bool succeeded)
 {
    /*
-    * Note: it is hard to implement the sem_post() wrapper correctly in    
-    * case sem_post() returns an error code. This is because handling this 
-    * case correctly requires restoring the vector clock associated with   
+    * Note: it is hard to implement the sem_post() wrapper correctly in
+    * case sem_post() returns an error code. This is because handling this
+    * case correctly requires restoring the vector clock associated with
     * the semaphore to its original value here. In order to do that without
-    * introducing a race condition, extra locking has to be added around   
-    * each semaphore call. Such extra locking would have to be added in    
+    * introducing a race condition, extra locking has to be added around
+    * each semaphore call. Such extra locking would have to be added in
     * drd_pthread_intercepts.c. However, it is hard to implement
     * synchronization in drd_pthread_intercepts.c in a portable way without
     * calling already redirected functions.
index 621cfa0d215dbd6cc14b4e92595fb5a60aa5b6eb..49691334064b618e09ecfa99ef7ed07a9590aa19 100644 (file)
@@ -11,7 +11,7 @@
   from memchec/mc_replace_strmem.c, which has the following copyright
   notice:
 
-  Copyright (C) 2000-2009 Julian Seward 
+  Copyright (C) 2000-2009 Julian Seward
   jseward@acm.org
 
   This program is free software; you can redistribute it and/or
@@ -49,7 +49,7 @@
    }
 
 STRNLEN(VG_Z_LIBC_SONAME, strnlen)
-   
+
 
 // Note that this replacement often doesn't get used because gcc inlines
 // calls to strlen() with its own built-in version.  This can be very
index 8261ce08e559d7029e14a721f76c9e43c294e431..99b6cb738271e58d32890c2a9b5f278fb7ebacab 100644 (file)
@@ -76,7 +76,7 @@ void DRD_(finish_suppression)(const Addr a1, const Addr a2)
    {
       VG_(message)(Vg_DebugMsg, "finish suppression of 0x%lx sz %ld\n",
                    a1, a2 - a1);
-      VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(), 12);   
+      VG_(get_and_pp_StackTrace)(VG_(get_running_tid)(), 12);
    }
 
    tl_assert(a1 < a2);
index 2c759c15f8f2f91d7fb1ea280a39e5537e02896a..52e1dc7f88504b65ffd8e75aa372107b8b111baa 100644 (file)
@@ -421,7 +421,7 @@ SizeT DRD_(thread_get_stack_size)(const DrdThreadId tid)
 }
 
 /**
- * Clean up thread-specific data structures. Call this just after 
+ * Clean up thread-specific data structures. Call this just after
  * pthread_join().
  */
 void DRD_(thread_delete)(const DrdThreadId tid)
@@ -561,7 +561,7 @@ void DRD_(thread_set_name)(const DrdThreadId tid, const char* const name)
 {
    tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
              && tid != DRD_INVALID_THREADID);
-   
+
    if (name == NULL || name[0] == 0)
       VG_(snprintf)(DRD_(g_threadinfo)[tid].name,
                     sizeof(DRD_(g_threadinfo)[tid].name),
@@ -602,7 +602,7 @@ void DRD_(thread_set_running_tid)(const ThreadId vg_tid,
 {
    tl_assert(vg_tid != VG_INVALID_THREADID);
    tl_assert(drd_tid != DRD_INVALID_THREADID);
-   
+
    if (vg_tid != s_vg_running_tid)
    {
       if (s_trace_context_switches
@@ -1241,8 +1241,8 @@ thread_report_conflicting_segments_segment(const DrdThreadId tid,
          for (q = DRD_(g_threadinfo)[i].last; q; q = q->prev)
          {
             /*
-             * Since q iterates over the segments of thread i in order of 
-             * decreasing vector clocks, if q->vc <= p->vc, then 
+             * Since q iterates over the segments of thread i in order of
+             * decreasing vector clocks, if q->vc <= p->vc, then
              * q->next->vc <= p->vc will also hold. Hence, break out of the
              * loop once this condition is met.
              */
index ea352b9df81523bb3564db142fc195b2e015a40e..83626d829e642bf8e130436505e5fc9de68e11ba 100644 (file)
@@ -238,7 +238,7 @@ Bool DRD_(running_thread_inside_pthread_create)(void)
 }
 
 /**
- * Reports whether or not recording of memory loads is enabled for the 
+ * Reports whether or not recording of memory loads is enabled for the
  * currently running client thread.
  */
 static __inline__
@@ -254,7 +254,7 @@ Bool DRD_(running_thread_is_recording_loads)(void)
 }
 
 /**
- * Reports whether or not recording memory stores is enabled for the 
+ * Reports whether or not recording memory stores is enabled for the
  * currently running client thread.
  */
 static __inline__
index a5985144063bed8c57edf37f856b961749307ad5..8c98ab6b0ada54507df9b0b23afc1a2933096590 100644 (file)
@@ -39,7 +39,7 @@
  * - Vector clocks are compared by comparing all counters of all threads.
  * - When a thread synchronization action is performed that guarantees that
  *   new actions of the current thread are executed after the actions of the
- *   other thread, the vector clock of the synchronization object and the 
+ *   other thread, the vector clock of the synchronization object and the
  *   current thread are combined (by taking the component-wise maximum).
  * - A vector clock is incremented during actions such as
  *   pthread_create(), pthread_mutex_unlock(), sem_post(). (Actions where
index e4eba066c1f15c30a98b54a21ffe08f371b951d3..f6a63b6583a6148a05a95cc665dd00fce1adc482 100644 (file)
@@ -26,7 +26,7 @@ int main(int argc, char** argv)
   int ign_rw = 1;
   int tmp;
   pthread_t tid;
-  
+
   while ((optchar = getopt(argc, argv, "r")) != EOF)
   {
     switch (optchar)
index 16efe033120f7bb5c82e6e4b105a137828b3ac74..2b71eb2c8b8672b796432919b3f0d1498b415035 100644 (file)
@@ -25,7 +25,7 @@ int main(int argc, char** argv)
   int optchar;
   int ign_rw = 1;
   pthread_t tid;
-  
+
   while ((optchar = getopt(argc, argv, "r")) != EOF)
   {
     switch (optchar)
index 8032ba2f20a0231e14a28d3ee7fe3423ff023bf3..9faead5692e2832db870cddde5dceace327c9525 100644 (file)
@@ -33,14 +33,14 @@ static void* custom_alloc(int size)
    if (hp + size2 > hp_lim) {
       hp = get_superblock();
       hp_lim = hp + SUPERBLOCK_SIZE - 1;
-   }  
+   }
 
    p = hp + RZ;
    hp += size2;
 
    VALGRIND_MALLOCLIKE_BLOCK( p, size, RZ, /*is_zeroed*/1 );
    return (void*)p;
-}     
+}
 
 static void custom_free(void* p)
 {
@@ -85,6 +85,6 @@ int main(void)
                         // unfortunately not identified as being in a free'd
                         // block because the freeing of the block and shadow
                         // chunk isn't postponed.
-   
+
    // leak from make_leak()
 }
index ad0168e48d34f2438d83abda9791cd8b1c157611..65d13a37fbe208687e4f7055689089a17441ce45 100644 (file)
@@ -55,7 +55,7 @@ int main(int argc, char** argv)
   pthread_mutex_init(&s_mutex, 0);
 
   /*
-   * Switch to line-buffered mode, such that timing information can be 
+   * Switch to line-buffered mode, such that timing information can be
    * obtained for each printf() call with strace.
    */
   setlinebuf(stdout);
index 7ef4cb761601c170393a1a0898b7c6795b9f4bba..a63649ba771850d19952dc8b2db1f695195df26b 100644 (file)
@@ -161,7 +161,7 @@ static elem_t* multiply_matrices(const elem_t* const a1,
 
 /** Apply the Gauss-Jordan elimination algorithm on the matrix p->a starting
  *  at row r0 and up to but not including row r1. It is assumed that as many
- *  threads execute this function concurrently as the count barrier p->b was 
+ *  threads execute this function concurrently as the count barrier p->b was
  *  initialized with. If the matrix p->a is nonsingular, and if matrix p->a
  *  has at least as many columns as rows, the result of this algorithm is that
  *  submatrix p->a[0..p->rows-1,0..p->rows-1] is the identity matrix.
index 4678740a5c9ed3e5c02276417933b74ed699b9d8..cd402ab0f4e9f3917bdf9cb74381e1946137bc74 100644 (file)
@@ -149,7 +149,7 @@ static elem_t* multiply_matrices(const elem_t* const a1,
 
 /** Apply the Gauss-Jordan elimination algorithm on the matrix p->a starting
  *  at row r0 and up to but not including row r1. It is assumed that as many
- *  threads execute this function concurrently as the count barrier p->b was 
+ *  threads execute this function concurrently as the count barrier p->b was
  *  initialized with. If the matrix p->a is nonsingular, and if matrix p->a
  *  has at least as many columns as rows, the result of this algorithm is that
  *  submatrix p->a[0..p->rows-1,0..p->rows-1] is the identity matrix.
index a2ddcfd90569907ead003b9b20c076b1808bf070..5276a349d45ce92122fadaee476ba23f283f694b 100644 (file)
@@ -1,4 +1,4 @@
-/** Broadcast a (POSIX threads) signal to all running threads, where the 
+/** Broadcast a (POSIX threads) signal to all running threads, where the
  *  number of threads can be specified on the command line. This test program
  *  is intended not only to test the correctness of drd but also to test
  *  whether performance does not degrade too much when the number of threads
@@ -96,7 +96,7 @@ static void thread_func(struct cthread* thread_info)
       printf("thread %d [%d] (1)\n", thread_info->m_threadnum, i);
     }
     csema_v(thread_info->m_sema);
-    
+
     // Wait until the main thread signals us via pthread_cond_broadcast().
     pthread_cond_wait(&s_cond, &s_mutex);
     if (s_trace)
index 18bbfebe4c7b84f197999b48145a9614350821da..696cd4b59a124ffde12391708da9591738ae28e4 100644 (file)
@@ -56,13 +56,13 @@ int main(int argc, char** argv)
     thread_arg[i] = i;
 
   pthread_mutex_init(&s_mutex, 0);
-  
+
   pthread_attr_init(&attr);
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
   assert(pthread_attr_getdetachstate(&attr, &detachstate) == 0);
   assert(detachstate == PTHREAD_CREATE_DETACHED);
   pthread_attr_setstacksize(&attr, 16384);
-  // Create count1 detached threads by setting the "detached" property via 
+  // Create count1 detached threads by setting the "detached" property via
   // thread attributes.
   for (i = 0; i < count1; i++)
   {
index 4d0223c34503c0dd3937f535f6f0629ad8a9f709..c91be67173a98dcb8f0fb2c04d7dcb7f9a4894e3 100644 (file)
@@ -51,13 +51,13 @@ int main(int argc, char** argv)
     thread_arg[i] = i;
 
   sem_init(&s_sem, 0, 0);
-  
+
   pthread_attr_init(&attr);
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
   assert(pthread_attr_getdetachstate(&attr, &detachstate) == 0);
   assert(detachstate == PTHREAD_CREATE_DETACHED);
   pthread_attr_setstacksize(&attr, 16384);
-  // Create count1 detached threads by setting the "detached" property via 
+  // Create count1 detached threads by setting the "detached" property via
   // thread attributes.
   for (i = 0; i < count1; i++)
   {
index 1fb79f25375e997cf234f9617a44798434acb424..5a8cb130ba8fa9ec94bc7af75d95586b3e862e5a 100644 (file)
@@ -56,7 +56,7 @@ int main(int argc, char** argv)
   sem_init(&s_sem, 0, 1);
 
   /*
-   * Switch to line-buffered mode, such that timing information can be 
+   * Switch to line-buffered mode, such that timing information can be
    * obtained for each printf() call with strace.
    */
   setlinebuf(stdout);
index 1960704c4dcee4ceffdcc6bf9bf47c0a11b5001c..d45200950f6a990b68e081760f61762cf1157641 100644 (file)
@@ -68,7 +68,7 @@ int main(int argc, char** argv)
   }
 
   /*
-   * Switch to line-buffered mode, such that timing information can be 
+   * Switch to line-buffered mode, such that timing information can be
    * obtained for each printf() call with strace.
    */
   setlinebuf(stdout);
index 81e3b313910bda04d06933724d261757e3d2c24b..05461c56f57e725820d0dfcaa8993f32a6479d7d 100644 (file)
@@ -3,7 +3,7 @@
   framework.
 
   Copyright (C) 2008-2008 Google Inc
-     opensource@google.com 
+     opensource@google.com
 
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   The GNU General Public License is contained in the file COPYING.
 */
 
-// Author: Konstantin Serebryany <opensource@google.com> 
+// Author: Konstantin Serebryany <opensource@google.com>
 //
-// Here we define few simple classes that wrap pthread primitives. 
+// Here we define few simple classes that wrap pthread primitives.
 //
-// We need this to create unit tests for helgrind (or similar tool) 
-// that will work with different threading frameworks. 
+// We need this to create unit tests for helgrind (or similar tool)
+// that will work with different threading frameworks.
 //
-// If one needs to test helgrind's support for another threading library, 
-// he/she can create a copy of this file and replace pthread_ calls 
-// with appropriate calls to his/her library. 
+// If one needs to test helgrind's support for another threading library,
+// he/she can create a copy of this file and replace pthread_ calls
+// with appropriate calls to his/her library.
 //
-// Note, that some of the methods defined here are annotated with 
-// ANNOTATE_* macros defined in dynamic_annotations.h. 
+// Note, that some of the methods defined here are annotated with
+// ANNOTATE_* macros defined in dynamic_annotations.h.
 //
-// DISCLAIMER: the classes defined in this header file 
-// are NOT intended for general use -- only for unit tests. 
+// DISCLAIMER: the classes defined in this header file
+// are NOT intended for general use -- only for unit tests.
 //
 
 #ifndef THREAD_WRAPPERS_PTHREAD_H
@@ -71,23 +71,23 @@ static inline bool RunningOnValgrind() { return RUNNING_ON_VALGRIND; }
 #include <assert.h>
 #ifdef NDEBUG
 # error "Pleeease, do not define NDEBUG"
-#endif 
+#endif
 #define CHECK assert
 
 /// Set this to true if malloc() uses mutex on your platform as this may
 /// introduce a happens-before arc for a pure happens-before race detector.
 const bool kMallocUsesMutex = false;
 
-/// Current time in milliseconds. 
+/// Current time in milliseconds.
 static inline int64_t GetCurrentTimeMillis() {
   struct timeval now;
   gettimeofday(&now, NULL);
   return now.tv_sec * 1000 + now.tv_usec / 1000;
 }
 
-/// Copy tv to ts adding offset in milliseconds. 
-static inline void timeval2timespec(timeval *const tv, 
-                                     timespec *ts, 
+/// Copy tv to ts adding offset in milliseconds.
+static inline void timeval2timespec(timeval *const tv,
+                                     timespec *ts,
                                      int64_t offset_milli) {
   const int64_t ten_9 = 1000000000LL;
   const int64_t ten_6 = 1000000LL;
@@ -154,16 +154,16 @@ class SpinLock {
 
 #endif // NO_SPINLOCK
 
-/// Just a boolean condition. Used by Mutex::LockWhen and similar. 
+/// Just a boolean condition. Used by Mutex::LockWhen and similar.
 class Condition {
  public:
   typedef bool (*func_t)(void*);
 
   template <typename T>
-  Condition(bool (*func)(T*), T* arg) 
+  Condition(bool (*func)(T*), T* arg)
   : func_(reinterpret_cast<func_t>(func)), arg_(arg) {}
 
-  Condition(bool (*func)()) 
+  Condition(bool (*func)())
   : func_(reinterpret_cast<func_t>(func)), arg_(NULL) {}
 
   bool Eval() { return func_(arg_); }
@@ -176,22 +176,22 @@ class Condition {
 
 /// Wrapper for pthread_mutex_t.
 ///
-/// pthread_mutex_t is *not* a reader-writer lock, 
-/// so the methods like ReaderLock() aren't really reader locks. 
-/// We can not use pthread_rwlock_t because it 
+/// pthread_mutex_t is *not* a reader-writer lock,
+/// so the methods like ReaderLock() aren't really reader locks.
+/// We can not use pthread_rwlock_t because it
 /// does not work with pthread_cond_t.
-/// 
-/// TODO: We still need to test reader locks with this class. 
-/// Implement a mode where pthread_rwlock_t will be used 
-/// instead of pthread_mutex_t (only when not used with CondVar or LockWhen). 
-/// 
+///
+/// TODO: We still need to test reader locks with this class.
+/// Implement a mode where pthread_rwlock_t will be used
+/// instead of pthread_mutex_t (only when not used with CondVar or LockWhen).
+///
 class Mutex {
   friend class CondVar;
- public: 
+ public:
   Mutex() {
     CHECK(0 == pthread_mutex_init(&mu_, NULL));
     CHECK(0 == pthread_cond_init(&cv_, NULL));
-    signal_at_unlock_ = true;  // Always signal at Unlock to make 
+    signal_at_unlock_ = true;  // Always signal at Unlock to make
                                // Mutex more friendly to hybrid detectors.
   }
   ~Mutex() {
@@ -202,7 +202,7 @@ class Mutex {
   bool TryLock()       { return (0 == pthread_mutex_trylock(&mu_));}
   void Unlock() {
     if (signal_at_unlock_) {
-      CHECK(0 == pthread_cond_signal(&cv_)); 
+      CHECK(0 == pthread_cond_signal(&cv_));
     }
     CHECK(0 == pthread_mutex_unlock(&mu_));
   }
@@ -214,11 +214,11 @@ class Mutex {
   void ReaderLockWhen(Condition cond)      { Lock(); WaitLoop(cond); }
   void Await(Condition cond)               { WaitLoop(cond); }
 
-  bool ReaderLockWhenWithTimeout(Condition cond, int millis)      
+  bool ReaderLockWhenWithTimeout(Condition cond, int millis)
     { Lock(); return WaitLoopWithTimeout(cond, millis); }
-  bool LockWhenWithTimeout(Condition cond, int millis)      
+  bool LockWhenWithTimeout(Condition cond, int millis)
     { Lock(); return WaitLoopWithTimeout(cond, millis); }
-  bool AwaitWithTimeout(Condition cond, int millis)      
+  bool AwaitWithTimeout(Condition cond, int millis)
     { return WaitLoopWithTimeout(cond, millis); }
 
  private:
@@ -248,10 +248,10 @@ class Mutex {
     return cond.Eval();
   }
 
-  // A hack. cv_ should be the first data member so that 
-  // ANNOTATE_CONDVAR_WAIT(&MU, &MU) and ANNOTATE_CONDVAR_SIGNAL(&MU) works. 
+  // A hack. cv_ should be the first data member so that
+  // ANNOTATE_CONDVAR_WAIT(&MU, &MU) and ANNOTATE_CONDVAR_SIGNAL(&MU) works.
   // (See also racecheck_unittest.cc)
-  pthread_cond_t  cv_; 
+  pthread_cond_t  cv_;
   pthread_mutex_t mu_;
   bool            signal_at_unlock_;  // Set to true if Wait was called.
 };
@@ -259,7 +259,7 @@ class Mutex {
 
 class MutexLock {  // Scoped Mutex Locker/Unlocker
  public:
-  MutexLock(Mutex *mu) 
+  MutexLock(Mutex *mu)
     : mu_(mu) {
     mu_->Lock();
   }
@@ -271,13 +271,13 @@ class MutexLock {  // Scoped Mutex Locker/Unlocker
 };
 
 
-/// Wrapper for pthread_cond_t. 
+/// Wrapper for pthread_cond_t.
 class CondVar {
  public:
   CondVar()   { CHECK(0 == pthread_cond_init(&cv_, NULL)); }
   ~CondVar()  { CHECK(0 == pthread_cond_destroy(&cv_)); }
   void Wait(Mutex *mu) { CHECK(0 == pthread_cond_wait(&cv_, &mu->mu_)); }
-  bool WaitWithTimeout(Mutex *mu, int millis) { 
+  bool WaitWithTimeout(Mutex *mu, int millis) {
     struct timeval now;
     struct timespec timeout;
     gettimeofday(&now, NULL);
@@ -293,7 +293,7 @@ class CondVar {
 
 // pthreads do not allow to use condvar with rwlock so we can't make
 // ReaderLock method of Mutex to be the real rw-lock.
-// So, we need a special lock class to test reader locks. 
+// So, we need a special lock class to test reader locks.
 #define NEEDS_SEPERATE_RW_LOCK
 class RWLock {
  public:
@@ -310,7 +310,7 @@ class RWLock {
 
 class ReaderLockScoped {  // Scoped RWLock Locker/Unlocker
  public:
-  ReaderLockScoped(RWLock *mu) 
+  ReaderLockScoped(RWLock *mu)
     : mu_(mu) {
     mu_->ReaderLock();
   }
@@ -323,7 +323,7 @@ class ReaderLockScoped {  // Scoped RWLock Locker/Unlocker
 
 class WriterLockScoped {  // Scoped RWLock Locker/Unlocker
  public:
-  WriterLockScoped(RWLock *mu) 
+  WriterLockScoped(RWLock *mu)
     : mu_(mu) {
     mu_->Lock();
   }
@@ -339,14 +339,14 @@ class WriterLockScoped {  // Scoped RWLock Locker/Unlocker
 
 /// Wrapper for pthread_create()/pthread_join().
 class MyThread {
- public: 
+ public:
   typedef void *(*worker_t)(void*);
 
-  MyThread(worker_t worker, void *arg = NULL, const char *name = NULL) 
+  MyThread(worker_t worker, void *arg = NULL, const char *name = NULL)
       :w_(worker), arg_(arg), name_(name) {}
-  MyThread(void (*worker)(void), void *arg = NULL, const char *name = NULL)   
+  MyThread(void (*worker)(void), void *arg = NULL, const char *name = NULL)
       :w_(reinterpret_cast<worker_t>(worker)), arg_(arg), name_(name) {}
-  MyThread(void (*worker)(void *), void *arg = NULL, const char *name = NULL) 
+  MyThread(void (*worker)(void *), void *arg = NULL, const char *name = NULL)
       :w_(reinterpret_cast<worker_t>(worker)), arg_(arg), name_(name) {}
 
   ~MyThread(){ w_ = NULL; arg_ = NULL;}
@@ -378,7 +378,7 @@ class ProducerConsumerQueue {
     //ANNOTATE_PCQ_DESTROY(this);
   }
 
-  // Put. 
+  // Put.
   void Put(void *item) {
     mu_.Lock();
       q_.push(item);
@@ -387,18 +387,18 @@ class ProducerConsumerQueue {
     mu_.Unlock();
   }
 
-  // Get. 
-  // Blocks if the queue is empty. 
-  void *Get() {    
+  // Get.
+  // Blocks if the queue is empty.
+  void *Get() {
     mu_.LockWhen(Condition(IsQueueNotEmpty, &q_));
       void * item = NULL;
       bool ok = TryGetInternal(&item);
-      CHECK(ok);    
+      CHECK(ok);
     mu_.Unlock();
     return item;
   }
 
-  // If queue is not empty, 
+  // If queue is not empty,
   // remove an element from queue, put it into *res and return true.
   // Otherwise return false.
   bool TryGet(void **res) {
@@ -411,9 +411,9 @@ class ProducerConsumerQueue {
  private:
   Mutex mu_;
   std::queue<void*> q_; // protected by mu_
-  
+
   // Requires mu_
-  bool TryGetInternal(void ** item_ptr) {     
+  bool TryGetInternal(void ** item_ptr) {
     if (q_.empty())
       return false;
     *item_ptr = q_.front();
@@ -421,7 +421,7 @@ class ProducerConsumerQueue {
     //ANNOTATE_PCQ_GET(this);
     return true;
   }
-  
+
   static bool IsQueueNotEmpty(std::queue<void*> * queue) {
      return !queue->empty();
   }
@@ -429,15 +429,15 @@ class ProducerConsumerQueue {
 
 
 
-/// Function pointer with zero, one or two parameters. 
+/// Function pointer with zero, one or two parameters.
 struct Closure {
   typedef void (*F0)();
   typedef void (*F1)(void *arg1);
   typedef void (*F2)(void *arg1, void *arg2);
-  int  n_params; 
-  void *f; 
-  void *param1; 
-  void *param2; 
+  int  n_params;
+  void *f;
+  void *param1;
+  void *param2;
 
   void Execute() {
     if (n_params == 0) {
@@ -450,7 +450,7 @@ struct Closure {
     }
     delete this;
   }
-}; 
+};
 
 Closure *NewCallback(void (*f)()) {
   Closure *res = new Closure;
@@ -483,24 +483,24 @@ Closure *NewCallback(void (*f)(P1, P2), P1 p1, P2 p2) {
   return res;
 }
 
-/*! A thread pool that uses ProducerConsumerQueue. 
-  Usage: 
+/*! A thread pool that uses ProducerConsumerQueue.
+  Usage:
   {
     ThreadPool pool(n_workers);
     pool.StartWorkers();
     pool.Add(NewCallback(func_with_no_args));
     pool.Add(NewCallback(func_with_one_arg, arg));
     pool.Add(NewCallback(func_with_two_args, arg1, arg2));
-    ... // more calls to pool.Add() 
-    
-    // the ~ThreadPool() is called: we wait workers to finish 
-    // and then join all threads in the pool. 
+    ... // more calls to pool.Add()
+
+    // the ~ThreadPool() is called: we wait workers to finish
+    // and then join all threads in the pool.
   }
 */
 class ThreadPool {
- public: 
-  //! Create n_threads threads, but do not start. 
-  explicit ThreadPool(int n_threads) 
+ public:
+  //! Create n_threads threads, but do not start.
+  explicit ThreadPool(int n_threads)
     : queue_(INT_MAX) {
     for (int i = 0; i < n_threads; i++) {
       MyThread *thread = new MyThread(&ThreadPool::Worker, this);
@@ -508,14 +508,14 @@ class ThreadPool {
     }
   }
 
-  //! Start all threads. 
+  //! Start all threads.
   void StartWorkers() {
     for (size_t i = 0; i < workers_.size(); i++) {
       workers_[i]->Start();
     }
   }
 
-  //! Add a closure. 
+  //! Add a closure.
   void Add(Closure *closure) {
     queue_.Put(closure);
   }
@@ -541,22 +541,22 @@ class ThreadPool {
     while (true) {
       Closure *closure = reinterpret_cast<Closure*>(pool->queue_.Get());
       if(closure == NULL) {
-        return NULL; 
+        return NULL;
       }
-      closure->Execute();     
+      closure->Execute();
     }
   }
 };
 
 #ifndef NO_BARRIER
-/// Wrapper for pthread_barrier_t. 
+/// Wrapper for pthread_barrier_t.
 class Barrier{
  public:
   explicit Barrier(int n_threads) {CHECK(0 == pthread_barrier_init(&b_, 0, n_threads));}
   ~Barrier()                      {CHECK(0 == pthread_barrier_destroy(&b_));}
   void Block() {
     // helgrind 3.3.0 does not have an interceptor for barrier.
-    // but our current local version does. 
+    // but our current local version does.
     // ANNOTATE_CONDVAR_SIGNAL(this);
     pthread_barrier_wait(&b_);
     // ANNOTATE_CONDVAR_WAIT(this, this);