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

C++ ALIGNED函数代码示例

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

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



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

示例1: assert

/*
 * new_name creates a new dictionary (name) entry and returns it
 */
static struct dict_name *new_name(
    struct dict_name *link, char *name, int length, int hidden)
{
    struct dict_name *pnm;  /* the new name */

    assert(ALIGNED(ph) == (intptr_t)ph, "misaligned (new_name)");

    /*
     * Since we're using the high bit of the length as a "hidden" or
     * "deleted" flag, cap the length at 127.
     */
    length = MIN(length, 127);

    /* Allot space for name + length byte so that suffix is aligned. */
    pnm = (struct dict_name *)ALIGNED((intptr_t)ph + length - SUFFIX_LEN);

    /* copy name string */
    memcpy(pnm->suffix + SUFFIX_LEN - length, name, length);
    pnm->length = length + (hidden ? 128 : 0);

    /* set link pointer */
    pnm->link = link;

    /* Allot entry */
    ph = (cell *)(pnm + 1);

#if defined(BEING_DEFINED)
    fprintf(stderr, "%p %p %.*s\n", pnm, link, length, name);
#endif

    return pnm;
}
开发者ID:eerpini,项目名称:muforth,代码行数:35,代码来源:dict.c


示例2: dummy_compact

static long *
dummy_compact (long *r, char *org_stack)
{
  memmove (org_stack, r,
           ALIGNED (2*sizeof (long)) + ALIGNED ((mpfr_custom_get_size) (p)));
  return (long *) org_stack;
}
开发者ID:SESA,项目名称:EbbRT-mpfr,代码行数:7,代码来源:tstckintc.c


示例3: dummy_new

/* a[0] is the kind, a[1] is the exponent, &a[2] is the mantissa */
static long *
dummy_new (void)
{
  long *r;

  r = (long *) new_st (ALIGNED (2 * sizeof (long)) +
                       ALIGNED (mpfr_custom_get_size (p)));
  (mpfr_custom_init) (&r[2], p);
  r[0] = (int) MPFR_NAN_KIND;
  r[1] = 0;
  return r;
}
开发者ID:Distrotech,项目名称:mpfr,代码行数:13,代码来源:tstckintc.c


示例4: strcpy

char *
strcpy (char *to, const char *from)
{
  char *return_value = to;
  if (to == from)
    return to;
  else if (ALIGNED (to) && ALIGNED (from))
    {
      unsigned long *to1 = (unsigned long *) to;
      const unsigned long *from1 = (const unsigned long *) from;
      unsigned long c;
      unsigned long magic = MAGIC;
      unsigned long not_magic = ~magic;
/*      unsigned long hi_bit = 0x80000000; */

      while ((c = *from1) != 0)
        {
          if (HAS_ZERO(c)) 
            {
              to = (char *) to1;
              from = (const char *) from1;
              goto slow_loop;
            }
          else
            {
              *to1 = c;
              to1++; 
              from1++;
            }
        }

      to = (char *) to1;
      *to = (char) 0;
      return return_value;
    }
  else
    {
      char c;

    slow_loop:

      while ((c = *from) != 0)
        {
          *to = c;
          to++;
          from++;
        }
      *to = (char) 0;
    }
  return return_value;
}
开发者ID:boukeversteegh,项目名称:chise,代码行数:51,代码来源:strcpy.c


示例5: while

void *n64_memcpy(void *dst, const void *src, size_t size)
{
    uint8_t *bdst = (uint8_t *)dst;
    uint8_t *bsrc = (uint8_t *)src;
    uint32_t *wdst = (uint32_t *)dst;
    uint32_t *wsrc = (uint32_t *)src;

    int size_to_copy = size;

    if (ALIGNED(bdst) && ALIGNED(bsrc))
    {
        int words_to_copy = size_to_copy / 4;
        int bytes_to_copy = size_to_copy % 4;

        while (words_to_copy--)
        {
            *wdst++ = *wsrc++;
        }

        bdst = (uint8_t *)wdst;
        bsrc = (uint8_t *)wsrc;

        while (bytes_to_copy--)
        {
            *bdst++ = *bsrc++;
        }
    }
    else
    {
        int w_to_copy = size_to_copy / 4;
        int b_to_copy = size_to_copy % 4;

        while (w_to_copy > 0)
        {
            *bdst++ = *bsrc++;
            *bdst++ = *bsrc++;
            *bdst++ = *bsrc++;
            *bdst++ = *bsrc++;

            w_to_copy--;
        }

        while(b_to_copy--)
        {
            *bdst++ = *bsrc++;
        }
    }

    return dst;
}
开发者ID:mehzemo,项目名称:64doom,代码行数:50,代码来源:n64memory.c


