apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject cvs commit: apr CHANGES
Date Sat, 16 Mar 2002 03:54:00 GMT
ianh        02/03/15 19:54:00

  Modified:    test     testatomic.c
               include  apr_atomic.h
               atomic/unix apr_atomic.c
               .        CHANGES
  Log:
  apr_atomic_dec now returns zero if the value is zero.
  
  Submitted by:	 Greg Ames
  
  Revision  Changes    Path
  1.11      +12 -1     apr/test/testatomic.c
  
  Index: testatomic.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testatomic.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- testatomic.c	15 Mar 2002 00:38:05 -0000	1.10
  +++ testatomic.c	16 Mar 2002 03:54:00 -0000	1.11
  @@ -85,7 +85,18 @@
   {
       apr_uint32_t oldval;
       apr_uint32_t casval=0;
  -    apr_atomic_set(&y,0);
  +    apr_atomic_set(&y,2);
  +    printf("%-60s", "testing apr_atomic_dec");
  +    if ( apr_atomic_dec(&y) == 0 ) {
  +        fprintf(stderr, "Failed\noldval =%d should not be zero\n",apr_atomic_read(&y));
  +        return APR_EGENERAL;
  +    }
  +    if ( apr_atomic_dec(&y) != 0 ) {
  +        fprintf(stderr, "Failed\noldval =%d should be zero\n",apr_atomic_read(&y));
  +        return APR_EGENERAL;
  +    }
  +    printf("OK\n");
  +
       printf("%-60s", "testing CAS");
       oldval = apr_atomic_cas(&casval,12,0);
       if (oldval != 0) {
  
  
  
  1.17      +4 -3      apr/include/apr_atomic.h
  
  Index: apr_atomic.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_atomic.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- apr_atomic.h	15 Mar 2002 00:38:05 -0000	1.16
  +++ apr_atomic.h	16 Mar 2002 03:54:00 -0000	1.17
  @@ -117,8 +117,9 @@
   /**
    * decrement the atomic variable by 1
    * @param mem pointer to the atomic value
  + * @returns zero if the value is zero, otherwise non-zero
    */
  -void apr_atomic_dec(volatile apr_atomic_t *mem);
  +int apr_atomic_dec(volatile apr_atomic_t *mem);
   
   /**
    * compare the atomic's value with cmp.
  @@ -158,7 +159,7 @@
   #define apr_atomic_t atomic_t
   
   #define apr_atomic_add(mem, val)     atomic_add(val,mem)
  -#define apr_atomic_dec(mem)          atomic_dec(mem)
  +#define apr_atomic_dec(mem)          !atomic_dec_and_test(mem)
   #define apr_atomic_inc(mem)          atomic_inc(mem)
   #define apr_atomic_set(mem, val)     atomic_set(mem, val)
   #define apr_atomic_read(mem)         atomic_read(mem)
  @@ -228,7 +229,7 @@
   void apr_atomic_set(volatile apr_atomic_t *mem, apr_uint32_t val);
   void apr_atomic_add(volatile apr_atomic_t *mem, apr_uint32_t val);
   void apr_atomic_inc(volatile apr_atomic_t *mem);
  -void apr_atomic_dec(volatile apr_atomic_t *mem);
  +int apr_atomic_dec(volatile apr_atomic_t *mem);
   #endif
   
   #if defined(APR_ATOMIC_NEED_CAS_DEFAULT)
  
  
  
  1.10      +3 -3      apr/atomic/unix/apr_atomic.c
  
  Index: apr_atomic.c
  ===================================================================
  RCS file: /home/cvs/apr/atomic/unix/apr_atomic.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- apr_atomic.c	13 Mar 2002 20:39:08 -0000	1.9
  +++ apr_atomic.c	16 Mar 2002 03:54:00 -0000	1.10
  @@ -123,7 +123,7 @@
       }
   /*    return *mem; */
   }
  -void apr_atomic_dec(volatile apr_atomic_t *mem) 
  +int apr_atomic_dec(volatile apr_atomic_t *mem) 
   {
       apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
       apr_uint32_t prev;
  @@ -132,9 +132,9 @@
           prev = *mem;
           (*mem)--;
           apr_thread_mutex_unlock(lock);
  -/*        return prev; */
  +        return prev; 
       }
  -/*    return *mem; */
  +    return *mem; 
   }
   
   #endif /* APR_ATOMIC_NEED_DEFAULT */
  
  
  
  1.242     +3 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.241
  retrieving revision 1.242
  diff -u -r1.241 -r1.242
  --- CHANGES	15 Mar 2002 02:26:10 -0000	1.241
  +++ CHANGES	16 Mar 2002 03:54:00 -0000	1.242
  @@ -1,5 +1,8 @@
   Changes with APR b1
   
  +  *) apr_atomic_dec now returns a zero value if the value of 
  +     the atomic is zero, non-zero otherwise [Ian Holsman]
  +
     *) When opening a file, only create an internal thread mutex
        if APR_XTHREAD is set.  [Brian Pane]
   
  
  
  

Mime
View raw message