The Community for Technology Leaders
RSS Icon
Subscribe
Issue No.03 - May/June (2008 vol.34)
pp: 357-376
Saurabh Srivastava , University of Maryland at College Park, College Park
Michael Hicks , University of Maryland at College Park, College Park
Jeffrey S. Foster , University of Maryland at College Park, College Park
Patrick Jenkins , University of Maryland at College Park, College Park
ABSTRACT
This paper presents CMod, a novel tool that provides a sound module system for C. CMod works by enforcing four rules that are based on principles of modular reasoning and on current programming practice. CMod's rules flesh out the convention that .h header files are module interfaces and .c source files are module implementations. Although this convention is well-known, existing explanations of it are incomplete, omitting important subtleties needed for soundness. In contrast, we have proven formally that CMod's rules enforce both information hiding and type-safe linking. To use CMod, the programmer develops and builds their software as usual, redirecting the compiler and linker to CMod's wrappers. We evaluated CMod by applying it to 30 open source programs, totaling more than one million LoC. Violations to CMod's rules revealed more than a thousand information hiding errors, dozens of typing errors, and hundreds of cases that, although not currently bugs, make programming mistakes more likely as the code evolves. At the same time, programs generally adhere to the assumptions underlying CMod's rules, and so we could fix rule violations with a modest effort. We conclude that CMod can effectively support modular programming in C: it soundly enforces type-safe linking and information-hiding while being largely compatible with existing practice.
INDEX TERMS
Coding Tools and Techniques, Modules, packages, Reliability, Code design, Information hiding
CITATION
Saurabh Srivastava, Michael Hicks, Jeffrey S. Foster, Patrick Jenkins, "Modular Information Hiding and Type-Safe Linking for C", IEEE Transactions on Software Engineering, vol.34, no. 3, pp. 357-376, May/June 2008, doi:10.1109/TSE.2008.25
REFERENCES
[1] M. Blume and A.W. Appel, “Hierarchical Modularity,” ACM Trans. Programming Languages and Systems, vol. 21, no. 4, pp. 813-847, 1999.
[2] L. Cannon, R. Elliott, L. Kirchoff, J. Miller, R. Mitze, E. Schan, N. Whittington, H. Spencer, D. Keppel, and M. Brader, Recommended C Style and Coding Standards, sixth ed., 1990.
[3] L. Cardelli, “Program Fragments, Linking, and Modularization,” Proc. 24th ACM SIGPLAN-SIGACT Symp. Principles of Programming Languages, pp. 266-277, 1997.
[4] http://www.cs.umd.edu/projects/PLCMod/, 2008.
[5] “COM: Component Object Model Technologies,” http://www.microsoft.com/comdefault.mspx , 2008.
[6] J. Condit, M. Harren, Z. Anderson, D. Gay, and G.C. Necula, “Dependent Types for Low-Level Programming,” Proc. European Symp. Programming, 2007.
[7] B. Cox and A. Novobilski, Object Oriented Programming: An Evolutionary Approach. Addison-Wesley, 1991.
[8] “Exhuberant Ctags,” http:/ctags.sourceforge.net/, 2008.
[9] M.D. Ernst, G.J. Badros, and D. Notkin, “An Empirical Analysis of C Preprocessor Use,” IEEE Trans. Software Eng., vol. 28, no. 12, Dec. 2002.
[10] J.-M. Favre, “CPP Denotational Semantics,” Proc. Third IEEE Int'l Workshop Source Code Analysis and Manipulation, 2003.
[11] M. Flatt and M. Felleisen, “Units: Cool Modules for HOT Languages,” Proc. ACM SIGPLAN Conf. Programming Language Design and Implementation, pp. 236-248, June 1998.
[12] N. Glew and G. Morrisett, “Type-Safe Linking and Modular Assembly Language,” Proc. 26th ACM SIGPLAN-SIGACT Symp. Principles of Programming Languages, 1999.
[13] “Once-Only Headers—the C Preprocessor,” http://gcc.gnu.org/onlinedocs/cppOnce_002dOnly-Headers.html#Once_002dOnly-Headers , 2008.
[14] T. Jim, J.G. Morrisett, D. Grossman, M.W. Hicks, J. Cheney, and Y. Wang, “Cyclone: A Safe Dialect of C,” Proc. USENIX Ann. Technical Conf., 2002.
[15] S. Johnson, “Lint, a C Program Checker,” Technical Report 65, Bell Labs, Sept. 1977.
[16] B.W. Kernighan and R. Pike, The Practice of Programming. Addison-Wesley Professional, 1999.
[17] B.W. Kernighan and D.M. Ritchie, The C Programming Language, second ed. Prentice Hall, 1988.
[18] K.N. King, C Programming: A Modern Approach. W.W. Norton, 1996.
[19] B. McCloskey and E. Brewer, “ASTEC: A New Approach to Refactoring C,” Proc. 12th Fast Software Encryption, 2005.
[20] S. McConnell, Code Complete. Microsoft Press, 1993.
[21] R. Morris, E. Kohler, J. Jannotti, and M.F. Kaashoek, “The Click Modular Router,” Proc. 17th ACM Symp. Operating Systems Principles, 1999.
[22] G. Morrisett, personal communication, July 2006.
[23] G.C. Necula, J. Condit, M. Harren, S. McPeak, and W. Weimer, “CCured: Type-Safe Retrofitting of Legacy Software,” ACM Trans. Programming Languages and Systems, vol. 27, no. 3, May 2005.
[24] G.C. Necula, S. McPeak, S.P. Rahul, and W. Weimer, “CIL: Intermediate Language and Tools for Analysis and Transformation of C Programs,” Proc. 11th Int'l Conf. Compiler Construction, pp. 213-228, 2002.
[25] PC-lint/FlexeLint, http://www.gimpel.comlintinfo.htm, Product of Gimpel Software, 1999.
[26] Advanced Topics in Types and Programming Languages, B.C. Pierce, ed. MIT Press, 2005.
[27] “Precompiled Headers—Using the GNU Compiler Collection (GCC),” http://gcc.gnu.org/onlinedocs/gccPrecompiled-Headers.html , 2008.
[28] A. Reid, M. Flatt, L. Stoller, J. Lepreau, and E. Eide, “Knit: Component Composition for Systems Software,” Proc. Fourth Symp. Operating Systems Design and Implementation, 2000.
[29] D. Spuler and A. Sajeev, “Static Detection of Preprocessor Macro Errors in C,” Technical Report 92/7, James Cook Univ., 1992.
[30] S. Srivastava, M. Hicks, and J.S. Foster, “Appendix to CMod: Modular Information Hiding and Type-Safe Linking for C,” Technical Report CS-TR-4874, Univ. of Maryland, 2007.
[31] S. Srivastava, M. Hicks, and J.S. Foster, “Modular Information Hiding and Type-Safe Linking for C,” Proc. ACM SIGPLAN Int'l Workshop Types in Language Design and Implementation, pp. 3-13, Jan. 2007.
[32] W.P. Stevens, G.J. Myers, and L.L. Constantine, “Structured Design,” IBM Systems J., vol. 13, no. 2, pp. 115-139, 1974.
[33] R. van Ommering, F. van der Linden, J. Kramer, and J. Magee, “The Koala Component Model for Consumer Electronics Software,” IEEE Software, 2000.
[34] D. Vandevoorde, “Modules in C++,” Technical Report N2073=06-0143, JTC1/SC22/WG21—The C++ Standards Committee, http://www.open-std.org/jtc1/sc22/wg21/docs/ papers/2006n2073.pdf, Sept. 2006.
19 ms
(Ver 2.0)

Marketing Automation Platform Marketing Automation Tool