示例6: return_mpfr

 /* Garbage the stack by keeping only x  */
static mpfr_ptr
return_mpfr (mpfr_ptr x, char *old_stack)
{
  void *mantissa       = mpfr_custom_get_significand (x);
  size_t size_mantissa = mpfr_custom_get_size (mpfr_get_prec (x));
  mpfr_ptr newx;

  memmove (old_stack, x, sizeof (mpfr_t));
  memmove (old_stack + ALIGNED (sizeof (mpfr_t)), mantissa, size_mantissa);
  newx = (mpfr_ptr) old_stack;
  mpfr_custom_move (newx, old_stack + ALIGNED (sizeof (mpfr_t)));
  stack = old_stack + ALIGNED (sizeof (mpfr_t)) + ALIGNED (size_mantissa);
  return newx;
}
开发者ID:SESA,项目名称:EbbRT-mpfr,代码行数:15,代码来源:tstckintc.c


示例7: hc2cfv_okp

static int hc2cfv_okp(const R *Rp, const R *Ip, const R *Rm, const R *Im, 
		      INT rs, INT mb, INT me, INT ms, 
		      const planner *plnr)
{
     return (1
	     && !NO_SIMDP(plnr)
	     && SIMD_STRIDE_OK(rs)
	     && SIMD_VSTRIDE_OK(ms)
             && ((me - mb) % VL) == 0
             && ((mb - 1) % VL) == 0 /* twiddle factors alignment */
	     && ALIGNED(Rp)
	     && ALIGNED(Rm)
	     && Ip == Rp + 1
	     && Im == Rm + 1);
}
开发者ID:dstuck,项目名称:tinker_integrated_PIMC,代码行数:15,代码来源:genus.c


示例8: CVMmemDisableWriteNotify

void
CVMmemDisableWriteNotify(CVMMemHandle *h)
{
    CVMMemPrivateData *c;

    CVMassert(wnlLock != NULL);

    CVMmutexLock(wnlLock);

    c = writeNotifyList;
    while (c != NULL) {
        if (d2h(c) == h) {
            CVMMemPrivateData *region;
            CVMAddr start = c->dataStart.start;
            CVMAddr end = c->end;

            CVMAddr alignedStart = ALIGNED(start);
            CVMAddr alignedEnd = ALIGNEDNEXT(end);

            /* Found the region. Unprotect it. */

            /* Now traverse the list again to check if part of the
             * aligned pages (first page and last page) belong to 
             * other regions.
             */
            region = writeNotifyList;
            while (region != NULL) {
		if (region->end < start &&
                    region->end >= alignedStart) {
                    alignedStart = ALIGNEDNEXT(start);
		}
                if (region->dataStart.start > end &&
                    region->dataStart.start <= alignedEnd) {
                    alignedEnd = ALIGNED(end);
                }
                region = region->next;
            }
            /* Unprotect the adjusted aligned region, so the next
             * write within the range would not cause a signal.
             */
            CVMmprotect((void*)alignedStart, (void*)alignedEnd, CVM_FALSE);
            CVMmutexUnlock(wnlLock);
            return;
        }
        c = c->nextWriteNotify;
    }
    CVMmutexUnlock(wnlLock);
}
开发者ID:AllBinary,项目名称:phoneme-components-cdc,代码行数:48,代码来源:mem_mgr.c


示例9: memcpy_no_movs

