Timestamp:
May 8, 2005, 2:11:22 PM (21 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
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     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
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
    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.