亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? sys.c

?? 包含lwip這個精簡IP協(xié)議棧的ucos源代碼.
?? C
字號:
/*
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels <adam@sics.se>
 *
 */

#include "lwip/sys.h"
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/memp.h"

#if (NO_SYS == 0)

struct sswt_cb
{
    int timeflag;
    sys_sem_t *psem;
};



void
sys_mbox_fetch(sys_mbox_t mbox, void **msg)
{
  u32_t time;
  struct sys_timeouts *timeouts;
  struct sys_timeout *tmptimeout;
  sys_timeout_handler h;
  void *arg;


 again:
  timeouts = sys_arch_timeouts();

  if (!timeouts || !timeouts->next) {
    sys_arch_mbox_fetch(mbox, msg, 0);
  } else {
    if (timeouts->next->time > 0) {
      time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
    } else {
      time = SYS_ARCH_TIMEOUT;
    }

    if (time == SYS_ARCH_TIMEOUT) {
      /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
   could be fetched. We should now call the timeout handler and
   deallocate the memory allocated for the timeout. */
      tmptimeout = timeouts->next;
      timeouts->next = tmptimeout->next;
      h = tmptimeout->h;
      arg = tmptimeout->arg;
      memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
      if (h != NULL) {
        LWIP_DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg));
      	h(arg);
      }

      /* We try again to fetch a message from the mbox. */
      goto again;
    } else {
      /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
   occured. The time variable is set to the number of
   milliseconds we waited for the message. */
      if (time <= timeouts->next->time) {
  timeouts->next->time -= time;
      } else {
  timeouts->next->time = 0;
      }
    }

  }
}

void
sys_sem_wait(sys_sem_t sem)
{
  u32_t time;
  struct sys_timeouts *timeouts;
  struct sys_timeout *tmptimeout;
  sys_timeout_handler h;
  void *arg;

  /*  while (sys_arch_sem_wait(sem, 1000) == 0);
      return;*/

 again:

  timeouts = sys_arch_timeouts();

  if (!timeouts || !timeouts->next) {
    sys_arch_sem_wait(sem, 0);
  } else {
    if (timeouts->next->time > 0) {
      time = sys_arch_sem_wait(sem, timeouts->next->time);
    } else {
      time = SYS_ARCH_TIMEOUT;
    }

    if (time == SYS_ARCH_TIMEOUT) {
      /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
   could be fetched. We should now call the timeout handler and
   deallocate the memory allocated for the timeout. */
      tmptimeout = timeouts->next;
      timeouts->next = tmptimeout->next;
      h = tmptimeout->h;
      arg = tmptimeout->arg;
      memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
      if (h != NULL) {
        LWIP_DEBUGF(SYS_DEBUG, ("ssw h=%p(%p)\n", (void *)h, (void *)arg));
        h(arg);
      }


      /* We try again to fetch a message from the mbox. */
      goto again;
    } else {
      /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
   occured. The time variable is set to the number of
   milliseconds we waited for the message. */
      if (time <= timeouts->next->time) {
  timeouts->next->time -= time;
      } else {
  timeouts->next->time = 0;
      }
    }

  }
}

void
sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
{
  struct sys_timeouts *timeouts;
  struct sys_timeout *timeout, *t;

  timeout = memp_malloc(MEMP_SYS_TIMEOUT);
  if (timeout == NULL) {
    return;
  }
  timeout->next = NULL;
  timeout->h = h;
  timeout->arg = arg;
  timeout->time = msecs;

  timeouts = sys_arch_timeouts();

  LWIP_DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%lu h=%p arg=%p\n",
    (void *)timeout, msecs, (void *)h, (void *)arg));

  LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL);

  if (timeouts->next == NULL) {
    timeouts->next = timeout;
    return;
  }

  if (timeouts->next->time > msecs) {
    timeouts->next->time -= msecs;
    timeout->next = timeouts->next;
    timeouts->next = timeout;
  } else {
    for(t = timeouts->next; t != NULL; t = t->next) {
      timeout->time -= t->time;
      if (t->next == NULL || t->next->time > timeout->time) {
        if (t->next != NULL) {
          t->next->time -= timeout->time;
        }
        timeout->next = t->next;
        t->next = timeout;
        break;
      }
    }
  }

}

/* Go through timeout list (for this task only) and remove the first matching entry,
   even though the timeout has not triggered yet.
*/

void
sys_untimeout(sys_timeout_handler h, void *arg)
{
    struct sys_timeouts *timeouts;
    struct sys_timeout *prev_t, *t;

    timeouts = sys_arch_timeouts();

    if (timeouts->next == NULL)
        return;

    for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next)
    {
        if ((t->h == h) && (t->arg == arg))
        {
            /* We have a match */
            /* Unlink from previous in list */
            if (prev_t == NULL)
                timeouts->next = t->next;
            else
                prev_t->next = t->next;
            /* If not the last one, add time of this one back to next */
            if (t->next != NULL)
                t->next->time += t->time;
            memp_free(MEMP_SYS_TIMEOUT, t);
            return;
        }
    }
    return;
}





static void
sswt_handler(void *arg)
{
    struct sswt_cb *sswt_cb = (struct sswt_cb *) arg;

    /* Timeout. Set flag to TRUE and signal semaphore */
    sswt_cb->timeflag = 1;
    sys_sem_signal(*(sswt_cb->psem));
}

/* Wait for a semaphore with timeout (specified in ms) */
/* timeout = 0: wait forever */
/* Returns 0 on timeout. 1 otherwise */

int
sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout)
{
    struct sswt_cb sswt_cb;

    sswt_cb.psem = &sem;
    sswt_cb.timeflag = 0;

    /* If timeout is zero, then just wait forever */
    if (timeout > 0)
        /* Create a timer and pass it the address of our flag */
        sys_timeout(timeout, sswt_handler, &sswt_cb);
    sys_sem_wait(sem);
    /* Was it a timeout? */
    if (sswt_cb.timeflag)
    {
        /* timeout */
        return 0;
    } else {
        /* Not a timeout. Remove timeout entry */
        sys_untimeout(sswt_handler, &sswt_cb);
        return 1;
    }

}


void
sys_msleep(u32_t ms)
{
  sys_sem_t delaysem = sys_sem_new(0);

  sys_sem_wait_timeout(delaysem, ms);

  sys_sem_free(delaysem);
}