/* Our fastpath can't handle OP_movs of uninit, which is common
 * w/ realloc, so we use a regular OP_mov loop.
 * XXX: share w/ drmem's replace_memcpy
 */
DO_NOT_OPTIMIZE
static void *
memcpy_no_movs(void *dst, const void *src, size_t size)
{
    register unsigned char *d = (unsigned char *) dst;
    register unsigned char *s = (unsigned char *) src;
    if (((ptr_uint_t)dst & 3) == ((ptr_uint_t)src & 3)) {
        /* same alignment, so we can do 4 aligned bytes at a time and stay
         * on fastpath
         */
        while (!ALIGNED(d, 4) && size > 0) {
            *d++ = *s++;
            size--;
        }
        while (size > 3) {
            *((unsigned int *)d) = *((unsigned int *)s);
            s += 4;
            d += 4;
            size -= 4;
        }
        while (size > 0) {
            *d++ = *s++;
            size--;
        }
    } else {
        while (size-- > 0) /* loop will terminate before underflow */
            *d++ = *s++;
    }
    return dst;
}
开发者ID:rnk,项目名称:drmemory,代码行数:34,代码来源:alloc_unopt.c


示例10: do_layer1

int do_layer1(mpg123_handle *fr)
{
  int clip=0;
  int i,stereo = fr->stereo;
  unsigned int balloc[2*SBLIMIT];
  unsigned int scale_index[2][SBLIMIT];
  ALIGNED(16) real fraction[2][SBLIMIT];
  int single = fr->single;

  fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32;

  if(stereo == 1 || single == SINGLE_MIX) /* I don't see mixing handled here */
    single = SINGLE_LEFT;

  I_step_one(balloc,scale_index,fr);

  for (i=0;i<SCALE_BLOCK;i++)
  {
    I_step_two(fraction,balloc,scale_index,fr);

    if(single != SINGLE_STEREO)
    {
      clip += (fr->synth_mono)( (real *) fraction[single], fr);
    }
    else
    {
      clip += (fr->synth)( (real *) fraction[0], 0, fr, 0);
      clip += (fr->synth)( (real *) fraction[1], 1, fr, 1);
    }
  }

  return clip;
}
开发者ID:3calabera,项目名称:ps3soundlib,代码行数:33,代码来源:layer1.c


示例11: convert_command_line

static void convert_command_line(int argc, char *argv[])
{
    char *pline;

    /* skip arg[0] */
    argc--;
    argv++;

    pcmd_line = (struct counted_string *)ph;
    pline = pcmd_line->data;

    while (argc--)
    {
        pline = str_copy(pline, *argv++);
        *pline++ = ' ';
    }
    pcmd_line->length = pline - pcmd_line->data;

    /* 
     * No need to null-terminate! This string is evaluated by the Forth
     * parser, not C code. Any pieces - like filenames - that get passed to
     * C are copied out of this string into the dictionary and
     * null-terminated first - just like input from _any other_ source.
     */
    ph = (cell *)ALIGNED(pline);
}
开发者ID:dram,项目名称:muforth,代码行数:26,代码来源:main.c


示例12: ksynch_init_var

/* We use volatile int rather than bool since these are used as futexes.
 * 0 is unset, 1 is set, and no other value is used.
 */
bool
ksynch_init_var(volatile int *futex)
{
    ASSERT(ALIGNED(futex, sizeof(int)));
    *futex = 0;
    return true;
}
开发者ID:FirstBlue,项目名称:dynamorio,代码行数:10,代码来源:ksynch_linux.c


示例13: memset

_CACHED
void *
memset(void *dest_p, int c, size_t n)
{
  void *orig_dest = dest_p;
  char *dst;

  /* fill with longs if applicable */
  if (ALIGNED(dest_p) && n > sizeof(uint32_t))
    {
      uint32_t lc;
      uint32_t *dstl = dest_p;
      c &= 0xff;
      lc = (c<<24)|(c<<16)|(c<<8)|c;
      while (n >= sizeof(uint32_t))
	{
	  *dstl++ = lc;
	  n -= sizeof(uint32_t);
	}
      dest_p = dstl;
    }

  dst = dest_p;
  while (n > 0) {
    *dst++ = c;
    --n;
  }

  return orig_dest;
}
开发者ID:jnlocke,项目名称:proplib,代码行数:30,代码来源:memset.c


