• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ AVERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中AVERT函数的典型用法代码示例。如果您正苦于以下问题:C++ AVERT函数的具体用法?C++ AVERT怎么用?C++ AVERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了AVERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: bufferNoSetRankSet

static void bufferNoSetRankSet(Buffer buffer, RankSet rankset)
{
  AVERT(Buffer, buffer);
  AVERT(RankSet, rankset);
  NOTREACHED; /* .norank */
}
开发者ID:Ravenbrook,项目名称:mps,代码行数:6,代码来源:buffer.c


示例2: MVFFInit

static Res MVFFInit(Pool pool, ArgList args)
{
  Size extendBy = MVFF_EXTEND_BY_DEFAULT;
  Size avgSize = MVFF_AVG_SIZE_DEFAULT;
  Size align = MVFF_ALIGN_DEFAULT;
  Bool slotHigh = MVFF_SLOT_HIGH_DEFAULT;
  Bool arenaHigh = MVFF_ARENA_HIGH_DEFAULT;
  Bool firstFit = MVFF_FIRST_FIT_DEFAULT;
  MVFF mvff;
  Arena arena;
  Res res;
  void *p;
  ArgStruct arg;

  AVERT(Pool, pool);
  arena = PoolArena(pool);

  /* .arg: class-specific additional arguments; see */
  /* <design/poolmvff/#method.init> */
  /* .arg.check: we do the same checks here and in MVFFCheck */
  /* except for arenaHigh, which is stored only in the segPref. */
  
  if (ArgPick(&arg, args, MPS_KEY_EXTEND_BY))
    extendBy = arg.val.size;
  
  if (ArgPick(&arg, args, MPS_KEY_MEAN_SIZE))
    avgSize = arg.val.size;
  
  if (ArgPick(&arg, args, MPS_KEY_ALIGN))
    align = arg.val.align;

  if (ArgPick(&arg, args, MPS_KEY_MVFF_SLOT_HIGH))
    slotHigh = arg.val.b;
  
  if (ArgPick(&arg, args, MPS_KEY_MVFF_ARENA_HIGH))
    arenaHigh = arg.val.b;
  
  if (ArgPick(&arg, args, MPS_KEY_MVFF_FIRST_FIT))
    firstFit = arg.val.b;

  AVER(extendBy > 0);           /* .arg.check */
  AVER(avgSize > 0);            /* .arg.check */
  AVER(avgSize <= extendBy);    /* .arg.check */
  AVER(SizeIsAligned(align, MPS_PF_ALIGN));
  AVERT(Bool, slotHigh);
  AVERT(Bool, arenaHigh);
  AVERT(Bool, firstFit);

  mvff = Pool2MVFF(pool);

  mvff->extendBy = extendBy;
  if (extendBy < ArenaAlign(arena))
    mvff->minSegSize = ArenaAlign(arena);
  else
    mvff->minSegSize = extendBy;
  mvff->avgSize = avgSize;
  pool->alignment = align;
  mvff->slotHigh = slotHigh;
  mvff->firstFit = firstFit;

  res = ControlAlloc(&p, arena, sizeof(SegPrefStruct), FALSE);
  if (res != ResOK)
    return res;

  mvff->segPref = (SegPref)p;
  SegPrefInit(mvff->segPref);
  SegPrefExpress(mvff->segPref, arenaHigh ? SegPrefHigh : SegPrefLow, NULL);

  mvff->total = 0;
  mvff->free = 0;

  res = FreelistInit(FreelistOfMVFF(mvff), align);
  if (res != ResOK)
    goto failInit;

  res = CBSInit(CBSOfMVFF(mvff), arena, (void *)mvff, align,
                /* fastFind */ TRUE, /* zoned */ FALSE, args);
  if (res != ResOK)
    goto failInit;

  mvff->sig = MVFFSig;
  AVERT(MVFF, mvff);
  EVENT8(PoolInitMVFF, pool, arena, extendBy, avgSize, align,
         BOOL(slotHigh), BOOL(arenaHigh), BOOL(firstFit));
  return ResOK;

failInit:
  ControlFree(arena, p, sizeof(SegPrefStruct));
  return res;
}
开发者ID:BarAgent,项目名称:mps-temporary,代码行数:90,代码来源:poolmvff.c


