
OS X 10.10 – Source Code - beltex
http://opensource.apple.com/release/os-x-1010/
======
chollida1
I opened one package at random

[http://opensource.apple.com/source/IOFWDVComponents/IOFWDVCo...](http://opensource.apple.com/source/IOFWDVComponents/IOFWDVComponents-207.4.1/DVControlComponent.c)

I see this:

#include <Carbon/Carbon.h>

//#include <Resources.h>

//#include <OSUtils.h>

//#include <Components.h>

#include "DeviceControlPriv.h"

#include "IsochronousDataHandler.h"

#include "DVVers.h"

#include <stdio.h>

#include <stdlib.h>

//#include <syslog.h>

// Debug messages

It's good to know that I'm not the only one who has commented out code in
their shipping code:)

~~~
nextweek2
This is bad practice, at best it shows a lack of confidence in what you've
written. At worse it shows you don't understand what's going on.

Version control shows the evolution of design, if you are leaving in dead code
you need to take a step back and think about the real solution.

~~~
ssmoot
I've heard this so much. Usually from people who reinvent the wheel five times
over.

I've _never_ seen anyone dig through VCS history to gain a better
understanding of code. And since presumably things change because the
understanding evolves, I'm not even sure what the thought process is that
would lead someone to do that.

You comment out code because your understanding might not be perfect, you
might want the option to easily roll-back, or even have a reminder that a
particular change was made. You'll remove it in the next revision or two.

So yeah. I've heard this before. It's complete and total nonsense IME.

~~~
benjamincburns
> I've never seen anyone dig through VCS history to gain a better
> understanding of code.

One of my favourite interview questions:

    
    
        A bug is found where given a specific series of user
        interactions an error is raised. You search for this error
        in code and you find that the error is raised in a very
        old module which was written in a different style from
        the main codebase by a developer who has long since left
        the company. From a quick look around you see that this
        code is very complex, and probably quite important. It's
        obvious that it will take quite a bit of time to 
        understand what's going on simply by just reading the
        code in the module where this error is raised.
    
        Your job is to fix the bug. How do you approach this
        problem?
    

At my company digging through VCS (and our ticketing system) in order to gain
a better understanding of code is a very common.

Edit:

I think if you're leaving commented out code for history's sake, you're Doing
It Wrong. I disagree with the GP's idealism as much as you do, however. My
beef with it is that if you're checking in commented code, you're obviously
not reviewing your own diffs. It means you're likely to commit minor changes
which were made for debugging purposes.

    
    
        // comment this, just to get this stupid module out of my way.
        //ensureNobodyDies();

~~~
ssmoot
Ticketing system sure. If you have the full history you'd get the original
requirements hopefully, and revisions or issues along the way.

VCS. Maybe it's just a Web vs Other development thing. The history of an
Action in Rails is going to be someone using mass-assignment unsafely. Or a
dozen stylistic tweaks. Or implementing a pattern. Or removing it.

It's about the worst possible way I can imagine to attempt to understand
requirements.

What I _do_ find helpful is "git blame", and just _talking_ to the person who
implemented it. And if they aren't available, then hopefully someone who was
there at the time, and involved with the feature, is. At least I have a time-
frame.

As a last resort, if no one has any clue what's going on? Scrolling through
VCS diffs would be an act of desperation perhaps. But I'd much rather look for
tests. Automated or a Manual Test Plan. A Specification. Or just use common
sense.

At the end of the day it's _most_ likely that I'm tasked with this issue
because the original implementation was a scheduling compromise, or the
original developer just couldn't think of how to make it simple, so they made
it complex.

 _Actual_ complexity is rarely justified by requirements I find. Unless I'm
the one writing it of course. ;-) Then it's absolutely the only sane way to
implement it and you just need to try harder to understand. Duh.

~~~
benjamincburns
> Actual complexity is rarely justified by requirements I find. Unless I'm the
> one writing it of course. ;-)

I appreciate your humility, and I largely agree with your approach. You'd
probably do quite well in my interview.

With respect to actual complexity rarely being justified, I'm presently a team
lead for a system which involves fairly precise modeling of some very
piecewise real world processes under very tight performance constraints. There
are so many things we just can't generalize, either because there's no clean
abstraction, or because abstraction comes with too much inefficiency. We try
to keep our processes from smelling too much like old stale spaghetti, but
unfortunately some things are just simply complex, and sometimes in the face
of such complexity the most elegant and/or performant solution can make
purists cringe.