示例14: replace_memcpy

END_DO_NOT_OPTIMIZE

IN_REPLACE_SECTION void *
replace_memcpy(void *dst, const void *src, size_t size)
{
    register unsigned char *d = (unsigned char *) dst;
    register unsigned char *s = (unsigned char *) src;
    if (((ptr_uint_t)dst & 3) == ((ptr_uint_t)src & 3)) {
        /* same alignment, so we can do 4 aligned bytes at a time and stay
         * on fastpath.  when not same alignment, I'm assuming it's faster
         * to have all 1-byte moves on fastpath rather than half 4-byte
         * (aligned) on fastpath and half 4-byte (unaligned) on slowpath.
         */
        while (!ALIGNED(d, 4) && size > 0) {
            *d++ = *s++;
            size--;
        }
        while (size > 3) {
            *((unsigned int *)d) = *((unsigned int *)s);
            s += 4;
            d += 4;
            size -= 4;
        }
        while (size > 0) {
            *d++ = *s++;
            size--;
        }
    } else {
        while (size-- > 0) /* loop will terminate before underflow */
            *d++ = *s++;
    }
    return dst;
}
开发者ID:unbaiat,项目名称:robocheck,代码行数:33,代码来源:replace.c


示例15: CVMmemManagerDumpStats

void
CVMmemManagerDumpStats()
{
    CVMMemPrivateData *d = memList;
    CVMconsolePrintf("Memory status:\n");
    while (d != NULL) {
        if (d->map != NULL) {
            CVMMemType type = d->type;
            int totalPage = (ALIGNEDNEXT(d->end) -  
                             ALIGNED(d->dataStart.start)) / CVMgetPagesize();
            CVMMemDirtyPages *dmap = d->map;
            if (type < CVM_MEM_NUM_TYPES) {
                CVMconsolePrintf("%s: Total Page = %d, Dirty Page = %d\n", 
                                 CVMmemType[type].name,
                                 totalPage, dmap->numberOfDirtypages);
                if (CVMmemType[type].report != NULL) {
                    CVMmemType[type].report();
                }
            } else {
                CVMconsolePrintf("%s: Total Page = %d, Dirty Page = %d\n", 
                        CVMcustomMemType[type - CVM_MEM_NUM_TYPES].name,
                        totalPage, dmap->numberOfDirtypages);
                if (CVMcustomMemType[type - CVM_MEM_NUM_TYPES].report != NULL) {
                    CVMcustomMemType[type - CVM_MEM_NUM_TYPES].report();
                }
            }
        }
        d = d->next;
    }
}
开发者ID:AllBinary,项目名称:phoneme-components-cdc,代码行数:30,代码来源:mem_mgr.c


示例16: CVMmemSetMonitorMode

void
CVMmemSetMonitorMode(CVMMemHandle *h, CVMMemMonMode mode)
{
    CVMMemPrivateData *d = h2d(h);
    d->mode = mode; /* set the new mode */
    if (mode == CVM_MEM_MON_NONE) {
        /* disable write notify */      
        CVMmemDisableWriteNotify(h);
    } else if (mode == CVM_MEM_MON_FIRST_WRITE ||
               mode == CVM_MEM_MON_ALL_WRITES) {
        if (d->map == NULL) {
            CVMMemDirtyPages *map;
            map = (CVMMemDirtyPages*)malloc(
                          sizeof(CVMMemDirtyPages));
            if (map != NULL) {
                map->memMap = (CVMUint8*)calloc(
                    sizeof(CVMUint8), 
                    (ALIGNEDNEXT(d->end) - ALIGNED(d->dataStart.start)) /
                                    CVMgetPagesize());
	        if (map->memMap == NULL) {
                    free(map);
                    return;
                }
                map->numberOfDirtypages = 0;
                d->map = map;
   	    } else {
                return;
            }
        }
        CVMmemEnableWriteNotify(
            h, (CVMUint32*)d->dataStart.start, (CVMUint32*)d->end);
    }
    return;
}
开发者ID:AllBinary,项目名称:phoneme-components-cdc,代码行数:34,代码来源:mem_mgr.c


