VirtualBox

Changeset 3502 in kBuild


Ignore:
Timestamp:
Dec 14, 2021 11:13:33 PM (3 years ago)
Author:
bird
Message:

kash: shthread.h: Did asm implementation of the two atomics so the code compiles with older GCC version that doesn't have the sync_add_and_fetch and sync_sub_and_fetch functionality.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shthread.h

    r3457 r3502  
    5252void shthread_set_shell(struct shinstance *);
    5353struct shinstance *shthread_get_shell(void);
     54void shthread_set_name(const char *name);
    5455
    5556int shmtx_init(shmtx *pmtx);
     
    6364#ifdef _MSC_VER
    6465    return _InterlockedIncrement((long *)valuep);
     66#elif defined(__GNUC__) && (K_ARCH == K_ARCH_AMD64 || K_ARCH == K_ARCH_X86)
     67    unsigned uRet;
     68    __asm__ __volatile__("lock; xaddl %1, %0" : "=m" (*valuep), "=r" (uRet) : "m" (*valuep), "1" (1) : "memory", "cc");
     69    return uRet + 1;
    6570#else
    6671    return __sync_add_and_fetch(valuep, 1);
     
    7277#ifdef _MSC_VER
    7378    return _InterlockedDecrement((long *)valuep);
     79#elif defined(__GNUC__) && (K_ARCH == K_ARCH_AMD64 || K_ARCH == K_ARCH_X86)
     80    unsigned uRet;
     81    __asm__ __volatile__("lock; xaddl %1, %0" : "=m" (*valuep), "=r" (uRet) : "m" (*valuep), "1" (-1) : "memory", "cc");
     82    return uRet - 1;
    7483#else
    7584    return __sync_sub_and_fetch(valuep, 1);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette