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

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

?? sys.c

?? ARM7的一些試驗程序
?? 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一区二区三区免费野_久草精品视频
成人教育av在线| 国产女人水真多18毛片18精品视频 | 久久爱www久久做| 日本伊人精品一区二区三区观看方式| 国产精品高潮呻吟久久| 日韩美女视频一区二区 | 亚洲女子a中天字幕| 亚洲欧洲日产国产综合网| 国产精品乱码一区二区三区软件 | 日韩欧美激情一区| 日韩欧美黄色影院| 久久综合九色综合97婷婷| 久久精品水蜜桃av综合天堂| 国产精品免费视频观看| 最好看的中文字幕久久| 亚洲午夜久久久久久久久电影院| 日韩精品免费专区| 黄色小说综合网站| caoporen国产精品视频| 在线精品视频一区二区三四| 欧美精品亚洲一区二区在线播放| 日韩一区二区不卡| 欧美经典一区二区| 韩国av一区二区三区| 99精品桃花视频在线观看| 欧美在线观看一区二区| 欧美va天堂va视频va在线| 国产精品天天看| 午夜日韩在线电影| 国产精品资源网| 欧美三级一区二区| 久久这里只有精品6| 亚洲男人天堂av| 黑人精品欧美一区二区蜜桃| 91丨九色丨尤物| 日韩欧美国产综合一区| 亚洲国产高清aⅴ视频| 亚洲国产精品久久久男人的天堂| 久久99久久精品| 色成年激情久久综合| 欧美精品一区二区三区蜜桃视频| 亚洲欧美日韩综合aⅴ视频| 久久99蜜桃精品| 欧美在线高清视频| 国产精品久久久久国产精品日日| 手机精品视频在线观看| 99久久综合国产精品| www成人在线观看| 亚洲va中文字幕| 成人高清在线视频| 久久亚洲二区三区| 五月婷婷久久丁香| 色悠悠亚洲一区二区| 国产片一区二区| 精品一区二区三区久久久| 欧美综合一区二区三区| ●精品国产综合乱码久久久久| 看片的网站亚洲| 欧美喷潮久久久xxxxx| 一区二区三区国产豹纹内裤在线| 国产69精品久久777的优势| 日韩精品一区二区三区视频播放 | 久久久91精品国产一区二区精品| 亚洲成av人片在线观看| 日本精品免费观看高清观看| 国产精品久久久久久久午夜片| 国产一区二区福利视频| 日韩欧美一卡二卡| 免费av成人在线| 欧美一区二区三区电影| 日本va欧美va精品发布| 7799精品视频| 美国毛片一区二区三区| 欧美zozo另类异族| 经典一区二区三区| 久久久天堂av| 欧美色网一区二区| 国产剧情一区在线| 在线电影国产精品| 日本成人在线视频网站| 91精品国产高清一区二区三区蜜臀| 亚洲资源中文字幕| 91麻豆精品久久久久蜜臀| 日韩成人精品在线观看| 欧美精品一区在线观看| 国产精品自在欧美一区| 国产精品欧美久久久久一区二区| 成年人国产精品| 亚洲国产另类精品专区| 制服丝袜一区二区三区| 国产一区二区在线观看视频| 国产亚洲1区2区3区| 91在线精品一区二区| 午夜欧美视频在线观看| 精品99999| 91在线观看美女| 日韩av在线发布| 国产女人18毛片水真多成人如厕 | 国产ts人妖一区二区| 日韩一区有码在线| 欧美精品日韩精品| 国模无码大尺度一区二区三区| 国产精品视频免费| 8x8x8国产精品| 成人黄色大片在线观看| 日韩精品成人一区二区三区| 久久久综合精品| 在线一区二区三区做爰视频网站| 美女视频第一区二区三区免费观看网站| 久久老女人爱爱| 欧美三级电影网站| 国产成人午夜精品影院观看视频 | 91精品国产综合久久精品性色| 精品一区二区三区影院在线午夜 | 国产一区在线观看视频| 亚洲欧美日韩精品久久久久| 日韩欧美国产电影| 在线亚洲一区二区| 国产成人av电影免费在线观看| 亚洲精品视频一区二区| 欧美精品一区二区三区在线播放| 97精品久久久午夜一区二区三区 | 性久久久久久久| 国产欧美精品国产国产专区| 欧美美女黄视频| 91丨porny丨户外露出| 极品少妇xxxx偷拍精品少妇| 亚洲一级不卡视频| 日韩一区在线看| 久久久久免费观看| 欧美一区二区三区系列电影| 色婷婷亚洲精品| 成人福利视频网站| 国产做a爰片久久毛片| 日本欧美一区二区在线观看| 亚洲综合精品久久| 亚洲同性gay激情无套| 国产婷婷色一区二区三区四区 | 亚洲一区二区高清| 国产精品美女视频| 欧美国产欧美综合| 国产亚洲精品超碰| 久久精品欧美日韩| 久久久久免费观看| 国产日韩亚洲欧美综合| 精品国产区一区| 精品黑人一区二区三区久久| 日韩视频一区二区三区在线播放| 欧美男人的天堂一二区| 欧美在线影院一区二区| 亚洲精品一线二线三线| 欧美老肥妇做.爰bbww| 成人精品高清在线| 国产毛片精品一区| 国产成人免费视频| 精品无人码麻豆乱码1区2区| 免费看日韩a级影片| 久久精品噜噜噜成人av农村| 老司机免费视频一区二区三区| 另类调教123区| 国产一区二区在线视频| 国产不卡视频一区二区三区| 成人高清在线视频| 91麻豆视频网站| 欧美日韩一区二区在线视频| 在线不卡一区二区| 欧美精品一区二区三区高清aⅴ | 欧美综合久久久| 99久久精品国产精品久久| youjizz久久| 欧美日韩久久一区| 日韩女优视频免费观看| 久久久不卡网国产精品二区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 久久久精品蜜桃| 中文字幕av在线一区二区三区| 成人免费一区二区三区视频 | 91激情五月电影| 欧美一区二区日韩一区二区| 久久免费看少妇高潮| 中文字幕一区二区三区精华液| 亚洲自拍与偷拍| 91在线观看成人| 欧美一区三区四区| 中文字幕精品一区二区三区精品| 国产偷国产偷亚洲高清人白洁| 亚洲人精品午夜| 麻豆成人免费电影| 91啪亚洲精品| 精品99999| 洋洋av久久久久久久一区| 久久成人免费电影| 一本大道久久a久久综合婷婷| 91精品国产免费| 亚洲国产成人私人影院tom| 亚洲精品国产高清久久伦理二区| 免费视频最近日韩| 91在线观看污| 国产偷v国产偷v亚洲高清| 亚洲欧美日韩一区二区三区在线观看|