void IMUMessage::clone(const IMUMessage& x) { clone(*(x.m_msg)); }
int main(int argc, char **argv) { char *path_info, *cp, *username, *filename, *extra, *program; struct passwd *pw; openlog("safeperl", LOG_PID, LOG_USER); /* * The format of an URL passed to us should be * .../cgi-bin/safeperl/username/filename/... * The file we then look for is ~username/cgi/bin/filename * (unless CGI_PREFIX has been defined as something else). * Since this program is safeperl, the stuff from /username * onwards gets passed to us in PATH_INFO. */ path_info = getenv("PATH_INFO"); if (!path_info) die("PATH_INFO not set"); if (path_info[0] != '/') die(usage); /* Parse the username */ username = path_info + 1; cp = strchr(username, '/'); if (!cp) die(usage); username = unescape(clone(username, cp - username)); /* Parse the filename */ filename = cp + 1; cp = strchr(filename, '/'); if (!cp) { filename = unescape(clone(filename, strlen(filename))); extra = env_info; } else { filename = unescape(clone(filename, cp - filename)); /* Parse the remaining stuff */ extra = clone(env_info, strlen(env_info) + strlen(cp + 1)); strcat(extra, cp + 1); /* guaranteed room */ } if (strchr(filename, '/')) die("safeperl filename may not have escaped slashes embedded"); /* Put the altered PATH_INFO into the environment */ if (putenv(extra)) die("Failed to alter PATH_INFO in environment"); /* Get and check the username requested */ pw = getpwnam(username); if (!pw || pw->pw_uid < MIN_USER_UID || pw->pw_uid > MAX_USER_UID) die("No such username"); /* Make room for string /homedirectory/public_html/cgi-bin/filename */ program = clone(pw->pw_dir, strlen(pw->pw_dir) + strlen(CGI_PREFIX)+ strlen(filename)); strcat(program, CGI_PREFIX); /* guaranteed room */ strcat(program, filename); /* guaranteed room */ syslog(LOG_INFO, "Running cgiperl %s as user %s", program, pw->pw_name); closelog(); /* Now become the user */ if (setgid(pw->pw_gid) < 0) die("setgid failed"); if (initgroups(pw->pw_name, pw->pw_gid)) die("initgroups failed"); if (setuid(pw->pw_uid) < 0) die("setuid failed"); if (chdir(pw->pw_dir) < 0) die("failed to chdir to home directory"); /* Ensure low resource limits */ limit(RLIMIT_CPU, CPU_LIMIT); limit(RLIMIT_DATA, DATA_LIMIT); limit(RLIMIT_CORE, CORE_LIMIT); limit(RLIMIT_RSS, RSS_LIMIT); (void) setpriority(PRIO_PROCESS, 0, CGI_NICE); /* * Off we go. We do not make any attempt to close file * descriptors or do similar clean-up stuff. Looking after * that is the responsibility of cgiperl. */ execl(CGIPERL_PATH, CGIPERL_PATH, program, (char *) 0); die("Failed to execl cgiperl"); /* NOTREACHED */ }
void processEvent(podio::EventStore& store, bool verboser, unsigned eventNum) { auto& failing = store.get<ExampleClusterCollection>("notthere"); if(failing.isValid() == true) { throw std::runtime_error("Collection 'notthere' should not be valid"); }; auto& strings = store.get<ExampleWithStringCollection>("strings"); if(strings.isValid()){ auto string = strings[0]; if (string.theString() != "SomeString") { throw std::runtime_error("Couldn't read string properly"); } } else { throw std::runtime_error("Collection 'strings' should be present."); } auto& clusters = store.get<ExampleClusterCollection>("clusters"); if(clusters.isValid()){ auto cluster = clusters[0]; for (auto i = cluster.Hits_begin(), end = cluster.Hits_end(); i!=end; ++i){ std::cout << " Referenced hit has an energy of " << i->energy() << std::endl; glob++; } } else { throw std::runtime_error("Collection 'clusters' should be present"); } auto& mcps = store.get<ExampleMCCollection>("mcparticles"); if( mcps.isValid() ){ // check that we can retrieve the correct parent daughter relation // set in write.cpp : // particle 0 has particles 2,3,4 and 5 as daughters: auto p = mcps[0] ; //-------- print relations for debugging: for( auto p : mcps ){ std::cout << " particle " << p.getObjectID().index << " has daughters: " ; for(auto it = p.daughters_begin(), end = p.daughters_end() ; it!=end ; ++it ){ std::cout << " " << it->getObjectID().index ; } std::cout << " and parents: " ; for(auto it = p.parents_begin(), end = p.parents_end() ; it!=end ; ++it ){ std::cout << " " << it->getObjectID().index ; } std::cout << std::endl ; } auto d0 = p.daughters(0) ; auto d1 = p.daughters(1) ; auto d2 = p.daughters(2) ; auto d3 = p.daughters(3) ; if( ! ( d0 == mcps[2] ) ) throw std::runtime_error(" error: 1. daughter of particle 0 is not particle 2 "); if( ! ( d1 == mcps[3] ) ) throw std::runtime_error(" error: 2. daughter of particle 0 is not particle 3 "); if( ! ( d2 == mcps[4] ) ) throw std::runtime_error(" error: 3. daughter of particle 0 is not particle 4 "); if( ! ( d3 == mcps[5] ) ) throw std::runtime_error(" error: 4. daughter of particle 0 is not particle 5 "); // particle 3 has particles 6,7,8 and 9 as daughters: p = mcps[3] ; d0 = p.daughters(0) ; d1 = p.daughters(1) ; d2 = p.daughters(2) ; d3 = p.daughters(3) ; if( ! ( d0 == mcps[6] ) ) throw std::runtime_error(" error: 1. daughter of particle 3 is not particle 6 "); if( ! ( d1 == mcps[7] ) ) throw std::runtime_error(" error: 2. daughter of particle 3 is not particle 7 "); if( ! ( d2 == mcps[8] ) ) throw std::runtime_error(" error: 3. daughter of particle 3 is not particle 8 "); if( ! ( d3 == mcps[9] ) ) throw std::runtime_error(" error: 4. daughter of particle 3 is not particle 9 "); } else { throw std::runtime_error("Collection 'mcparticles' should be present"); } //std::cout << "Fetching collection 'refs'" << std::endl; auto& refs = store.get<ExampleReferencingTypeCollection>("refs"); if(refs.isValid()){ auto ref = refs[0]; for (auto j = ref.Clusters_begin(), end = ref.Clusters_end(); j!=end; ++j){ for (auto i = j->Hits_begin(), end = j->Hits_end(); i!=end; ++i){ //std::cout << " Referenced object has an energy of " << i->energy() << std::endl; glob++; } } } else { throw std::runtime_error("Collection 'refs' should be present"); } //std::cout << "Fetching collection 'OneRelation'" << std::endl; auto& rels = store.get<ExampleWithOneRelationCollection>("OneRelation"); if(rels.isValid()) { //std::cout << "Referenced object has an energy of " << (*rels)[0].cluster().energy() << std::endl; glob++; } else { throw std::runtime_error("Collection 'OneRelation' should be present"); } // std::cout << "Fetching collection 'WithVectorMember'" << std::endl; auto& vecs = store.get<ExampleWithVectorMemberCollection>("WithVectorMember"); if(vecs.isValid()) { std::cout << vecs.size() << std::endl; for( auto item : vecs ) for (auto c = item.count_begin(), end = item.count_end(); c!=end; ++c){ std::cout << " Counter value " << (*c) << std::endl; glob++; } } else { throw std::runtime_error("Collection 'WithVectorMember' should be present"); } auto& comps = store.get<ExampleWithComponentCollection>("Component"); if (comps.isValid()) { auto comp = comps[0]; int a = comp.component().data.x + comp.component().data.z; } auto& arrays = store.get<ExampleWithArrayCollection>("arrays"); if (arrays.isValid() && arrays.size() != 0) { auto array = arrays[0]; if (array.myArray(1) != eventNum) { throw std::runtime_error("Array not properly set."); } if (array.arrayStruct().data.p.at(2) != 2*eventNum) { throw std::runtime_error("Array not properly set."); } if (array.structArray(0).x != eventNum) { throw std::runtime_error("Array of struct not properly set."); } } else { throw std::runtime_error("Collection 'arrays' should be present"); } auto& nmspaces = store.get<ex::ExampleWithARelationCollection>("WithNamespaceRelation"); auto& copies = store.get<ex::ExampleWithARelationCollection>("WithNamespaceRelationCopy"); auto& cpytest = store.create<ex::ExampleWithARelationCollection>("TestConstCopy"); if (nmspaces.isValid() && copies.isValid()) { for (int j = 0; j < nmspaces.size(); j++) { auto nmsp = nmspaces[j]; auto cpy = copies[j]; cpytest.push_back(nmsp.clone()); if (nmsp.ref().isAvailable()) { if (nmsp.ref().data().x != cpy.ref().data().x || nmsp.ref().data().y != cpy.ref().data().y) { throw std::runtime_error("Copied item has differing data in OneToOne referenced item."); } // check direct accessors of POD sub members if (nmsp.ref().x() != cpy.ref().x()) { throw std::runtime_error("Getting wrong values when using direct accessors for sub members."); } if (nmsp.number() != cpy.number()) { throw std::runtime_error("Copied item has differing member."); } if (!(nmsp.ref().getObjectID() == cpy.ref().getObjectID())) { throw std::runtime_error("Copied item has wrong OneToOne references."); } } auto cpy_it = cpy.refs_begin(); for (auto it = nmsp.refs_begin(); it != nmsp.refs_end(); ++it, ++cpy_it) { if (it->data().x != cpy_it->data().x || it->data().y != cpy_it->data().y) { throw std::runtime_error("Copied item has differing data in OneToMany referenced item."); } if (!(it->getObjectID() == cpy_it->getObjectID())) { throw std::runtime_error("Copied item has wrong OneToMany references."); } } } } else { throw std::runtime_error("Collection 'WithNamespaceRelation' and 'WithNamespaceRelationCopy' should be present"); } }
int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr, void* (*start_routine)(void*), void* arg) { ErrnoRestorer errno_restorer; // Inform the rest of the C library that at least one thread was created. __isthreaded = 1; pthread_internal_t* thread = __create_thread_struct(); if (thread == NULL) { return EAGAIN; } if (attr == NULL) { pthread_attr_init(&thread->attr); } else { thread->attr = *attr; attr = NULL; // Prevent misuse below. } // Make sure the stack size and guard size are multiples of PAGE_SIZE. thread->attr.stack_size = BIONIC_ALIGN(thread->attr.stack_size, PAGE_SIZE); thread->attr.guard_size = BIONIC_ALIGN(thread->attr.guard_size, PAGE_SIZE); if (thread->attr.stack_base == NULL) { // The caller didn't provide a stack, so allocate one. thread->attr.stack_base = __create_thread_stack(thread); if (thread->attr.stack_base == NULL) { __free_thread_struct(thread); return EAGAIN; } } else { // The caller did provide a stack, so remember we're not supposed to free it. thread->attr.flags |= PTHREAD_ATTR_FLAG_USER_ALLOCATED_STACK; } // Make room for the TLS area. // The child stack is the same address, just growing in the opposite direction. // At offsets >= 0, we have the TLS slots. // At offsets < 0, we have the child stack. thread->tls = reinterpret_cast<void**>(reinterpret_cast<uint8_t*>(thread->attr.stack_base) + thread->attr.stack_size - BIONIC_ALIGN(BIONIC_TLS_SLOTS * sizeof(void*), 16)); void* child_stack = thread->tls; __init_tls(thread); // Create a mutex for the thread in TLS to wait on once it starts so we can keep // it from doing anything until after we notify the debugger about it // // This also provides the memory barrier we need to ensure that all // memory accesses previously performed by this thread are visible to // the new thread. pthread_mutex_init(&thread->startup_handshake_mutex, NULL); pthread_mutex_lock(&thread->startup_handshake_mutex); thread->start_routine = start_routine; thread->start_routine_arg = arg; thread->set_cached_pid(getpid()); int flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID; void* tls = thread->tls; #if defined(__i386__) // On x86 (but not x86-64), CLONE_SETTLS takes a pointer to a struct user_desc rather than // a pointer to the TLS itself. user_desc tls_descriptor; __init_user_desc(&tls_descriptor, false, tls); tls = &tls_descriptor; #endif int rc = clone(__pthread_start, child_stack, flags, thread, &(thread->tid), tls, &(thread->tid)); if (rc == -1) { int clone_errno = errno; // We don't have to unlock the mutex at all because clone(2) failed so there's no child waiting to // be unblocked, but we're about to unmap the memory the mutex is stored in, so this serves as a // reminder that you can't rewrite this function to use a ScopedPthreadMutexLocker. pthread_mutex_unlock(&thread->startup_handshake_mutex); if (!thread->user_allocated_stack()) { munmap(thread->attr.stack_base, thread->attr.stack_size); } __free_thread_struct(thread); __libc_format_log(ANDROID_LOG_WARN, "libc", "pthread_create failed: clone failed: %s", strerror(errno)); return clone_errno; } int init_errno = __init_thread(thread, true); if (init_errno != 0) { // Mark the thread detached and replace its start_routine with a no-op. // Letting the thread run is the easiest way to clean up its resources. thread->attr.flags |= PTHREAD_ATTR_FLAG_DETACHED; thread->start_routine = __do_nothing; pthread_mutex_unlock(&thread->startup_handshake_mutex); return init_errno; } // Publish the pthread_t and unlock the mutex to let the new thread start running. *thread_out = reinterpret_cast<pthread_t>(thread); pthread_mutex_unlock(&thread->startup_handshake_mutex); return 0; }
static ct_process_t __local_spawn_cb(ct_handler_t h, ct_process_desc_t ph, int (*cb)(void *), void *arg, bool is_exec) { struct container *ct = cth2ct(h); struct process_desc *p = prh2pr(ph); int ret = -1, pid, aux; struct ct_clone_arg ca; if (ct->state != CT_STOPPED) return ERR_PTR(-LCTERR_BADCTSTATE); ret = fs_mount(ct); if (ret) return ERR_PTR(ret); if ((ct->flags & CT_KILLABLE) && !(ct->nsmask & CLONE_NEWPID)) { if (add_service_controller(ct)) goto err_cg; } ret = cgroups_create(ct); if (ret) goto err_cg; ret = -1; if (pipe(ca.child_wait_pipe)) goto err_pipe; if (pipe(ca.parent_wait_pipe)) goto err_pipe2; ca.cb = cb; ca.arg = arg; ca.ct = ct; ca.p = p; ca.is_exec = is_exec; pid = clone(ct_clone, &ca.stack_ptr, ct->nsmask | SIGCHLD, &ca); if (pid < 0) goto err_clone; ct->p.pid = pid; close(ca.child_wait_pipe[0]); close(ca.parent_wait_pipe[1]); if (ct->nsmask & CLONE_NEWUSER) { if (write_id_mappings(pid, &ct->uid_map, "uid_map")) goto err_net; if (write_id_mappings(pid, &ct->gid_map, "gid_map")) goto err_net; } if (net_start(ct)) goto err_net; spawn_wake_and_close(ca.child_wait_pipe, 0); aux = spawn_wait(ca.parent_wait_pipe); if (aux != 0) { ret = aux; goto err_ch; } aux = spawn_wait_and_close(ca.parent_wait_pipe); if (aux != INT_MIN) { ret = -1; goto err_ch; } ct->state = CT_RUNNING; return &ct->p.h; err_ch: net_stop(ct); err_net: spawn_wake_and_close(ca.child_wait_pipe, -1); libct_process_wait(&ct->p.h, NULL); err_clone: close(ca.parent_wait_pipe[0]); close(ca.parent_wait_pipe[1]); err_pipe2: close(ca.child_wait_pipe[0]); close(ca.child_wait_pipe[1]); err_pipe: cgroups_destroy(ct); err_cg: fs_umount(ct); return ERR_PTR(ret); }
bool ShikudetailSceneJiaye::init() { if(!Scene::init())return false; auto spriteBackground = Sprite::create("ShikudetailScene//背景遮罩.png"); spriteBackground->setPosition(1024,768); spriteBackground->setOpacity(0); spriteBackground->runAction(FadeIn::create(1)); this->addChild(spriteBackground); auto spriteBackButton = Sprite::create("MapScene//从这个地图开始一直停留在右下角的返回上级按钮.png"); spriteBackButton->setPosition(1970,80); spriteBackButton->setOpacity(0); spriteBackButton->runAction(FadeIn::create(1)); this->addChild(spriteBackButton,100); auto spriteText = Sprite::create("ShikudetailScene//Jiaye//文字.png"); spriteText->setPosition(1576,121); spriteText->setOpacity(0); spriteText->runAction(FadeIn::create(1)); this->addChild(spriteText); auto spriteButtonIntro = Sprite::create("ShikudetailScene//Jiaye//佛像.png"); auto spriteButtonIntroP = Sprite::create("ShikudetailScene//Jiaye//佛像点击.png"); spriteButtonIntro->setPosition(319,180); spriteButtonIntro->runAction(FadeIn::create(1)); spriteButtonIntro->setOpacity(0); spriteBackground->addChild(spriteButtonIntro,1); spriteButtonIntroP->setPosition(319,180); spriteBackground->addChild(spriteButtonIntroP,2); spriteButtonIntroP->setOpacity(0); //spriteButtonIntroP->runAction(FadeIn::create(1)); /*auto spriteButtonBg = Sprite::create("ShikudetailScene//阿南//.png"); auto spriteButtonBgP = Sprite::create("ShikudetailScene//阿南//背景点击.png"); spriteButtonBg->setPosition(578,180); spriteButtonBg->setOpacity(0); spriteButtonBg->runAction(FadeIn::create(1)); spriteBackground->addChild(spriteButtonBg,1); spriteButtonBgP->setPosition(578,180); spriteBackground->addChild(spriteButtonBgP,2); spriteButtonBgP->setOpacity(0);*/ auto spriteButtonStory = Sprite::create("ShikudetailScene//Jiaye//典故.png"); auto spriteButtonStoryP = Sprite::create("ShikudetailScene//Jiaye//典故点击.png"); spriteButtonStory->setPosition(578+578-319,180); spriteButtonStory->setOpacity(0); spriteButtonStory->runAction(FadeIn::create(1)); spriteBackground->addChild(spriteButtonStory,1); spriteButtonStoryP->setPosition(578+578-319,180); spriteBackground->addChild(spriteButtonStoryP,2); spriteButtonStoryP->setOpacity(0); spriteButtonStoryP->runAction(FadeIn::create(1)); auto spriteIntroImg = Sprite::create("ShikudetailScene//Jiaye//佛像配图.png"); spriteIntroImg->setPosition(1550,785); spriteIntroImg->setOpacity(0); this->addChild(spriteIntroImg); auto spriteIntroText = Sprite::create("ShikudetailScene//Jiaye//佛像文字.png"); spriteIntroText->setPosition(935/2+109,810); spriteIntroText->setOpacity(0); spriteBackground->addChild(spriteIntroText,-1); //auto spriteBgImg = Sprite::create("ShikudetailScene//阿南背景配图.png"); //auto spriteBgText = Sprite::create("ShikudetailScene//阿南背景文字.png"); auto spriteStoryImg = Sprite::create("ShikudetailScene//Jiaye//典故配图.png"); spriteStoryImg->setPosition(1550,785); spriteStoryImg->setOpacity(0); spriteStoryImg->runAction(FadeIn::create(1)); this->addChild(spriteStoryImg); auto spriteStoryText = Sprite::create("ShikudetailScene//Jiaye//典故文字.png"); spriteStoryText->setPosition(935/2+109,439); spriteStoryText->setOpacity(0); spriteStoryText->runAction(Sequence::create(DelayTime::create(1),FadeIn::create(1), NULL) ); spriteBackground->addChild(spriteStoryText,-1); auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); listener->onTouchBegan = [=](Touch* touch, Event* event) { // event->getCurrentTarget() 返回 *listener's* sceneGraphPriority 节点. auto target = static_cast<Sprite*>(event->getCurrentTarget()); // 获取当前触控点相对与按钮的位置 Point locationInNode = target->convertToNodeSpace(touch->getLocation()); Size s = target->getContentSize(); Rect rect = Rect(0, 0, s.width, s.height); // 检测点击区域 if (rect.containsPoint(locationInNode)) { log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y); //target->setOpacity(180); if (target == spriteButtonIntro) { spriteButtonIntroP->runAction(FadeIn::create(0.2)); spriteIntroImg->runAction(FadeIn::create(0.2)); spriteIntroText->runAction(FadeIn::create(0.2)); } else { if(target == spriteButtonStory) { spriteButtonIntroP->runAction(FadeOut::create(0.2)); spriteIntroImg->runAction(FadeOut::create(0.2)); spriteIntroText->runAction(FadeOut::create(0.2)); } } /* if (target == spriteButtonBg) { spriteButtonBgP->runAction(FadeIn::create(0.2)); } else { spriteButtonBgP->runAction(FadeOut::create(0.2)); }*/ if (target == spriteButtonStory) { spriteButtonStoryP->runAction(FadeIn::create(0.2)); spriteStoryImg->runAction(FadeIn::create(0.2)); spriteStoryText->runAction(FadeIn::create(0.2)); } else { if(target == spriteButtonIntro) { spriteButtonStoryP->runAction(FadeOut::create(0.2)); spriteStoryImg->runAction(FadeOut::create(0.2)); spriteStoryText->runAction(FadeOut::create(0.2)); } } return true; } return false; }; // 当移动触控的时候 listener->onTouchMoved = [=](Touch* touch, Event* event) { auto target = static_cast<Sprite*>(event->getCurrentTarget()); auto delta = touch->getDelta(); delta.x=0; log("x=%f,y=%f",target->getPositionX(),target->getPositionY()); auto tmp = target->getPositionY()+delta.y; if (target == spriteStoryText) { if(tmp<1150 && tmp > 439) { //target->runAction(MoveTo::create(0,Vec2(tmp,768))); target->setPositionY(tmp); } } }; // 结束 listener->onTouchEnded = [=](Touch* touch, Event* event) { auto target = static_cast<Sprite*>(event->getCurrentTarget()); log("sprite onTouchesEnded.. "); //target->setOpacity(255); if (target == spriteBackButton) { Director::getInstance()->popScene(); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("se//back.mp3"); } }; _eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), spriteBackButton); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, spriteButtonIntro); //_eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), spriteButtonBg); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), spriteButtonStory); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), spriteStoryText); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), spriteIntroText); return true; }
/*--------------------------------------------*/ void Effect_Class::initEditMode() { clone(); }
StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o) : RefCounted<StyleRareNonInheritedData>() , opacity(o.opacity) , m_aspectRatioDenominator(o.m_aspectRatioDenominator) , m_aspectRatioNumerator(o.m_aspectRatioNumerator) , m_perspective(o.m_perspective) , m_perspectiveOriginX(o.m_perspectiveOriginX) , m_perspectiveOriginY(o.m_perspectiveOriginY) , lineClamp(o.lineClamp) , m_draggableRegionMode(o.m_draggableRegionMode) , m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox) , m_flexibleBox(o.m_flexibleBox) , m_marquee(o.m_marquee) , m_multiCol(o.m_multiCol) , m_transform(o.m_transform) , m_willChange(o.m_willChange) , m_filter(o.m_filter) , m_grid(o.m_grid) , m_gridItem(o.m_gridItem) , m_content(o.m_content ? o.m_content->clone() : nullptr) , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr) , m_boxShadow(o.m_boxShadow) , m_boxReflect(o.m_boxReflect) , m_animations(o.m_animations ? CSSAnimationData::create(*o.m_animations) : nullptr) , m_transitions(o.m_transitions ? CSSTransitionData::create(*o.m_transitions) : nullptr) , m_mask(o.m_mask) , m_maskBoxImage(o.m_maskBoxImage) , m_pageSize(o.m_pageSize) , m_shapeOutside(o.m_shapeOutside) , m_shapeMargin(o.m_shapeMargin) , m_shapeImageThreshold(o.m_shapeImageThreshold) , m_clipPath(o.m_clipPath) , m_textDecorationColor(o.m_textDecorationColor) , m_visitedLinkTextDecorationColor(o.m_visitedLinkTextDecorationColor) , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor) , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor) , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor) , m_visitedLinkBorderRightColor(o.m_visitedLinkBorderRightColor) , m_visitedLinkBorderTopColor(o.m_visitedLinkBorderTopColor) , m_visitedLinkBorderBottomColor(o.m_visitedLinkBorderBottomColor) , m_order(o.m_order) , m_objectPosition(o.m_objectPosition) , m_pageSizeType(o.m_pageSizeType) , m_transformStyle3D(o.m_transformStyle3D) , m_backfaceVisibility(o.m_backfaceVisibility) , m_alignContent(o.m_alignContent) , m_alignItems(o.m_alignItems) , m_alignItemsOverflowAlignment(o.m_alignItemsOverflowAlignment) , m_alignSelf(o.m_alignSelf) , m_alignSelfOverflowAlignment(o.m_alignSelfOverflowAlignment) , m_justifyContent(o.m_justifyContent) , userDrag(o.userDrag) , textOverflow(o.textOverflow) , marginBeforeCollapse(o.marginBeforeCollapse) , marginAfterCollapse(o.marginAfterCollapse) , m_appearance(o.m_appearance) , m_borderFit(o.m_borderFit) , m_textCombine(o.m_textCombine) , m_textDecorationStyle(o.m_textDecorationStyle) , m_wrapFlow(o.m_wrapFlow) , m_wrapThrough(o.m_wrapThrough) , m_hasCurrentOpacityAnimation(o.m_hasCurrentOpacityAnimation) , m_hasCurrentTransformAnimation(o.m_hasCurrentTransformAnimation) , m_hasCurrentFilterAnimation(o.m_hasCurrentFilterAnimation) , m_runningOpacityAnimationOnCompositor(o.m_runningOpacityAnimationOnCompositor) , m_runningTransformAnimationOnCompositor(o.m_runningTransformAnimationOnCompositor) , m_runningFilterAnimationOnCompositor(o.m_runningFilterAnimationOnCompositor) , m_hasAspectRatio(o.m_hasAspectRatio) , m_effectiveBlendMode(o.m_effectiveBlendMode) , m_touchAction(o.m_touchAction) , m_objectFit(o.m_objectFit) , m_isolation(o.m_isolation) , m_justifyItems(o.m_justifyItems) , m_justifyItemsOverflowAlignment(o.m_justifyItemsOverflowAlignment) , m_justifyItemsPositionType(o.m_justifyItemsPositionType) , m_justifySelf(o.m_justifySelf) , m_justifySelfOverflowAlignment(o.m_justifySelfOverflowAlignment) , m_scrollBehavior(o.m_scrollBehavior) , m_requiresAcceleratedCompositingForExternalReasons(o.m_requiresAcceleratedCompositingForExternalReasons) , m_hasInlineTransform(o.m_hasInlineTransform) { }
CStalkerAnimationState::CStalkerAnimationState (const CStalkerAnimationState &stalker_animation_state) { clone (stalker_animation_state.m_in_place,m_in_place); }
Rcpp::IntegerVector stl_sort(Rcpp::IntegerVector x) { //http://gallery.rcpp.org/articles/sorting/ Rcpp::IntegerVector y = clone(x); std::sort(y.begin(), y.end()); return y; }
trie(const trie &rhs) : charset_size{rhs.charset_size}, start_char{rhs.start_char} { root = clone(rhs.root); }
/** * Clones the tile stamp. Changes made to the clone do not affect the original * stamp. */ TileStamp TileStamp::clone() const { TileStamp clone(*this); clone.d.detach(); return clone; }
IMUMessage::IMUMessage(const carmen_imu_message& x) { m_msg = NULL; clone(x); }
IMUMessage::IMUMessage(const IMUMessage& x) : AbstractMessage(x) { m_msg = NULL; clone(x); }
QgsLineString* QgsLineString::curveToLine( double tolerance, SegmentationToleranceType toleranceType ) const { Q_UNUSED( tolerance ); Q_UNUSED( toleranceType ); return static_cast<QgsLineString*>( clone() ); }
QgsPolygonV2 *QgsPolygonV2::surfaceToPolygon() const { return clone(); }
QgsAbstractGeometry* QgsLineString::toCurveType() const { QgsCompoundCurve* compoundCurve = new QgsCompoundCurve(); compoundCurve->addCurve( clone() ); return compoundCurve; }
SkPicture* SkPicture::clone() const { SkPicture* clonedPicture = SkNEW(SkPicture); clone(clonedPicture, 1); return clonedPicture; }
void Datasetore_Session_Persister_Buffer::flush() { vector<SessionPersistence_Content> clone(_buffer); _persister->persist(clone); _buffer.clear(); }
request_mput(request_mput &packet) { clone(packet, packet.alloc); }
int main(int argc, char **argv) { char * stack = (char*) malloc(STACK_SIZE); stack += STACK_SIZE; childTime = 0; parentTime = 0; struct tms tt; double clk = (double) sysconf(_SC_CLK_TCK); if (argc < 2) { printf("y u no give enough arguments?\n"); printHelp(); free(stack); return 1; } N = atoi(argv[1]); NK = N; if (N < 0) { printf("y u no give correct number?\n"); printHelp(); free(stack); return 2; } long startPoint = times(NULL); while (N--) { parentTime = times(NULL); #ifdef FORK childPID = fork(); #elif VFORK childPID = vfork(); #elif CLONE childPID = clone(fn, stack, SIGCHLD, NULL); #elif VCLONE childPID = clone(fn, stack, SIGCHLD | CLONE_VM | CLONE_VFORK, NULL); #endif if (childPID < 0) { printf("Blad fork()\n"); return 3; } else if (childPID == 0) { fn(NULL); } else { int status = -1; wait(&status); childTime += WEXITSTATUS(status); } } long now = times(&tt); parentTime = now - startPoint; printf("Counter = %d\n\n", counter); printf("Parent times:\n"); printf("real: %lf[s]\n", (double)parentTime / clk); printf("user: %lf[s]\n", (double)tt.tms_utime / clk); printf("sys: %lf[s]\n", (double)tt.tms_stime / clk); printf("\nChildren times:\n"); printf("real: %lf[s]\n", (double)childTime / clk); printf("user: %lf[s]\n", (double)tt.tms_cutime / clk); printf("sys: %lf[s]\n", (double)tt.tms_cstime / clk); double rc = ((double)(childTime))/clk; double uc = ((double)(tt.tms_cutime))/clk; double sc = ((double)(tt.tms_cstime))/clk; double rp = ((double)(parentTime))/clk; double up = (double)(tt.tms_utime)/clk; double sp = (double)(tt.tms_stime)/clk; FILE* fd = fopen("vclone.tmp","a+"); fprintf(fd,"ChildCount\t%d\tRealTimeSum\t%.2f\tUserTimeSum\t%.2f\tSystemTimeSum\t%.2f\tSys+UsTimeSum\t%.2f\tRealTimeChild\t%.2f\tUserTimeChild\t%.2f\tSystemTimeChild\t%.2f\tSys+UsTimeCh\t%.2f\tRealTimeParent\t%.2f\tUserTimeParent\t%.2f\tSystemTimePar.\t%.2f\tSys+UsTimePar\t%.2f\n", NK,rc+rp,uc+up,sc+sp,uc+up+sc+sp,rc,uc,sc,uc+sc,rp,up,sp,up+sp); fclose(fd); return 0; }
// to avoid redudant memory copy, swap packet inner data owner void swap(request_mput &packet) { clone(packet, false); packet.reset(); }
int main() { std::list<Puzzle> solutions; static std::stack<Puzzle> alternatives; char inputString[81]; std::string inputPuzzle = readAndVerify(inputString); Puzzle puzzle(inputPuzzle); puzzle.generatePossibleValues(); alternatives.push(puzzle); while (!alternatives.empty()) { puzzle = alternatives.top(); alternatives.pop(); //decide all immediately decideable cells puzzle.decideCells(); //try simplification strats bool simplificationFound = true; while (!puzzle.solved() && simplificationFound) { simplificationFound = false; do { simplificationFound = hiddenSingles(puzzle); } while (simplificationFound == true); //fall back to guessing if (!simplificationFound) { Puzzle alternative; alternative = *clone(puzzle); if ((simplificationFound = guess(puzzle, alternative))) { //record alternative if guess is wrong alternatives.push(alternative); } } //decide all immediately decidable cells before looking for further simplifications if (simplificationFound) { puzzle.decideCells(); } } //if solution is found or contradiction is found(no simplifications) if (puzzle.solved()) { solutions.push_back(puzzle); } } if (solutions.empty()) { std::cout << "No solutions.\n"; } if (!solutions. empty()) { while (!solutions.empty()) { solutions.front().printPuzzle(); solutions.pop_front(); } } std::exit(0); }//end main
PSID clone() const { return clone(m_sid); }
ofImage_<PixelType>& ofImage_<PixelType>::operator=(const ofImage_<PixelType>& mom) { if(&mom==this) return *this; clone(mom); update(); return *this; }
//=========================================================================== // Split curve in specified parameter values std::vector<shared_ptr<SplineCurve> > SplineCurve::split(std::vector<double>& param, double fuzzy) const //=========================================================================== { std::vector<shared_ptr<SplineCurve> > sub_cvs; // Make sure that the curve is k-periodic shared_ptr<SplineCurve> cv = shared_ptr<SplineCurve>(clone()); cv->makeKnotStartRegular(); cv->makeKnotEndRegular(); // Make sure that the input parameters are in increasing sequence std::sort(param.begin(), param.end()); // If split parameters are close to existing knots, we snap size_t ki; for (ki=0; ki<param.size(); ++ki) cv->basis().knotIntervalFuzzy(param[ki], fuzzy); // Add knots until all split parameter have multiplicity equal to the order std::vector<double> knots, new_knots; int kk = cv->order(); int kj; for (ki=0; ki<param.size(); ++ki) for (kj=0; kj<kk; ++kj) knots.push_back(param[ki]); // Extract the knots to insert std::set_difference(knots.begin(), knots.end(), cv->basis().begin(), cv->basis().end(), std::back_inserter(new_knots)); // Insert knots cv->insertKnot(new_knots); // Extract sub curves std::vector<double>::const_iterator end = cv->basis().end(); std::vector<double>::const_iterator start = cv->basis().begin(); SplineCurve* the_subCurve; std::vector<double>::const_iterator coefs_start; for (ki=0; ki<param.size(); ++ki) { std::vector<double>::const_iterator curr = std::find(start + kk, end, param[ki]) + (kk - 1); // Depending on whether the curve is rational or not, the constructor // takes slightly different arguments coefs_start = (cv->rational_ ? (cv->rcoefs_begin() + (cv->dimension() + 1) * (start - cv->basis().begin())) : (cv->coefs_begin() + cv->dimension() * (start - cv->basis().begin()))); // Constructing the subcurve the_subCurve = new SplineCurve ((int)(curr - start) + 1 - kk, kk, start, coefs_start, cv->dimension(), cv->rational()); if (is_elementary_curve_) { the_subCurve->is_elementary_curve_ = true; ElementaryCurve *tmp = NULL; try { tmp =elementary_curve_->subCurve(the_subCurve->startparam(), the_subCurve->endparam(), fuzzy); } catch (...) { the_subCurve->is_elementary_curve_ = false; the_subCurve->elementary_curve_.reset(); } if (tmp) the_subCurve->elementary_curve_ = shared_ptr<ElementaryCurve>(tmp); } sub_cvs.push_back(shared_ptr<SplineCurve>(the_subCurve)); start = curr - kk + 1; } // Depending on whether the curve is rational or not, the constructor // takes slightly different arguments coefs_start = (cv->rational_ ? (cv->rcoefs_begin() + (cv->dimension() + 1) * (start - cv->basis().begin())) : (cv->coefs_begin() + cv->dimension() * (start - cv->basis().begin()))); // Constructing the subcurve the_subCurve = new SplineCurve ((int)(end - start) - kk, kk, start, coefs_start, cv->dimension(), cv->rational()); if (is_elementary_curve_) { the_subCurve->is_elementary_curve_ = true; ElementaryCurve *tmp; try { tmp = elementary_curve_->subCurve(the_subCurve->startparam(), the_subCurve->endparam(), fuzzy); } catch (...) { the_subCurve->is_elementary_curve_ = false; tmp = NULL; } if (tmp) the_subCurve->elementary_curve_ = shared_ptr<ElementaryCurve>(tmp); } sub_cvs.push_back(shared_ptr<SplineCurve>(the_subCurve)); return sub_cvs; }
//---------------------------------------------------------- ofImage& ofImage::operator=(const ofImage& mom) { clone(mom); update(); return *this; }
/** * Return the maximum value that this field could have, given the current date. * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual * maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar, * for some years the actual maximum for MONTH is 12, and for others 13. * @stable ICU 2.0 */ int32_t GregorianCalendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const { /* It is a known limitation that the code here (and in getActualMinimum) * won't behave properly at the extreme limits of GregorianCalendar's * representable range (except for the code that handles the YEAR * field). That's because the ends of the representable range are at * odd spots in the year. For calendars with the default Gregorian * cutover, these limits are Sun Dec 02 16:47:04 GMT 292269055 BC to Sun * Aug 17 07:12:55 GMT 292278994 AD, somewhat different for non-GMT * zones. As a result, if the calendar is set to Aug 1 292278994 AD, * the actual maximum of DAY_OF_MONTH is 17, not 30. If the date is Mar * 31 in that year, the actual maximum month might be Jul, whereas is * the date is Mar 15, the actual maximum might be Aug -- depending on * the precise semantics that are desired. Similar considerations * affect all fields. Nonetheless, this effect is sufficiently arcane * that we permit it, rather than complicating the code to handle such * intricacies. - liu 8/20/98 * UPDATE: No longer true, since we have pulled in the limit values on * the year. - Liu 11/6/00 */ switch (field) { case UCAL_YEAR: /* The year computation is no different, in principle, from the * others, however, the range of possible maxima is large. In * addition, the way we know we've exceeded the range is different. * For these reasons, we use the special case code below to handle * this field. * * The actual maxima for YEAR depend on the type of calendar: * * Gregorian = May 17, 292275056 BC - Aug 17, 292278994 AD * Julian = Dec 2, 292269055 BC - Jan 3, 292272993 AD * Hybrid = Dec 2, 292269055 BC - Aug 17, 292278994 AD * * We know we've exceeded the maximum when either the month, date, * time, or era changes in response to setting the year. We don't * check for month, date, and time here because the year and era are * sufficient to detect an invalid year setting. NOTE: If code is * added to check the month and date in the future for some reason, * Feb 29 must be allowed to shift to Mar 1 when setting the year. */ { if(U_FAILURE(status)) return 0; Calendar *cal = clone(); if(!cal) { status = U_MEMORY_ALLOCATION_ERROR; return 0; } cal->setLenient(TRUE); int32_t era = cal->get(UCAL_ERA, status); UDate d = cal->getTime(status); /* Perform a binary search, with the invariant that lowGood is a * valid year, and highBad is an out of range year. */ int32_t lowGood = kGregorianCalendarLimits[UCAL_YEAR][1]; int32_t highBad = kGregorianCalendarLimits[UCAL_YEAR][2]+1; while ((lowGood + 1) < highBad) { int32_t y = (lowGood + highBad) / 2; cal->set(UCAL_YEAR, y); if (cal->get(UCAL_YEAR, status) == y && cal->get(UCAL_ERA, status) == era) { lowGood = y; } else { highBad = y; cal->setTime(d, status); // Restore original fields } } delete cal; return lowGood; } default: return Calendar::getActualMaximum(field,status); } }
/* Returns either the pid of the child process we run or -E* on failure. */ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv) { struct helper_data data; unsigned long stack, sp; int pid, fds[2], ret, n; stack = alloc_stack(0, __cant_sleep()); if (stack == 0) return -ENOMEM; ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); if (ret < 0) { ret = -errno; printk(UM_KERN_ERR "run_helper : pipe failed, errno = %d\n", errno); goto out_free; } ret = os_set_exec_close(fds[1]); if (ret < 0) { printk(UM_KERN_ERR "run_helper : setting FD_CLOEXEC failed, " "ret = %d\n", -ret); goto out_close; } sp = stack + UM_KERN_PAGE_SIZE - sizeof(void *); data.pre_exec = pre_exec; data.pre_data = pre_data; data.argv = argv; data.fd = fds[1]; data.buf = __cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) : uml_kmalloc(PATH_MAX, UM_GFP_KERNEL); pid = clone(helper_child, (void *) sp, CLONE_VM, &data); if (pid < 0) { ret = -errno; printk(UM_KERN_ERR "run_helper : clone failed, errno = %d\n", errno); goto out_free2; } close(fds[1]); fds[1] = -1; /* * Read the errno value from the child, if the exec failed, or get 0 if * the exec succeeded because the pipe fd was set as close-on-exec. */ n = read(fds[0], &ret, sizeof(ret)); if (n == 0) { ret = pid; } else { if (n < 0) { n = -errno; printk(UM_KERN_ERR "run_helper : read on pipe failed, " "ret = %d\n", -n); ret = n; } CATCH_EINTR(waitpid(pid, NULL, __WCLONE)); } out_free2: kfree(data.buf); out_close: if (fds[1] != -1) close(fds[1]); close(fds[0]); out_free: free_stack(stack, 0); return ret; }
inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o) : RefCounted<StyleRareNonInheritedData>() , opacity(o.opacity) , m_aspectRatioDenominator(o.m_aspectRatioDenominator) , m_aspectRatioNumerator(o.m_aspectRatioNumerator) , m_perspective(o.m_perspective) , m_perspectiveOriginX(o.m_perspectiveOriginX) , m_perspectiveOriginY(o.m_perspectiveOriginY) , lineClamp(o.lineClamp) , m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox) , m_flexibleBox(o.m_flexibleBox) , m_marquee(o.m_marquee) , m_multiCol(o.m_multiCol) , m_transform(o.m_transform) #if ENABLE(CSS_FILTERS) , m_filter(o.m_filter) #endif #if ENABLE(CSS_GRID_LAYOUT) , m_grid(o.m_grid) , m_gridItem(o.m_gridItem) #endif #if ENABLE(CSS_SCROLL_SNAP) , m_scrollSnapPoints(o.m_scrollSnapPoints) #endif , m_content(o.m_content ? o.m_content->clone() : nullptr) , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr) , m_boxShadow(o.m_boxShadow ? std::make_unique<ShadowData>(*o.m_boxShadow) : nullptr) , m_boxReflect(o.m_boxReflect) , m_animations(o.m_animations ? std::make_unique<AnimationList>(*o.m_animations) : nullptr) , m_transitions(o.m_transitions ? std::make_unique<AnimationList>(*o.m_transitions) : nullptr) , m_mask(o.m_mask) , m_maskBoxImage(o.m_maskBoxImage) , m_pageSize(o.m_pageSize) #if ENABLE(CSS_SHAPES) , m_shapeOutside(o.m_shapeOutside) , m_shapeMargin(o.m_shapeMargin) , m_shapeImageThreshold(o.m_shapeImageThreshold) #endif , m_clipPath(o.m_clipPath) , m_textDecorationColor(o.m_textDecorationColor) , m_visitedLinkTextDecorationColor(o.m_visitedLinkTextDecorationColor) , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor) , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor) , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor) , m_visitedLinkBorderRightColor(o.m_visitedLinkBorderRightColor) , m_visitedLinkBorderTopColor(o.m_visitedLinkBorderTopColor) , m_visitedLinkBorderBottomColor(o.m_visitedLinkBorderBottomColor) , m_order(o.m_order) , m_flowThread(o.m_flowThread) , m_regionThread(o.m_regionThread) #if ENABLE(CSS_SCROLL_SNAP) , m_scrollSnapType(o.m_scrollSnapType) #endif , m_regionFragment(o.m_regionFragment) , m_regionBreakAfter(o.m_regionBreakAfter) , m_regionBreakBefore(o.m_regionBreakBefore) , m_regionBreakInside(o.m_regionBreakInside) , m_pageSizeType(o.m_pageSizeType) , m_transformStyle3D(o.m_transformStyle3D) , m_backfaceVisibility(o.m_backfaceVisibility) , m_alignContent(o.m_alignContent) , m_alignItems(o.m_alignItems) , m_alignSelf(o.m_alignSelf) , m_justifyContent(o.m_justifyContent) , m_justifySelf(o.m_justifySelf) , m_justifySelfOverflowAlignment(o.m_justifySelfOverflowAlignment) , userDrag(o.userDrag) , textOverflow(o.textOverflow) , marginBeforeCollapse(o.marginBeforeCollapse) , marginAfterCollapse(o.marginAfterCollapse) , m_appearance(o.m_appearance) , m_borderFit(o.m_borderFit) , m_textCombine(o.m_textCombine) , m_textDecorationStyle(o.m_textDecorationStyle) , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation) , m_aspectRatioType(o.m_aspectRatioType) #if ENABLE(CSS_COMPOSITING) , m_effectiveBlendMode(o.m_effectiveBlendMode) , m_isolation(o.m_isolation) #endif , m_objectFit(o.m_objectFit) { }