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

C++ JUNLIKELY函数代码示例

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

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



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

示例1: ParseInclude

/** Parse an include. */
void ParseInclude(const TokenNode *tp, int depth) {

   char *temp;

   Assert(tp);

   if(JUNLIKELY(!tp->value)) {

      ParseError(tp, "no include file specified");

   } else {

      temp = CopyString(tp->value);

      ExpandPath(&temp);

      if(JUNLIKELY(!ParseFile(temp, depth))) {
         ParseError(tp, "could not open included file %s", temp);
      }

      Release(temp);

   }

}
开发者ID:Nehamkin,项目名称:jwm,代码行数:26,代码来源:parse.c


示例2: Allocate

/** Read a file. */
char *ReadFile(FILE *fd)
{

   const int BLOCK_SIZE = 1024;  // Start at 1k.

   char *buffer;
   int len, max;

   len = 0;
   max = BLOCK_SIZE;
   buffer = Allocate(max + 1);

   for(;;) {
      const size_t count = fread(&buffer[len], 1, max - len, fd);
      len += count;
      if(len < max) {
         break;
      }
      max *= 2;
      if(JUNLIKELY(max < 0)) {
         /* File is too big. */
         break;
      }
      buffer = Reallocate(buffer, max + 1);
      if(JUNLIKELY(buffer == NULL)) {
         FatalError(_("out of memory"));
      }
   }
   buffer[len] = 0;

   return buffer;

}
开发者ID:Nehamkin,项目名称:jwm,代码行数:34,代码来源:parse.c


示例3: Allocate

/** Read a file. */
char *ReadFile(FILE *fd)
{

   const int BLOCK_SIZE = 1 << 14;  // Start at 16k.

   char *buffer;
   int len, max;
   int ch;

   len = 0;
   max = BLOCK_SIZE;
   buffer = Allocate(max + 1);

   for(;;) {
      ch = fgetc(fd);
      if(JUNLIKELY(ch == EOF || ch == 0)) {
         break;
      }
      buffer[len++] = ch;
      if(JUNLIKELY(len >= max)) {
         max *= 2;
         if(JUNLIKELY(max < 0)) {
            /* File is too big. */
            break;
         }
         buffer = Reallocate(buffer, max + 1);
      }
   }
   buffer[len] = 0;

   return buffer;

}
开发者ID:technosaurus,项目名称:jwm,代码行数:34,代码来源:parse.c


示例4: StartupFonts

/** Startup font support. */
void StartupFonts(void)
{

   unsigned int x;

   /* Inherit unset fonts from the tray for tray items. */
   if(!fontNames[FONT_TASK]) {
      fontNames[FONT_TASK] = CopyString(fontNames[FONT_TRAY]);
   }
   if(!fontNames[FONT_TRAYBUTTON]) {
      fontNames[FONT_TRAYBUTTON] = CopyString(fontNames[FONT_TRAY]);
   }
   if(!fontNames[FONT_CLOCK]) {
      fontNames[FONT_CLOCK] = CopyString(fontNames[FONT_TRAY]);
   }
   if(!fontNames[FONT_PAGER]) {
      fontNames[FONT_PAGER] = CopyString(fontNames[FONT_TRAY]);
   }

#ifdef USE_XFT

   for(x = 0; x < FONT_COUNT; x++) {
      if(fontNames[x]) {
         fonts[x] = JXftFontOpenName(display, rootScreen, fontNames[x]);
         if(!fonts[x]) {
            fonts[x] = JXftFontOpenXlfd(display, rootScreen, fontNames[x]);
         }
         if(JUNLIKELY(!fonts[x])) {
            Warning(_("could not load font: %s"), fontNames[x]);
         }
      }
      if(!fonts[x]) {
         fonts[x] = JXftFontOpenName(display, rootScreen, DEFAULT_FONT);
      }
      if(JUNLIKELY(!fonts[x])) {
         FatalError(_("could not load the default font: %s"), DEFAULT_FONT);
      }
   }

#else /* USE_XFT */

   for(x = 0; x < FONT_COUNT; x++) {
      if(fontNames[x]) {
         fonts[x] = JXLoadQueryFont(display, fontNames[x]);
         if(JUNLIKELY(!fonts[x] && fontNames[x])) {
            Warning(_("could not load font: %s"), fontNames[x]);
         }
      }
      if(!fonts[x]) {
         fonts[x] = JXLoadQueryFont(display, DEFAULT_FONT);
      }
      if(JUNLIKELY(!fonts[x])) {
         FatalError(_("could not load the default font: %s"), DEFAULT_FONT);
      }
   }

#endif /* USE_XFT */

}
开发者ID:George-Shaw,项目名称:jwm,代码行数:60,代码来源:font.c


