auxiliary check since it is an extra rule for how the interfaces should called.
*/
-/**
- @Begin
- @Options:
- LANG = C;
- @Global_define:
- @DeclareVar:
- bool writer_lock_acquired;
- int reader_lock_cnt;
- @InitVar:
- writer_lock_acquired = false;
- reader_lock_cnt = 0;
- @Happens_before:
- # Since commit_point_set has no ID attached, A -> B means that for any B,
- # the previous A happens before B.
- #Read_Unlock -> Read_Lock
- Read_Unlock -> Write_Lock
- Read_Unlock -> Write_Trylock(HB_Write_Trylock_Succ)
- #Read_Unlock -> Read_Trylock(HB_Read_Trylock_Succ)
-
- Write_Unlock -> Write_Lock
- Write_Unlock -> Write_Trylock(HB_Write_Trylock_Succ)
-
- Write_Unlock -> Read_Lock
- Write_Unlock -> Read_Trylock(HB_Read_Trylock_Succ)
-
+/** @DeclareState:
+ bool writer_lock_acquired;
+ int reader_lock_cnt;
+ @Initial: writer_lock_acquired = false;
+ reader_lock_cnt = 0;
@Commutativity: Read_Lock <-> Read_Lock: true
@Commutativity: Read_Lock <-> Read_Unlock: true
@Commutativity: Read_Lock <-> Read_Trylock: true
@Commutativity: Write_Trylock <-> Write_Trylock: !_Method1.__RET__ || !_Method2.__RET__
@Commutativity: Write_Trylock <-> Write_Unlock: !_Method1.__RET__
@Commutativity: Write_Trylock <-> Write_Lock: !_Method1.__RET__
- @End
*/
static inline int read_can_lock(rwlock_t *lock)
}
static public void main(String[] args) {
- String[] dirNames = { Environment.REGISTER };
+ String[] dirNames = { Environment.REGISTER, Environment.MS_QUEUE, Environment.LINUXRWLOCKS, Environment.MCS_LOCK };
for (int i = 0; i < dirNames.length; i++) {
String dirName = dirNames[i];
code.addLine("");
// Users included headers
+ // FIXME: We don't add user-defined headers, but as a workaround we only add forward class.
code.addLine(ShortComment("User included headers go here"));
for (String header : headerFiles) {
code.addLine(IncludeHeader(header));
}
code.addLine("");
+
+// code.addLine(ShortComment("Forward declaration goes here"));
+// for (String type : extractor.forwardClass) {
+// code.addLine("class " + type + ";");
+// }
+// code.addLine("");
code.addLine("using namespace std;");
code.addLine("");
public final static String REGISTER = "register";
public final static String MS_QUEUE = "ms-queue";
public final static String LINUXRWLOCKS = "linuxrwlocks";
+ public final static String MCS_LOCK = "mcs-lock";
}
if (type.equals("int") || type.equals("unsigned")
|| type.equals("unsigned int")
|| type.equals("int unsigned") || type.equals("double")
- || type.equals("double")) {
+ || type.equals("double") || type.equals("bool")) {
// NEW->x = OLD->x;
code.addLine(SpecNaming.NewStateInst + "->" + name + " = "
+ SpecNaming.OldStateInst + "->" + name + ";");
public final HashMap<File, EntryConstruct> entryMap;
public final HashSet<String> headerFiles;
+
+ // In the generated header file, we need to forward the user-defined
+ public final HashSet<String> forwardClass;
private GlobalConstruct globalConstruct;
OPLabelSet = new HashSet<String>();
entryMap = new HashMap<File, EntryConstruct>();
headerFiles = new HashSet<String>();
+ forwardClass = new HashSet<String>();
globalConstruct = null;
}
line = lineReader.readLine();
lineNum = lineReader.getLineNumber();
construct.processFunctionDeclaration(line);
+
+ // Record those user-defined struct
+ // RET
+ String returnType = construct.getFunctionHeader().returnType;
+ if (SpecUtils.isUserDefinedStruct(returnType))
+ forwardClass.add(SpecUtils.getPlainType(returnType));
+ // Arguments
+ for (VariableDeclaration decl : construct.getFunctionHeader().args) {
+ if (SpecUtils.isUserDefinedStruct(decl.type))
+ forwardClass.add(SpecUtils.getPlainType(decl.type));
+ }
+
} catch (IOException e) {
errMsg = "Spec error in file \""
+ file.getName()
* annotations or the beginning line of the next primitive
* @throws WrongAnnotationException
*/
- public static Primitive extractPrimitive(File file, int beginLineNum,
- ArrayList<String> annotations, IntObj curIdx)
+ public static Primitive extractPrimitive(File file, int beginLineNum, ArrayList<String> annotations, IntObj curIdx)
throws WrongAnnotationException {
if (curIdx.getVal() == annotations.size()) // The current index points
// to the end
}
// Assert that we must have found one primitive
if (primitive == null) {
- WrongAnnotationException
- .err(file, curLineNum,
- "Something is wrong! We must have found one primitve here!\n");
+ WrongAnnotationException.err(file, curLineNum,
+ "Something is wrong! We must have found one primitve here!\n");
}
// Process the current "primitive"
primitive.addLine(trimmedCode);
}
} else {
- WrongAnnotationException
- .err(file, curLineNum,
- "The state annotation should have correct primitive syntax (sub-annotations)");
+ WrongAnnotationException.err(file, curLineNum,
+ "The state annotation should have correct primitive syntax (sub-annotations)");
}
// Deal with other normal line. E.g. y = 1;
if (primitive.contents.size() == 0) { // The content of the primitive is
// empty
- WrongAnnotationException.warning(file, curLineNum, "Primitive "
- + primitive.name + " is empty.");
+ WrongAnnotationException.warning(file, curLineNum, "Primitive " + primitive.name + " is empty.");
}
return primitive;
}
return null;
}
}
+
+ public static boolean isUserDefinedStruct(String type) {
+ // FIXME: We only consider the type is either a one-level pointer or a
+ // struct
+ String bareType = trimSpace(type.replace('*', ' '));
+ return !bareType.equals("int") && !bareType.matches("unsigned\\s+int") && !bareType.equals("unsigned")
+ && !bareType.equals("bool") && !bareType.equals("double") && !bareType.equals("float")
+ && !bareType.equals("void");
+ }
+
+ public static String getPlainType(String type) {
+ // FIXME: We only consider the type is either a one-level pointer or a
+ // struct
+ String bareType = trimSpace(type.replace('*', ' '));
+ return bareType;
+ }
}