interval.c

来自「linux下的多线程调试工具」· C语言 代码 · 共 58 行

C
58
字号
/* Copyright (C) 2004,2005,2006  Bull S.A. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#if HAVE_CONFIG_H#include <config.h>#endif#include "modules.h"static unsigned int type = INT_NULL;static unsigned long long inf,max;static unsigned int current_evt = 0;static int init (int mtype, unsigned long long *minf,                 unsigned long long *mmax) {    type = mtype;    if (mtype == INT_NULL) return 0;    if ((mtype < INT_EVT) || (mtype > INT_TIME)) return -1;    if (*minf > *mmax) return -2;    inf = *minf; max = *mmax;    return 0;}static int accept_inter (ptt_timestamp_t *time, int nb_event) {    switch (type) {        case INT_NULL: break;        case INT_EVT: current_evt+=nb_event;                      if (current_evt <= inf) return 0;                      else if (current_evt - nb_event > max) return 2;                      else return 1;                      break;        case INT_TIME: if (*time < inf) return 0;                       else if (*time > max) return 2;                       break;    }    return 1;}struct interval interval = {    .init = init,    .accept = accept_inter};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?