Add a <limits> header for gcc2.

Hacked from the gcc4 version. There may be wrong values returned in some
cases.

Fixes #6701.