------
jevinskie
This inspires me to update my script that converted opensource.apple.com into
Github repos [0] (even creating the repo using the Github API). It needed more
work because some of the Apple source releases are messed up and include
another copy of the source tree in a directory at the root of a tarball!

I asked Github if it was OK to upload the tens of gigabytes of source that the
entirety of opensource.apple.com is and I got a "Sure, why not?" response. =)

I think the last time I updated these repos was around 10.7 or 10.8

[0]: [https://github.com/Apple-FOSS-Mirror/](https://github.com/Apple-FOSS-
Mirror/)

Edit: I was always wondering how I could manipulate git such that anyone could
checkout my scripts and create identical git repos (same commit hashes and
all) with a single command. I am somewhat hesitant to update the repos now
because it would involve rewriting old commits since I haven't solved this
problem yet.

~~~
voltagex_
That's a brilliant idea. Couldn't you test a newer version of your script
against a new branch?

~~~
jevinskie
Yeah... once I find it on my old backups. =) Ironically, my script that
produces git repos was not itself version controlled. Lesson learned (for the
umpteenth time). I wasn't comfortable putting it public due to sloppiness and
I didn't yet have my own GitLab server. I now have the latter and am motivated
to fix the former (put the script itself on Github). =)

~~~
voltagex_
Let me know how you go. Contact details are in my profile. I've got way too
many projects to finish right now, but I'd like to boot XNU in a VM at some
point.

------
chrisBob
For those of us who don't know what we are looking at, and just see the title
of "OS X 10.10 - Source Code", is this just Darwin, or is there more here than
that?

~~~
thelibrarian
My understanding (which may be out of date) is that this is the complete OS
but without the GUI layer - it is the kernel, init system, shell, and user-
space CLI utilities. It does not include the GUI shell (Aqua), the GUI
libraries (Frameworks in OS X terminology), or GUI applications (iTunes, Mail,
Safari etc.).

