+
+
+
+ //declare a char pointer if needed : starts at the end of the structs.
+ //if(structCount + hasStrSeq > 1) {
+ // fprintf(fp,"\t\tchar * ptr = (char*)buff + header_length");
+ // for(pos1=0;pos1<structCount;pos1++){
+ // fprintf(fp," + sizeof(struct %s_%s_%d)",ev->name, facName,pos1+1);
+ // }
+ // if(structCount + hasStrSeq > 1) fprintf(fp,";\n");
+ //}
+
+ // Declare an alias pointer of the struct type to the beginning
+ // of the reserved area, just after the event header.
+ if(ev->type != 0) {
+ unsigned align = max(alignment, td->alignment);
+ if(align > 1) {
+ fprintf(fp,"\t\tptr+=(%u - ((unsigned int)ptr&(%u-1)))&(%u-1);\n",
+ align, align, align);
+ }
+
+ fprintf(fp, "\t\t__1 = (struct %s_%s_1 *)(ptr);\n",
+ ev->name, facName);
+ }
+ //allocate memory for new struct and initialize it
+ //if(whichTypeFirst == 1){ //struct first
+ //for(pos1=0;pos1<structCount;pos1++){
+ // if(pos1==0) fprintf(fp,
+ // "\tstruct %s_%s_1 * __1 = (struct %s_%s_1 *)buff;\n",
+ // ev->name, facName,ev->name, facName);
+ //MD disabled else fprintf(fp,
+ // "\tstruct %s_%s_%d __%d;\n",
+ // ev->name, facName,pos1+1,pos1+1);
+ //}
+ //}else if(whichTypeFirst == 2){
+ // for(pos1=0;pos1<structCount;pos1++)
+ // fprintf(fp,"\tstruct %s_%s_%d __%d;\n",
+ // ev->name, facName,pos1+1,pos1+1);
+ //}
+ fprintf(fp,"\n");
+
+ if(structCount) fprintf(fp,"\t\t//initialize structs\n");
+ //flag = 0;
+ //structCount = 0;
+ if(ev->type != 0)
+ for(pos1 = 0; pos1 < ev->type->fields.position; pos1++){
+ fld = (field_t *)ev->type->fields.array[pos1];
+ td = fld->type;
+ if(td->type != ARRAY && td->type != SEQUENCE && td->type != STRING){
+ //if(flag == 0){
+ // flag = 1;
+ // structCount++;
+ // if(structCount > 1) fprintf(fp,"\n");
+ //}
+ fprintf(fp, "\t\t__1->%s = %s;\n", fld->name, fld->name );
+
+ //if(structCount == 1 && whichTypeFirst == 1)
+ // fprintf(fp, "\t__1->%s = %s;\n",fld->name,fld->name );
+ //else
+ // fprintf(fp, "\t__%d.%s = %s;\n",structCount ,fld->name,fld->name);
+ }
+ //else flag = 0;
+ }
+ if(structCount) fprintf(fp,"\n");
+ //set ptr to the end of first struct if needed;
+ //if(structCount + hasStrSeq > 1){
+ // fprintf(fp,"\n\t\t//set ptr to the end of the first struct\n");
+ // fprintf(fp,"\t\tptr += sizeof(struct %s_%s_1);\n\n",ev->name, facName);
+ //}
+
+ fprintf(fp,"\n");
+ fprintf(fp, "\t\t/* Commit the work */\n");
+ fprintf(fp, "\t\trelay_commit(channel->rchan->buf[smp_processor_id()],\n"
+ "\t\t\t\tbuff, event_length);\n");
+ fprintf(fp, "\t\tltt_write_commit_counter("
+ "channel->rchan->buf[smp_processor_id()],\n"
+ "\t\t\t\tbuff);\n");
+
+ /* End of traces iteration */
+ fprintf(fp, "\t}\n\n");
+
+ fprintf(fp, "\n");
+ // The generated preempt_check_resched is not dangerous because
+ // interrupts are disabled.
+ fprintf(fp, "\tspin_unlock(<t_traces.locks[smp_processor_id()]);\n");
+
+ fprintf(fp, "unlock:\n");
+ fprintf(fp, "\tbarrier();\n");
+ fprintf(fp, "\tltt_nesting[smp_processor_id()]--;\n");
+ fprintf(fp, "\t/* Re-enable interrupts */\n");
+ fprintf(fp, "\tlocal_irq_restore(_flags);\n");
+ fprintf(fp, "\tpreempt_enable_no_resched();\n");
+ //fprintf(fp, "\tpreempt_check_resched();\n");
+