inline int setup_coroutine(cothread_ctx* tctx, coroutine* c, size_t ssize) { if (getcontext(&c->ctx) == -1) return -1; //void* sp = malloc(ssize); //Ìí¼Óstack overflow guard page size_t guard_page_size = getpagesize(); size_t buff_size = ssize + guard_page_size; void* sp = valloc( buff_size ); if ( !sp ) return -2; int res = mprotect(sp, guard_page_size, PROT_READ); if ( res != 0 ) ; c->stk_size = ssize; c->ctx.uc_link = NULL; c->ctx.uc_stack.ss_sp = sp; c->ctx.uc_stack.ss_size = buff_size; c->ctx.uc_stack.ss_flags = 0; makecontext(&c->ctx, (void (*)(void))&FiberFunc, 2, tctx, c); return 0; }
static void provide(char *conf_name, int mvm_id, char c) { struct CONF *conf; unsigned long sz = PAGE_SIZE*NUM_PAGES*mr_count; int fd, i; void *mem; conf = config_parse(conf_name); assert(conf); mem = valloc(sz); assert(mem); memset(mem, c, sz); for_each_mr (i) mr_array[i].addr = mem + (i * mr_array[i].sz); printf("[0] initialize %d: ", mvm_id); notify(""); fd = init_mvm(sz, mem, conf, mvm_id); if (fd < 0) { fprintf(stderr, "can't open /dev/heca\n"); return; } notify("[3] dirty pages:"); c = (mvm_id % 2)? 'd' : 'e'; dirty_pages(NUM_PUSHBACK, c); notify("[6] dirty and print pages (2):"); dirty_pages(NUM_PUSHBACK, '2'); print_pages(NUM_PUSHBACK); notify("[.]disconnect:\n"); heca_close(fd); }
ILvoid *vec_malloc( ILuint size ) { size = size % 16 > 0 ? size + 16 - (size % 16) : size; // align size value #ifdef POSIX_MEMALIGN char *buffer; return posix_memalign(&buffer, 16, size) == 0 ? buffer : NULL; #else #ifdef VALLOC return valloc( size ); #else #ifdef MEMALIGN return memalign( 16, size ); #else // Memalign hack from ffmpeg for MinGW void *ptr; int diff; ptr = malloc(size+16+1); diff= ((-(int)ptr - 1)&15) + 1; ptr += diff; ((char*)ptr)[-1]= diff; return ptr; #endif #endif #endif }
bool Context::Init(std::function<void()> const& fn, char* shared_stack, uint32_t shared_stack_cap) { if (-1 == getcontext(&impl_->ctx_)) return false; impl_->fn_ = fn; #if defined(ENABLE_SHARED_STACK) impl_->shared_stack_ = shared_stack; impl_->shared_stack_cap_ = shared_stack_cap; impl_->ctx_.uc_stack.ss_sp = shared_stack; impl_->ctx_.uc_stack.ss_size = shared_stack_cap; impl_->ctx_.uc_link = NULL; makecontext(&impl_->ctx_, (void(*)(void))&ucontext_func, 1, &impl_->fn_); // save coroutine stack first 16 bytes. assert(!impl_->stack_); impl_->stack_size_ = 16; impl_->stack_capacity_ = std::max<uint32_t>(16, g_Scheduler.GetOptions().init_commit_stack_size); impl_->stack_ = (char*)malloc(impl_->stack_capacity_); memcpy(impl_->stack_, shared_stack + shared_stack_cap - impl_->stack_size_, impl_->stack_size_); #else impl_->stack_size_ = this->stack_size_; impl_->stack_ = (char*)valloc(impl_->stack_size_); impl_->ctx_.uc_stack.ss_sp = impl_->stack_; impl_->ctx_.uc_stack.ss_size = impl_->stack_size_; impl_->ctx_.uc_link = NULL; makecontext(&impl_->ctx_, (void(*)(void))&ucontext_func, 1, &impl_->fn_); #endif return true; }
/* read_op() * * Returns 0 on success, -errno on failure. */ static int read_op(struct capfs_upcall *up, struct capfs_downcall *down) { int err; if (up->u.rw.io.type != IO_CONTIG) return -EINVAL; if (up->u.rw.io.u.contig.size <= CAPFS_OPT_IO_SIZE) { /* use our standard little buffer */ up->xfer.ptr = orig_iobuf; up->xfer.size = up->u.rw.io.u.contig.size; } else { /* need a big buffer; this is freed in main */ if ((big_iobuf = (char *) valloc(up->u.rw.io.u.contig.size)) == NULL) return -errno; memset(big_iobuf, 0, up->u.rw.io.u.contig.size); up->xfer.ptr = big_iobuf; up->xfer.size = up->u.rw.io.u.contig.size; } err = do_capfs_op(up, down); if (err < 0) { PDEBUG(D_LIB, "do_capfs_op failed\n"); } return err; }
void server_main() { char *buf = (char*)valloc(MAX_MSIZE); int sock, namelen, seq = 0; long nbytes, msize; struct sockaddr_in it; GO_AWAY; sock = udp_server(UDP_XACT, SOCKOPT_NONE); while (1) { namelen = sizeof(it); if (recvfrom(sock, (void*)buf, 2 * sizeof(long), 0, (struct sockaddr*)&it, &namelen) < 0) { fprintf(stderr, "bw_udp server: recvfrom: got wrong size\n"); exit(9); } nbytes = ntohl(*(long*)buf); msize = ntohl(*((long*)buf + 1)); while (nbytes > 0) { if (sendto(sock, (void*)buf, msize, 0, (struct sockaddr*)&it, sizeof(it)) < 0) { perror("bw_udp sendto"); exit(9); } nbytes -= msize; } } }
explicit ucontext_context_impl(Functor & cb, std::ptrdiff_t stack_size) : m_stack_size(stack_size == -1 ? (std::ptrdiff_t)default_stack_size : stack_size), m_stack(alloc_stack(m_stack_size)), cb_(&cb) { HPX_ASSERT(m_stack); funp_ = &trampoline<Functor>; int error = HPX_COROUTINE_MAKE_CONTEXT( &m_ctx, m_stack, m_stack_size, funp_, cb_, nullptr); HPX_UNUSED(error); HPX_ASSERT(error == 0); #if defined(HPX_HAVE_THREAD_STACKOVERFLOW_DETECTION) // concept inspired by the following links: // // https://rethinkdb.com/blog/handling-stack-overflow-on-custom-stacks/ // http://www.evanjones.ca/software/threading.html // segv_stack.ss_sp = valloc(SEGV_STACK_SIZE); segv_stack.ss_flags = 0; segv_stack.ss_size = SEGV_STACK_SIZE; std::memset(&action, '\0', sizeof(action)); action.sa_flags = SA_SIGINFO|SA_ONSTACK; //SA_STACK action.sa_sigaction = &ucontext_context_impl::sigsegv_handler; sigaltstack(&segv_stack, nullptr); sigfillset(&action.sa_mask); sigaction(SIGSEGV, &action, nullptr); #endif }
ACL_DBUF_POOL *acl_dbuf_pool_create(int block_size) { #ifdef USE_VALLOC ACL_DBUF_POOL *pool = (ACL_DBUF_POOL*) valloc(sizeof(ACL_DBUF_POOL)); memset(pool, 0, sizeof(ACL_DBUF_POOL)); #else ACL_DBUF_POOL *pool = (ACL_DBUF_POOL*) acl_mycalloc(1, sizeof(ACL_DBUF_POOL)); #endif int size, page_size; #ifdef ACL_UNIX page_size = getpagesize(); #elif defined(WIN32) SYSTEM_INFO info; memset(&info, 0, sizeof(SYSTEM_INFO)); GetSystemInfo(&info); page_size = info.dwPageSize; if (page_size <= 0) page_size = 4096; #else page_size = 4096; #endif size = (block_size / page_size) * page_size; if (size == 0) size = page_size; pool->block_size = size; pool->head = NULL; return (pool); }
static int psex_rma2_alloc(hca_info_t *hca_info, int size, mem_info_t *mem_info) { int rc; mem_info->mr = NULL; /* Region for buffers */ mem_info->ptr = valloc(size); if (!mem_info->ptr) goto err_malloc; rc = rma2_register(hca_info->rma2_port, mem_info->ptr, size, &mem_info->mr); if (!mem_info->mr) goto err_reg_mr; return 0; /* --- */ err_reg_mr: free(mem_info->ptr); mem_info->ptr = NULL; psex_err_rma2_error("rma2_register()", rc); /*if (rc == RMA2_ERR_NO_MEM)*/ print_mlock_help(size); return -1; err_malloc: psex_err_errno("malloc()", errno); return -1; }
static int write_root_dentry() { char *buf = NULL; int extend_size = 0; int extend_no = 0; extend_size = vbfs_params.extend_size_kb * 1024; if ((buf = valloc(extend_size)) == NULL) { fprintf(stderr, "No mem\n"); return -1; } extend_no = vbfs_superblk.bitmap_offset + vbfs_superblk.bitmap_count; printf("root dirent extend %u\n", extend_no); prepare_root_dentry(buf); if (write_extend(extend_no, buf)) { free(buf); return -1; } free(buf); return 0; }
void initialize(iter_t iterations, void *cookie) { char buf[100]; state_t *state = (state_t *) cookie; if (iterations) return; state->buf = valloc(state->msize); if (!state->buf) { perror("valloc"); exit(1); } touch(state->buf, state->msize); state->sock = tcp_connect(state->server, TCP_DATA, SOCKOPT_READ|SOCKOPT_WRITE|SOCKOPT_REUSE); if (state->sock < 0) { perror("socket connection"); exit(1); } sprintf(buf, "%lu", (unsigned long)state->msize); if (write(state->sock, buf, strlen(buf) + 1) != strlen(buf) + 1) { perror("control write"); exit(1); } }
static int write_bad_extend() { int ret = 0; char *extend = NULL; int extend_size = 0; int extend_no = 0; int i; extend_size = vbfs_params.extend_size_kb * 1024; if ((extend = valloc(extend_size)) == NULL) { fprintf(stderr, "No mem\n"); return -1; } extend_no = vbfs_superblk.bad_extend_offset; memset(extend, 0, extend_size); for (i = 0; i < vbfs_superblk.bad_extend_count; i ++) { if (write_extend(extend_no, extend)) { free(extend); return -1; } extend_no ++; } free(extend); return ret; }
void server_main() { char *buf = (char*)valloc(MAX_MSIZE); int sock, sent, namelen, seq = 0; struct sockaddr_in it; GO_AWAY; sock = udp_server(UDP_XACT, SOCKOPT_REUSE); while (1) { int nbytes; namelen = sizeof(it); if ((nbytes = recvfrom(sock, (void*)buf, MAX_MSIZE, 0, (struct sockaddr*)&it, &namelen)) < 0) { fprintf(stderr, "lat_udp server: recvfrom: got wrong size\n"); exit(9); } sent = ntohl(*(int*)buf); if (sent < 0) { udp_done(UDP_XACT); exit(0); } if (sent != ++seq) { seq = sent; } *(int*)buf = htonl(seq); if (sendto(sock, (void*)buf, nbytes, 0, (struct sockaddr*)&it, sizeof(it)) < 0) { perror("lat_udp sendto"); exit(9); } } }
/** * Allocate a page-aligned chunk of memory of the given size. * * @param size size in bytes to allocate * @return pointer to allocated memory or null. */ INLINE void* sysValloc(size_t size) { if (hasMemProtection) { return valloc(size); } else { return malloc(size); } }
/* * implementations of renamed kernel malloc/free routines */ void *anp_sys_malloc(unsigned long size,int type,int flags) { #ifdef NOPE return malloc(size); #endif return valloc(size); }
void*xvalloc(size_t size) { char*x; if(size==0)return NULL; if((x= valloc(size))==NULL)complain("xvalloc: %m"); return x; }
__pmTracePDU * __pmtracefindPDUbuf(int need) { bufctl_t *pcp; for (pcp = buf_free; pcp != NULL; pcp = pcp->bc_next) { if (pcp->bc_size >= need) break; } if (pcp == NULL) { if ((pcp = (bufctl_t *)malloc(sizeof(*pcp))) == NULL) return NULL; pcp->bc_pincnt = 0; pcp->bc_size = TRACE_PDU_CHUNK * (1 + need/TRACE_PDU_CHUNK); if ((pcp->bc_buf = (char *)valloc(pcp->bc_size)) == NULL) { free(pcp); return NULL; } pcp->bc_next = buf_free; pcp->bc_bufend = &pcp->bc_buf[pcp->bc_size]; buf_free = pcp; } #ifdef PMTRACE_DEBUG if (__pmstate & PMTRACE_STATE_PDUBUF) { fprintf(stderr, "__pmtracefindPDUbuf(%d) -> 0x%p\n", need, pcp->bc_buf); pdubufdump(); } #endif return (__pmTracePDU *)pcp->bc_buf; }
void zend_interned_strings_init(TSRMLS_D) { #ifndef ZTS size_t size = 1024 * 1024; #if ZEND_DEBUG_INTERNED_STRINGS CG(interned_strings_start) = valloc(size); #else CG(interned_strings_start) = malloc(size); #endif CG(interned_strings_top) = CG(interned_strings_start); CG(interned_strings_snapshot_top) = CG(interned_strings_start); CG(interned_strings_end) = CG(interned_strings_start) + size; zend_hash_init(&CG(interned_strings), 0, NULL, NULL, 1); CG(interned_strings).nTableMask = CG(interned_strings).nTableSize - 1; CG(interned_strings).arBuckets = (Bucket **) pecalloc(CG(interned_strings).nTableSize, sizeof(Bucket *), CG(interned_strings).persistent); #if ZEND_DEBUG_INTERNED_STRINGS mprotect(CG(interned_strings_start), CG(interned_strings_end) - CG(interned_strings_start), PROT_READ); #endif #endif zend_new_interned_string = zend_new_interned_string_int; zend_interned_strings_snapshot = zend_interned_strings_snapshot_int; zend_interned_strings_restore = zend_interned_strings_restore_int; }
// This function calls all the vanilla heap allocation functions. It is never // called, and exists purely to help config/check_vanilla_allocations.py. See // that script for more details. extern void AllTheNonBasicVanillaNewAllocations() { // posix_memalign and aligned_alloc aren't available on all Linux // configurations. //char *q; //posix_memalign((void**)&q, 16, 16); intptr_t p = intptr_t(malloc(16)) + intptr_t(calloc(1, 16)) + intptr_t(realloc(nullptr, 16)) + intptr_t(new char) + intptr_t(new char) + intptr_t(new char) + intptr_t(new char[16]) + intptr_t(memalign(16, 16)) + //intptr_t(q) + //intptr_t(aligned_alloc(16, 16)) + intptr_t(valloc(4096)) + intptr_t(strdup("dummy")); printf("%u\n", uint32_t(p)); // make sure |p| is not optimized away free((int*)p); // this would crash if ever actually called MOZ_CRASH(); }
void *xvalloc(size_t size) { void *ret = valloc(size); if (unlikely(!ret)) panic("Out of memory"); return ret; }
void *judy_open (uint max) { JudySeg *seg; Judy *judy; uint amt; if( (seg = valloc(JUDY_seg)) ) { seg->seg = NULL; seg->next = JUDY_seg; } else { #ifdef STANDALONE judy_abort ("No virtual memory"); #else return NULL; #endif } amt = sizeof(Judy) + max * sizeof(JudyStack); #ifdef STANDALONE MaxMem += JUDY_seg; #endif if( amt & 0x07 ) amt |= 0x07, amt++; seg->next -= amt; judy = (Judy *)((uchar *)seg + seg->next); memset(judy, 0, amt); judy->seg = seg; judy->max = max; return judy; }
static int psoib_vapi_alloc(hca_info_t *hca_info, int size, enum ibv_access_flags access_perm, mem_info_t *mem_info) { mem_info->mr = NULL; /* Region for buffers */ mem_info->ptr = valloc(size); if (!mem_info->ptr) goto err_malloc; // printf("ibv_reg_mr(pd = %p, ptr = %p, size = %d, access_perm = 0x%x)\n", // hca_info->pd, mem_info->ptr, size, access_perm); mem_info->mr = ibv_reg_mr(hca_info->pd, mem_info->ptr, size, access_perm); if (!mem_info->mr) goto err_reg_mr; return 0; /* --- */ err_reg_mr: free(mem_info->ptr); mem_info->ptr = NULL; psoib_err_errno("ibv_reg_mr() failed", errno); if (errno == ENOMEM) print_mlock_help(size); return -1; err_malloc: psoib_err_errno("malloc() failed!", errno); return -1; }
/* ** dbuf_alloc - allocates a dbufbuf structure either from freelist or ** creates a new one. */ static dbufbuf *dbuf_alloc() { Reg1 dbufbuf *dbptr, *db2ptr; Reg2 int num; dbufalloc++; if (dbptr = freelist) { freelist = freelist->next; return dbptr; } #ifdef VALLOC num = getpagesize()/sizeof(dbufbuf); if (num < 0) num = 1; dbufblocks += num; dbptr = (dbufbuf *)valloc(num*sizeof(dbufbuf)); if (!dbptr) return (dbufbuf *)NULL; for (db2ptr = dbptr; num > 1; num--) { db2ptr = (dbufbuf *)((char *)dbptr + sizeof(dbufbuf)); db2ptr->next = freelist; freelist = db2ptr; } return dbptr; #else dbufblocks++; return (dbufbuf *)MyMalloc(sizeof(dbufbuf)); #endif }
void Red3dInitScreen() { intraFontInit(); ltn = intraFontLoad("flash0:/font/ltn8.pgf", 0); if(!ltn) sceKernelExitGame(); intraFontSetStyle(ltn, 1.0f, 0xFFFFFFFF, 0xBFBFBFBF, 0); void *fbp0 = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned int)) * SCREEN_HEIGHT)); void *fbp1 = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned int)) * SCREEN_HEIGHT)); void *zbp = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned short)) * SCREEN_HEIGHT)); pspDebugScreenInit(); sceGuInit(); sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_8888, fbp0, FRAMEBUFFER_WIDTH); sceGuDispBuffer(SCREEN_WIDTH, SCREEN_HEIGHT, fbp1, FRAMEBUFFER_WIDTH); sceGuDepthBuffer(zbp, FRAMEBUFFER_WIDTH); sceGuOffset(2048 - (SCREEN_WIDTH/2),2048 - (SCREEN_HEIGHT/2)); sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT); sceGuDepthRange(65535, 0); sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); sceGuDepthFunc(GU_GEQUAL); sceGuEnable(GU_DEPTH_TEST); sceGuEnable(GU_SCISSOR_TEST); sceGuFrontFace(GU_CCW); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_CULL_FACE); sceGuEnable(GU_CLIP_PLANES); sceGuEnable(GU_BLEND); sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuEnable(GU_TEXTURE_2D); sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGBA); sceGuTexFilter(GU_LINEAR,GU_LINEAR); sceGuFinish(); sceGuSync(0,0); Red3dSetupScreen(); }
TsIoThread::TsIoThread (const int fd, const int endpoint) : fd(fd), endpoint(endpoint), is_cancelled(false), buf_pushIndex(0), buf_popIndex(0) { //buf = new uint8_t[TSBULKSIZE * TSBUFFERSIZE]; buf = (uint8_t*)valloc(TSBULKSIZE * TSBUFFERSIZE); actualSize = new size_t[TSBUFFERSIZE]; }
void *detio_valloc(size_t size) { void *ptr; int lret = det_disable_logical_clock(); ptr = valloc(size); if ( lret == 0 ) det_enable_logical_clock(0); return ptr; }
char* page_aligned_allocator::malloc(page_aligned_allocator::size_type bytes) { TORRENT_ASSERT(bytes > 0); // just sanity check (this needs to be pretty high // for cases where the cache size is several gigabytes) TORRENT_ASSERT(bytes < 0x30000000); TORRENT_ASSERT(int(bytes) >= page_size()); #ifdef TORRENT_DEBUG_BUFFERS const int page = page_size(); const int num_pages = (bytes + (page-1)) / page + 2; const int orig_bytes = bytes; bytes = num_pages * page; #endif char* ret; #if TORRENT_USE_POSIX_MEMALIGN if (posix_memalign(reinterpret_cast<void**>(&ret), page_size(), bytes) != 0) ret = NULL; #elif TORRENT_USE_MEMALIGN ret = static_cast<char*>(memalign(page_size(), bytes)); #elif defined TORRENT_WINDOWS ret = static_cast<char*>(_aligned_malloc(bytes, page_size())); #elif defined TORRENT_BEOS area_id id = create_area("", &ret, B_ANY_ADDRESS , (bytes + page_size() - 1) & (page_size()-1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); if (id < B_OK) return NULL; ret = static_cast<char*>(ret); #else ret = static_cast<char*>(valloc(size_t(bytes))); #endif if (ret == NULL) return NULL; #ifdef TORRENT_DEBUG_BUFFERS // make the two surrounding pages non-readable and -writable alloc_header* h = (alloc_header*)ret; h->size = orig_bytes; h->magic = 0x1337; print_backtrace(h->stack, sizeof(h->stack)); #ifdef TORRENT_WINDOWS #define mprotect(buf, size, prot) VirtualProtect(buf, size, prot, NULL) #define PROT_READ PAGE_READONLY #endif mprotect(ret, page, PROT_READ); mprotect(ret + (num_pages-1) * page, page, PROT_READ); #ifdef TORRENT_WINDOWS #undef mprotect #undef PROT_READ #endif // fprintf(stderr, "malloc: %p head: %p tail: %p size: %d\n", ret + page, ret, ret + page + bytes, int(bytes)); return ret + page; #endif // TORRENT_DEBUG_BUFFERS return ret; }
void initialize(iter_t iterations, void *cookie) { int pipes[2]; struct _state* state = (struct _state*)cookie; if (iterations) return; if (pipe(pipes) == -1) { perror("pipe"); exit(1); } handle_scheduler(benchmp_childid(), 0, 1); switch (state->pid = fork()) { case 0: close(pipes[0]); handle_scheduler(benchmp_childid(), 1, 1); state->buf = (char*)valloc(state->xfer); if (state->buf == NULL) { perror("child: no memory"); exit(2); } touch(state->buf, state->xfer); writer(pipes[1], state->buf, state->xfer); return; /*NOTREACHED*/ case -1: perror("fork"); exit(3); /*NOTREACHED*/ default: break; } close(pipes[1]); state->readfd = pipes[0]; state->buf = (char*)valloc(state->xfer + getpagesize()); if (state->buf == NULL) { perror("parent: no memory"); exit(4); } touch(state->buf, state->xfer + getpagesize()); state->buf += 128; /* destroy page alignment */ }
int usdt_create_tracepoints(usdt_probe_t *probe) { /* Prepare the tracepoints - for each probe, a separate chunk * of memory with the tracepoint code copied into it, to give * us unique addresses for each tracepoint. * * On Oracle Linux, this must be an mmapped file because USDT * probes there are implemented as uprobes, which are * addressed by inode and offset. The file used is a small * mkstemp'd file we immediately unlink. * * Elsewhere, we can use the heap directly because USDT will * instrument any memory mapped by the process. */ size_t size; #ifdef __linux__ int fd; char tmp[20] = "/tmp/libusdtXXXXXX"; if ((fd = mkstemp(tmp)) < 0) return (-1); if (unlink(tmp) < 0) return (-1); if (write(fd, "\0", FUNC_SIZE) < FUNC_SIZE) return (-1); probe->isenabled_addr = (int (*)())mmap(NULL, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); #else probe->isenabled_addr = (int (*)())valloc(FUNC_SIZE); #endif if (probe->isenabled_addr == NULL) return (-1); /* ensure that the tracepoints will fit the heap we're allocating */ size = ((char *)usdt_tracepoint_end - (char *)usdt_tracepoint_isenabled); assert(size < FUNC_SIZE); size = ((char *)usdt_tracepoint_probe - (char *)usdt_tracepoint_isenabled); probe->probe_addr = (char *)probe->isenabled_addr + size; memcpy((void *)probe->isenabled_addr, (const void *)usdt_tracepoint_isenabled, FUNC_SIZE); #ifdef __linux__ mprotect((void *)probe->isenabled_addr, FUNC_SIZE, PROT_READ | PROT_EXEC); #else mprotect((void *)probe->isenabled_addr, FUNC_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC); #endif return (0); }
BufferFrame::BufferFrame(const PID& id) : id(id), dirty(false), queue(QUEUE_NONE) { tableNext = tablePrev = nullptr; queueNext = queuePrev = nullptr; // use valloc over malloc for aligned memory pages. data = valloc(SIZE); assert(data != nullptr); }