当前位置: 首页>>代码示例>>C++>>正文


C++ ALIGNED函数代码示例

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


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


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