Changeset 35


Ignore:
Timestamp:
Jun 19, 2010, 6:36:10 PM (15 years ago)
Author:
dmik
Message:

jdk/hpi: Port windows/monitor_md to EMX.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/jdk/src/windows/hpi/src/monitor_md.c

    r2 r35  
    104104 */
    105105
    106 static int __fastcall sysMonitorEnter2(sys_thread_t *self, sys_mon_t *mid)
     106static EMXONLY(inline) int EMXNOP(__fastcall)
     107sysMonitorEnter2(sys_thread_t *self, sys_mon_t *mid)
    107108{
    108109    if (mid->semaphore == NULL) {
     
    138139sysMonitorEnter(sys_thread_t *self, sys_mon_t *mid)
    139140{
     141#ifdef __EMX__
     142    if (self == mid->monitor_owner) {
     143        ++mid->entry_count;
     144        return SYS_OK;
     145    }
     146
     147    if (systemIsMP) {
     148        register char isZero;
     149        asm volatile (
     150              "lock incl %0; sete %1"
     151            : "=m" (mid->atomic_count), "=q" (isZero)
     152            : "m" (mid->atomic_count)
     153            : "memory"
     154        );
     155        if (isZero) {
     156            mid->monitor_owner = self;
     157            mid->entry_count = 1;
     158            return SYS_OK;
     159        }
     160    } else {
     161        if (!++mid->atomic_count) {
     162            mid->monitor_owner = self;
     163            mid->entry_count = 1;
     164            return SYS_OK;
     165        }
     166    }
     167
     168    return sysMonitorEnter2(self, mid);
     169#else /* __EMX__ */
    140170    __asm
    141171    {
     
    177207        jmp  sysMonitorEnter2;
    178208    }
     209#endif /* __EMX__ */
    179210}
    180211#else
     
    213244 */
    214245
    215 static int __fastcall
     246static EMXONLY(inline) int EMXNOP(__fastcall)
    216247sysMonitorExit2(sys_thread_t *self, sys_mon_t *mid)
    217248{
     
    237268
    238269#ifndef _WIN64
    239 __declspec(naked) int __cdecl
     270EMXNOP(__declspec(naked)) int EMXNOP(__cdecl)
    240271sysMonitorExit(sys_thread_t *self, sys_mon_t *mid)
    241272{
     273#ifdef __EMX__
     274    if (self != mid->monitor_owner)
     275        return SYS_ERR;
     276
     277    if (--mid->entry_count)
     278        return SYS_ERR;
     279
     280    mid->monitor_owner = 0;
     281
     282    if (systemIsMP) {
     283        register char isLessThanZero;
     284        asm volatile (
     285              "lock decl %0; setge %1"
     286            : "=m" (mid->atomic_count), "=q" (isLessThanZero)
     287            : "m" (mid->atomic_count)
     288            : "memory"
     289        );
     290        if (isLessThanZero)
     291            return SYS_OK;
     292    } else {
     293        if (--mid->atomic_count < 0)
     294            return SYS_OK;
     295    }
     296
     297    return sysMonitorExit2(self, mid);
     298#else /* __EMX__ */
    242299    __asm
    243300    {
     
    277334        jmp sysMonitorExit2;        /* forwading call */
    278335    }
     336#endif /* __EMX__ */
    279337}
    280338#else
Note: See TracChangeset for help on using the changeset viewer.