From: bdemsky Date: Tue, 19 Aug 2008 10:20:57 +0000 (+0000) Subject: end of reformatting X-Git-Tag: buildscript^6~101 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=062fb7babfc2fe3b15b0e4e9e3f5b4a24cb16f7f;p=IRC.git end of reformatting --- diff --git a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java index 9fcde860..11397ad6 100644 --- a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java +++ b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java @@ -428,7 +428,7 @@ public class PrefetchAnalysis { for (Enumeration ecld = child_prefetch_set_copy.keys(); ecld.hasMoreElements();) { PrefetchPair childpp = (PrefetchPair) ecld.nextElement(); - if (childpp.base == currfsen.getDst()){ + if (childpp.base == currfsen.getDst()) { int sizedesc = childpp.desc.size(); if((childpp.getDescAt(0) instanceof IndexDescriptor)) { int sizetempdesc = ((IndexDescriptor)(childpp.getDescAt(0))).tddesc.size(); @@ -792,7 +792,7 @@ nexttemp: newvisited.addLast(fn); for(int i=0; i - this.node2Combine.elementAt(next).elementAt(0).getCid()))){ + this.node2Combine.elementAt(next).elementAt(0).getCid()))) { // break the rule that a node can only be combined to nodes with smaller colorid. // or no more buckets // backtrack diff --git a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java index 25c4960f..ab29066c 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java +++ b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java @@ -119,7 +119,7 @@ public class ScheduleAnalysis { ClassDescriptor cd = cNode.getClassDescriptor(); Vector rootnodes = taskanalysis.getRootNodes(cd); if(rootnodes != null) { - for(int h = 0; h < rootnodes.size(); h++){ + for(int h = 0; h < rootnodes.size(); h++) { FlagState root=(FlagState)rootnodes.elementAt(h); Vector allocatingTasks = root.getAllocatingTasks(); if(allocatingTasks != null) { @@ -236,7 +236,7 @@ public class ScheduleAnalysis { try { int repeat = (int)Math.ceil(se.getNewRate() * se.getProbability() / 100); int rate = 0; - if(repeat > 1){ + if(repeat > 1) { for(int j = 1; j< repeat; j++ ) { cloneSNodeList(se, true); } @@ -412,7 +412,7 @@ public class ScheduleAnalysis { se.setProbability(100); } else { repeat -= rate; - if(repeat > 0){ + if(repeat > 0) { // clone the whole ScheduleNode lists starting with se's target for(int j = 0; j < repeat; j++ ) { cloneSNodeList(se, true); @@ -596,7 +596,7 @@ public class ScheduleAnalysis { Queue toiterate = new LinkedList(); toiterate.add(nfs); fStates.add(nfs); - while(!toiterate.isEmpty()){ + while(!toiterate.isEmpty()) { FlagState tfs = toiterate.poll(); Iterator it_edges = tfs.edges(); while(it_edges.hasNext()) { @@ -660,7 +660,7 @@ public class ScheduleAnalysis { Vector toremove = new Vector(); Vector rCNodes = new Vector(); rCNodes.addElement(sCNode); - if(it_isEdges != null){ + if(it_isEdges != null) { while(it_isEdges.hasNext()) { ScheduleEdge tse = (ScheduleEdge)it_isEdges.next(); if(rCNodes.contains(tse.getSourceCNode())) { diff --git a/Robust/src/Analysis/Scheduling/ScheduleNode.java b/Robust/src/Analysis/Scheduling/ScheduleNode.java index 8129cd6d..e55bf2e5 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleNode.java +++ b/Robust/src/Analysis/Scheduling/ScheduleNode.java @@ -132,7 +132,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { return false; } } - if ((fs.executionTime != this.executionTime)){ + if ((fs.executionTime != this.executionTime)) { return false; } if(fs.classNodes != null) { @@ -171,7 +171,7 @@ public class ScheduleNode extends GraphNode implements Cloneable { ScheduleNode o = null; try { o = (ScheduleNode) super.clone(); - } catch(CloneNotSupportedException e){ + } catch(CloneNotSupportedException e) { e.printStackTrace(); } o.uid = ScheduleNode.nodeID++; diff --git a/Robust/src/Analysis/Scheduling/SchedulingUtil.java b/Robust/src/Analysis/Scheduling/SchedulingUtil.java index 64e411de..e474c672 100644 --- a/Robust/src/Analysis/Scheduling/SchedulingUtil.java +++ b/Robust/src/Analysis/Scheduling/SchedulingUtil.java @@ -339,7 +339,7 @@ public class SchedulingUtil { isfirst = true; } tmpLabel = tmpTaskNodes.get(tmpTaskNode); - switch(taction.getType()){ + switch(taction.getType()) { case Action.ADDOBJ: { if(!isfirst) { tmpLabel.append("\\n"); diff --git a/Robust/src/Analysis/Scheduling/TaskSimulator.java b/Robust/src/Analysis/Scheduling/TaskSimulator.java index 000abfd9..8748bb8b 100644 --- a/Robust/src/Analysis/Scheduling/TaskSimulator.java +++ b/Robust/src/Analysis/Scheduling/TaskSimulator.java @@ -169,7 +169,7 @@ public class TaskSimulator { } else { if((this.paraQueues != null) && (this.paraQueues.elementAt(i) != null) && - (this.paraQueues.elementAt(i).contains(obj))){ + (this.paraQueues.elementAt(i).contains(obj))) { this.paraQueues.elementAt(i).remove(obj); this.objVersionTbl.remove(obj); } diff --git a/Robust/src/Analysis/TaskStateAnalysis/ExecutionGraph.java b/Robust/src/Analysis/TaskStateAnalysis/ExecutionGraph.java index 36be0eb4..1155a6dd 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/ExecutionGraph.java +++ b/Robust/src/Analysis/TaskStateAnalysis/ExecutionGraph.java @@ -55,7 +55,7 @@ public class ExecutionGraph { EGTaskNode srcnode=new EGTaskNode(alloctask.getSymbol(),alloctask, fs); nodes.add(srcnode); srcnode.setSource(); - for (Iterator edges = fs.edges(); edges.hasNext();){ + for (Iterator edges = fs.edges(); edges.hasNext();) { FEdge edge = (FEdge)edges.next(); EGTaskNode targetnode=getNode(edge, map, nodes); EGEdge newedge=new EGEdge(fs, targetnode); @@ -98,7 +98,7 @@ public class ExecutionGraph { private void test(Hashtable graph) { System.out.println("\nGraph contains :"); Collection c = graph.values(); - for ( Iterator it = c.iterator(); it.hasNext();){ + for ( Iterator it = c.iterator(); it.hasNext();) { EGTaskNode tn = (EGTaskNode)it.next(); System.out.println(tn.getTextLabel()+" ID "+tn.getLabel()+" FS "+tn.getFSName()); } @@ -107,7 +107,7 @@ public class ExecutionGraph { //create dot files execution_classname_.dot private void printDOTFile() throws java.io.IOException { Enumeration e = executiongraph.keys(); - while (e.hasMoreElements()){ + while (e.hasMoreElements()) { createDOTFile((ClassDescriptor)e.nextElement()); } } @@ -128,13 +128,13 @@ public class ExecutionGraph { private void traverse(java.io.PrintWriter output, Set v) { EGTaskNode tn; - for(Iterator it1 = v.iterator(); it1.hasNext();){ + for(Iterator it1 = v.iterator(); it1.hasNext();) { tn = (EGTaskNode)it1.next(); output.println("\t"+tn.getLabel()+" [label=\""+tn.getTextLabel()+"\""); if (tn.isMultipleParams()) output.println(", color=blue"); output.println("];"); - for(Iterator it2 = tn.edges(); it2.hasNext();){ + for(Iterator it2 = tn.edges(); it2.hasNext();) { output.println("\t"+tn.getLabel()+" -> "+((EGTaskNode)((EGEdge)it2.next()).getTarget()).getLabel()+";"); } } diff --git a/Robust/src/Analysis/TaskStateAnalysis/FlagComparator.java b/Robust/src/Analysis/TaskStateAnalysis/FlagComparator.java index 66971e18..2b343414 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/FlagComparator.java +++ b/Robust/src/Analysis/TaskStateAnalysis/FlagComparator.java @@ -20,7 +20,7 @@ public class FlagComparator implements Comparator { public int getFlagInt(FlagState fs) { int flagid=0; - for(Iterator flags = fs.getFlags(); flags.hasNext();){ + for(Iterator flags = fs.getFlags(); flags.hasNext();) { FlagDescriptor flagd = (FlagDescriptor)flags.next(); int id=1<<((Integer)flaginfo.get(flagd)).intValue(); flagid|=id; diff --git a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java index 2034015d..1ce4eaaf 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/FlagState.java +++ b/Robust/src/Analysis/TaskStateAnalysis/FlagState.java @@ -114,7 +114,7 @@ public class FlagState extends GraphNode implements Cloneable { /** Sets the flagstate as a source node. */ public void setAsSourceNode() { - if(!issourcenode){ + if(!issourcenode) { issourcenode=true; this.tasks=new Vector(); } @@ -172,10 +172,10 @@ public class FlagState extends GraphNode implements Cloneable { HashSet newset1=(HashSet)flagstate.clone(); Hashtable newtags1=(Hashtable)tags.clone(); - if (tags.containsKey(tag)){ + if (tags.containsKey(tag)) { //Code could try to remove flag that doesn't exist - switch (tags.get(tag).intValue()){ + switch (tags.get(tag).intValue()) { case ONETAG: newtags1.put(tag,new Integer(MULTITAGS)); return new FlagState[] {this, new FlagState(newset1, cd, newtags1)}; @@ -203,8 +203,8 @@ public class FlagState extends GraphNode implements Cloneable { } public FlagState[] clearTag(TagDescriptor tag) { - if (tags.containsKey(tag)){ - switch(tags.get(tag).intValue()){ + if (tags.containsKey(tag)) { + switch(tags.get(tag).intValue()) { case ONETAG: HashSet newset=(HashSet)flagstate.clone(); Hashtable newtags=(Hashtable)tags.clone(); @@ -239,7 +239,7 @@ public class FlagState extends GraphNode implements Cloneable { */ public String toString(FlagDescriptor[] flags) { StringBuffer sb = new StringBuffer(flagstate.size()); - for(int i=0; i < flags.length; i++){ + for(int i=0; i < flags.length; i++) { if (get(flags[i])) sb.append(1); else @@ -268,7 +268,7 @@ public class FlagState extends GraphNode implements Cloneable { Hashtable newtags=(Hashtable)tags.clone(); if (status) newset.add(fd); - else if (newset.contains(fd)){ + else if (newset.contains(fd)) { newset.remove(fd); } @@ -305,9 +305,9 @@ public class FlagState extends GraphNode implements Cloneable { else label+=", "+fd.toString(); } - for (Enumeration en_tags=getTags(); en_tags.hasMoreElements();){ + for (Enumeration en_tags=getTags(); en_tags.hasMoreElements();) { TagDescriptor td=(TagDescriptor)en_tags.nextElement(); - switch (tags.get(td).intValue()){ + switch (tags.get(td).intValue()) { case ONETAG: if (label==null) label=td.toString()+"(1)"; @@ -410,7 +410,7 @@ public class FlagState extends GraphNode implements Cloneable { FlagState o = null; try { o = (FlagState) super.clone(); - } catch(CloneNotSupportedException e){ + } catch(CloneNotSupportedException e) { e.printStackTrace(); } o.uid = FlagState.nodeid++; @@ -444,7 +444,7 @@ public class FlagState extends GraphNode implements Cloneable { int gap = 0; for(int i = 0; i < this.edges.size(); i++) { int temp = ((FEdge) this.edges.elementAt(index)).getInvokeNumGap(); - if((temp > gap) && (next.getTask().equals(td))){ + if((temp > gap) && (next.getTask().equals(td))) { index = i; gap = temp; } diff --git a/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java index ed0e3609..220843ef 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/SafetyAnalysis.java @@ -141,7 +141,7 @@ public class SafetyAnalysis { //Conservatively handle tag changes setotd=new HashSet(); } else if(egnode.isMultipleParams()) { - if( goodMultiple(egnode)){ + if( goodMultiple(egnode)) { Predicate p=returnPredicate(egnode); Set oldsetotd; if (fstootd.containsKey(egnode.getPostFS())) @@ -226,9 +226,9 @@ public class SafetyAnalysis { private HashSet createIntersection(Set A, Set B, ClassDescriptor cd) { HashSet result = new HashSet(); - for(Iterator b_it = B.iterator(); b_it.hasNext();){ + for(Iterator b_it = B.iterator(); b_it.hasNext();) { OptionalTaskDescriptor otd_b = (OptionalTaskDescriptor)b_it.next(); - for(Iterator a_it = A.iterator(); a_it.hasNext();){ + for(Iterator a_it = A.iterator(); a_it.hasNext();) { OptionalTaskDescriptor otd_a = (OptionalTaskDescriptor)a_it.next(); if(otd_a.td==otd_b.td&& otd_a.getIndex()==otd_b.getIndex()) { @@ -236,7 +236,7 @@ public class SafetyAnalysis { newfs.addAll(otd_a.enterflagstates); newfs.addAll(otd_b.enterflagstates); OptionalTaskDescriptor newotd = new OptionalTaskDescriptor(otd_b.td, otd_b.getIndex(), newfs, combinePredicates(otd_a.predicate, otd_b.predicate)); - if(optionaltaskdescriptors.get(cd).get(newotd)!=null){ + if(optionaltaskdescriptors.get(cd).get(newotd)!=null) { newotd = optionaltaskdescriptors.get(cd).get(newotd); } else { newotd.setuid(); @@ -300,7 +300,7 @@ public class SafetyAnalysis { result.flags.putAll(A.flags); result.tags.putAll(A.tags); Collection c = B.vardescriptors; - for(Iterator varit = c.iterator(); varit.hasNext();){ //maybe change that + for(Iterator varit = c.iterator(); varit.hasNext();) { //maybe change that VarDescriptor vd = (VarDescriptor)varit.next(); if(result.vardescriptors.contains(vd)) System.out.println("Already in "); @@ -309,10 +309,10 @@ public class SafetyAnalysis { } } Collection vardesc = result.vardescriptors; - for(Iterator varit = vardesc.iterator(); varit.hasNext();){ + for(Iterator varit = vardesc.iterator(); varit.hasNext();) { VarDescriptor vd = (VarDescriptor)varit.next(); HashSet bflags = B.flags.get(vd); - if( bflags == null ){ + if( bflags == null ) { continue; } else { if (result.flags.containsKey(vd)) @@ -321,7 +321,7 @@ public class SafetyAnalysis { result.flags.put(vd, bflags); } TagExpressionList btags = B.tags.get(vd); - if( btags != null ){ + if( btags != null ) { if (result.tags.containsKey(vd)) System.out.println("Tag found but there should be nothing to do because same tag"); else @@ -356,7 +356,7 @@ public class SafetyAnalysis { FlatFlagActionNode ffan=(FlatFlagActionNode)fn1; if (ffan.getTaskType() == FlatFlagActionNode.TASKEXIT) { HashSet tempset = new HashSet(); - for(Iterator it_fs = otd.enterflagstates.iterator(); it_fs.hasNext();){ + for(Iterator it_fs = otd.enterflagstates.iterator(); it_fs.hasNext();) { FlagState fstemp = (FlagState)it_fs.next(); Vector processed=new Vector(); @@ -376,9 +376,9 @@ public class SafetyAnalysis { Vector oldprocess=processed; processed=new Vector(); - for (Enumeration en=oldprocess.elements(); en.hasMoreElements();){ + for (Enumeration en=oldprocess.elements(); en.hasMoreElements();) { FlagState fsworking=(FlagState)en.nextElement(); - if (!ffan.getTagChange(ttp)){ + if (!ffan.getTagChange(ttp)) { processed.addAll(Arrays.asList(fsworking.clearTag(ttp.getTag()))); } else processed.add(fsworking); } @@ -392,9 +392,9 @@ public class SafetyAnalysis { Vector oldprocess=processed; processed=new Vector(); - for (Enumeration en=oldprocess.elements(); en.hasMoreElements();){ + for (Enumeration en=oldprocess.elements(); en.hasMoreElements();) { FlagState fsworking=(FlagState)en.nextElement(); - if (ffan.getTagChange(ttp)){ + if (ffan.getTagChange(ttp)) { processed.addAll(Arrays.asList(fsworking.setTag(ttp.getTag()))); } else processed.add(fsworking); } @@ -429,29 +429,29 @@ public class SafetyAnalysis { System.out.println("\nTesting class : "+cdtemp.getSymbol()+"\n"); Hashtable hashtbtemp = safeexecution.get(cdtemp); Enumeration fses = hashtbtemp.keys(); - while(fses.hasMoreElements()){ + while(fses.hasMoreElements()) { FlagState fs = (FlagState)fses.nextElement(); System.out.println("\t"+fs.getTextLabel()+"\n\tSafe tasks to execute :\n"); HashSet availabletasks = (HashSet)hashtbtemp.get(fs); - for(Iterator otd_it = availabletasks.iterator(); otd_it.hasNext();){ + for(Iterator otd_it = availabletasks.iterator(); otd_it.hasNext();) { OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next(); System.out.println("\t\tTASK "+otd.td.getSymbol()+" UID : "+otd.getuid()+"\n"); System.out.println("\t\twith flags :"); - for(Iterator myfses = otd.enterflagstates.iterator(); myfses.hasNext();){ + for(Iterator myfses = otd.enterflagstates.iterator(); myfses.hasNext();) { System.out.println("\t\t\t"+((FlagState)myfses.next()).getTextLabel()); } System.out.println("\t\tand exitflags :"); - for(Iterator fseshash = otd.exitfses.iterator(); fseshash.hasNext();){ + for(Iterator fseshash = otd.exitfses.iterator(); fseshash.hasNext();) { HashSet temphs = (HashSet)fseshash.next(); System.out.println(""); - for(Iterator exfses = temphs.iterator(); exfses.hasNext();){ + for(Iterator exfses = temphs.iterator(); exfses.hasNext();) { System.out.println("\t\t\t"+((FlagState)exfses.next()).getTextLabel()); } } Predicate predicate = otd.predicate; System.out.println("\t\tPredicate constraints :"); Collection c = predicate.vardescriptors; - for(Iterator varit = c.iterator(); varit.hasNext();){ + for(Iterator varit = c.iterator(); varit.hasNext();) { VarDescriptor vard = (VarDescriptor)varit.next(); System.out.println("\t\t\tClass "+vard.getType().getClassDesc().getSymbol()); } @@ -461,25 +461,25 @@ public class SafetyAnalysis { System.out.println("\n\n\n\tOptionaltaskdescriptors contains : "); Collection c_otd = optionaltaskdescriptors.get(cdtemp).values(); - for(Iterator otd_it = c_otd.iterator(); otd_it.hasNext();){ + for(Iterator otd_it = c_otd.iterator(); otd_it.hasNext();) { OptionalTaskDescriptor otd = (OptionalTaskDescriptor)otd_it.next(); System.out.println("\t\tTASK "+otd.td.getSymbol()+" UID : "+otd.getuid()+"\n"); System.out.println("\t\twith flags :"); - for(Iterator myfses = otd.enterflagstates.iterator(); myfses.hasNext();){ + for(Iterator myfses = otd.enterflagstates.iterator(); myfses.hasNext();) { System.out.println("\t\t\t"+((FlagState)myfses.next()).getTextLabel()); } System.out.println("\t\tand exitflags :"); - for(Iterator fseshash = otd.exitfses.iterator(); fseshash.hasNext();){ + for(Iterator fseshash = otd.exitfses.iterator(); fseshash.hasNext();) { HashSet temphs = (HashSet)fseshash.next(); System.out.println(""); - for(Iterator exfses = temphs.iterator(); exfses.hasNext();){ + for(Iterator exfses = temphs.iterator(); exfses.hasNext();) { System.out.println("\t\t\t"+((FlagState)exfses.next()).getTextLabel()); } } Predicate predicate = otd.predicate; System.out.println("\t\tPredicate contains :"); Collection c = predicate.vardescriptors; - for(Iterator varit = c.iterator(); varit.hasNext();){ + for(Iterator varit = c.iterator(); varit.hasNext();) { VarDescriptor vard = (VarDescriptor)varit.next(); System.out.println("\t\t\tClass "+vard.getType().getClassDesc().getSymbol()); HashSet temphash = predicate.flags.get(vard.getName()); @@ -510,7 +510,7 @@ public class SafetyAnalysis { FlatFlagActionNode ffan=(FlatFlagActionNode)fn1; if (ffan.getTaskType() == FlatFlagActionNode.TASKEXIT) { Iterator it_ttp=ffan.getTempTagPairs(); - if(it_ttp.hasNext()){ + if(it_ttp.hasNext()) { System.out.println("Tag change detected in Task "+tn.getName()); return true; } else continue; // avoid queueing the return node if reachable @@ -547,10 +547,10 @@ public class SafetyAnalysis { private void traverse(java.io.PrintWriter output, Collection v) { EGTaskNode tn; - for(Iterator it1 = v.iterator(); it1.hasNext();){ + for(Iterator it1 = v.iterator(); it1.hasNext();) { tn = (EGTaskNode)it1.next(); output.println("\t"+tn.getLabel()+" [label=\""+tn.getTextLabel()+"\""); - if (tn.isOptional()){ + if (tn.isOptional()) { if (tn.isMultipleParams()) output.println(", shape = tripleoctagon"); else @@ -559,7 +559,7 @@ public class SafetyAnalysis { output.println(", shape=octagon"); output.println("];"); - for(Iterator it2 = tn.edges(); it2.hasNext();){ + for(Iterator it2 = tn.edges(); it2.hasNext();) { EGTaskNode tn2 = (EGTaskNode)((Edge)it2.next()).getTarget(); output.println("\t"+tn.getLabel()+" -> "+tn2.getLabel()+";"); } diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java index 3d637732..621805f1 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java @@ -238,7 +238,7 @@ public class TaskAnalysis { initFStates.addElement(fs); } Vector targetFStates = ffan.getTargetFStates(fs); - for(Enumeration en=fsv_taskexit.elements(); en.hasMoreElements();){ + for(Enumeration en=fsv_taskexit.elements(); en.hasMoreElements();) { FlagState fs_taskexit=(FlagState)en.nextElement(); if (!sourcenodes.containsKey(fs_taskexit)) { toprocess.add(fs_taskexit); @@ -303,9 +303,9 @@ public class TaskAnalysis { private boolean isTaskTrigger_tag(TagExpressionList tel, FlagState fs) { - if (tel!=null){ - for (int i=0; i oldprocess=processed; processed=new Vector(); - for (Enumeration en=oldprocess.elements(); en.hasMoreElements();){ + for (Enumeration en=oldprocess.elements(); en.hasMoreElements();) { FlagState fsworking=(FlagState)en.nextElement(); - if (!ffan.getTagChange(ttp)){ + if (!ffan.getTagChange(ttp)) { processed.addAll(Arrays.asList(fsworking.clearTag(ttp.getTag()))); } else processed.add(fsworking); } @@ -359,9 +359,9 @@ public class TaskAnalysis { Vector oldprocess=processed; processed=new Vector(); - for (Enumeration en=oldprocess.elements(); en.hasMoreElements();){ + for (Enumeration en=oldprocess.elements(); en.hasMoreElements();) { FlagState fsworking=(FlagState)en.nextElement(); - if (ffan.getTagChange(ttp)){ + if (ffan.getTagChange(ttp)) { processed.addAll(Arrays.asList(fsworking.setTag(ttp.getTag()))); } else processed.add(fsworking); } diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskGraph.java b/Robust/src/Analysis/TaskStateAnalysis/TaskGraph.java index 432e3d49..6bfb23cb 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskGraph.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskGraph.java @@ -86,17 +86,17 @@ public class TaskGraph { for(Iterator it2=src.iterator(); it2.hasNext();) { TaskDescriptor td=(TaskDescriptor)it2.next(); sn=new TaskNode(td.getSymbol()); - if(fs.edges().hasNext()){ + if(fs.edges().hasNext()) { addEdges(fs,sn,tasknodes); } } } - while(it_inedges.hasNext()){ + while(it_inedges.hasNext()) { FEdge inedge=(FEdge)it_inedges.next(); tn=new TaskNode(inedge.getLabel()); - if(fs.edges().hasNext()){ + if(fs.edges().hasNext()) { addEdges(fs,tn,tasknodes); } } @@ -106,7 +106,7 @@ public class TaskGraph { private void produceAllTaskNodes() { alltasknodes=new Hashtable(); - for(Iterator it_tasks=state.getTaskSymbolTable().getDescriptorsIterator(); it_tasks.hasNext();){ + for(Iterator it_tasks=state.getTaskSymbolTable().getDescriptorsIterator(); it_tasks.hasNext();) { TaskDescriptor td=(TaskDescriptor)it_tasks.next(); TaskNode tn=new TaskNode(td.getSymbol()); alltasknodes.put(tn,tn); @@ -119,7 +119,7 @@ public class TaskGraph { ClassDescriptor cd=(ClassDescriptor) classit.next(); Set fsnodes; - if (cd.hasFlags()&&((fsnodes=taskanalysis.getFlagStates(cd))!=null)){ + if (cd.hasFlags()&&((fsnodes=taskanalysis.getFlagStates(cd))!=null)) { // System.out.println("\nWorking on fses of Class: "+cd.getSymbol()); // @@ -132,17 +132,17 @@ public class TaskGraph { TaskNode tn,sn; - if (fs.isSourceNode()){ + if (fs.isSourceNode()) { // System.out.println("A sourcenode"); // - if(fs.edges().hasNext()){ + if(fs.edges().hasNext()) { Vector allocatingtasks=fs.getAllocatingTasks(); // if (allocatingtasks.iterator().hasNext()) System.out.println("has been allocated by "+allocatingtasks.size()+" tasks"); // - for(Iterator it_at=allocatingtasks.iterator(); it_at.hasNext();){ + for(Iterator it_at=allocatingtasks.iterator(); it_at.hasNext();) { TaskDescriptor allocatingtd=(TaskDescriptor)it_at.next(); // System.out.println(allocatingtd.getSymbol()); @@ -154,10 +154,10 @@ public class TaskGraph { } } - while(it_inedges.hasNext()){ + while(it_inedges.hasNext()) { FEdge inedge=(FEdge)it_inedges.next(); tn=new TaskNode(inedge.getLabel()); - if(fs.edges().hasNext()){ + if(fs.edges().hasNext()) { addEdges(fs,tn,alltasknodes,ColorID); } } @@ -202,7 +202,7 @@ public class TaskGraph { // Hashtable tasknodes=(Hashtable)cdtonodes.get(fs.getClassDescriptor()); tn=(TaskNode)canonicalizeTaskNode(tasknodes, tn); - for (Iterator it_edges=fs.edges(); it_edges.hasNext();){ + for (Iterator it_edges=fs.edges(); it_edges.hasNext();) { TaskNode target=new TaskNode(((FEdge)it_edges.next()).getLabel()); target=(TaskNode)canonicalizeTaskNode(tasknodes,target); @@ -216,7 +216,7 @@ public class TaskGraph { private void addEdges(FlagState fs, TaskNode tn,Hashtable tasknodes,int ColorID) { tn=(TaskNode)canonicalizeTaskNode(tasknodes, tn); - for (Iterator it_edges=fs.edges(); it_edges.hasNext();){ + for (Iterator it_edges=fs.edges(); it_edges.hasNext();) { TaskNode target=new TaskNode(((FEdge)it_edges.next()).getLabel()); target=(TaskNode)canonicalizeTaskNode(tasknodes,target); diff --git a/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java b/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java index 6249993f..6a2d3aab 100644 --- a/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java +++ b/Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java @@ -604,9 +604,9 @@ public class TaskTagAnalysis { private static boolean isTaskTrigger_tag(TagExpressionList tel, FlagState fs) { - if (tel!=null){ - for (int i=0; i> 8); bytes[i + 2] = (byte) (random >> 16); bytes[i + 3] = (byte) (random >> 24); } - if (max < bytes.length){ + if (max < bytes.length) { random = next(32); - for (int j = max; j < bytes.length; j++){ + for (int j = max; j < bytes.length; j++) { bytes[j] = (byte) random; random >>= 8; } @@ -383,7 +383,7 @@ public class Random * @return the next pseudorandom Gaussian distributed double */ public synchronized double nextGaussian() { - if (haveNextNextGaussian){ + if (haveNextNextGaussian) { haveNextNextGaussian = false; return nextNextGaussian; } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 08b6f06c..298c4084 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -99,7 +99,7 @@ public class BuildCode { if (state.TASK) { outtask=new PrintWriter(new FileOutputStream(PREFIX+"task.h"), true); outtaskdefs=new PrintWriter(new FileOutputStream(PREFIX+"taskdefs.c"), true); - if (state.OPTIONAL){ + if (state.OPTIONAL) { outoptionalarrays=new PrintWriter(new FileOutputStream(PREFIX+"optionalarrays.c"), true); optionalheaders=new PrintWriter(new FileOutputStream(PREFIX+"optionalstruct.h"), true); } @@ -168,7 +168,7 @@ public class BuildCode { } /* Generate information for task with optional parameters */ - if (state.TASK&&state.OPTIONAL){ + if (state.TASK&&state.OPTIONAL) { generateOptionalArrays(outoptionalarrays, optionalheaders, state.getAnalysisResult(), state.getOptionalTaskDescriptors()); outoptionalarrays.close(); } @@ -442,7 +442,7 @@ public class BuildCode { outclassdefs.println(" int version;"); outclassdefs.println(" struct ___Object___ * original;"); } - if(state.OPTIONAL){ + if(state.OPTIONAL) { outclassdefs.println(" int numfses;"); outclassdefs.println(" int * fses;"); } @@ -1036,12 +1036,12 @@ public class BuildCode { classdefout.println(" int flag;"); if((!state.MULTICORE) || (cn.getSymbol().equals("TagDescriptor"))) { classdefout.println(" void * flagptr;"); - } else if (state.MULTICORE){ + } else if (state.MULTICORE) { classdefout.println(" int isolate;"); // indicate if this object is shared or not classdefout.println(" int version;"); classdefout.println(" struct ___Object___ * original;"); } - if (state.OPTIONAL){ + if (state.OPTIONAL) { classdefout.println(" int numfses;"); classdefout.println(" int * fses;"); } @@ -2519,7 +2519,7 @@ public class BuildCode { Hashtable slotnumber=new Hashtable(); int current_slot=0; - for(Iterator vard_it = c_vard.iterator(); vard_it.hasNext();){ + for(Iterator vard_it = c_vard.iterator(); vard_it.hasNext();) { VarDescriptor vard = (VarDescriptor)vard_it.next(); TypeDescriptor typed = vard.getType(); @@ -2527,8 +2527,8 @@ public class BuildCode { HashSet fen_hashset = predicate.flags.get(vard.getSymbol()); output.println("int predicateflags_"+predicateindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={"); int numberterms=0; - if (fen_hashset!=null){ - for (Iterator fen_it = fen_hashset.iterator(); fen_it.hasNext();){ + if (fen_hashset!=null) { + for (Iterator fen_it = fen_hashset.iterator(); fen_it.hasNext();) { FlagExpressionNode fen = (FlagExpressionNode)fen_it.next(); if (fen!=null) { DNFFlag dflag=fen.getDNF(); @@ -2562,7 +2562,7 @@ public class BuildCode { TagExpressionList tagel = predicate.tags.get(vard.getSymbol()); output.println("int predicatetags_"+predicateindex+"_OTD"+otd.getuid()+"_"+cdtemp.getSafeSymbol()+"[]={"); int numtags = 0; - if (tagel!=null){ + if (tagel!=null) { for(int j=0; j mos = ordertd(availabletasks).iterator(); mos.hasNext();){ + for(Iterator mos = ordertd(availabletasks).iterator(); mos.hasNext();) { OptionalTaskDescriptor mm = mos.next(); if(!mos.hasNext()) output.println("&optionaltaskdescriptor_"+mm.getuid()+"_"+cdtemp.getSafeSymbol()); @@ -2714,7 +2714,7 @@ public class BuildCode { //process flag information (what the flag after failure is) so we know what optionaltaskdescriptors to choose. int flagid=0; - for(Iterator flags = fs.getFlags(); flags.hasNext();){ + for(Iterator flags = fs.getFlags(); flags.hasNext();) { FlagDescriptor flagd = (FlagDescriptor)flags.next(); int id=1<<((Integer)flaginfo.get(flagd)).intValue(); flagid|=id; @@ -2726,7 +2726,7 @@ public class BuildCode { boolean first = true; Enumeration tag_enum = fs.getTags(); output.println("int tags_FS"+fscounter+"_"+cdtemp.getSafeSymbol()+"[]={"); - while(tag_enum.hasMoreElements()){ + while(tag_enum.hasMoreElements()) { tagcounter++; TagDescriptor tagd = (TagDescriptor)tag_enum.nextElement(); if(first==true) @@ -2798,7 +2798,7 @@ public class BuildCode { //Build the array of fsanalysiswrappers output.println("struct fsanalysiswrapper * fsanalysiswrapperarray_"+cdtemp.getSafeSymbol()+"[] = {"); boolean needcomma=false; - for(int i = 0; iobjptr = (void *)" + tmpinfo.name + ";"); @@ -1066,7 +1066,7 @@ public class BuildCodeMultiCore extends BuildCode { } else { tmpinfo.fs = tmpFState; } - if(!contains(sendto, tmpinfo)){ + if(!contains(sendto, tmpinfo)) { qinfo = outputtransqueues(tmpinfo.fs, targetcore, output); output.println("tmpObjInfo = RUNMALLOC(sizeof(struct transObjInfo));"); output.println("tmpObjInfo->objptr = (void *)" + tmpinfo.name + ";"); @@ -1120,7 +1120,7 @@ public class BuildCodeMultiCore extends BuildCode { } else { tmpinfo.fs = tmpFState; } - if(!contains(sendto, tmpinfo)){ + if(!contains(sendto, tmpinfo)) { qinfo = outputtransqueues(tmpinfo.fs, targetcores.elementAt(i), output); output.println("tmpObjInfo = RUNMALLOC(sizeof(struct transObjInfo));"); output.println("tmpObjInfo->objptr = (void *)" + tmpinfo.name + ";"); diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 4908a190..13acd63b 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -175,7 +175,7 @@ public class BuildIR { ParseNodeVector pnv=paramlist.getChildren(); for(int i=0; i"+td.getParamType(i)+"
"); pw.println("Task Graph:        " +td.getParamType(i)+"
"); @@ -126,14 +126,14 @@ public class WebInterface { private String sourcenode(Vector cd_nodeid,OutputStream out, HTTPResponse resp) { Vector rootnodes=taskanalysis.getRootNodes((ClassDescriptor)cd_nodeid.elementAt(0)); - for(Iterator it_rootnodes=rootnodes.iterator(); it_rootnodes.hasNext();){ + for(Iterator it_rootnodes=rootnodes.iterator(); it_rootnodes.hasNext();) { FlagState root=(FlagState)it_rootnodes.next(); - if (root.getLabel().equals((String)cd_nodeid.elementAt(1))){ + if (root.getLabel().equals((String)cd_nodeid.elementAt(1))) { try { PrintWriter pw=new PrintWriter(out); pw.println("

Allocating tasks for "+root.getTextLabel()+":


"); Vector tasks=root.getAllocatingTasks(); - for(Iterator it_tasks=tasks.iterator(); it_tasks.hasNext();){ + for(Iterator it_tasks=tasks.iterator(); it_tasks.hasNext();) { TaskDescriptor td=(TaskDescriptor)it_tasks.next(); pw.println("
Task:   "+td.toString()+"
"); printTask(td,pw); @@ -177,7 +177,7 @@ public class WebInterface { pw.println("ps
"); //pw.println(""); pw.println(""); - while((str=mapbr.readLine())!=null){ + while((str=mapbr.readLine())!=null) { pw.println(str); } @@ -216,7 +216,7 @@ public class WebInterface { // pw.println(""); pw.println(""); - while((str=mapbr.readLine())!=null){ + while((str=mapbr.readLine())!=null) { pw.println(str); } pw.flush(); @@ -234,7 +234,7 @@ public class WebInterface { PrintWriter pw=new PrintWriter(out); for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); it_classes.hasNext();) { ClassDescriptor cd=(ClassDescriptor) it_classes.next(); - if (cd.hasFlags()){ + if (cd.hasFlags()) { if (taskanalysis.getFlagStates(cd)!=null) { pw.println(""+ cd.getSymbol() +""); pw.println("
"); diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 28389107..0c9a0a7a 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -271,10 +271,10 @@ public class Main { int tint = 0; for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); it_classes.hasNext();) { ClassDescriptor cd=(ClassDescriptor) it_classes.next(); - if(cd.hasFlags()){ + if(cd.hasFlags()) { Vector rootnodes=ta.getRootNodes(cd); if(rootnodes!=null) - for(Iterator it_rootnodes=rootnodes.iterator(); it_rootnodes.hasNext();){ + for(Iterator it_rootnodes=rootnodes.iterator(); it_rootnodes.hasNext();) { FlagState root=(FlagState)it_rootnodes.next(); Vector allocatingTasks = root.getAllocatingTasks(); if(allocatingTasks != null) { @@ -288,7 +288,7 @@ public class Main { if(numEdges - j == 1) { pfe.setProbability(total); } else { - if((total != 0) && (total != 1)){ + if((total != 0) && (total != 1)) { do { tint = r.nextInt()%total; } while(tint <= 0); diff --git a/Robust/src/Runtime/DSTM/interface/dht.c b/Robust/src/Runtime/DSTM/interface/dht.c index fc181991..3fd73494 100644 --- a/Robust/src/Runtime/DSTM/interface/dht.c +++ b/Robust/src/Runtime/DSTM/interface/dht.c @@ -336,7 +336,7 @@ void dhtInit(unsigned int seedIpAddr, unsigned int maxKeyCapacity) { if (bind(udpPollSock.fd, (struct sockaddr *)&myAddr, socklen) < 0) perror("dhtInit():bind()"); - if (seed == 0){ + if (seed == 0) { dhtLog("I am the leader\n"); leader = myHostData.ipAddr; setState(LEAD_NORMAL1_STATE); @@ -385,7 +385,7 @@ int dhtInsert(unsigned int key, unsigned int val) { toAddr.sin_family = AF_INET; toAddr.sin_port = htons(UDP_PORT); - while (status != OPERATION_OK){ + while (status != OPERATION_OK) { pthread_mutex_lock(&stateMutex); while (!(state == NORMAL_STATE || state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE || state == REBUILD4_STATE @@ -394,7 +394,7 @@ int dhtInsert(unsigned int key, unsigned int val) { toAddr.sin_addr.s_addr = htonl(getKeyOwner(key)); pthread_mutex_unlock(&stateMutex); - if ((pollsock.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){ + if ((pollsock.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("dhtInsert():socket()"); return -1; } @@ -404,29 +404,29 @@ int dhtInsert(unsigned int key, unsigned int val) { write4(&outBuffer[1], key); write4(&outBuffer[5], val); - for (i = 0; i < INSERT_RETRIES; i++){ + for (i = 0; i < INSERT_RETRIES; i++) { if (sendto(pollsock.fd, outBuffer, 9, 0, (struct sockaddr *)&toAddr, - socklen) < 0){ + socklen) < 0) { perror("dhtInsert():sendto()"); break; } retval = poll(&pollsock, 1, INSERT_TIMEOUT_MS); - if (retval < 0){ + if (retval < 0) { perror("dhtInsert():poll()"); break; } - if (retval > 0){ + if (retval > 0) { bytesRcvd = recvfrom(pollsock.fd, inBuffer, 2, 0, (struct sockaddr *)&fromAddr, &socklen); if (fromAddr.sin_addr.s_addr == toAddr.sin_addr.s_addr && fromAddr.sin_port == toAddr.sin_port - && bytesRcvd == 2 && inBuffer[0] == INSERT_RES){ + && bytesRcvd == 2 && inBuffer[0] == INSERT_RES) { status = inBuffer[1]; //status from remote host break; } } } - if (status != OPERATION_OK){ + if (status != OPERATION_OK) { pthread_mutex_lock(&stateMutex); setState(REBUILD0_STATE); outBuffer[0] = REBUILD_REQ; @@ -445,7 +445,7 @@ int dhtInsertMult(unsigned int numKeys, unsigned int *keys, unsigned int *va int i; status = 0; - for (i = 0; i < numKeys; i++){ + for (i = 0; i < numKeys; i++) { if (dhtInsert(keys[i], vals[i]) != 0) status = -1; } @@ -468,7 +468,7 @@ int dhtRemove(unsigned int key) { toAddr.sin_family = AF_INET; toAddr.sin_port = htons(UDP_PORT); - while (!(status == OPERATION_OK || status == KEY_NOT_FOUND)){ + while (!(status == OPERATION_OK || status == KEY_NOT_FOUND)) { pthread_mutex_lock(&stateMutex); while (!(state == NORMAL_STATE || state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE)) @@ -476,7 +476,7 @@ int dhtRemove(unsigned int key) { toAddr.sin_addr.s_addr = htonl(getKeyOwner(key)); pthread_mutex_unlock(&stateMutex); - if ((pollsock.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){ + if ((pollsock.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("dhtRemove():socket()"); return -1; } @@ -485,29 +485,29 @@ int dhtRemove(unsigned int key) { outBuffer[0] = REMOVE_CMD; write4(&outBuffer[1], key); - for (i = 0; i < REMOVE_RETRIES; i++){ + for (i = 0; i < REMOVE_RETRIES; i++) { if (sendto(pollsock.fd, outBuffer, 5, 0, (struct sockaddr *)&toAddr, - socklen) < 0){ + socklen) < 0) { perror("dhtRemove():sendto()"); break; } retval = poll(&pollsock, 1, REMOVE_TIMEOUT_MS); - if (retval < 0){ + if (retval < 0) { perror("dhtRemove():poll()"); break; } - if (retval > 0){ + if (retval > 0) { bytesRcvd = recvfrom(pollsock.fd, inBuffer, 2, 0, (struct sockaddr *)&fromAddr, &socklen); if (fromAddr.sin_addr.s_addr == toAddr.sin_addr.s_addr && fromAddr.sin_port == toAddr.sin_port - && bytesRcvd == 2 && inBuffer[0] == REMOVE_RES){ + && bytesRcvd == 2 && inBuffer[0] == REMOVE_RES) { status = inBuffer[1]; //status from remote host break; } } } - if (!(status == OPERATION_OK || status == KEY_NOT_FOUND)){ + if (!(status == OPERATION_OK || status == KEY_NOT_FOUND)) { pthread_mutex_lock(&stateMutex); setState(REBUILD0_STATE); outBuffer[0] = REBUILD_REQ; @@ -526,7 +526,7 @@ int dhtRemoveMult(unsigned int numKeys, unsigned int *keys) { int i; status = 0; - for (i = 0; i < numKeys; i++){ + for (i = 0; i < numKeys; i++) { if (dhtRemove(keys[i]) != 0) status = -1; } @@ -549,14 +549,14 @@ int dhtSearch(unsigned int key, unsigned int *val) { toAddr.sin_family = AF_INET; toAddr.sin_port = htons(UDP_PORT); - while (!(status == OPERATION_OK || status == KEY_NOT_FOUND)){ + while (!(status == OPERATION_OK || status == KEY_NOT_FOUND)) { pthread_mutex_lock(&stateMutex); while (numBlocks == 0) pthread_cond_wait(&stateCond, &stateMutex); toAddr.sin_addr.s_addr = htonl(getKeyOwner(key)); pthread_mutex_unlock(&stateMutex); - if ((pollsock.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){ + if ((pollsock.fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("dhtSearch():socket()"); return -1; } @@ -565,30 +565,30 @@ int dhtSearch(unsigned int key, unsigned int *val) { outBuffer[0] = SEARCH_CMD; write4(&outBuffer[1], key); - for (i = 0; i < SEARCH_RETRIES; i++){ + for (i = 0; i < SEARCH_RETRIES; i++) { if (sendto(pollsock.fd, outBuffer, 5, 0, (struct sockaddr *)&toAddr, - socklen) < 0){ + socklen) < 0) { perror("dhtSearch():sendto()"); break; } retval = poll(&pollsock, 1, SEARCH_TIMEOUT_MS); - if (retval < 0){ + if (retval < 0) { perror("dhtSearch():poll()"); break; } - if (retval > 0){ + if (retval > 0) { bytesRcvd = recvfrom(pollsock.fd, inBuffer, 6, 0, (struct sockaddr *)&fromAddr, &socklen); if (fromAddr.sin_addr.s_addr == toAddr.sin_addr.s_addr && fromAddr.sin_port == toAddr.sin_port - && bytesRcvd == 6 && inBuffer[0] == SEARCH_RES){ + && bytesRcvd == 6 && inBuffer[0] == SEARCH_RES) { status = inBuffer[1]; //status from remote host *val = read4(&inBuffer[2]); break; } } } - if (!(status == OPERATION_OK || status == KEY_NOT_FOUND)){ + if (!(status == OPERATION_OK || status == KEY_NOT_FOUND)) { pthread_mutex_lock(&stateMutex); setState(REBUILD0_STATE); outBuffer[0] = REBUILD_REQ; @@ -605,7 +605,7 @@ int dhtSearch(unsigned int key, unsigned int *val) { int dhtSearchMult(unsigned int numKeys, unsigned int *keys, unsigned int *vals) { int i; int status = 0; - for (i = 0; i < numKeys; i++){ + for (i = 0; i < numKeys; i++) { if (dhtSearch(keys[i], &vals[i]) != 0) status = -1; } @@ -623,7 +623,7 @@ int msgSizeOk(unsigned char *msg, unsigned int size) { if (size < 1) return 1; - switch (msg[0]){ + switch (msg[0]) { case WHO_IS_LEADER_CMD: case LEAVE_REQ: case LEAVE_RES: @@ -713,7 +713,7 @@ unsigned int getMyIpAddr(const char *interfaceStr) { memset(&interfaceInfo, 0, sizeof(struct ifreq)); - if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){ + if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("getMyIpAddr():socket()"); return 1; } @@ -721,7 +721,7 @@ unsigned int getMyIpAddr(const char *interfaceStr) { strcpy(interfaceInfo.ifr_name, interfaceStr); myAddr->sin_family = AF_INET; - if(ioctl(sock, SIOCGIFADDR, &interfaceInfo) != 0){ + if(ioctl(sock, SIOCGIFADDR, &interfaceInfo) != 0) { perror("getMyIpAddr():ioctl()"); return 1; } @@ -738,7 +738,7 @@ int udpSend(unsigned char *msg, unsigned int size, unsigned int destIp) { peerAddr.sin_addr.s_addr = htonl(destIp); peerAddr.sin_port = htons(UDP_PORT); - if (size >= 1){ + if (size >= 1) { if (msg[0] < NUM_MSG_TYPES) dhtLog("udpSend(): sending %s to %s, %d bytes\n", msg_types[msg[0]], inet_ntoa(peerAddr.sin_addr), size); @@ -748,7 +748,7 @@ int udpSend(unsigned char *msg, unsigned int size, unsigned int destIp) { } if (sendto(udpPollSock.fd, (void *)msg, size, 0, (struct sockaddr *)&peerAddr, - socklen) < 0){ + socklen) < 0) { perror("udpSend():sendto()"); return -1; } @@ -759,8 +759,8 @@ int udpSend(unsigned char *msg, unsigned int size, unsigned int destIp) { int udpSendAll(unsigned char *msg, unsigned int size) { int i; int status = 0; - for (i = 0; i < numHosts; i++){ - if ((hostReplied[i] == 0) && (hostArray[i].ipAddr != myHostData.ipAddr)){ + for (i = 0; i < numHosts; i++) { + if ((hostReplied[i] == 0) && (hostArray[i].ipAddr != myHostData.ipAddr)) { if (udpSend(msg, size, hostArray[i].ipAddr) != 0) status = -1; } @@ -786,12 +786,12 @@ void setState(unsigned int newState) { gettimeofday(&now, NULL); - if (newState >= NUM_STATES){ + if (newState >= NUM_STATES) { dhtLog("setState(): ERROR: invalid state %d\n", newState); } else { if (timeout_vals[newState].tv_sec == 0 - && timeout_vals[newState].tv_usec == 0){ //no timer + && timeout_vals[newState].tv_usec == 0) { //no timer timerSet = 0; } else { @@ -852,14 +852,14 @@ int removeHost(unsigned int ipAddr) { if (i == -1) return -1; - for (j = 0; j < numBlocks; j++){ + for (j = 0; j < numBlocks; j++) { if (blockOwnerArray[j] == i) blockOwnerArray[j] = 0; //TODO: is this what I want to have happen? else if (blockOwnerArray[j] > i) blockOwnerArray[j]--; } - for (; i < numHosts - 1; i++){ + for (; i < numHosts - 1; i++) { hostArray[i] = hostArray[i+1]; hostReplied[i] = hostReplied[i+1]; } @@ -871,7 +871,7 @@ int removeHost(unsigned int ipAddr) { void removeUnresponsiveHosts() { int i; - for (i = 0; i < numHosts; i++){ + for (i = 0; i < numHosts; i++) { if (!hostReplied[i] && hostArray[i].ipAddr != myHostData.ipAddr) removeHost(hostArray[i].ipAddr); } @@ -883,13 +883,13 @@ int addHost(struct hostData newHost) { int i; int j; - for (i = 0; i < numHosts; i++){ - if (hostArray[i].ipAddr == newHost.ipAddr){ + for (i = 0; i < numHosts; i++) { + if (hostArray[i].ipAddr == newHost.ipAddr) { hostArray[i] = newHost; hostReplied[i] = 0; return 0; } else if (hostArray[i].ipAddr > newHost.ipAddr) { - if (numHosts == hostArraySize){ + if (numHosts == hostArraySize) { newHostArray = calloc(2 * hostArraySize, sizeof(struct hostData)); newHostReplied = calloc(2 * hostArraySize, sizeof(unsigned char)); memcpy(newHostArray, hostArray, (i * sizeof(struct hostData))); @@ -907,14 +907,14 @@ int addHost(struct hostData newHost) { hostArraySize = 2 * hostArraySize; } else { - for (j = numHosts; j > i; j--){ + for (j = numHosts; j > i; j--) { hostArray[j] = hostArray[j-1]; hostReplied[j] = hostReplied[j-1]; } hostArray[i] = newHost; hostReplied[i] = 0; } - for(j = 0; j < numBlocks; j++){ + for(j = 0; j < numBlocks; j++) { if (blockOwnerArray[j] >= i) blockOwnerArray[j]++; } @@ -924,7 +924,7 @@ int addHost(struct hostData newHost) { } //nothing greater, add to end - if (numHosts == hostArraySize){ + if (numHosts == hostArraySize) { newHostArray = calloc(2 * hostArraySize, sizeof(struct hostData)); newHostReplied = calloc(2 * hostArraySize, sizeof(unsigned char)); memcpy(newHostArray, hostArray, (numHosts * sizeof(struct hostData))); @@ -945,7 +945,7 @@ int addHost(struct hostData newHost) { void makeAssignments() { int i; - if (numBlocks < numHosts){ + if (numBlocks < numHosts) { free(blockOwnerArray); while (numBlocks < numHosts) numBlocks *= 2; @@ -963,7 +963,7 @@ void writeHostList() { struct in_addr tmpAddr; fprintf(logfile, "numHosts = %d\n", numHosts); - for (i = 0; i < numHosts; i++){ + for (i = 0; i < numHosts; i++) { tmpAddr.s_addr = htonl(hostArray[i].ipAddr); fprintf(logfile, "%d) %s, %d\n", i, inet_ntoa(tmpAddr), hostArray[i].maxKeyCapacity); @@ -980,10 +980,10 @@ void dhtLog(const char *format, ...) { va_start(args, format); // if (fprintf(logfile, "%d.%06d:", now.tv_sec, now.tv_usec) < 0) // { perror("dhtLog():fprintf()"); } - if (vfprintf(logfile, format, args) < 0){ + if (vfprintf(logfile, format, args) < 0) { perror("dhtLog():vfprintf()"); } - if (fflush(logfile) == EOF){ + if (fflush(logfile) == EOF) { perror("dhtLog():fflush()"); } va_end(args); @@ -1033,16 +1033,16 @@ void *udpListen() { dhtLog("udpListen(): linstening on port %d...\n", UDP_PORT); - while (1){ + while (1) { pollret = poll(&udpPollSock, 1, TIMEOUT_PERIOD); pthread_mutex_lock(&stateMutex); oldState = state; - if (pollret < 0){ + if (pollret < 0) { perror("udpListen():poll()"); } else if (pollret > 0) { bytesRcvd = recvfrom(udpPollSock.fd, inBuffer, MAX_MSG_SIZE, 0, (struct sockaddr *)&peerAddr, &socklen); - if (bytesRcvd < 1){ + if (bytesRcvd < 1) { dhtLog("udpListen(): ERROR: bytesRcvd = %d\n", bytesRcvd); } else if (inBuffer[0] >= NUM_MSG_TYPES) { dhtLog("udpListen(): ERROR: unknown msg type = %d\n", inBuffer[0]); @@ -1058,7 +1058,7 @@ void *udpListen() { dhtLog(" %x", inBuffer[i]); dhtLog("\n"); peerIp = ntohl(peerAddr.sin_addr.s_addr); - if (peerIp == seed && inBuffer[0] == WHO_IS_LEADER_RES){ + if (peerIp == seed && inBuffer[0] == WHO_IS_LEADER_RES) { tmpHost.ipAddr = peerIp; tmpHost.maxKeyCapacity = 0; addHost(tmpHost); @@ -1066,7 +1066,7 @@ void *udpListen() { leader = read4(&inBuffer[1]); tmpAddr.s_addr = htonl(leader); dhtLog("leader = %s\n", inet_ntoa(tmpAddr)); - if (leader != 0){ + if (leader != 0) { setState(INIT2_STATE); outBuffer[0] = JOIN_REQ; write4(&outBuffer[1], myHostData.maxKeyCapacity); @@ -1088,15 +1088,15 @@ void *udpListen() { dhtLog(" %x", inBuffer[i]); dhtLog("\n"); peerIp = ntohl(peerAddr.sin_addr.s_addr); - switch (inBuffer[0]){ + switch (inBuffer[0]) { case INSERT_CMD: if (state == NORMAL_STATE || state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE || state == REBUILD4_STATE - || state == REBUILD5_STATE || state == LEAD_REBUILD3_STATE){ + || state == REBUILD5_STATE || state == LEAD_REBUILD3_STATE) { tmpKey = read4(&inBuffer[1]); tmpVal = read4(&inBuffer[5]); outBuffer[0] = INSERT_RES; - if (getKeyOwner(tmpKey) == myHostData.ipAddr){ + if (getKeyOwner(tmpKey) == myHostData.ipAddr) { if (chashInsert(myHashTable, tmpKey, (void *)tmpVal) == 0) outBuffer[1] = OPERATION_OK; else @@ -1113,10 +1113,10 @@ void *udpListen() { case REMOVE_CMD: if (state == NORMAL_STATE || state == LEAD_NORMAL1_STATE - || state == LEAD_NORMAL2_STATE){ + || state == LEAD_NORMAL2_STATE) { tmpKey = read4(&inBuffer[1]); outBuffer[0] = REMOVE_RES; - if (getKeyOwner(tmpKey) == myHostData.ipAddr){ + if (getKeyOwner(tmpKey) == myHostData.ipAddr) { if (chashRemove(myHashTable, tmpKey) == 0) outBuffer[1] = OPERATION_OK; else @@ -1133,11 +1133,11 @@ void *udpListen() { case SEARCH_CMD: if (state == NORMAL_STATE || state == LEAD_NORMAL1_STATE - || state == LEAD_NORMAL2_STATE){ + || state == LEAD_NORMAL2_STATE) { tmpKey = read4(&inBuffer[1]); outBuffer[0] = SEARCH_RES; - if (getKeyOwner(tmpKey) == myHostData.ipAddr){ - if ((tmpVal = (unsigned int)chashSearch(myHashTable, tmpKey)) != 0){ + if (getKeyOwner(tmpKey) == myHostData.ipAddr) { + if ((tmpVal = (unsigned int)chashSearch(myHashTable, tmpKey)) != 0) { outBuffer[1] = OPERATION_OK; write4(&outBuffer[2], tmpVal); } else @@ -1168,7 +1168,7 @@ void *udpListen() { break; case JOIN_REQ: - if (state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE){ + if (state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE) { tmpHost.ipAddr = peerIp; tmpHost.maxKeyCapacity = read4(&inBuffer[1]); addHost(tmpHost); @@ -1184,7 +1184,7 @@ void *udpListen() { outBuffer[0] = JOIN_RES; outBuffer[1] = 0; //status, success udpSend(outBuffer, 2, peerIp); - if (allReplied()){ + if (allReplied()) { makeAssignments(); setState(LEAD_REBUILD2_STATE); outBuffer[0] = DHT_UPDATE_CMD; @@ -1200,7 +1200,7 @@ void *udpListen() { break; case JOIN_RES: - if (state == REBUILD1_STATE){ + if (state == REBUILD1_STATE) { setState(REBUILD2_STATE); } else if (state == INIT2_STATE) { setState(NORMAL_STATE); @@ -1208,7 +1208,7 @@ void *udpListen() { break; case LEAVE_REQ: - if (state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE){ //TODO: make this graceful, instead of just rebuilding + if (state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE) { //TODO: make this graceful, instead of just rebuilding removeHost(peerIp); if (state != LEAD_NORMAL2_STATE) setState(LEAD_NORMAL2_STATE); @@ -1216,7 +1216,7 @@ void *udpListen() { break; case DHT_UPDATE_CMD: - if (state == REBUILD2_STATE && peerIp == leader){ + if (state == REBUILD2_STATE && peerIp == leader) { free(hostArray); free(blockOwnerArray); numHosts = read2(&inBuffer[1]); @@ -1235,9 +1235,9 @@ void *udpListen() { break; case DHT_UPDATE_RES: - if (state == LEAD_REBUILD2_STATE){ + if (state == LEAD_REBUILD2_STATE) { checkReplied(peerIp); - if (allReplied()){ + if (allReplied()) { setState(LEAD_REBUILD3_STATE); outBuffer[0] = FILL_DHT_CMD; udpSendAll(outBuffer, 1); @@ -1253,7 +1253,7 @@ void *udpListen() { case ELECT_LEADER_CMD: tmpUInt = read4(&inBuffer[1]); if ((state == ELECT1_STATE || state == ELECT2_STATE) - && tmpUInt >= electionOriginator){ //already participating in a higher-priority election + && tmpUInt >= electionOriginator) { //already participating in a higher-priority election outBuffer[0] = ELECT_LEADER_RES; outBuffer[1] = 0xFF; udpSend(outBuffer, 2, peerIp); @@ -1267,7 +1267,7 @@ void *udpListen() { //don't bother forwarding the message to originator or parent checkReplied(electionOriginator); checkReplied(electionParent); - if (allReplied()){ //in case that is everybody I know of + if (allReplied()) { //in case that is everybody I know of setState(ELECT2_STATE); outBuffer[0] = ELECT_LEADER_RES; outBuffer[1] = 0; @@ -1284,20 +1284,20 @@ void *udpListen() { break; case ELECT_LEADER_RES: - if (state == ELECT1_STATE){ + if (state == ELECT1_STATE) { checkReplied(peerIp); - if (inBuffer[1] != 0xFF){ + if (inBuffer[1] != 0xFF) { tmpUShort = read2(&inBuffer[2]); hostDataPtr = (struct hostData *)&inBuffer[4]; for (i = 0; i < tmpUShort; i++) addHost(hostDataPtr[i]); writeHostList(); } - if (allReplied()){ + if (allReplied()) { setState(ELECT2_STATE); - if (electionOriginator == myHostData.ipAddr){ + if (electionOriginator == myHostData.ipAddr) { leader = hostArray[0].ipAddr; - if (leader == myHostData.ipAddr){ //I am the leader + if (leader == myHostData.ipAddr) { //I am the leader dhtLog("I am the leader!\n"); setState(LEAD_REBUILD1_STATE); outBuffer[0] = REBUILD_CMD; @@ -1328,7 +1328,7 @@ void *udpListen() { break; case CONGRATS_CMD: - if (state == ELECT2_STATE){ //I am the leader + if (state == ELECT2_STATE) { //I am the leader leader = myHostData.ipAddr; dhtLog("I am the leader!\n"); tmpUShort = read2(&inBuffer[1]); @@ -1343,7 +1343,7 @@ void *udpListen() { break; case REBUILD_REQ: - if (state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE){ + if (state == LEAD_NORMAL1_STATE || state == LEAD_NORMAL2_STATE) { setState(LEAD_REBUILD1_STATE); outBuffer[0] = REBUILD_CMD; udpSendAll(outBuffer, 1); @@ -1359,7 +1359,7 @@ void *udpListen() { break; case FILL_DHT_CMD: - if (state == REBUILD3_STATE && peerIp == leader){ + if (state == REBUILD3_STATE && peerIp == leader) { setState(REBUILD4_STATE); if (fillStatus != 0) dhtLog("udpListen(): ERROR: fillTask already running\n"); @@ -1370,9 +1370,9 @@ void *udpListen() { break; case FILL_DHT_RES: - if (state == LEAD_REBUILD3_STATE){ + if (state == LEAD_REBUILD3_STATE) { checkReplied(peerIp); - if (allReplied() && fillStatus == 2){ + if (allReplied() && fillStatus == 2) { fillStatus = 0; setState(LEAD_REBUILD4_STATE); outBuffer[0] = RESUME_NORMAL_CMD; @@ -1382,7 +1382,7 @@ void *udpListen() { break; case RESUME_NORMAL_CMD: - if (state == REBUILD5_STATE && peerIp == leader){ + if (state == REBUILD5_STATE && peerIp == leader) { setState(NORMAL_STATE); outBuffer[0] = RESUME_NORMAL_RES; udpSend(outBuffer, 1, leader); @@ -1390,9 +1390,9 @@ void *udpListen() { break; case RESUME_NORMAL_RES: - if (state == LEAD_REBUILD4_STATE){ + if (state == LEAD_REBUILD4_STATE) { checkReplied(peerIp); - if (allReplied()){ + if (allReplied()) { setState(LEAD_NORMAL1_STATE); } } @@ -1400,8 +1400,8 @@ void *udpListen() { } } } - if (state == REBUILD4_STATE){ - switch (fillStatus){ + if (state == REBUILD4_STATE) { + switch (fillStatus) { case 0: dhtLog("udpListen(): ERROR: fillStatus=0 in REBUILD4_STATE\n"); break; @@ -1423,8 +1423,8 @@ void *udpListen() { break; } } - if (state == LEAD_REBUILD3_STATE){ - switch (fillStatus){ + if (state == LEAD_REBUILD3_STATE) { + switch (fillStatus) { case 0: dhtLog("udpListen(): ERROR: fillStatus=0 in LEAD_REBUILD3_STATE\n"); break; @@ -1432,7 +1432,7 @@ void *udpListen() { break; case 2: //I'm done, now is everybody else also done? - if (allReplied()){ + if (allReplied()) { fillStatus = 0; setState(LEAD_REBUILD4_STATE); outBuffer[0] = RESUME_NORMAL_CMD; @@ -1448,14 +1448,14 @@ void *udpListen() { break; } } - if (timerSet){ + if (timerSet) { gettimeofday(&now, NULL); - if (timercmp(&now, &timer, >)){ - if (timeoutCntr < retry_vals[state]){ + if (timercmp(&now, &timer, >)) { + if (timeoutCntr < retry_vals[state]) { timeoutCntr++; timeradd(&now, &timeout_vals[state], &timer); dhtLog("udpListen(): retry: %d\n", timeoutCntr); - switch (state){ + switch (state) { case INIT1_STATE: outBuffer[0] = WHO_IS_LEADER_CMD; udpSend(outBuffer, 1, seed); @@ -1474,7 +1474,7 @@ void *udpListen() { break; case ELECT2_STATE: - if (electionOriginator == myHostData.ipAddr){ //retry notify leader + if (electionOriginator == myHostData.ipAddr) { //retry notify leader outBuffer[0] = CONGRATS_CMD; write2(&outBuffer[1], numHosts); memcpy(&outBuffer[3], hostArray, sizeof(struct hostData) @@ -1552,7 +1552,7 @@ void *udpListen() { { dhtLog("udpListen(): timed out in state %s after %d retries\n", state_names[state], timeoutCntr); - switch (state){ + switch (state) { case INIT1_STATE: setState(EXIT2_STATE); break; @@ -1570,9 +1570,9 @@ void *udpListen() { dhtLog("after\n"); writeHostList(); setState(ELECT2_STATE); - if (electionOriginator == myHostData.ipAddr){ + if (electionOriginator == myHostData.ipAddr) { leader = hostArray[0].ipAddr; - if (leader == myHostData.ipAddr){ //I am the leader + if (leader == myHostData.ipAddr) { //I am the leader dhtLog("I am the leader!\n"); setState(LEAD_REBUILD1_STATE); outBuffer[0] = REBUILD_CMD; diff --git a/Robust/src/Runtime/DSTM/interface/dstmserver.c b/Robust/src/Runtime/DSTM/interface/dstmserver.c index b6317037..c1e36c8b 100644 --- a/Robust/src/Runtime/DSTM/interface/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface/dstmserver.c @@ -306,7 +306,7 @@ int readClientReq(trans_commit_data_t *transinfo, int acceptfd) { /* Create an array of oids for modified objects */ oidmod = (unsigned int *) calloc(fixed.nummod, sizeof(unsigned int)); - if (oidmod == NULL){ + if (oidmod == NULL) { printf("calloc error %s, %d\n", __FILE__, __LINE__); return 1; } @@ -774,7 +774,7 @@ checkversion: UnLock(STATUSPTR(header)); } else { UnLock(STATUSPTR(header)); - if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0){ + if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("processReqNotify():socket()"); return; } @@ -783,7 +783,7 @@ checkversion: remoteAddr.sin_port = htons(LISTEN_PORT); remoteAddr.sin_addr.s_addr = htonl(mid); - if (connect(sd, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0){ + if (connect(sd, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0) { printf("Error: processReqNotify():error %d connecting to %s:%d\n", errno, inet_ntoa(remoteAddr.sin_addr), LISTEN_PORT); close(sd); diff --git a/Robust/src/Runtime/DSTM/interface/ip.c b/Robust/src/Runtime/DSTM/interface/ip.c index 81237854..d5c6b45a 100644 --- a/Robust/src/Runtime/DSTM/interface/ip.c +++ b/Robust/src/Runtime/DSTM/interface/ip.c @@ -67,7 +67,7 @@ unsigned int getMyIpAddr(const char *interfaceStr) { memset(&interfaceInfo, 0, sizeof(struct ifreq)); - if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){ + if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("getMyIpAddr():socket()"); return 1; } @@ -75,7 +75,7 @@ unsigned int getMyIpAddr(const char *interfaceStr) { strcpy(interfaceInfo.ifr_name, interfaceStr); myAddr->sin_family = AF_INET; - if(ioctl(sock, SIOCGIFADDR, &interfaceInfo) != 0){ + if(ioctl(sock, SIOCGIFADDR, &interfaceInfo) != 0) { perror("getMyIpAddr():ioctl()"); return 1; } diff --git a/Robust/src/Runtime/DSTM/interface/mlookup.c b/Robust/src/Runtime/DSTM/interface/mlookup.c index 21951a10..4d5c6263 100644 --- a/Robust/src/Runtime/DSTM/interface/mlookup.c +++ b/Robust/src/Runtime/DSTM/interface/mlookup.c @@ -195,10 +195,10 @@ unsigned int *mhashGetKeys(unsigned int *numKeys) { keys = calloc(*numKeys, sizeof(unsigned int)); keyindex = 0; - for (i = 0; i < mlookup.size; i++){ - if (mlookup.table[i].key != 0){ + for (i = 0; i < mlookup.size; i++) { + if (mlookup.table[i].key != 0) { curr = &mlookup.table[i]; - while (curr != NULL){ + while (curr != NULL) { keys[keyindex++] = curr->key; curr = curr->next; } diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 8b18916f..3eaa411d 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -131,7 +131,7 @@ inline int arrayLength(int *array) { inline int findmax(int *array, int arraylength) { int max, i; max = array[0]; - for(i = 0; i < arraylength; i++){ + for(i = 0; i < arraylength; i++) { if(array[i] > max) { max = array[i]; } @@ -307,7 +307,7 @@ void randomdelay() { /* This function initializes things required in the transaction start*/ transrecord_t *transStart() { transrecord_t *tmp; - if((tmp = calloc(1, sizeof(transrecord_t))) == NULL){ + if((tmp = calloc(1, sizeof(transrecord_t))) == NULL) { printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__); return NULL; } @@ -332,7 +332,7 @@ objheader_t *transRead(transrecord_t *record, unsigned int oid) { return NULL; } - if((objheader = chashSearch(record->lookupTable, oid)) != NULL){ + if((objheader = chashSearch(record->lookupTable, oid)) != NULL) { #ifdef TRANSSTATS nchashSearch++; #endif @@ -595,7 +595,7 @@ int transCommit(transrecord_t *record) { for (i = 0; i < threadnum; i++) { rc = pthread_join(thread[i], NULL); - if(rc){ + if(rc) { printf("Error: return code from pthread_join() is %d\n", rc); pthread_cond_destroy(&tcond); pthread_mutex_destroy(&tlock); @@ -858,7 +858,7 @@ void decideResponse(thread_data_array_t *tdata) { /* clear objects from prefetch cache */ cleanPCache(tdata); #endif - } else if(transagree == tdata->buffer->f.mcount){ + } else if(transagree == tdata->buffer->f.mcount) { /* Send Commit */ *(tdata->replyctrl) = TRANS_COMMIT; *(tdata->replyretry) = 0; @@ -1048,7 +1048,7 @@ void *handleLocalReq(void *threadarg) { pthread_cond_wait(localtdata->tdata->threshold, localtdata->tdata->lock); } pthread_mutex_unlock(localtdata->tdata->lock); - if(*(localtdata->tdata->replyctrl) == TRANS_ABORT){ + if(*(localtdata->tdata->replyctrl) == TRANS_ABORT) { if(transAbortProcess(localtdata) != 0) { printf("Error in transAbortProcess() %s,%d\n", __FILE__, __LINE__); fflush(stdout); @@ -1191,7 +1191,7 @@ prefetchpile_t *foundLocal(char *ptr) { goto tuple; } //Entire prefetch is local - if (newbase==endindex&&checkoid(oid)){ + if (newbase==endindex&&checkoid(oid)) { numLocal++; goto tuple; } @@ -1465,7 +1465,7 @@ int startRemoteThread(unsigned int oid, unsigned int mid) { int bytesSent; int status; - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){ + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("startRemoteThread():socket()"); return -1; } @@ -1475,7 +1475,7 @@ int startRemoteThread(unsigned int oid, unsigned int mid) { remoteAddr.sin_port = htons(LISTEN_PORT); remoteAddr.sin_addr.s_addr = htonl(mid); - if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0){ + if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0) { printf("startRemoteThread():error %d connecting to %s:%d\n", errno, inet_ntoa(remoteAddr.sin_addr), LISTEN_PORT); status = -1; @@ -1494,7 +1494,7 @@ int startRemoteThread(unsigned int oid, unsigned int mid) { static unsigned int id = 0xFFFFFFFF; unsigned int getNewOID(void) { id += 2; - if (id > oidMax || id < oidMin){ + if (id > oidMax || id < oidMin) { id = (oidMin | 1); } return id; @@ -1510,7 +1510,7 @@ int processConfigFile() { in_addr_t tmpAddr; configFile = fopen(CONFIG_FILENAME, "r"); - if (configFile == NULL){ + if (configFile == NULL) { printf("error opening %s:\n", CONFIG_FILENAME); perror(""); return -1; @@ -1520,14 +1520,14 @@ int processConfigFile() { sizeOfHostArray = 8; hostIpAddrs = calloc(sizeOfHostArray, sizeof(unsigned int)); - while(fgets(lineBuffer, maxLineLength, configFile) != NULL){ + while(fgets(lineBuffer, maxLineLength, configFile) != NULL) { commentBegin = strchr(lineBuffer, '#'); if (commentBegin != NULL) *commentBegin = '\0'; token = strtok(lineBuffer, delimiters); - while (token != NULL){ + while (token != NULL) { tmpAddr = inet_addr(token); - if ((int)tmpAddr == -1){ + if ((int)tmpAddr == -1) { printf("error in %s: bad token:%s\n", CONFIG_FILENAME, token); fclose(configFile); return -1; @@ -1539,7 +1539,7 @@ int processConfigFile() { fclose(configFile); - if (numHostsInSystem < 1){ + if (numHostsInSystem < 1) { printf("error in %s: no IP Adresses found\n", CONFIG_FILENAME); return -1; } @@ -1549,7 +1549,7 @@ int processConfigFile() { myIpAddr = getMyIpAddr("eth0"); #endif myIndexInHostArray = findHost(myIpAddr); - if (myIndexInHostArray == -1){ + if (myIndexInHostArray == -1) { printf("error in %s: IP Address of eth0 not found\n", CONFIG_FILENAME); return -1; } @@ -1569,7 +1569,7 @@ void addHost(unsigned int hostIp) { if (findHost(hostIp) != -1) return; - if (numHostsInSystem == sizeOfHostArray){ + if (numHostsInSystem == sizeOfHostArray) { tmpArray = calloc(sizeOfHostArray * 2, sizeof(unsigned int)); memcpy(tmpArray, hostIpAddrs, sizeof(unsigned int) * numHostsInSystem); free(hostIpAddrs); @@ -1614,7 +1614,7 @@ int reqNotify(unsigned int *oidarry, unsigned short *versionarry, unsigned int n return; } - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){ + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("reqNotify():socket()"); return -1; } @@ -1645,7 +1645,7 @@ int reqNotify(unsigned int *oidarry, unsigned short *versionarry, unsigned int n } /* Send number of oids, oidarry, version array, machine id and threadid */ - if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0){ + if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0) { printf("reqNotify():error %d connecting to %s:%d\n", errno, inet_ntoa(remoteAddr.sin_addr), LISTEN_PORT); free(ndata); @@ -1704,16 +1704,16 @@ void threadNotify(unsigned int oid, unsigned short version, unsigned int tid) { return; } else { for(i = 0; i < ndata->numoid; i++) { - if(ndata->oidarry[i] == oid){ + if(ndata->oidarry[i] == oid) { objIsFound = 1; index = i; } } - if(objIsFound == 0){ + if(objIsFound == 0) { printf("threadNotify(): Oid not found %s, %d\n", __FILE__, __LINE__); return; } else { - if(version <= ndata->versionarry[index]){ + if(version <= ndata->versionarry[index]) { printf("threadNotify(): New version %d has not changed since last version for oid = %d, %s, %d\n", version, oid, __FILE__, __LINE__); return; } else { @@ -1741,7 +1741,7 @@ int notifyAll(threadlist_t **head, unsigned int oid, unsigned int version) { ptr = *head; mid = ptr->mid; //create a socket connection to that machine - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){ + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("notifyAll():socket()"); return -1; } @@ -1751,7 +1751,7 @@ int notifyAll(threadlist_t **head, unsigned int oid, unsigned int version) { remoteAddr.sin_port = htons(LISTEN_PORT); remoteAddr.sin_addr.s_addr = htonl(mid); //send Thread Notify response and threadid to that machine - if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0){ + if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0) { printf("notifyAll():error %d connecting to %s:%d\n", errno, inet_ntoa(remoteAddr.sin_addr), LISTEN_PORT); fflush(stdout); diff --git a/Robust/src/Runtime/multicoretask.c b/Robust/src/Runtime/multicoretask.c index 11680236..06d36412 100644 --- a/Robust/src/Runtime/multicoretask.c +++ b/Robust/src/Runtime/multicoretask.c @@ -258,7 +258,7 @@ int main(int argc, char **argv) { thread_data_array[i].numreceiveobjs = 0; printf("[main] creating thread %d\n", i); rc[i] = pthread_create(&threads[i], NULL, run, (void *)&thread_data_array[i]); - if (rc[i]){ + if (rc[i]) { printf("[main] ERROR; return code from pthread_create() is %d\n", rc[i]); fflush(stdout); exit(-1); @@ -511,7 +511,7 @@ void run(void* arg) { #ifdef RAWDEBUG raw_test_pass(0xee13); #endif - while(halt--){ + while(halt--) { } isfirst = false; #ifdef RAWDEBUG @@ -703,7 +703,7 @@ void createstartupobject(int argc, char ** argv) { int hashCodetpd(struct taskparamdescriptor *ftd) { int hash=(int)ftd->task; int i; - for(i=0; inumParameters; i++){ + for(i=0; inumParameters; i++) { hash^=(int)ftd->parameterArray[i]; } return hash; @@ -2877,7 +2877,7 @@ backtrackinit: tpd->task=task; tpd->numParameters=numiterators+1; tpd->parameterArray=RUNMALLOC(sizeof(void *)*(numiterators+1)); - for(j=0; j<=numiterators; j++){ + for(j=0; j<=numiterators; j++) { tpd->parameterArray[j]=taskpointerarray[j]; //store the actual parameters } /* Enqueue task */ @@ -2955,7 +2955,7 @@ backtrackinit: tpd->task=task; tpd->numParameters=numiterators+1; tpd->parameterArray=RUNMALLOC_I(sizeof(void *)*(numiterators+1)); - for(j=0; j<=numiterators; j++){ + for(j=0; j<=numiterators; j++) { tpd->parameterArray[j]=taskpointerarray[j]; //store the actual parameters } /* Enqueue task */ @@ -3186,7 +3186,7 @@ newtask: if(hashsize(activetasks) == 1) { // only one task right now, wait a little while before next try int halt = 10000; - while(halt--){ + while(halt--) { } } goto newtask; @@ -3404,11 +3404,11 @@ parameterpresent: }*/ /* Actually call task */ #ifdef PRECISE_GC - ((int *)taskpointerarray)[0]=currtpd->numParameters; + ((int *)taskpointerarray)[0]=currtpd->numParameters; taskpointerarray[1]=NULL; #endif execute: - if(debugtask){ + if(debugtask) { #ifndef RAW printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount)); #endif diff --git a/Robust/src/Runtime/task.c b/Robust/src/Runtime/task.c index e44a0737..fd325fd4 100644 --- a/Robust/src/Runtime/task.c +++ b/Robust/src/Runtime/task.c @@ -85,7 +85,7 @@ void createstartupobject(int argc, char ** argv) { int hashCodetpd(struct taskparamdescriptor *ftd) { int hash=(int)ftd->task; int i; - for(i=0; inumParameters; i++){ + for(i=0; inumParameters; i++) { hash^=(int)ftd->parameterArray[i]; } return hash; @@ -301,7 +301,7 @@ int flagcomp(const int *val1, const int *val2) { void flagorand(void * ptr, int ormask, int andmask) { #ifdef OPTIONAL struct ___Object___ * obj = (struct ___Object___ *)ptr; - if(obj->numfses){ /*store the information about fses*/ + if(obj->numfses) { /*store the information about fses*/ int flag, i, j,counter, offset=0; for(i=0; inumfses; i++) { int oldoffset; @@ -444,7 +444,7 @@ nextloop: int checktags(struct ___Object___ * currobj, struct fsanalysiswrapper * fswrapper) { /* Check Tags */ struct ___Object___ * tagptr = currobj->___tags___; - if(fswrapper->numtags>0){ + if(fswrapper->numtags>0) { if (tagptr==NULL) return 0; //that means the object has no tag but that param //needs tag @@ -901,7 +901,7 @@ int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *pr /* Find initial state */ for(j=0; jiterators[j], taskpointerarray OPTARG(failed))){ + if(toiHasNext(¶meter->iterators[j], taskpointerarray OPTARG(failed))) { toiNext(¶meter->iterators[j], taskpointerarray OPTARG(failed)); } else if (j>0) { /* Need to backtrack */ @@ -925,7 +925,7 @@ backtrackinit: #ifdef OPTIONAL tpd->failed=RUNMALLOC(sizeof(int)*(numiterators+1)); #endif - for(j=0; j<=numiterators; j++){ + for(j=0; j<=numiterators; j++) { tpd->parameterArray[j]=taskpointerarray[j]; //store the actual parameters #ifdef OPTIONAL tpd->failed[j]=failed[j]; @@ -951,7 +951,7 @@ backtrackinit: for(j=numiterators-1; jiterators[j], taskpointerarray OPTARG(failed))){ + if(toiHasNext(¶meter->iterators[j], taskpointerarray OPTARG(failed))) { toiNext(¶meter->iterators[j], taskpointerarray OPTARG(failed)); } else if (j>0) { /* Need to backtrack */ @@ -1177,7 +1177,7 @@ parameterpresent: restorecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, checkpoint, forward, reverse); #ifdef OPTIONAL - for(counter=0; countertask->numParameters; counter++){ + for(counter=0; countertask->numParameters; counter++) { //enqueue as failed enqueueoptional(currtpd->parameterArray[counter], numfsesarray[counter], fsesarray[counter], currtpd->task, counter); @@ -1200,7 +1200,7 @@ parameterpresent: } /* Actually call task */ #ifdef PRECISE_GC - ((int *)taskpointerarray)[0]=currtpd->numParameters; + ((int *)taskpointerarray)[0]=currtpd->numParameters; taskpointerarray[1]=NULL; #endif #ifdef OPTIONAL @@ -1211,7 +1211,7 @@ parameterpresent: ((struct ___Object___ *)taskpointerarray[i+OFFSET])->fses=fsesarray[i]; } #endif - if(debugtask){ + if(debugtask) { printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount)); ((void(*) (void **))currtpd->task->taskptr)(taskpointerarray); printf("EXIT %s count=%d\n",currtpd->task->name, (instaccum-instructioncount)); diff --git a/Robust/src/c.cfg b/Robust/src/c.cfg index 9348f9f7..0bd5843a 100644 --- a/Robust/src/c.cfg +++ b/Robust/src/c.cfg @@ -28,3 +28,4 @@ sp_brace_else = Add sp_catch_brace = Add sp_brace_catch = Add sp_try_brace = Add +sp_after_sparen = Add \ No newline at end of file diff --git a/Robust/src/java.cfg b/Robust/src/java.cfg index 545f6e79..fa02b056 100644 --- a/Robust/src/java.cfg +++ b/Robust/src/java.cfg @@ -28,4 +28,5 @@ sp_else_brace = Add sp_brace_else = Add sp_catch_brace = Add sp_brace_catch = Add -sp_try_brace = Add \ No newline at end of file +sp_try_brace = Add +sp_after_sparen = Add \ No newline at end of file