O'Reilly logo

Shared Source CLI Essentials by Ted Neward, Geoff Shilling, David Stutz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Porting Rotor

So, you’re thinking of moving the SSCLI code base onto another operating system or targeting a hot new experimental processor. What is involved?

Besides basic portability hygiene, such as using the portability macros found sscli/clr/src/inc/palclr.h and the endian and CPU-specific conditional compilation switches, there are several areas of Rotor that present unique challenges. The PAL, the JIT compiler, and the execution engine each have code that must be modified for every port. To help you make these modifications, many of the spots that have platform-specific code have been written to compile correctly when moved to a new CPU platform, using conditionally compiled code that will either assert or issue a warning when run. The PORTABILITY_ASSERT and PORTABILITY_WARNING macros, defined in clr/src/inc/palclr.h, are used for this purpose, as follows:

    #if defined(_X86_)
      _ASSERTE(SOMETHINGTOCHECK > SOMEVALUE);
      // x86 code here
    #elif defined(_AMD64_) || defined(_PPC_)
      // other code here
    #else
      PORTABILITY_ASSERT("Calling convention not specified for new platform");
    #endif

Using grep or findstr to search for “PORTABILITY,” “PPC,” “UNIX,” “APPLE,” and other related strings will help find these spots, and indicate the size of the task at hand.

Also important to consider is the toolchain that you will be using: many small incompatibilities and differences exist between compilers (and even versions of the same compiler), and if you propose using a compiler that has ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required