Ignore:
Timestamp:
May 8, 2005, 2:11:22 PM (20 years ago)
Author:
bird
Message:

Ported the BSD SysV Semaphore module.

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1983 r1984  
    7777static __inline__ int __atomic_set_bit(__volatile__ void *pv, unsigned uBit)
    7878{
    79     __asm__ __volatile__("lock btsl %2, %1\n\t"
     79    __asm__ __volatile__("lock; btsl %2, %1\n\t"
    8080                         "sbbl %0,%0"
    8181                         : "=r" (uBit),
     
    9595static __inline__ void __atomic_clear_bit(__volatile__ void *pv, unsigned uBit)
    9696{
    97     __asm__ __volatile__("lock btrl %1, %0"
     97    __asm__ __volatile__("lock; btrl %1, %0"
    9898                         : "=m" (*(__volatile__ unsigned *)pv)
    9999                         : "r" (uBit));
     
    128128static __inline__ void __atomic_add(__volatile__ unsigned *pu, const unsigned uAdd)
    129129{
    130     __asm__ __volatile__("lock addl %1, %0"
     130    __asm__ __volatile__("lock; addl %1, %0"
    131131                         : "=m" (*pu)
    132                          : "nr" (uAdd), 
     132                         : "nr" (uAdd),
    133133                           "m"  (*pu));
    134134}
     
    142142static __inline__ void __atomic_sub(__volatile__ unsigned *pu, const unsigned uSub)
    143143{
    144     __asm__ __volatile__("lock subl %1, %0"
     144    __asm__ __volatile__("lock; subl %1, %0"
    145145                         : "=m" (*pu)
    146                          : "nr" (uSub), 
     146                         : "nr" (uSub),
    147147                           "m"  (*pu));
    148148}
     
    156156static __inline__ void __atomic_increment(__volatile__ unsigned *pu)
    157157{
    158     __asm__ __volatile__("lock incl %0"
    159                          : "=m" (*pu) 
     158    __asm__ __volatile__("lock; incl %0"
     159                         : "=m" (*pu)
    160160                         : "m"  (*pu));
    161161}
    162162
    163163/**
     164 * Atomically increments a 32-bit unsigned value.
     165 *
     166 * @param   pu32    Pointer to the value to increment.
     167 */
     168static __inline__ void __atomic_increment_u32(uint32_t __volatile__ *pu32)
     169{
     170    __asm__ __volatile__("lock; incl %0"
     171                         : "=m" (*pu32)
     172                         : "m"  (*pu32));
     173}
     174
     175/**
     176 * Atomically increments a 16-bit unsigned value.
     177 *
     178 * @param   pu16    Pointer to the value to increment.
     179 */
     180static __inline__ void __atomic_increment_u16(uint16_t __volatile__ *pu16)
     181{
     182    __asm__ __volatile__("lock; incw %0"
     183                         : "=m" (*pu16)
     184                         : "m"  (*pu16));
     185}
     186
     187/**
    164188 * Atomically decrements a 32-bit unsigned value.
    165189 *
     
    168192static __inline__ void __atomic_decrement(__volatile__ unsigned *pu)
    169193{
    170     __asm__ __volatile__("lock decl %0"
    171                          : "=m" (*pu) 
     194    __asm__ __volatile__("lock; decl %0"
     195                         : "=m" (*pu)
    172196                         : "m"  (*pu));
     197}
     198
     199/**
     200 * Atomically decrements a 32-bit unsigned value.
     201 *
     202 * @param   pu      Pointer to the value to decrement.
     203 */
     204static __inline__ void __atomic_decrement_u32(__volatile__ uint32_t *pu32)
     205{
     206    __asm__ __volatile__("lock; decl %0"
     207                         : "=m" (*pu32)
     208                         : "m"  (*pu32));
     209}
     210
     211/**
     212 * Atomically decrements a 16-bit unsigned value.
     213 *
     214 * @param   pu16    Pointer to the value to decrement.
     215 */
     216static __inline__ void __atomic_decrement_u16(uint16_t __volatile__ *pu16)
     217{
     218    __asm__ __volatile__("lock; decw %0"
     219                         : "=m" (*pu16)
     220                         : "m"  (*pu16));
    173221}
    174222
     
    192240                         "2:\n\t"
    193241                         "incl  %0\n\t"
    194                          "lock  cmpxchgl %0, %1\n\t"
     242                         "lock; cmpxchgl %0, %1\n\t"
    195243                         "jz    3f\n\t"
    196244                         "jmp   1b\n"
     
    228276                         "2:\n\t"
    229277                         "incw  %w0\n\t"
    230                          "lock  cmpxchgw %w0, %2\n\t"
     278                         "lock; cmpxchgw %w0, %2\n\t"
    231279                         "jz    3f\n\t"
    232280                         "jmp   1b\n\t"
     
    261309                         "2:\n\t"
    262310                         "decl  %0\n\t"
    263                          "lock  cmpxchgl %0, %1\n\t"
     311                         "lock; cmpxchgl %0, %1\n\t"
    264312                         "jz    3f\n\t"
    265313                         "jmp   1b\n"
     
    297345                         "2:\n\t"
    298346                         "decw  %%bx\n\t"
    299                          "lock  cmpxchgw %w0, %1\n\t"
     347                         "lock; cmpxchgw %w0, %1\n\t"
    300348                         "jz    3f\n\t"
    301349                         "jmp   1b\n"
     
    321369static inline unsigned __atomic_cmpxchg32(volatile uint32_t *pu32, uint32_t u32New, uint32_t u32Old)
    322370{
    323     __asm__ __volatile__("lock  cmpxchgl %2, %1\n\t"
     371    __asm__ __volatile__("lock; cmpxchgl %2, %1\n\t"
    324372                         "setz  %%al\n\t"
    325373                         "movzx %%al, %%eax\n\t"
Note: See TracChangeset for help on using the changeset viewer.