示例3: VMBase

Addr VMBase(VM vm)
{
  AVERT(VM, vm);

  return vm->base;
}
开发者ID:BarAgent,项目名称:mps-temporary,代码行数:6,代码来源:vmix.c


示例4: SplayDebugCount

Count SplayDebugCount(SplayTree splay)
{
  AVERT(SplayTree, splay);
  return TreeDebugCount(SplayTreeRoot(splay), splay->compare, splay->nodeKey);
}
开发者ID:aseaday,项目名称:mps-temporary,代码行数:5,代码来源:splay.c


示例5: SplaySplitRev

static Compare SplaySplitRev(SplayStateStruct *stateReturn,
                             SplayTree splay, TreeKey key,
                             TreeCompareFunction compare)
{
  Tree middle, leftLast, rightFirst;
  Compare cmp;

  AVERT(SplayTree, splay);
  AVER(FUNCHECK(compare));
  AVER(!SplayTreeIsEmpty(splay));
  
  leftLast = TreeEMPTY;
  rightFirst = TreeEMPTY;
  middle = SplayTreeRoot(splay);
  for (;;) {
    cmp = compare(middle, key);
    switch(cmp) {
    default:
      NOTREACHED;
      /* defensive fall-through */
    case CompareEQUAL:
      goto stop;

    case CompareLESS:
      if (!TreeHasLeft(middle))
        goto stop;
      middle = SplayZigRev(middle, &rightFirst);
      cmp = compare(middle, key);
      switch(cmp) {
      default:
        NOTREACHED;
        /* defensive fall-through */
      case CompareEQUAL:
        goto stop;
      case CompareLESS:
        if (!TreeHasLeft(middle))
          goto stop;
        middle = SplayZigZigRev(middle, &rightFirst);
        splay->updateNode(splay, TreeRight(rightFirst));
        break;
      case CompareGREATER:
        if (!TreeHasRight(middle))
          goto stop;
        middle = SplayZagRev(middle, &leftLast);
        break;
      }
      break;

    case CompareGREATER:
      if (!TreeHasRight(middle))
        goto stop;
      middle = SplayZagRev(middle, &leftLast);
      cmp = compare(middle, key);
      switch(cmp) {
      default:
        NOTREACHED;
        /* defensive fall-through */
      case CompareEQUAL:
        goto stop;
      case CompareGREATER:
        if (!TreeHasRight(middle))
          goto stop;
        middle = SplayZagZagRev(middle, &leftLast);
        splay->updateNode(splay, TreeLeft(leftLast));
        break;
      case CompareLESS:
        if (!TreeHasLeft(middle))
          goto stop;
        middle = SplayZigRev(middle, &rightFirst);
        break;
      }
      break;
    }
  }

stop:
  stateReturn->middle = middle;
  stateReturn->leftLast = leftLast;
  stateReturn->rightFirst = rightFirst;
  return cmp;
}
开发者ID:aseaday,项目名称:mps-temporary,代码行数:81,代码来源:splay.c


示例6: VMAlign

Align VMAlign(VM vm)
{
  AVERT(VM, vm);
  return vm->align;
}
开发者ID:glycerine,项目名称:mps-kit-1.108.0-x86_64-linux-port,代码行数:5,代码来源:vmi5.c


示例7: MessageOnQueue

static Bool MessageOnQueue(Message message)
{
  AVERT(Message, message);

  return !RingIsSingle(&message->queueRing);
}
开发者ID:S0043640wipro,项目名称:RiCRiPInt,代码行数:6,代码来源:message.c


示例8: SplaySplay

