Skip to content

Commit

Permalink
work out the cpu architecture at compile time, so MacOS fat binaries …
Browse files Browse the repository at this point in the history
…work
  • Loading branch information
vp-of-awesome committed Sep 19, 2008
1 parent ac13718 commit c53282a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ext/Platform.c
Expand Up @@ -7,6 +7,25 @@

static VALUE modulePlatform = Qnil;

/*
* Determine the cpu type at compile time - useful for MacOSX where the the
* system installed ruby incorrectly reports 'host_cpu' as 'powerpc' when running
* on intel.
*/
#ifdef __i386__
#define CPU "i386"
#elif defined(__ppc__) || defined(__powerpc__)
#define CPU "powerpc"
#elif defined(__x86_64__)
#define CPU "x86_64"
#elif defined(__sparc__)
#define CPU "sparc"
#elif defined(__sparcv9__)
#define CPU "sparcv9"
#else
#error "Unknown cpu type"
#endif

void
rb_FFI_Platform_Init()
{
Expand All @@ -18,6 +37,6 @@ rb_FFI_Platform_Init()
rb_define_const(platform, "LITTLE_ENDIAN", INT2FIX(LITTLE_ENDIAN));
rb_define_const(platform, "BIG_ENDIAN", INT2FIX(BIG_ENDIAN));
rb_define_const(platform, "OS_", rb_str_new2(OS));
rb_define_const(platform, "ARCH_", rb_str_new2(ARCH));
rb_define_const(platform, "ARCH_", rb_str_new2(CPU));
modulePlatform = platform;
}

0 comments on commit c53282a

Please sign in to comment.