示例5: strlen

/** Create a button tray component. */
TrayComponentType *CreateTrayButton(const char *iconName,
   const char *label, const char *action,
   const char *popup, int width, int height) {

   TrayButtonType *bp;
   TrayComponentType *cp;

   if(JUNLIKELY((label == NULL || strlen(label) == 0)
      && (iconName == NULL || strlen(iconName) == 0))) {
      Warning(_("no icon or label for TrayButton"));
      return NULL;
   }

   if(JUNLIKELY(width < 0)) {
      Warning(_("invalid TrayButton width: %d"), width);
      width = 0;
   }
   if(JUNLIKELY(height < 0)) {
      Warning(_("invalid TrayButton height: %d"), height);
      height = 0;
   }

   bp = Allocate(sizeof(TrayButtonType));
   bp->next = buttons;
   buttons = bp;

   bp->icon = NULL;
   bp->iconName = CopyString(iconName);
   bp->label = CopyString(label);
   bp->action = CopyString(action);
   bp->popup = CopyString(popup);

   cp = CreateTrayComponent();
   cp->object = bp;
   bp->cp = cp;
   cp->requestedWidth = width;
   cp->requestedHeight = height;

   bp->mousex = -POPUP_DELTA;
   bp->mousey = -POPUP_DELTA;

   cp->Create = Create;
   cp->Destroy = Destroy;
   cp->SetSize = SetSize;
   cp->Resize = Resize;

   cp->ProcessButtonPress = ProcessButtonPress;
   cp->ProcessButtonRelease = ProcessButtonRelease;
   if(popup || label) {
      cp->ProcessMotionEvent = ProcessMotionEvent;
   }

   return cp;

}
开发者ID:bbidulock,项目名称:jwmtools,代码行数:56,代码来源:traybutton.c


示例6: StartupFonts

/** Startup font support. */
void StartupFonts(void)
{

   unsigned int x;

   /* Inherit unset fonts from the tray for tray items. */
   for(x = 0; x < ARRAY_LENGTH(INHERITED_FONTS); x++) {
      const FontType dest = INHERITED_FONTS[x].dest;
      if(!fontNames[dest]) {
         const FontType src = INHERITED_FONTS[x].src;
         fontNames[dest] = CopyString(fontNames[src]);
      }
   }

#ifdef USE_XFT

   for(x = 0; x < FONT_COUNT; x++) {
      if(fontNames[x]) {
         fonts[x] = JXftFontOpenName(display, rootScreen, fontNames[x]);
         if(!fonts[x]) {
            fonts[x] = JXftFontOpenXlfd(display, rootScreen, fontNames[x]);
         }
         if(JUNLIKELY(!fonts[x])) {
            Warning(_("could not load font: %s"), fontNames[x]);
         }
      }
      if(!fonts[x]) {
         fonts[x] = JXftFontOpenName(display, rootScreen, DEFAULT_FONT);
      }
      if(JUNLIKELY(!fonts[x])) {
         FatalError(_("could not load the default font: %s"), DEFAULT_FONT);
      }
   }

#else /* USE_XFT */

   for(x = 0; x < FONT_COUNT; x++) {
      if(fontNames[x]) {
         fonts[x] = JXLoadQueryFont(display, fontNames[x]);
         if(JUNLIKELY(!fonts[x] && fontNames[x])) {
            Warning(_("could not load font: %s"), fontNames[x]);
         }
      }
      if(!fonts[x]) {
         fonts[x] = JXLoadQueryFont(display, DEFAULT_FONT);
      }
      if(JUNLIKELY(!fonts[x])) {
         FatalError(_("could not load the default font: %s"), DEFAULT_FONT);
      }
   }

#endif /* USE_XFT */

}
开发者ID:Israel-,项目名称:jwm,代码行数:55,代码来源:font.c


示例7: ParseKey

