Cole, a Win64 Porting Tool

Cole (named after Cole Porter) is a program under continuous development to help you change your programs so that they compile under both the ILP32 data model and the P64 data model. In the ILP32 data model, all Integers, Longs, and Pointers (ILP) are 32 bits long. In P64, all pointers are 64 bit quantities. If your code assumes that a pointer is 32 bits long, it will break under P64, and if your code assumes pointers are 64 bits longs, your code will break under ILP32. To have your code work properly under both models, you must use abstract types, defined via the typedef mechanism, to define integral values that are meant to hold or refer to pointers as integrals. These typedefs isolate the particular representation of pointers allowing your code to work independently of pointer size.

In summary, the Win64 Abstract Type System as enforced by Cole, has the following rules:

When Cole finds a type violation, it suggests a possible remediation. For example, when Cole discovers that an integral variable, say "long i", needs to have pointer-precision size, because of statement "i = (long) pfoo", Cole will suggest that "pfoo" be cast to "LONG_PTR" and that "i" be declared to have type "LONG_PTR". In addition, the error message will give the precise source address where "i" is declared, and an error message will occur for the declaration site, as well. Cole performs limited interprocedural type propagation so that as much can be remediated in one use of Cole as possible.

Cole reports violations of its type rules, and all suspicious coding idioms. Cole detects and reports

Until the halting problem becomes decidable, Cole is unable to catch type violations due to union types. That is, using union types, a value can be written as, say, a pointer type, but read as ULONG, which may or may not read enough bytes depending on whether the underlying platform is ILP32 or P64.

Environment Variables

Cole is controlled by three environment variables, all of which have reasonable default values.

Cole Status

We make no guarantees of Cole's performance on Alpha specific programs. The Alpha C++ front end extends C++ in ways that Cole has not yet been taught about.

Reading the Output

Cole displays type errors using a three-frame Html window. The left frame lists, as a tree, the files that Cole has examined, the middle frame lists the errors in a given file, and the right frame display code, with errors highlighted in red.

For those type errors that require changing the source code far away from the type error (for example, when a variable or type declaration should change), hyperlinks on the type error take you to the declarations that must be changed. Declarations that must be changed hyperlink (one of) the cast(s) that force it to be changed. Tooltips explain the error for all highlighted items.

Errors are categorized, and you can turn on and off error reporting by category. The options "button" on the Cole banner will yield check boxes for each class of error. As error categories are enabled/disabled, a count of the number of issues remaining is updated. Due to unforseen limitations in the implementation of JavaScript, the realtime updating of error categories can take considerable time (30 seconds for all the files in Word, for example, on a Xeon processor).

It readily becomes apparent that Cole would be even more powerful if it could peer into macro definitions. The C/C++ front end we use assigns all constituent elements of a macro the same source position information, namely, the invocation site of a macro. When macro invocations are highlighted, it means the error is either in its definition, or in its arguments.