示例17: CVMmemEnableWriteNotify

void
CVMmemEnableWriteNotify(CVMMemHandle *h, CVMUint32* start, CVMUint32* end)
{
    CVMMemPrivateData *r = h2d(h);
    CVMAddr alignedStart = ALIGNED(start);
    CVMAddr alignedEnd = ALIGNEDNEXT(end);

    if (wnlLock == NULL) {
        wnlLock = malloc(sizeof(CVMMutex));
        CVMmutexInit(wnlLock);
    }
    CVMmutexLock(wnlLock);

    /* Add to the write notify list. */
    if (writeNotifyList == NULL) {
        r->nextWriteNotify = NULL;
    } else {
        r->nextWriteNotify = writeNotifyList;
    }
    writeNotifyList = r;

    CVMmutexUnlock(wnlLock);

    /* Protect the aligned region that contains the start and end to
     * enable write notify.
     */
    CVMmprotect((void*)alignedStart, (void*)alignedEnd, CVM_TRUE);
}
开发者ID:AllBinary,项目名称:phoneme-components-cdc,代码行数:28,代码来源:mem_mgr.c


示例18: ALIGNED

/* allocates a RUN_SIZE-aligned memory block and adds it to mem_map */ 
static void *run_alloc(malloc_t *heap, int type)
{
    uintptr_t addri, alignedi;
    void *addr;

    /* allocate twice the size so we can align ourselves */
    if (cgc_allocate(RUN_SIZE * 2, 0, &addr) != 0)
        return NULL;

    addri = (uintptr_t) addr;
    alignedi = ALIGNED(addri, RUN_SIZE);

    /* cgc_free the memory that is extra */
    if (addri < alignedi)
        cgc_deallocate((void *)addri, alignedi - addri);
    if (alignedi + RUN_SIZE < addri + RUN_SIZE * 2)
        cgc_deallocate((void *)(alignedi + RUN_SIZE), (addri + RUN_SIZE * 2) - (alignedi + RUN_SIZE));

    /* add run to mem_map */
    DBG_ASSERT(heap->mem_map[alignedi / RUN_SIZE] == MM_UNALLOCATED);
    heap->mem_map[alignedi / RUN_SIZE] = type;

    /* return the aligned memory block */
    return (void *)alignedi;
}
开发者ID:chubbymaggie,项目名称:cb-multios,代码行数:26,代码来源:malloc_common.c


示例19: strncat

char* strncat (char* destination, const char* source, size_t num)
{
	char *s = destination;

	/* Skip over the data in s1 as quickly as possible.  */
	if (ALIGNED (destination))
	{
		unsigned long *aligned_s1 = (unsigned long *)destination;
		
		while (!DETECTNULL (*aligned_s1))
			aligned_s1++;

		destination = (char *)aligned_s1;
	}

	while (*destination)
		destination++;

	/* s1 now points to the its trailing null character, now copy
		up to N bytes from S2 into S1 stopping if a NULL is encountered
		in S2.

		It is not safe to use strncpy here since it copies EXACTLY N
		characters, NULL padding if necessary.  */
	while (num-- != 0 && (*destination++ = *source++))
	{
		if (num == 0)
			*destination = '\0';
	}
	
	return s;
}
开发者ID:Fadekraft,项目名称:MollenOS,代码行数:32,代码来源:strncat.c


示例20: t_okp_t1bu

static int t_okp_t1bu(const ct_desc *d,
		      const R *rio, const R *iio,
		      INT rs, INT vs, INT m, INT mb, INT me, INT ms,
		      const planner *plnr)
{									
     return  t_okp_commonu(d, rio, iio, rs, vs, m, mb, me, ms, plnr)
	  && rio == iio + 1
	  && ALIGNED(iio);
}
开发者ID:Aegisub,项目名称:fftw3,代码行数:9,代码来源:genus.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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