/** Parse a key binding. */
void ParseKey(const TokenNode *tp) {

   const char *key;
   const char *code;
   const char *mask;
   const char *action;
   const char *command;
   KeyType k;
   int x;

   Assert(tp);

   mask = FindAttribute(tp->attributes, "mask");
   key = FindAttribute(tp->attributes, "key");
   code = FindAttribute(tp->attributes, "keycode");

   action = tp->value;
   if(JUNLIKELY(action == NULL)) {
      ParseError(tp, "no action specified for Key");
      return;
   }

   command = NULL;
   k = KEY_NONE;
   if(!strncmp(action, "exec:", 5)) {
      k = KEY_EXEC;
      command = action + 5;
   } else if(!strncmp(action, "root:", 5)) {
      k = KEY_ROOT;
      command = action + 5;
   } else {
      for(x = 0; KEY_MAP[x].name; x++) {
         if(!strcmp(action, KEY_MAP[x].name)) {
            k = KEY_MAP[x].key;
            break;
         }
      }
   }

   /* Insert the binding if it's valid. */
   if(JUNLIKELY(k == KEY_NONE)) {

      ParseError(tp, "invalid Key action: \"%s\"", action);

   } else {

      InsertBinding(k, mask, key, code, command);

   }

}
开发者ID:technosaurus,项目名称:jwm,代码行数:52,代码来源:parse.c


示例8: Warning

/** Create a swallowed application tray component. */
TrayComponentType *CreateSwallow(const char *name, const char *command,
                                 int width, int height) {

   TrayComponentType *cp;
   SwallowNode *np;

   if(JUNLIKELY(!name)) {
      Warning(_("cannot swallow a client with no name"));
      return NULL;
   }

   /* Make sure this name isn't already used. */
   for(np = swallowNodes; np; np = np->next) {
      if(JUNLIKELY(!strcmp(np->name, name))) {
         Warning(_("cannot swallow the same client multiple times"));
         return NULL;
      }
   }

   np = Allocate(sizeof(SwallowNode));
   np->name = CopyString(name);
   np->command = CopyString(command);

   np->next = swallowNodes;
   swallowNodes = np;

   cp = CreateTrayComponent();
   np->cp = cp;
   cp->object = np;
   cp->Destroy = Destroy;
   cp->Resize = Resize;

   if(width) {
      cp->requestedWidth = width;
      np->userWidth = 1;
   } else {
      cp->requestedWidth = 1;
      np->userWidth = 0;
   }
   if(height) {
      cp->requestedHeight = height;
      np->userHeight = 1;
   } else {
      cp->requestedHeight = 1;
      np->userHeight = 0;
   }

   return cp;

}
开发者ID:bbidulock,项目名称:jwmtools,代码行数:51,代码来源:swallow.c


示例9: ParseKey

/** Parse a key binding. */
void ParseKey(const TokenNode *tp) {

   const char *key;
   const char *code;
   const char *mask;
   const char *action;
   const char *command;
   KeyType k;

   Assert(tp);

   mask = FindAttribute(tp->attributes, "mask");
   key = FindAttribute(tp->attributes, "key");
   code = FindAttribute(tp->attributes, "keycode");

   action = tp->value;
   if(JUNLIKELY(action == NULL)) {
      ParseError(tp, "no action specified for Key");
      return;
   }

   command = NULL;
   k = KEY_NONE;
   if(!strncmp(action, "exec:", 5)) {
      k = KEY_EXEC;
      command = action + 5;
   } else if(!strncmp(action, "root:", 5)) {
      k = KEY_ROOT;
      command = action + 5;
   } else {
      /* Look up the option in the key map using binary search. */
      const int x = FindValue(KEY_MAP, KEY_MAP_COUNT, action);
      if(x >= 0) {
         k = (KeyType)x;
      }
   }

   /* Insert the binding if it's valid. */
   if(JUNLIKELY(k == KEY_NONE)) {

      ParseError(tp, "invalid Key action: \"%s\"", action);

   } else {

      InsertBinding(k, mask, key, code, command);

   }

}
开发者ID:Nehamkin,项目名称:jwm,代码行数:50,代码来源:parse.c


示例10: OpenConnection

/** Open a connection to the X server. */
void OpenConnection(void)
{

   display = JXOpenDisplay(displayString);
   if(JUNLIKELY(!display)) {
      if(displayString) {
         printf("error: could not open display %s\n", displayString);
      } else {
         printf("error: could not open display\n");
      }
      DoExit(1);
   }

   rootScreen = DefaultScreen(display);
   rootWindow = RootWindow(display, rootScreen);
   rootWidth = DisplayWidth(display, rootScreen);
   rootHeight = DisplayHeight(display, rootScreen);
   rootDepth = DefaultDepth(display, rootScreen);
   rootVisual = DefaultVisual(display, rootScreen);
   rootColormap = DefaultColormap(display, rootScreen);
   rootGC = DefaultGC(display, rootScreen);
   colormapCount = MaxCmapsOfScreen(ScreenOfDisplay(display, rootScreen));

   XSetGraphicsExposures(display, rootGC, False);


}
开发者ID:kuailexs,项目名称:jwm,代码行数:28,代码来源:main.c