#endif /* NO_SYS */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品丝袜中出| 亚洲美女在线国产| 亚洲色图清纯唯美| 麻豆国产精品官网| 色美美综合视频| 国产日产精品1区| 日韩电影在线观看一区| 成人午夜免费av| 日韩欧美一二区| 亚洲www啪成人一区二区麻豆| 成人av在线网站| 精品福利一区二区三区| 日韩高清一级片| 欧美性色黄大片| 亚洲精品v日韩精品| 高清在线成人网| 久久日一线二线三线suv| 日韩精品成人一区二区三区| 91久久国产最好的精华液| 国产精品久久久久久福利一牛影视| 麻豆国产一区二区| 欧美一级视频精品观看| 五月激情综合婷婷| 在线播放欧美女士性生活| 亚洲高清在线精品| 色菇凉天天综合网| 亚洲视频一区在线| 99精品黄色片免费大全| 国产精品乱码妇女bbbb| 成人av网址在线观看| 国产精品少妇自拍| voyeur盗摄精品| 国产精品久久久久影院老司| 岛国一区二区三区| 国产精品美女久久久久久久网站| 国产福利电影一区二区三区| 欧美国产日韩a欧美在线观看 | 国产美女精品人人做人人爽| 日韩精品资源二区在线| 久久精品国产在热久久| 精品处破学生在线二十三| 国产精品18久久久久久vr| 国产日产欧美一区| 色爱区综合激月婷婷| 亚洲午夜电影在线观看| 欧美一区二区精品| 国产永久精品大片wwwapp| 国产精品视频免费| 在线观看av一区| 人人爽香蕉精品| 久久这里只有精品6| 大白屁股一区二区视频| 亚洲免费成人av| 91麻豆精品国产91久久久久久久久| 免费成人在线播放| 国产日韩欧美综合一区| 97久久精品人人澡人人爽| 亚洲高清在线精品| 久久久久99精品国产片| 97精品国产97久久久久久久久久久久| 夜夜嗨av一区二区三区| 欧美不卡一二三| 99r国产精品| 人人狠狠综合久久亚洲| 国产精品美女久久久久aⅴ国产馆| 97久久超碰国产精品电影| 午夜av区久久| 国产精品九色蝌蚪自拍| 欧美日韩国产一区| 高清不卡一区二区在线| 亚洲理论在线观看| 欧美精品一区二区三区蜜桃视频| 97se亚洲国产综合在线| 精品一区二区在线免费观看| 亚洲欧美另类久久久精品2019| 777xxx欧美| 91免费观看在线| 久久99国产乱子伦精品免费| 亚洲另类春色校园小说| 久久久久久久综合色一本| 欧美日韩免费观看一区二区三区 | 亚洲黄色录像片| 亚洲精品一区二区三区影院 | 亚洲一线二线三线久久久| 欧美精品一区二区三区一线天视频| 色婷婷精品大在线视频| 高清不卡在线观看| 精品综合久久久久久8888| 一区二区三区精品视频在线| 久久亚洲一区二区三区四区| 精品视频在线免费观看| 成人国产在线观看| 国内精品不卡在线| 免费一级欧美片在线观看| 一区二区不卡在线视频 午夜欧美不卡在 | 91在线播放网址| 成人午夜短视频| 国产一区二区三区综合| 麻豆91在线观看| 日韩精品福利网| 日韩国产欧美视频| 亚洲va韩国va欧美va| 亚洲人吸女人奶水| 日韩伦理电影网| 亚洲视频在线观看一区| 中文字幕一区二区三区在线播放| 久久精品欧美一区二区三区不卡| 日韩欧美的一区二区| 欧美电影免费观看高清完整版在线 | 欧美无乱码久久久免费午夜一区| 成人高清av在线| 成人性色生活片| 国产成人综合在线| 成人午夜视频在线| 国产xxx精品视频大全| 国产精品一卡二卡在线观看| 久久精工是国产品牌吗| 精品一区二区三区影院在线午夜 | 久久久国际精品| 久久综合国产精品| 久久久精品tv| 国产精品剧情在线亚洲| 亚洲人成影院在线观看| 亚洲制服丝袜在线| 午夜不卡av在线| 极品销魂美女一区二区三区| 国产精品77777竹菊影视小说| 国产99精品国产| 91色视频在线| 欧美日韩国产综合草草| 日韩免费观看高清完整版 | 成人动漫精品一区二区| 91麻豆国产自产在线观看| 欧美性猛片aaaaaaa做受| 91精品国产欧美一区二区成人| 欧美成人激情免费网| 国产蜜臀97一区二区三区| 亚洲色图.com| 日一区二区三区| 精品亚洲成av人在线观看| 不卡视频一二三四| 欧美丰满美乳xxx高潮www| 欧美成人精品福利| 亚洲精品一卡二卡| 日韩激情视频在线观看| 国产成人欧美日韩在线电影| 日本高清不卡视频| 精品国产乱码久久久久久老虎| 欧美激情综合五月色丁香| 一区二区国产盗摄色噜噜| 国产在线播精品第三| 91豆麻精品91久久久久久| 久久色在线视频| 亚洲一区在线电影| 国产毛片精品视频| 欧美日韩免费不卡视频一区二区三区| 久久综合狠狠综合久久激情| 玉米视频成人免费看| 国产精品自拍毛片| 777午夜精品免费视频| 中文字幕一区二区视频| 精品一二线国产| 欧美日韩视频不卡| 国产精品日产欧美久久久久| 青青青伊人色综合久久| 91福利区一区二区三区| 国产精品人人做人人爽人人添| 性久久久久久久久久久久| 成人精品gif动图一区| 欧美sm美女调教| 图片区小说区国产精品视频| 99久久精品国产导航| 久久久91精品国产一区二区三区| 亚洲成人激情av| 欧洲生活片亚洲生活在线观看| 久久精品欧美一区二区三区不卡 | 亚洲高清在线视频| 99精品欧美一区| 国产精品视频在线看| 久久99国产精品免费| 日韩手机在线导航| 日韩精品福利网| 欧美色窝79yyyycom| 亚洲精品网站在线观看| 盗摄精品av一区二区三区| 久久久影视传媒| 国产成人午夜精品影院观看视频| 精品国产网站在线观看| 奇米精品一区二区三区在线观看 | 国产女同互慰高潮91漫画| 美女爽到高潮91| 日韩视频一区二区三区 | 成人av在线资源| 中文字幕免费不卡| 国产成人精品午夜视频免费| 久久亚洲二区三区| 国产麻豆精品一区二区| 国产亚洲一区二区在线观看| 韩国精品一区二区| www久久精品|