In general, US law says that you are the one who owns the copyright to your work, and you own that copyright automatically from the moment you set your work down in tangible form. US law has a concept of "work for hire," but traditionally work done in academia is not considered work for hire. More about that here: Copyright for lectures, slides and textbook: university or professor? So you own the copyright, not the school.
It actually doesn't even matter if the school has some policy on this matter, because the law says that work for hire is determined based on certain legal criteria, not based on the employer's policy. Even if you signed a piece of paper saying it was a work for hire, that wouldn't necessarily make it a work for hire unless it met the relevant legal tests.
Brian Borchers asks in a comment:
What is your institution's policy on the ownership of copyright of the thesis? Are you allowed to keep the copyright or must you transfer copyright to the university?
He has also pointed out in a comment that there are some schools, such as MIT, that claim in their policies that they are entitled to claim the copyright on a thesis. For the reasons described above, I suspect that this is not actually something they can legally do, but in any case it has no effect on the answer to your question.
Also, if the university is to own the right to my code, another concern of mine would be that I have used various open-source libraries and I would worry about running into license issues for using those as well.
This is a non-issue. If those libraries are under the GPL (or some other "viral" license), what would violate those licenses would be if you linked them to your code and then redistributed the binary, and your code was not under GPL. That's because linking your code to the libraries creates what's known in copyright law as a "derivative work." This has nothing to do with printing out your code and putting it in your thesis. The thesis is a derivative work of your code, but the thesis is not a derivative work of the libraries, because the libraries aren't in it.