示例11: UpdateTaskBar

/** Update all task bars. */
void UpdateTaskBar(void)
{
   TaskBarType *bp;
   int lastHeight = -1;

   if(JUNLIKELY(shouldExit)) {
      return;
   }

   for(bp = bars; bp; bp = bp->next) {
      if(bp->layout == LAYOUT_VERTICAL) {
         TaskEntry *tp;
         lastHeight = bp->cp->requestedHeight;
         if(bp->userHeight > 0) {
            bp->itemHeight = bp->userHeight;
         } else {
            bp->itemHeight = GetStringHeight(FONT_TASKLIST) + 12;
         }
         bp->cp->requestedHeight = 0;
         for(tp = taskEntries; tp; tp = tp->next) {
            if(ShouldShowEntry(tp)) {
               bp->cp->requestedHeight += bp->itemHeight;
            }
         }
         bp->cp->requestedHeight = Max(1, bp->cp->requestedHeight);
         if(lastHeight != bp->cp->requestedHeight) {
            ResizeTray(bp->cp->tray);
         }
      }
      ComputeItemSize(bp);
      Render(bp);
   }
}
开发者ID:JamesLinus,项目名称:jwm,代码行数:34,代码来源:taskbar.c


示例12: ParseModifierString

/** Parse a modifier mask string. */
unsigned int ParseModifierString(const char *str)
{
    unsigned int mask;
    unsigned int x, y;
    char found;

    if(!str) {
        return MASK_NONE;
    }

    mask = MASK_NONE;
    for(x = 0; str[x]; x++) {

        found = 0;
        for(y = 0; modifiers[y].name; y++) {
            if(modifiers[y].name == str[x]) {
                mask |= modifiers[y].mask;
                found = 1;
                break;
            }
        }

        if(JUNLIKELY(!found)) {
            Warning(_("invalid modifier: \"%c\""), str[x]);
        }

    }

    return mask;

}
开发者ID:kuailexs,项目名称:jwm,代码行数:32,代码来源:key.c


示例13: SetClientDesktop

/** Set a client's desktop. This will update transients. */
void SetClientDesktop(ClientNode *np, unsigned int desktop)
{

   ClientNode *tp;

   Assert(np);

   if(JUNLIKELY(desktop >= settings.desktopCount)) {
      return;
   }

   if(!(np->state.status & STAT_STICKY)) {
      int x;
      for(x = 0; x < LAYER_COUNT; x++) {
         for(tp = nodes[x]; tp; tp = tp->next) {
            if(tp == np || tp->owner == np->window) {

               tp->state.desktop = desktop;

               if(desktop == currentDesktop) {
                  ShowClient(tp);
               } else {
                  HideClient(tp);
               }

               SetCardinalAtom(tp->window, ATOM_NET_WM_DESKTOP,
                               tp->state.desktop);
            }
         }
      }
      RequirePagerUpdate();
      RequireTaskUpdate();
   }

}
开发者ID:pecarter-work,项目名称:jwm,代码行数:36,代码来源:client.c


示例14: Warning

/** Create a dock component. */
TrayComponentType *CreateDock(int width)
{
   TrayComponentType *cp;

   if(JUNLIKELY(dock != NULL && dock->cp != NULL)) {
      Warning(_("only one Dock allowed"));
      return NULL;
   } else if(dock == NULL) {
      dock = Allocate(sizeof(DockType));
      dock->nodes = NULL;
      dock->window = None;
   }

   cp = CreateTrayComponent();
   cp->object = dock;
   cp->requestedWidth = 1;
   cp->requestedHeight = 1;
   dock->cp = cp;
   dock->itemSize = width;

   cp->SetSize = SetSize;
   cp->Create = Create;
   cp->Resize = Resize;

   return cp;

}
开发者ID:JamesLinus,项目名称:jwm,代码行数:28,代码来源:dock.c


示例15: RunCommand

/** Execute an external program. */
void RunCommand(const char *command) {

   const char *displayString;
   char *str;

   if(JUNLIKELY(!command)) {
      return;
   }

   displayString = DisplayString(display);

   if(!fork()) {
      close(ConnectionNumber(display));
      if(displayString && displayString[0]) {
         str = malloc(strlen(displayString) + 9);
         sprintf(str, "DISPLAY=%s", displayString);
         putenv(str);
      }
      setsid();
      execl(SHELL_NAME, SHELL_NAME, "-c", command, NULL);
      Warning(_("exec failed: (%s) %s"), SHELL_NAME, command);
      exit(EXIT_SUCCESS);
   }

}
开发者ID:bbidulock,项目名称:jwmtools,代码行数:26,代码来源:command.c


