Its so funny you mentioned one for apple. I stumbled across this apple site the other day. It has an amazing amount of source code for everyhting on the mac. Check it out.
For linux you might want to check out the fsf haven't really delved into it though.
[edit]Just wanted to add that waldo is correct about each os being different and such. that's an obvious point. The apple site allows you to code in C as well as some other languages as well. hope that helps[/edit]