这篇教程C++ ALIGNED函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ALIGNED函数的典型用法代码示例。如果您正苦于以下问题:C++ ALIGNED函数的具体用法?C++ ALIGNED怎么用?C++ ALIGNED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ALIGNED函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,
示例2: dummy_compactstatic 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,
示例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,
示例4: strcpychar *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,
示例5: whilevoid *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,
示例6: return_mpfr /* Garbage the stack by keeping only x */static mpfr_ptrreturn_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,
示例7: hc2cfv_okpstatic 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,
示例8: CVMmemDisableWriteNotifyvoidCVMmemDisableWriteNotify(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,
示例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_OPTIMIZEstatic 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,
示例10: do_layer1int 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,
示例11: convert_command_linestatic 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,
示例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. */boolksynch_init_var(volatile int *futex){ ASSERT(ALIGNED(futex, sizeof(int))); *futex = 0; return true;}
开发者ID:FirstBlue,项目名称:dynamorio,代码行数:10,
示例13: memset_CACHEDvoid *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,
示例14: replace_memcpyEND_DO_NOT_OPTIMIZEIN_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,
示例15: CVMmemManagerDumpStatsvoidCVMmemManagerDumpStats(){ 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,
示例16: CVMmemSetMonitorModevoidCVMmemSetMonitorMode(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,
示例17: CVMmemEnableWriteNotifyvoidCVMmemEnableWriteNotify(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,
示例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,
示例19: strncatchar* 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,
示例20: t_okp_t1bustatic 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,
示例21: pdmap/* * Add kernel mappings for pa -> va for a section of size bytes. * Called only after the va range is known to be unoccupied. */static intpdmap(uintptr_t pa, int attr, uintptr_t va, usize size){ uintptr_t pae; PTE *pd, *pde, *pt, *pte; int pdx, pgsz; Page *pg; pd = (PTE*)(PDMAP+PDX(PDMAP)*4096); for(pae = pa + size; pa < pae; pa += pgsz) { pdx = PDX(va); pde = &pd[pdx]; /* * Check if it can be mapped using a big page, * i.e. is big enough and starts on a suitable boundary. * Assume processor can do it. */ if(ALIGNED(pa, PGLSZ(1)) && ALIGNED(va, PGLSZ(1)) && (pae-pa) >= PGLSZ(1)) { assert(*pde == 0); *pde = pa|attr|PtePS|PteP; pgsz = PGLSZ(1); } else { if(*pde == 0) { pg = mmuptpalloc(); assert(pg != nil && pg->pa != 0); *pde = pg->pa|PteRW|PteP; memset((PTE*)(PDMAP+pdx*4096), 0, 4096); } assert(*pde != 0); pt = (PTE*)(PDMAP+pdx*4096); pte = &pt[PTX(va)]; assert(!(*pte & PteP)); *pte = pa|attr|PteP; pgsz = PGLSZ(0); } va += pgsz; } return 0;}
开发者ID:Shamar,项目名称:harvey,代码行数:48,
示例22: hh_collectvoid hh_collect(value aggressive_val) {#ifdef _WIN32 // TODO GRGR return;#else int aggressive = Bool_val(aggressive_val); int flags = MAP_PRIVATE | MAP_ANON | MAP_NORESERVE; int prot = PROT_READ | PROT_WRITE; char* dest; size_t mem_size = 0; char* tmp_heap; float space_overhead = aggressive ? 1.2 : 2.0; if(used_heap_size() < (size_t)(space_overhead * heap_init_size)) { // We have not grown past twice the size of the initial size return; } tmp_heap = (char*)mmap(NULL, heap_size, prot, flags, 0, 0); dest = tmp_heap; if(tmp_heap == MAP_FAILED) { printf("Error while collecting: %s/n", strerror(errno)); exit(2); } assert(my_pid == master_pid); // Comes from the master // Walking the table size_t i; for(i = 0; i < HASHTBL_SIZE; i++) { if(hashtbl[i].addr != NULL) { // Found a non empty slot size_t bl_size = Get_buf_size(hashtbl[i].addr); size_t aligned_size = ALIGNED(bl_size); char* addr = Get_buf(hashtbl[i].addr); memcpy(dest, addr, bl_size); // This is where the data ends up after the copy hashtbl[i].addr = heap_init + mem_size + sizeof(size_t); dest += aligned_size; mem_size += aligned_size; } } // Copying the result back into shared memory memcpy(heap_init, tmp_heap, mem_size); *heap = heap_init + mem_size; if(munmap(tmp_heap, heap_size) == -1) { printf("Error while collecting: %s/n", strerror(errno)); exit(2); }#endif}
开发者ID:aresLove,项目名称:hhvm,代码行数:54,
示例23: hh_allocstatic char* hh_alloc(size_t size) { size_t slot_size = ALIGNED(size + sizeof(size_t)); char* chunk = __sync_fetch_and_add(heap, (char*)slot_size);#ifdef _WIN32 if (!VirtualAlloc(chunk, slot_size, MEM_COMMIT, PAGE_READWRITE)) { win32_maperr(GetLastError()); uerror("VirtualAlloc1", Nothing); }#endif *((size_t*)chunk) = size; return (chunk + sizeof(size_t));}
开发者ID:aresLove,项目名称:hhvm,代码行数:12,
示例24: ksynch_wake/* Wakes up at most one thread waiting on the futex if the kernel supports * SYS_futex syscall. Does nothing if the kernel doesn't support SYS_futex. */ptr_int_tksynch_wake(volatile int *futex){ ptr_int_t res; ASSERT(ALIGNED(futex, sizeof(int))); if (kernel_futex_support) { res = dynamorio_syscall(SYS_futex, 6, futex, FUTEX_WAKE, 1, NULL, NULL, 0); } else { res = -1; } return res;}
开发者ID:FirstBlue,项目名称:dynamorio,代码行数:15,
示例25: new_ststatic void *new_st (size_t s){ void *p = (void *) stack; stack += ALIGNED (s); if (MPFR_UNLIKELY (stack > (char *) &Buffer[BUFFER_SIZE])) { printf ("Stack overflow./n"); exit (1); } return p;}
开发者ID:SESA,项目名称:EbbRT-mpfr,代码行数:12,
示例26: okpstatic int okp(const kdft_desc *d, const R *ri, const R *ii, const R *ro, const R *io, INT is, INT os, INT vl, INT ivs, INT ovs, const planner *plnr){ return (RIGHT_CPU() && ALIGNED(ii) && ALIGNED(io) && !NO_SIMDP(plnr) && SIMD_STRIDE_OK(is) && SIMD_STRIDE_OK(os) && SIMD_VSTRIDE_OK(ivs) && SIMD_VSTRIDE_OK(ovs) && ri == ii + 1 && ro == io + 1 && (vl % VL) == 0 && (!d->is || (d->is == is)) && (!d->os || (d->os == os)) && (!d->ivs || (d->ivs == ivs)) && (!d->ovs || (d->ovs == ovs)) );}
开发者ID:exic,项目名称:last.fm-dbus,代码行数:22,
示例27: n1f_okpstatic int n1f_okp(const kdft_desc *d, const R *ri, const R *ii, const R *ro, const R *io, INT is, INT os, INT vl, INT ivs, INT ovs, const planner *plnr){ return (1 && ALIGNED(ri) && ALIGNED(ro) && !NO_SIMDP(plnr) && SIMD_STRIDE_OK(is) && SIMD_STRIDE_OK(os) && SIMD_VSTRIDE_OK(ivs) && SIMD_VSTRIDE_OK(ovs) && ii == ri + 1 && io == ro + 1 && (vl % VL) == 0 && (!d->is || (d->is == is)) && (!d->os || (d->os == os)) && (!d->ivs || (d->ivs == ivs)) && (!d->ovs || (d->ovs == ovs)) );}
开发者ID:Aegisub,项目名称:fftw3,代码行数:22,
注:本文中的ALIGNED函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ALIGN_DOWN函数代码示例 C++ ALIGN函数代码示例 |