// // ::virtual_makeObjects // virtual void virtual_makeObjects(ObjectVector *objects, VariableData *dst) { VariableType::Reference type = getType(); bigsint size = type->getSize(pos); VariableType::BasicType bt = type->getBasicType(); VariableData::Pointer src = expr->getData(); VariableData::Pointer data = VariableData::create_stack(size); VariableData::Pointer tmp = VariableData:: create_stack(src->type == VariableData::MT_FARPTR ? 2 : 1); if (dst->type != VariableData::MT_VOID) make_objects_memcpy_prep(objects, dst, data, pos); if(bt == VariableType::BT_INT_L || bt == VariableType::BT_INT_LL || bt == VariableType::BT_UNS_L || bt == VariableType::BT_UNS_LL) { doL(objects, dst, src, tmp); } else if (VariableType::IsTypeInteger(bt)) { doI(objects, dst, src, tmp); } else if (bt == VariableType::BT_PTR) { bigsint value = type->getReturn()->getSize(pos); if(type->getSize(pos) == 1) { if(value == 1) doP(objects, dst, src, tmp, NULL); else doP(objects, dst, src, tmp, objects->getValue(value)); } else { if(value == 1) doPF(objects, dst, src, tmp, NULL); else doPF(objects, dst, src, tmp, objects->getValue(value)); } } else if (VariableType::IsTypeFixed(bt)) { doX(objects, dst, src, tmp); } else Error_NP("invalid BT"); if (dst->type != VariableData::MT_VOID) make_objects_memcpy_post(objects, dst, data, type, context, pos); }
int io() { Port *p, *n; fd_set rdfds, wrfds, exfds; /* fds to check */ struct timeval tm; /* Timeout value */ struct itimerval tmrtn; int last; /* Highest fd */ int init; /* Build arguments for select: clear file descriptors */ FD_ZERO(&rdfds); FD_ZERO(&wrfds); FD_ZERO(&exfds); // mutex_lock(io_mutex); /* Set timeout */ if((init=waittim())!=-1) { tm.tv_usec=init; tm.tv_sec=0; } else { tm.tv_sec=3600; tm.tv_usec=0; } tmrtn.it_interval.tv_usec=0; tmrtn.it_interval.tv_sec=0; tmrtn.it_value.tv_usec=0; tmrtn.it_value.tv_sec=3600; /* Find highest fd */ last=0; /* Find fds which need to be checked */ for(p=ports.next;p;p=p->link.next) { if(p->fd>last) last=p->fd; /* printf("%d:\n",p->fd); */ if(p->read && !p->has_reader) { /* printf("selecton %d\n",p->fd); */ FD_SET(p->fd,&rdfds); if(p->fd>last) last=p->fd+1; } if((p->oold!=p->onew || !p->out.empty()) && !p->has_writer) { FD_SET(p->fd,&wrfds); if(p->fd>last) last=p->fd+1; } /* we should up the open count on the port here */ } // mutex_unlock(io_mutex); /* Return if there was nothing to do. */ if(!last && init==-1) return 0; doX(); /* Check for events */ setitimer(ITIMER_REAL,&tmrtn,NULL); select(last+1,&rdfds,&wrfds,&exfds,&tm); /* printf("select returns\n"); */ // mutex_lock(io_mutex); /* Handle any timer events */ if(init!=-1) { getitimer(ITIMER_REAL,&tmrtn); note((3600 - tmrtn.it_value.tv_sec) * 1000000 - tmrtn.it_value.tv_usec); // if(anyfns()) tasks=1; } /* Check which fds were returned by select() */ /* printf("thread=%d\n",thread_self()); */ for(p=ports.next;p;p=n) { n=p->link.next; if(p->fd!=-1 && FD_ISSET(p->fd,&rdfds)) { p->doread(); } if(p->fd!=-1 && FD_ISSET(p->fd,&wrfds)) { p->dowrite(); } } // mutex_unlock(io_mutex); return 1; }