VirtualBox

Changeset 48439 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Sep 11, 2013 5:17:23 PM (11 years ago)
Author:
vboxsync
Message:

Provide real sys_arch_mbox_tryfetch.

XXX: We can't rename it with a #define since lwip/sys.h thinks we are
providing a fake tryfetch and doesn't declare it as a function. For
now leave it unrenamed - it doesn't cause conflicts.

Location:
trunk/src/VBox/Devices/Network/lwip-new/vbox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/lwip-new/vbox/include/lwip-namespace.h

    r48109 r48439  
    125125#define stats_init lwip_stats_init
    126126#define sys_arch_mbox_fetch lwip_sys_arch_mbox_fetch
    127 #define sys_arch_mbox_tryfetch(mbox, msg) lwip_sys_arch_mbox_fetch((mbox), (msg), 1)
     127#if 0 /* XXX: cf. lwip/sys.h which misinterprets this */
     128#define sys_arch_mbox_tryfetch lwip_sys_arch_mbox_tryfetch
     129#endif
    128130#define sys_arch_protect lwip_sys_arch_protect
    129131#define sys_arch_sem_wait lwip_sys_arch_sem_wait
  • trunk/src/VBox/Devices/Network/lwip-new/vbox/sys_arch.c

    r47888 r48439  
    386386}
    387387
     388/**
     389 * Try to get an entry from an mbox.
     390 */
     391u32_t sys_arch_mbox_tryfetch(sys_mbox_t *pvMbox, void **msg)
     392{
     393    int rc;
     394    struct sys_mbox *mbox = NULL;
     395    if (!pvMbox || !*pvMbox) return SYS_MBOX_EMPTY;
     396    mbox = (struct sys_mbox*)*pvMbox;
     397
     398    rc = LWIPMutexRequest((mbox)->mutex);
     399    AssertRC(rc);
     400    if ((mbox)->head == (mbox)->tail)
     401    {
     402        /* (mbox) is empty, don't wait */
     403        rc = LWIPMutexRelease((mbox)->mutex);
     404        AssertRC(rc);
     405        return SYS_MBOX_EMPTY;
     406    }
     407    if (((mbox)->head + 1) % MBOX_ENTRIES_MAX == (mbox)->tail)
     408    {
     409        rc = RTSemEventMultiSignal((mbox)->nonfull);
     410        AssertRC(rc);
     411    }
     412    if (msg != NULL)
     413        *msg = (mbox)->apvEntries[(mbox)->tail];
     414    (mbox)->tail++;
     415    (mbox)->tail %= MBOX_ENTRIES_MAX;
     416    rc = RTSemEventMultiSignal((mbox)->nonfull);
     417    if ((mbox)->head == (mbox)->tail)
     418    {
     419        rc = RTSemEventMultiReset((mbox)->nonempty);
     420        AssertRC(rc);
     421    }
     422    rc = LWIPMutexRelease((mbox)->mutex);
     423    AssertRC(rc);
     424    return 0;
     425}
     426
    388427/** Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */
    389428int sys_mbox_valid(sys_mbox_t *pvMbox)
Note: See TracChangeset for help on using the changeset viewer.

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