summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-01-04 19:46:24 +0000
committerrubidium <rubidium@openttd.org>2014-01-04 19:46:24 +0000
commit4575420dcc347f65609ccc8fbabcd356857fe3e5 (patch)
treefbe4bdec98bbb431d585442d4b139f45a7916c53 /src
parentb48bb25288ae26a5a7a7c4477705473677d9f6a4 (diff)
downloadopenttd-4575420dcc347f65609ccc8fbabcd356857fe3e5.tar.xz
(svn r26225) -Document: more tidbits about cpuid and PIC (Eagle_Rainbow)
Diffstat (limited to 'src')
-rw-r--r--src/cpu.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cpu.cpp b/src/cpu.cpp
index 7776821ce..1a878c182 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
-/** @file cpu.cpp OS/CPU/compiler dependant CPU specific calls. */
+/** @file cpu.cpp OS/CPU/compiler dependent CPU specific calls. */
#include "stdafx.h"
#include "core/bitmath_func.hpp"
@@ -97,12 +97,20 @@ void ottd_cpuid(int info[4], int type)
void ottd_cpuid(int info[4], int type)
{
#if defined(__i386) && defined(__PIC__)
- /* The easy variant would be just cpuid, however... ebx gets clobbered by PIC. */
+ /* The easy variant would be just cpuid, however... ebx is being used by the GOT (Global Offset Table)
+ * in case of PIC;
+ * clobbering ebx is no alternative: some compiler versions don't like this
+ * and will issue an error message like
+ * "can't find a register in class 'BREG' while reloading 'asm'"
+ */
__asm__ __volatile__ (
"xchgl %%ebx, %1 \n\t"
"cpuid \n\t"
"xchgl %%ebx, %1 \n\t"
: "=a" (info[0]), "=r" (info[1]), "=c" (info[2]), "=d" (info[3])
+ /* It is safe to write "=r" for (info[1]) as in case that PIC is enabled for i386,
+ * the compiler will not choose EBX as target register (but something else).
+ */
: "a" (type)
);
#else