~~~
comex
It would be more accurate to say that it's most of a fairly random subset of
the OS that was made open source back in the day - there's very little of
newer projects (regardless of what 'layer' of the OS they're at), including
ones that replaced older ones, some old stuff is gone, and I'm not sure it
ever really counted as complete.

Some examples:

\- The main kernel is open source (although not 100% identical to the version
in OS X), but many kernel extensions are closed source, including quite basic
stuff like disk image mounting.

\- In one open source kernel extension I'm interested in, IOUSBFamily,
functionality has been randomly disappearing in favor of empty .cpp files.
Like several of the opensource releases, it doesn't actually compile...

\- A version of CoreFoundation (C level API) is available, but not the full
thing. The Objective-C runtime is available, but the core Objective-C
libraries have never been.

\- libxpc, which is rather low-level functionality added a few releases ago,
was never open sourced; launchd is gone in this release, but before that it
didn't compile, thanks to missing xpc headers.

\- Bootloaders: BootX from PowerPC was open source, but the x86 EFI stuff was
always closed source.

\- libm is gone this release. cctools may be gone. Some libSystem libraries
such as malloc and pthread were separated out in a previous release, but not
open sourced; they're back now, though.

~~~
thelibrarian
Thanks for expanding on that - it is disappointing how Apple are releasing
less and less with each iteration.

------
reubenmorais
Here's a diff between the 10.9 package list [0] and this one:
[https://gist.github.com/anonymous/014e71ac38a4776811f7](https://gist.github.com/anonymous/014e71ac38a4776811f7)

Few changes, but some interesting things pop out, like the addition of
libmalloc and libpthread and the removal of memcached and securityd.

[0]
[http://opensource.apple.com/release/os-x-109/](http://opensource.apple.com/release/os-x-109/)

~~~
pilif
The removal of launchd is a bit of a bummer.

~~~
lambda
Not running 10.10 at the moment; did they switch to something else, or just
not release the source?

~~~
bigdubs
launchd is still the launch agent for 10.10, they probably just removed the
source for this version.

~~~
calinet6
Ah, the freedoms of permissive licenses... better than proprietary at least.

~~~
cowsandmilk
they wrote launchd. Even if they released it under GPL, as the copyright
owners, they would have the freedom to make future releases closed source.

------
voltagex_
A great, although sad post about the state of building (booting) Darwin:
[http://superuser.com/a/634080](http://superuser.com/a/634080)

------
codezero
Bummed they didn't fix the bug I submitted in vfs_syscall. In fsetxattr when
key values are too long it returns EPERM instead of ENAMETOOLONG as described
in the man page :(

Bug is not present in setxattr:
[http://opensource.apple.com/source/xnu/xnu-2782.1.97/bsd/vfs...](http://opensource.apple.com/source/xnu/xnu-2782.1.97/bsd/vfs/vfs_syscalls.c)

------
adamnemecek
The procmail source is something else
[https://opensource.apple.com/source/procmail/procmail-14/pro...](https://opensource.apple.com/source/procmail/procmail-14/procmail/src/procmail.c)

~~~
astrodust
For a real head trip, read Sendmail's.

------
3rd3
Why is iOS only disclosed up to version 6.1.3?
[https://opensource.apple.com/](https://opensource.apple.com/)

~~~
JohnTHaller
I believe Apple stopped releasing any source for iOS at that point. The open
source projects they pull from are BSD/MIT which permits and encourages closed
source usage.

~~~
saurik
WebCore and JavaScriptCore are LGPL, so they can't stop providing the source
code for their mobile builds. I sent Apple a request for disclosure a couple
days ago. In a week or so if I haven't gotten anything I will start
escalating.

~~~
orbitur
Can you not get to that stuff through the WebKit repo?

edit: Looks like you can:
[https://github.com/WebKit/webkit/tree/master/Source](https://github.com/WebKit/webkit/tree/master/Source)

This is where I was digging to find whether or not JavaScriptCore would still
work with WKWebView. Spoiler: it won't.

~~~
saurik
No: the mobile version of WebCore is different, and for example comes with
binary object blobs (which is sufficient for LGPL compliance) for source code
that Apple refuses to provide as open source. I wish I had been here earlier
to correct this misinformation :/ (though I'm also glad I've gotten in the
habit of not checking Hacker News after I comment). Note the
libWebCore_{Sim,armv7,armv7s}.a that is provided in the WebCore source
repository at opensource.apple.com.

[http://www.opensource.apple.com/source/WebCore/WebCore-1640....](http://www.opensource.apple.com/source/WebCore/WebCore-1640.28/)

It is also simply not sufficient to say "here is a repository with a lot of
code in it": you have to be able to specify what exact code was used for the
build (which is what I care about, as I'm constantly trying to analyze the
version of WebCore on the device: I have no interest in compiling my own copy
or building my own browser), and it is not the main WebCore repository's job
to keep tags or branches around for specific versions of iOS that Apple
distributes.

~~~
Igglyboo
>It is also simply not sufficient to say "here is a repository with a lot of
code in it": you have to be able to specify what exact code was used for the
build

Does the LGPL really specify that? IIRC the license is pretty vague and that
seems way too specific to hold up in court.

~~~
pb2au
The LGPL references the terms of the GPL in the context of the library
released under the license. For both versions 2 and 3 of the GPL, it states
that build instructions must be made available [1].

[1] [https://www.gnu.org/licenses/quick-guide-gplv3.html#less-
sou...](https://www.gnu.org/licenses/quick-guide-gplv3.html#less-source-to-
distribute-new-system-libraries-exception)

------
tkubacki
in recent years even MS is releasing more meaningful open source code than
Apple (eg. asp.net vnext, PCL) or I'm missing something

~~~
lolo_
Not sure they're releasing any OS code publicly though :-) internals still
have to be somewhat guessed/reverse engineered at.

~~~
Someone
There are strings attached, but it is not that hard to get access to the
Windows source code: [http://www.microsoft.com/en-
us/sharedsource/default.aspx](http://www.microsoft.com/en-
us/sharedsource/default.aspx)

------
preillyme
Yeah, I'm for sure missing launchd and memcached. But I suppose they've got
their reasons.

~~~
duskwuff
memcached is still open source. Apple's just no longer redistributing source
for it (probably because it's no longer included with the OS).

------
arunc
What version control does Apple use? Is this the same that is being hosted in
the linking site as well?

------
voltagex_
Any idea what's up with the cert on
[https://opensource.apple.com/](https://opensource.apple.com/)?

~~~
cpach
It works fine for me. AFAICT the cert they use is okey.

[Fingerprint: 92 D3 F3 46 0E BA A5 FE D5 5E C8 AE 19 59 82 57 85 FE AE 88 A5
9D F7 BE FC 47 89 38 5F BC 4A E9 (SHA-256)]

------
locomoco
Now will someone figure out a terminal command to turn off the MacBook Pro
display for Yosemite?

Like the following: [http://osxdaily.com/2011/09/14/disable-the-internal-
screen-o...](http://osxdaily.com/2011/09/14/disable-the-internal-screen-on-a-
macbook-pro-or-air-in-mac-os-x-10-7-lion/)

------
RexRollman
Do they not create bootable, installable images of Darwin anymore?

~~~
voltagex_
From memory, this is the first release of the Darwin source in ages, but
[https://opensource.apple.com/](https://opensource.apple.com/) looks to have
been updated.

[http://www.puredarwin.org/](http://www.puredarwin.org/) looks abandoned, and
OpenDarwin disappeared long ago -
[http://www.applematters.com/article/opendarwin-dies-a-
lonely...](http://www.applematters.com/article/opendarwin-dies-a-lonely-
death/)

~~~
NSCFType
> From memory, this is the first release of the Darwin source in ages

Ages? [https://opensource.apple.com/](https://opensource.apple.com/) looks
like it has for a while, except for the addition of 10.10 (I grab CFLite,
libclosure, libdispatch, and objc4 whenever they're made available after a
release).

------
dangayle
Does anyone know what they're using Twisted for?

~~~
jdub
A bunch of the OS X Server stuff, including calendars, feeds, etc.

~~~
dangayle
Really. I'll have to dig into it to see how they're using it.

------
eccstartup
swift is not open source?

~~~
DerekL
Not currently. But it's a development tool, and not a part of OS X, so it
wouldn't be listed here anyway. For instance, this page has Clang, GCC, Git,
etc.: [http://opensource.apple.com/release/developer-
tools-51/](http://opensource.apple.com/release/developer-tools-51/)

------
iunk
and they fixed a few Integer overflows \- int size = inCapacity *
sizeof(dictEntry); \+ if (inCapacity > (UINT_MAX / sizeof(dictEntry))) \+
return false;

\+ unsigned int size = inCapacity * sizeof(dictEntry);

------
ahmett
And the good old shellshocked bash version 3.2
[http://opensource.apple.com/source/bash/bash-94.1.2/version....](http://opensource.apple.com/source/bash/bash-94.1.2/version.h)

~~~
0x0
You have to look for the vulnerable code, not just the version string.
Supposedly it has already been patched.

~~~
ctpide
a patch was released for OS X versions below 10.10 only, so I would assume it
should be applied to OS X 10.10:
[http://support.apple.com/kb/HT6495](http://support.apple.com/kb/HT6495)

~~~
0x0
I would assume that the patch has already been applied to the shipping final
version of 10.10.0; installing system packages designed for older OSX releases
sounds dangerous.

~~~
redwall_hp
Just install a newer bash with homebrew ¯\\_(ツ)_/¯

That's what I did, before Apple even released a patch for Mavericks.

------
chicofarm
does this mean we can compile Yosemite from the code here and install it on a
modern Mac?

Or is this just the Darwin kernel code?

Are the aqua/user interface layer also included here?

Any CONTEXT related to this source code would be greatly appropriated.

~~~
72deluxe
Vast portions of code that makes it usable are missing; as someone above
stated, Aqua is missing as well as core items like disk image mounting etc.

I tried many years ago to use Darwin in the "haha I can run Mac OSX but not
actually buy a Mac" sort of idea - it was an exercise in hard work (as I
hadn't a clue what I was doing) and what I did managed to get to boot wasn't
massively useful for "real" work (a CLI with no windowing layer) like
development etc. or anything you do day to day.

Quite interesting nonetheless, but not massively useful.

~~~
jarin
It's not intended to be used standalone, it's there for other OSS developers
to be able to use.

------
jiyinyiyong
Hi Ubuntu! How do you think about this?

------
amaks
Just by glancing over the code overall looks like a poorly structured and
inconsistent code, lacking centralized coding guidelines or practices. Pretty
scary for a shipping product to have code like this.

------
bingeboy
This is a good step into making Star Trek law the real law.

------
justcommenting
for a second there i was hoping to see that they had merged
[https://github.com/fix-macosx/](https://github.com/fix-macosx/)