示例16: ParseFile

/**
 * Parse a specific file.
 * @return 1 on success and 0 on failure.
 */
char ParseFile(const char *fileName, int depth)
{

   TokenNode *tokens;
   FILE *fd;
   char *buffer;

   depth += 1;
   if(JUNLIKELY(depth > MAX_INCLUDE_DEPTH)) {
      ParseError(NULL, "include depth (%d) exceeded", MAX_INCLUDE_DEPTH);
      return 0;
   }

   fd = fopen(fileName, "r");
   if(!fd) {
      return 0;
   }

   buffer = ReadFile(fd);
   fclose(fd);

   tokens = Tokenize(buffer, fileName);
   Release(buffer);
   Parse(tokens, depth);
   ReleaseTokens(tokens);

   return 1;

}
开发者ID:Nehamkin,项目名称:jwm,代码行数:33,代码来源:parse.c


示例17: ParseKeyString

/** Parse a key string. */
KeySym ParseKeyString(const char *str)
{
    KeySym symbol;
    symbol = JXStringToKeysym(str);
    if(JUNLIKELY(symbol == NoSymbol)) {
        Warning(_("invalid key symbol: \"%s\""), str);
    }
    return symbol;
}
开发者ID:kuailexs,项目名称:jwm,代码行数:10,代码来源:key.c


示例18: ParseConfig

/** Parse the JWM configuration. */
void ParseConfig(const char *fileName)
{
   if(!ParseFile(fileName, 0)) {
      if(JUNLIKELY(!ParseFile(SYSTEM_CONFIG, 0))) {
         ParseError(NULL, "could not open %s or %s", fileName, SYSTEM_CONFIG);
      }
   }
   ValidateTrayButtons();
   ValidateKeys();
}
开发者ID:Nehamkin,项目名称:jwm,代码行数:11,代码来源:parse.c


示例19: ParseUnsigned

/** Parse an unsigned integer. */
unsigned int ParseUnsigned(const TokenNode *tp, const char *str)
{
   const long value = strtol(str, NULL, 0);
   if(JUNLIKELY(value < 0 || value > UINT_MAX)) {
      ParseError(tp, _("invalid setting: %s"), str);
      return 0;
   } else {
      return (unsigned int)value;
   }
}
开发者ID:Nehamkin,项目名称:jwm,代码行数:11,代码来源:parse.c


示例20: strlen

/** Load an image from the specified file. */
ImageNode *LoadImage(const char *fileName, int rwidth, int rheight,
                     char preserveAspect)
{
   unsigned i;
   unsigned name_length;
   ImageNode *result = NULL;

   /* Make sure we have a reasonable file name. */
   if(!fileName) {
      return result;
   }
   name_length = strlen(fileName);
   if(JUNLIKELY(name_length == 0)) {
      return result;
   }

   /* Make sure the file exists. */
   if(access(fileName, R_OK) < 0) {
      return result;
   }

   /* First we attempt to use the extension to determine the type
    * to avoid trying all loaders. */
   for(i = 0; i < IMAGE_LOADER_COUNT; i++) {
      const char *ext = IMAGE_LOADERS[i].extension;
      const unsigned ext_length = strlen(ext);
      if(JLIKELY(name_length >= ext_length)) {
         const unsigned offset = name_length - ext_length;
         if(!StrCmpNoCase(&fileName[offset], ext)) {
            const ImageLoader loader = IMAGE_LOADERS[i].loader;
            result = (loader)(fileName, rwidth, rheight, preserveAspect);
            if(JLIKELY(result)) {
               return result;
            }
            break;
         }
      }
   }

   /* We were unable to load by extension, so try everything. */
   for(i = 0; i < IMAGE_LOADER_COUNT; i++) {
      const ImageLoader loader = IMAGE_LOADERS[i].loader;
      result = (loader)(fileName, rwidth, rheight, preserveAspect);
      if(result) {
         /* We were able to load the image, so it must have either the
          * wrong extension or an extension we don't recognize. */
         Warning(_("unrecognized extension for \"%s\", expected \"%s\""),
                 fileName, IMAGE_LOADERS[i].extension);
         return result;
      }
   }

   /* No image could be loaded. */
   return result;
}
开发者ID:Israel-,项目名称:jwm,代码行数:56,代码来源:image.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ J_ASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ JString函数代码示例发布时间: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