static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
                       void *key, SplayCompareMethod compareMethod) {
    /* The sides structure avoids a boundary case in SplayLink* */
    SplayNodeStruct sides; /* rightTop and leftTop */
    SplayNode top, leftLast, rightFirst;
    Bool found;
    Compare compareTop;

    AVERT(SplayTree, tree);
    AVER(nodeReturn != NULL);
    AVER(FUNCHECK(compareMethod));

    top = SplayTreeRoot(tree); /* will be copied back at end */

    if (top == NULL) {
        *nodeReturn = NULL;
        return FALSE;
    }

    /* short-circuit case where node is already top */
    compareTop = (*compareMethod)(key, top);
    if (compareTop == CompareEQUAL) {
        *nodeReturn = top;
        return TRUE;
    }

    SplayNodeInit(&sides); /* left and right trees now NULL */
    leftLast = &sides;
    rightFirst = &sides;

    while(TRUE) {
        /* compareTop is already initialised above. */
        switch(compareTop) {

        case CompareLESS: {
            SplayNode topLeft = SplayNodeLeftChild(top);
            if (topLeft == NULL) {
                found = FALSE;
                goto assemble;
            } else {
                Compare compareTopLeft = (*compareMethod)(key, topLeft);

                switch(compareTopLeft) {

                case CompareEQUAL: {                 /* zig */
                    SplayLinkRight(&top, &rightFirst);
                    found = TRUE;
                    goto assemble;
                    } /* break; */

                case CompareLESS: {                  /* zig-zig */
                    if (SplayNodeLeftChild(topLeft) == NULL)
                        goto terminalZig;
                    SplayRotateRight(&top, tree);
                    SplayLinkRight(&top, &rightFirst);
                }
                break;

                case CompareGREATER: {               /* zig-zag */
                    if (SplayNodeRightChild(topLeft) == NULL)
                        goto terminalZig;
                    SplayLinkRight(&top, &rightFirst);
                    SplayLinkLeft(&top, &leftLast);
                }
                break;

                default: {
                    NOTREACHED;
                }
                break;
                }
            }
        }
        break;

        case CompareGREATER: {
            SplayNode topRight = SplayNodeRightChild(top);
            if (topRight == NULL) {
                found = FALSE;
                goto assemble;
            } else {
                Compare compareTopRight = (*compareMethod)(key, topRight);

                switch(compareTopRight) {

                case CompareEQUAL: {                 /* zag */
                    SplayLinkLeft(&top, &leftLast);
                    found = TRUE;
                    goto assemble;
                    } /* break; */

                case CompareGREATER: {               /* zag-zag */
                    if (SplayNodeRightChild(topRight) == NULL)
                        goto terminalZag;
                    SplayRotateLeft(&top, tree);
                    SplayLinkLeft(&top, &leftLast);
                }
                break;

                case CompareLESS: {                  /* zag-zig */
//.........这里部分代码省略.........
开发者ID:glycerine,项目名称:mps-kit-1.108.0-x86_64-linux-port,代码行数:101,代码来源:splay.c


示例9: SplayTreeFinish

void SplayTreeFinish(SplayTree tree)
{
    AVERT(SplayTree, tree);
    SplayTreeSetRoot(tree, NULL);
    tree->compare = NULL;
}
开发者ID:glycerine,项目名称:mps-kit-1.108.0-x86_64-linux-port,代码行数:6,代码来源:splay.c


示例10: BTFindResRangeHigh

static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn,
                               BT bt,
                               Index searchBase, Index searchLimit,
                               Count minLength,
                               Count maxLength)
{
  Bool foundRes;         /* true if a reset bit is found */
  Index resLimit;        /* limit of a candidate reset range */
  Index resIndex;        /* index of highest reset bit found */
  Index unseenLimit;     /* limit of testing so far */
  Index minBase;         /* base of minimal acceptable range */
  Index resBase;         /* base of search for a candidate range */

  AVER(baseReturn != NULL);
  AVER(limitReturn != NULL);
  AVERT(BT, bt);
  AVER(searchBase < searchLimit);
  AVER(minLength > 0);
  AVER(minLength <= maxLength);
  AVER(maxLength <= searchLimit - searchBase);

  foundRes = FALSE;     /* don't know first reset bit */
  minBase = 0;          /* avoid spurious compiler warning */
  resLimit = searchLimit;    /* haven't seen anything yet */
  unseenLimit = searchLimit; /* haven't seen anything yet */
  resBase = searchBase + minLength -1;

  while (resLimit > resBase) {
    Index setIndex;  /* index of first set bit found */
    Bool foundSet = FALSE; /* true if a set bit is found */

    /* Find the first reset bit if it's not already known */
    if (!foundRes) {
      /* Look for the limit of a range */
      BTFindResHigh(&foundRes, &resIndex, bt, resBase, unseenLimit);
      if (!foundRes) {
        /* failure */
        return FALSE;
      }
      resLimit = resIndex + 1;
      unseenLimit = resIndex;
      minBase = resLimit - minLength;
    }

    /* Look to see if there is any set bit in the minimum range */
    BTFindSet(&foundSet, &setIndex, bt, minBase, unseenLimit);
    if (!foundSet) {
      /* Found minimum range. Extend it. */
      Index setBase;   /* base of search for set bit */
      Index setLimit;  /* limit search for set bit */
      Index baseIndex; /* base of reset range found */
      foundSet = FALSE;
      setLimit = minBase;
      if ((searchBase + maxLength) > resLimit)
        setBase = searchBase;
      else
        setBase  = resLimit - maxLength;
      if (setLimit > setBase)
        BTFindSetHigh(&foundSet, &setIndex, bt, setBase, setLimit);
      if (foundSet)
        baseIndex = setIndex+1;
      else
        baseIndex = setBase;
     
      AVER(resLimit - baseIndex >= minLength);
      AVER(resLimit - baseIndex <= maxLength);
      *baseReturn = baseIndex;
      *limitReturn = resLimit;
      return TRUE;
     
    } else {
      /* Range was too small. Try again */
      unseenLimit = minBase;
      resLimit = setIndex;
      if (resLimit != minBase) {
        /* Already found the start of next candidate range. This wraps
         * round if minLength > resLimit (all the variables are
         * unsigned so this behaviour is defined), but that means that
         * resLimit <= resBase and so the loop will exit. */
        AVER(resLimit >= minLength || resLimit <= resBase);
        minBase = resLimit - minLength;
      } else {
        foundRes = FALSE;
      }
    }
  }

  /* failure */
  return FALSE;
}
开发者ID:BarAgent,项目名称:mps-temporary,代码行数:90,代码来源:bt.c


示例11: SplayAssemble

static void SplayAssemble(SplayTree tree, SplayNode top,
                          SplayNode leftTop, SplayNode leftLast,
                          SplayNode rightTop, SplayNode rightFirst) {
    AVERT(SplayTree, tree);
    AVERT(SplayNode, top);
    AVER(leftTop == NULL ||
         (SplayNodeCheck(leftTop) && SplayNodeCheck(leftLast)));
    AVER(rightTop == NULL ||
         (SplayNodeCheck(rightTop) && SplayNodeCheck(rightFirst)));

    if (leftTop != NULL) {
        SplayNodeSetRightChild(leftLast, SplayNodeLeftChild(top));
        SplayNodeSetLeftChild(top, leftTop);

        if (tree->updateNode != NULL) {
            /* Update client property using pointer reversal (Ugh!). */
            SplayNode node, parent, rightChild;

            /* Reverse the pointers between leftTop and leftLast */
            /* leftLast is not reversed. */
            node = leftTop;
            parent = NULL;
            while(node != leftLast) {
                rightChild = SplayNodeRightChild(node);
                SplayNodeSetRightChild(node, parent); /* pointer reversal */
                parent = node;
                node = rightChild;
            }

            /* Now restore the pointers, updating the client property. */
            /* node is leftLast, parent is the last parent (or NULL). */
            SplayNodeUpdate(tree, node);
            while(node != leftTop) {
                rightChild = node;
                node = parent;
                parent = SplayNodeRightChild(node);
                SplayNodeSetRightChild(node, rightChild); /* un-reverse pointer */
                SplayNodeUpdate(tree, node);
            }
        }
    }
    /* otherwise leave top->left alone */

    if (rightTop != NULL) {
        SplayNodeSetLeftChild(rightFirst, SplayNodeRightChild(top));
        SplayNodeSetRightChild(top, rightTop);

        if (tree->updateNode != NULL) {
            /* Update client property using pointer reversal (Ugh!). */
            SplayNode node, parent, leftChild;

            /* Reverse the pointers between rightTop and rightFirst */
            /* ightFirst is not reversed. */
            node = rightTop;
            parent = NULL;
            while(node != rightFirst) {
                leftChild = SplayNodeLeftChild(node);
                SplayNodeSetLeftChild(node, parent); /* pointer reversal */
                parent = node;
                node = leftChild;
            }

            /* Now restore the pointers, updating the client property. */
            /* node is rightFirst, parent is the last parent (or NULL). */
            SplayNodeUpdate(tree, node);
            while(node != rightTop) {
                leftChild = node;
                node = parent;
                parent = SplayNodeLeftChild(node);
                SplayNodeSetLeftChild(node, leftChild); /* un-reverse pointer */
                SplayNodeUpdate(tree, node);
            }
        }
    }
    /* otherwise leave top->right alone */

    if (tree->updateNode != NULL)
        SplayNodeUpdate(tree, top);
}
开发者ID:glycerine,项目名称:mps-kit-1.108.0-x86_64-linux-port,代码行数:79,代码来源:splay.c


示例12: BTFindResRange

static Bool BTFindResRange(Index *baseReturn, Index *limitReturn,
                           BT bt,
                           Index searchBase, Index searchLimit,
                           Count minLength, Count maxLength)
{
  Bool foundRes;         /* true if a reset bit is found */
  Index resBase;         /* base of a candidate reset range */
  Index unseenBase;      /* base of testing so far */
  Index minLimit;        /* limit of minimal acceptable range */
  Index resLimit;        /* limit of search for a candidate range */

  AVER(baseReturn != NULL);
  AVER(limitReturn != NULL);
  AVERT(BT, bt);
  AVER(searchBase < searchLimit);
  AVER(minLength > 0);
  AVER(minLength <= maxLength);
  AVER(maxLength <= searchLimit - searchBase);

  foundRes = FALSE;     /* don't know first reset bit */
  minLimit = 0;         /* avoid spurious compiler warning */
  resBase = searchBase; /* haven't seen anything yet */
  unseenBase = searchBase;  /* haven't seen anything yet */
  resLimit = searchLimit - minLength + 1;

  while (resBase < resLimit) {
    Index setIndex;  /* index of last set bit found */
    Bool foundSet = FALSE; /* true if a set bit is found */

    /* Find the first reset bit if it's not already known */
    if (!foundRes) {
      BTFindRes(&foundRes, &resBase, bt, unseenBase, resLimit);
      if (!foundRes) {
        /* failure */
        return FALSE;
      }
      unseenBase = resBase + 1;
      minLimit = resBase + minLength;
    }

    /* Look to see if there is any set bit in the minimum range */
    BTFindSetHigh(&foundSet, &setIndex, bt, unseenBase, minLimit);
    if (!foundSet) {
      /* Found minimum range. Extend it. */
      Index setBase;   /* base of search for set bit */
      Index setLimit;  /* limit search for set bit */
      foundSet = FALSE;
      setBase = minLimit;
      setLimit = resBase + maxLength;
      if (setLimit > searchLimit)
        setLimit = searchLimit;
      if (setLimit > setBase)
        BTFindSet(&foundSet, &setIndex, bt, setBase, setLimit);
      if (!foundSet)
        setIndex = setLimit;
       
      AVER(setIndex - resBase >= minLength);
      AVER(setIndex - resBase <= maxLength);
      *baseReturn = resBase;
      *limitReturn = setIndex;
      return TRUE;
       
    } else {
      /* Range was too small. Try again */
      unseenBase = minLimit;
      resBase = setIndex + 1;
      if (resBase != minLimit) {
        /* Already found the start of next candidate range */
        minLimit = resBase + minLength;
        /* minLimit might just have gone out of bounds, but in that
         * case resBase >= resLimit and so the loop will exit. */
        AVER(minLimit <= searchLimit || resBase >= resLimit);
      } else {
        foundRes = FALSE;
      }
    }
  }

  /* failure */
  return FALSE;
}
开发者ID:BarAgent,项目名称:mps-temporary,代码行数:81,代码来源:bt.c


示例13: ArenaRootsWalk

static Res ArenaRootsWalk(Globals arenaGlobals, mps_roots_stepper_t f,
                          void *p, size_t s)
{
  Arena arena;
  rootsStepClosureStruct rscStruct;
  rootsStepClosure rsc = &rscStruct;
  Trace trace;
  ScanState ss;
  Rank rank;
  Res res;
  Seg seg;

  AVERT(Globals, arenaGlobals);
  AVER(FUNCHECK(f));
  /* p and s are arbitrary client-provided closure data. */
  arena = GlobalsArena(arenaGlobals);

  /* Scan all the roots with a minimal trace.  Invoke the scanner with a */
  /* rootsStepClosure, which is a subclass of ScanState and contains the */
  /* client-provided closure.  Supply a special fix method in order to */
  /* call the client closure.  This fix method must perform no tracing */
  /* operations of its own. */

  res = TraceCreate(&trace, arena, TraceStartWhyWALK);
  /* Have to fail if no trace available.  Unlikely due to .assume.parked. */
  if (res != ResOK)
    return res;

  /* ArenaRootsWalk only passes references to GCable pools to the client. */
  /* NOTE: I'm not sure why this is. RB 2012-07-24 */
  if (SegFirst(&seg, arena)) {
    do {
      if (PoolHasAttr(SegPool(seg), AttrGC)) {
        res = TraceAddWhite(trace, seg);
        AVER(res == ResOK);
      }
    } while (SegNext(&seg, arena, seg));
  }

  /* Make the roots grey so that they are scanned */
  res = RootsIterate(arenaGlobals, rootWalkGrey, trace);
  /* Make this trace look like any other trace. */
  arena->flippedTraces = TraceSetAdd(arena->flippedTraces, trace);

  rootsStepClosureInit(rsc, arenaGlobals, trace, RootsWalkFix, f, p, s);
  ss = rootsStepClosure2ScanState(rsc);

  for(rank = RankAMBIG; rank < RankLIMIT; ++rank) {
    ss->rank = rank;
    AVERT(ScanState, ss);
    res = RootsIterate(arenaGlobals, rootWalk, (void *)ss);
    if (res != ResOK)
      break;
  }

  /* Turn segments black again. */
  if (SegFirst(&seg, arena)) {
    do {
      if (PoolHasAttr(SegPool(seg), AttrGC)) {
        SegSetGrey(seg, TraceSetDel(SegGrey(seg), trace));
        SegSetWhite(seg, TraceSetDel(SegWhite(seg), trace));
      }
    } while (SegNext(&seg, arena, seg));
  }

  rootsStepClosureFinish(rsc);
  /* Make this trace look like any other finished trace. */
  trace->state = TraceFINISHED;
  TraceDestroy(trace);
  AVER(!ArenaEmergency(arena)); /* There was no allocation. */

  return res;
}
开发者ID:BarAgent,项目名称:mps-temporary,代码行数:73,代码来源:walk.c


示例14: bufferNoReassignSeg

static void bufferNoReassignSeg(Buffer buffer, Seg seg)
{
  AVERT(Buffer, buffer);
  AVERT(Seg, seg);
  NOTREACHED; /* .noseg */
}
开发者ID:Ravenbrook,项目名称:mps,代码行数:6,代码来源:buffer.c


示例15: VMReserved

Size VMReserved(VM vm)
{
  AVERT(VM, vm);
  return vm->reserved;
}
开发者ID:glycerine,项目名称:mps-kit-1.108.0-x86_64-linux-port,代码行数:5,代码来源:vmi5.c


示例16: DEFINE_CLASS

DEFINE_CLASS(Inst, Inst, klass)
{
  InstClassInitInternal(klass);
  klass->instStruct.klass = CLASS(InstClass);
  AVERT(InstClass, klass);
}
开发者ID:Ravenbrook,项目名称:mps,代码行数:6,代码来源:protocol.c


示例17: VMMapped

Size VMMapped(VM vm)
{
  AVERT(VM, vm);
  return vm->mapped;
}
开发者ID:glycerine,项目名称:mps-kit-1.108.0-x86_64-linux-port,代码行数:5,代码来源:vmi5.c


示例18: FreelistFinish

void FreelistFinish(Freelist fl)
{
  AVERT(Freelist, fl);
  fl->sig = SigInvalid;
  fl->list = NULL;
}
开发者ID:alisheikh,项目名称:hornet,代码行数:6,代码来源:freelist.c


示例19: VMCreate

Res VMCreate(VM *vmReturn, Size size)
{
  void *addr;
  Align align;
  int zero_fd;
  VM vm;
  Res res;

  AVER(vmReturn != NULL);

  align = (Align)sysconf(_SC_PAGESIZE);
  AVER(SizeIsP2(align));
  size = SizeAlignUp(size, align);
  if((size == 0) || (size > (Size)(size_t)-1))
    return ResRESOURCE;

  zero_fd = open("/dev/zero", O_RDONLY);
  if(zero_fd == -1)
    return ResFAIL;

  /* Map in a page to store the descriptor on. */
  addr = mmap((void *)0, (size_t)SizeAlignUp(sizeof(VMStruct), align),
              PROT_READ | PROT_WRITE, MAP_PRIVATE,
              zero_fd, (off_t)0);
  if(addr == MAP_FAILED) {
    AVER(errno == ENOMEM || errno == EAGAIN); /* .assume.mmap.err */
    res = (errno == ENOMEM || errno == EAGAIN) ? ResMEMORY : ResFAIL;
    goto failVMMap;
  }
  vm = (VM)addr;

  vm->zero_fd = zero_fd;
  vm->align = align;

  /* .map.reserve: MAP_AUTORESRV is necessary to avoid reserving swap. */
  addr = mmap((void *)0, (size_t)size, PROT_NONE, MAP_SHARED | MAP_AUTORESRV,
	      zero_fd, (off_t)0);
  if(addr == MAP_FAILED) {
    AVER(errno == ENOMEM); /* .assume.mmap.err */
    res = (errno == ENOMEM) ? ResRESOURCE : ResFAIL;
    goto failReserve;
  }

  vm->base = (Addr)addr;
  vm->limit = AddrAdd(vm->base, size);
  vm->reserved = size;
  vm->mapped = (Size)0;

  vm->sig = VMSig;

  AVERT(VM, vm);

  EVENT_PAA(VMCreate, vm, vm->base, vm->limit);

  *vmReturn = vm;
  return ResOK;

failReserve:
  (void)munmap((void *)vm, (size_t)SizeAlignUp(sizeof(VMStruct), align));
failVMMap:
  (void)close(zero_fd);
  return res;
}
开发者ID:glycerine,项目名称:mps-kit-1.108.0-x86_64-linux-port,代码行数:63,代码来源:vmi5.c


示例20: FreelistBlockNext

/* FreelistBlockNext -- return the next block in the list, or NULL if
 * there are no more blocks.
 */
static FreelistBlock FreelistBlockNext(FreelistBlock block)
{
  AVERT(FreelistBlock, block);
  return FreelistTagReset(block->small.next);
}
开发者ID:alisheikh,项目名称:hornet,代码行数:8,代码来源:freelist.c



注:本文中的AVERT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AVG_ASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ AVERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap