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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sys.c

?? 自已寫的lwip+ucos程序已調通
?? C
字號:
/*
 * Copyright (c) 2001-2003 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 "sys.h"
#include "opt.h"
#include "def.h"
#include "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 = 0xffffffff;
    }

    if(time == 0xffffffff) {
      /* If time == 0xffffffff, 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) {
        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 != 0xffffffff, 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 = 0xffffffff;
    }

    if(time == 0xffffffff) {
      /* If time == 0xffffffff, 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) {
	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 != 0xffffffff, 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();
  
  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;
    }
    
}


/*-----------------------------------------------------------------------------------*/

#endif /* NO_SYS */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av高清不卡在线| 日韩一级免费一区| 日韩欧美一区二区久久婷婷| 精品久久人人做人人爽| 亚洲激情欧美激情| 国产成人午夜99999| 欧美精品色综合| 亚洲美女在线一区| 国产成人av影院| 精品久久久久久久一区二区蜜臀| 中文字幕一区日韩精品欧美| 麻豆91精品91久久久的内涵| 欧美三区在线观看| 自拍偷拍亚洲欧美日韩| 国产精品一区二区久久精品爱涩| 欧美日韩在线三级| 亚洲女人小视频在线观看| 国产九九视频一区二区三区| 欧美一区二区三区免费| 亚洲国产成人高清精品| 成人av在线一区二区三区| 久久精品在线免费观看| 久久66热re国产| 欧美成人vr18sexvr| 婷婷中文字幕一区三区| 欧美日免费三级在线| 一区二区视频在线看| 91美女在线观看| 亚洲日本护士毛茸茸| 99久久精品免费看| 国产精品精品国产色婷婷| 国产福利91精品一区二区三区| 久久综合久久综合久久| 国产精品一品二品| 欧美经典一区二区三区| 国产盗摄精品一区二区三区在线| 国产亚洲视频系列| 高清不卡一二三区| 亚洲欧洲性图库| 色婷婷久久久亚洲一区二区三区| 亚洲男人的天堂在线观看| 91色porny在线视频| 亚洲小说春色综合另类电影| 欧美一a一片一级一片| 亚洲最新视频在线观看| 欧美精品电影在线播放| 美女视频黄 久久| 久久女同互慰一区二区三区| 国产不卡在线播放| 亚洲精品视频一区| 7777精品伊人久久久大香线蕉完整版| 日本网站在线观看一区二区三区 | 国产高清不卡二三区| 精品电影一区二区| 不卡视频在线观看| 亚洲国产三级在线| 日韩写真欧美这视频| 高清国产一区二区| 洋洋成人永久网站入口| 欧美成人video| jizzjizzjizz欧美| 日韩中文字幕区一区有砖一区 | 91原创在线视频| 亚洲成人自拍偷拍| 精品剧情v国产在线观看在线| 国产成人综合自拍| 性做久久久久久久免费看| 日韩欧美美女一区二区三区| 成人综合激情网| 麻豆国产精品一区二区三区| 中文字幕在线视频一区| 欧美乱妇20p| 丁香另类激情小说| 日本视频一区二区三区| 国产精品嫩草99a| 在线播放视频一区| 成人av免费在线播放| 日本在线不卡一区| 中文字幕中文在线不卡住| 欧美一区二区三区啪啪| 91免费国产视频网站| 久久精品国产一区二区| 一区二区三区免费| 国产欧美精品国产国产专区| 欧美日本在线视频| 91美女视频网站| 国产成人啪免费观看软件| 视频在线观看一区| 中文字幕一区二区三区不卡| 日韩欧美国产精品一区| 欧美色精品在线视频| 国产mv日韩mv欧美| 久久精品国产99国产| 亚洲成人av一区| 亚洲乱码国产乱码精品精小说| 欧美大胆人体bbbb| 欧美老肥妇做.爰bbww| 色综合久久中文综合久久97| 国产精品影视在线观看| 久久成人免费日本黄色| 日日夜夜精品视频免费| 亚洲欧美国产高清| 国产精品国产馆在线真实露脸| 精品国产欧美一区二区| 91精品午夜视频| 欧美午夜宅男影院| 91日韩一区二区三区| gogogo免费视频观看亚洲一| 国产精品 日产精品 欧美精品| 日韩福利电影在线| 日韩精品久久久久久| 日韩黄色小视频| 成人午夜视频在线观看| 国产最新精品免费| 国产乱码精品一品二品| 精品一区二区在线看| 精品一区二区精品| 久久精品72免费观看| 久久精品国产亚洲aⅴ| 蜜臀av性久久久久蜜臀aⅴ四虎| 五月婷婷激情综合网| 天堂成人免费av电影一区| 亚洲国产va精品久久久不卡综合| 亚洲精品菠萝久久久久久久| 亚洲精品videosex极品| 一区二区三区中文字幕精品精品 | 99视频超级精品| 91麻豆国产自产在线观看| 97成人超碰视| 欧美在线观看一区二区| 欧美日韩国产经典色站一区二区三区| 欧美日韩色一区| 日韩一区二区在线观看视频| 精品国产一二三区| 国产精品妹子av| 一二三四社区欧美黄| 五月开心婷婷久久| 六月丁香婷婷久久| 国产另类ts人妖一区二区| 97国产一区二区| 欧美日韩国产区一| 久久综合精品国产一区二区三区| 亚洲国产岛国毛片在线| 亚洲影院理伦片| 精品一区二区综合| 9i在线看片成人免费| 欧美日韩国产综合视频在线观看| 欧美一区二区三区免费观看视频| 久久精品欧美一区二区三区麻豆 | aaa亚洲精品| 欧美伊人精品成人久久综合97| 日韩欧美一区二区在线视频| 国产欧美一区二区精品性色超碰| 亚洲免费在线视频一区 二区| 日日夜夜精品视频天天综合网| 国产乱人伦偷精品视频不卡| 日本韩国精品在线| 2023国产精品| 亚洲另类在线一区| 国产乱码精品1区2区3区| 在线免费观看日韩欧美| 久久日一线二线三线suv| 亚洲精品国产一区二区精华液 | 国产在线不卡视频| 91福利国产成人精品照片| 日韩精品一区二区三区视频播放 | 99久久久精品| 精品国产91九色蝌蚪| 一区av在线播放| 国产黄色成人av| 欧美一区二区私人影院日本| 亚洲欧洲精品天堂一级| 精彩视频一区二区| 欧美日韩一级大片网址| 亚洲视频精选在线| 国产一区二区美女| 51久久夜色精品国产麻豆| 亚洲色图.com| 国产成人精品三级麻豆| 精品国精品自拍自在线| 亚洲成av人片一区二区| 色综合久久66| 国产精品久久久久久久久久久免费看| 精品一区二区成人精品| 91精品国产综合久久久蜜臀图片| 午夜精品久久久久久久| 经典三级视频一区| 大白屁股一区二区视频| 国产精品毛片高清在线完整版| 成人午夜电影小说| 亚洲品质自拍视频| 欧美日韩在线播放三区四区| 午夜亚洲国产au精品一区二区| 日韩一级精品视频在线观看| 国产乱子伦视频一区二区三区| 国产精品久久久久毛片软件| 欧美最猛性xxxxx直播| 麻豆成人av在线| 中文字幕在线不卡| 在线观看免费视频综合|