Changeset 1382


Ignore:
Timestamp:
Apr 26, 2004, 2:09:44 AM (21 years ago)
Author:
bird
Message:

Fixed a bunch of errors in atomic stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/386/builtin.h

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1381 r1382  
    4949static __inline__ int __atomic_set_bit(__volatile__ void *pv, unsigned uBit)
    5050{
    51     int rc;
    5251    __asm__ __volatile__("lock btsl %2, %1\n\t"
    5352                         "sbbl %0,%0"
    54                          : "=r" (rc),
     53                         : "=r" (uBit),
    5554                           "=m" (*(__volatile__ unsigned *)pv)
    56                          : "r" (uBit)
     55                         : "0" (uBit)
    5756                         : "memory");
    58     return rc;
     57    return uBit;
    5958}
    6059
     
    8786                         "sbbl %0, %0\t\n"
    8887                         : "=r" (uBit)
    89                          : "m"  (*(const __volatile__ unsigned *)pv));
     88                         : "m"  (*(const __volatile__ unsigned *)pv),
     89                           "0"  (uBit));
    9090    return uBit;
    9191}
     
    118118 *
    119119 * @returns 0 if incremented.
    120  * @returns *pu + 1 when not updated.
     120 * @returns uMax when not updated.
    121121 * @param   pu      Pointer to the value to increment.
    122122 * @param   uMax    *pu must not be above this value.
     
    125125{
    126126    unsigned rc;
    127     __asm__ __volatile__("movl  %1, %%eax\n"
     127    __asm__ __volatile__("movl  (%1), %%eax\n\t"
    128128                         "1:\n\t"
    129129                         "lea   1(%%eax), %0\n\t"
    130                          "cmpl  %0, %2\n\t"
     130                         "cmpl  %2, %0\n\t"
    131131                         "jna   2f\n\t"
     132                         "decl  %0\n\t"
    132133                         "jmp   4f\n"
    133134                         "2:\n\t"
    134                          "lock  cmpxchgl %0, %1\n\t"
     135                         "lock  cmpxchgl %0, (%1)\n\t"
    135136                         "jz    3f\n\t"
    136137                         "jmp   1b\n"
     
    138139                         "xorl  %0, %0\n\t"
    139140                         "4:"
    140                          : "=r" (rc),
    141                            "=m" (pu)
    142                          : "r"  (uMax)
     141                         : "=b" (rc)
     142                         : "c"  (pu),
     143                           "d"  (uMax)
    143144                         : "%eax");
    144145    return rc;
     
    149150 * Atomically decrements a 32-bit unsigned value if greater than a min.
    150151 *
    151  * @returns 0 if incremented.
    152  * @returns *pu + 1 when not updated.
    153  * @param   pu      Pointer to the value to decrement.
     152 * @returns 0 if decremented.
     153 * @returns uMin when not updated.
     154 * @param   pu      Pointer to the   value to decrement.
    154155 * @param   uMin    *pu must not be below this value.
    155156 */
    156 static __inline__ int __atomic_increment_min(__volatile__ unsigned *pu, unsigned uMin)
     157static __inline__ int __atomic_decrement_min(__volatile__ unsigned *pu, unsigned uMin)
    157158{
    158159    unsigned rc;
    159     __asm__ __volatile__("movl  %1, %%eax\n"
     160    __asm__ __volatile__("movl  (%1), %%eax\n"
    160161                         "1:\n\t"
    161162                         "lea   -1(%%eax), %0\n\t"
    162                          "cmpl  %0, %2\n\t"
     163                         "cmpl  %2, %0\n\t"
    163164                         "jnb   2f\n\t"
     165                         "incl  %0\n\t"
    164166                         "jmp   4f\n"
    165167                         "2:\n\t"
    166                          "lock  cmpxchgl %0, %1\n\t"
     168                         "lock  cmpxchgl %0, (%1)\n\t"
    167169                         "jz    3f\n\t"
    168170                         "jmp   1b\n"
     
    170172                         "xorl  %0, %0\n\t"
    171173                         "4:"
    172                          : "=r" (rc),
    173                            "=m" (*pu)
    174                          : "r"  (uMin)
     174                         : "=b" (rc)
     175                         : "c"  (pu),
     176                           "d"  (uMin)
    175177                         : "%eax");
    176178    return rc;
Note: See TracChangeset for help on using the changeset viewer.