Favorite Comments and Constants in OpenSolaris Source
While perusing the code for OpenSolaris, my fellow interns and I have come across some great comments, variable names, and documentation, as any large code base must inevitably have:- usr/src/uts/common/os/clock.c: "If the TOD chip isn't giving correct time, then set it to the time that was passed in as a rough estimate. If we don't have an estimate, then set the clock back to a time when Oliver North, ALF and Dire Straits were all on the collective brain: 1987." (Found by Dan)
- usr/src/uts/i86pc/os/machdep.c: "This routine is almost correct now, but not quite." (also from Dan)
- usr/src/uts/common/os/condvar.c: Regarding
cv_wait_stop(), "This is a horrible kludge. It is evil. It is vile. It is swill. If your code has to call this function then your code is the same." - usr/src/uts/common/sys/dumphdr.h: The magic number at the start of all core dumps:
#define DUMP_MAGIC 0xdefec8edU /* dump magic number */
- usr/src/lib/watchmalloc/common/malloc.c: While poking around in mdb, I printed the words at the end of an array and found
0xbaddcabband0xfeedface. So I opened the OS source browser, searched, and found:/* * Patterns to be copied into freed blocks and allocated blocks. * 0xfeedbeef and 0xfeedface are invalid pointer values in all programs. */ static uint64_t patterns[2] = { 0xdeadbeefdeadbeefULL, /* pattern in a freed block */ 0xbaddcafebaddcafeULL /* pattern in an allocated block */ }; - Earlier today I found out that the Solaris libc defines a struct uberdata. It ends up being used on the sly in the psig command.
- For a good time, follow
int bsd_evil_hackthrough the grub source.
Posted by csg [Personal] ( August 01, 2007 02:58 PM ) Permalink | Comments[1]
