Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to recognize 32 or 64 bit from within an extension

47 views
Skip to first unread message

Jan Honza Odvarko

unread,
Jan 26, 2012, 6:42:35 AM1/26/12
to
To do a little bug workaround I need to recognize whether Firefox is running in 32 or 64 bits.

I am getting following values when using:

Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).XPCOMABI

Mac VM on Windows Vista: x86_64-gcc3
Ubuntu 9.04 VM on Windows Vista: x86-gcc3
Windows XP & Vista: x86-msvc

Is this safe way to get such information?

What values I am supposed to get on real Mac 32/64 installation and Linux 32/64 installation?

Or is there any other and better option to get the info?

Honza

Boris Zbarsky

unread,
Jan 26, 2012, 7:03:46 AM1/26/12
to
On 1/26/12 12:42 PM, Jan Honza Odvarko wrote:
> To do a little bug workaround I need to recognize whether Firefox is running in 32 or 64 bits.
>
> I am getting following values when using:
>
> Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).XPCOMABI
>
> Mac VM on Windows Vista: x86_64-gcc3
> Ubuntu 9.04 VM on Windows Vista: x86-gcc3
> Windows XP& Vista: x86-msvc
>
> Is this safe way to get such information?
>
> What values I am supposed to get on real Mac 32/64 installation and Linux 32/64 installation?

I get "x86-gcc3" in a 32-bit Mac build, and "x86_64-gcc3" in a 64-bit
Mac build.

I suspect that for your specific use case (which really cares about
32-bit GCC, not 32-bit in general), just testing for "x86-gcc3" is fine.

-Boris

Dave Townsend

unread,
Jan 26, 2012, 1:57:29 PM1/26/12
to
On 01/26/12 03:42, Jan Honza Odvarko wrote:
> To do a little bug workaround I need to recognize whether Firefox is running in 32 or 64 bits.
>
> I am getting following values when using:
>
> Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).XPCOMABI
>
> Mac VM on Windows Vista: x86_64-gcc3
> Ubuntu 9.04 VM on Windows Vista: x86-gcc3
> Windows XP& Vista: x86-msvc
>
> Is this safe way to get such information?
>
> What values I am supposed to get on real Mac 32/64 installation and Linux 32/64 installation?
>
> Or is there any other and better option to get the info?

Don't think there is anything better, the ABI is
{CPU_ARCH}-{TARGET_COMPILER_ABI}, just stripping out the CPU_ARCH and
comparing it with known values you care about would work.

https://developer.mozilla.org/en/XPCOM_ABI

David Rajchenbach-Teller

unread,
Jan 26, 2012, 2:24:44 PM1/26/12
to Dave Townsend, dev-pl...@lists.mozilla.org
There is a bug open for recognizing the OS from JS (recall that we
cannot use nsIXULRuntime from chrome workers). We can extend this to
incorporate information on 32-bits/64-bits.

https://bugzilla.mozilla.org/show_bug.cgi?id=709771

Cheers,
David
> _______________________________________________
> dev-platform mailing list
> dev-pl...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform


--
David Rajchenbach-Teller, PhD
Performance Team, Mozilla

signature.asc

Benjamin Smedberg

unread,
Jan 26, 2012, 2:37:05 PM1/26/12
to David Rajchenbach-Teller, dev-pl...@lists.mozilla.org, Dave Townsend
On 1/26/2012 2:24 PM, David Rajchenbach-Teller wrote:
> There is a bug open for recognizing the OS from JS (recall that we
> cannot use nsIXULRuntime from chrome workers). We can extend this to
> incorporate information on 32-bits/64-bits.
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=709771
Why do you need to do this from workers? Why not do this before you
launch the worker and then tell the worker that information via a
message if that's critically important?

--BDS

David Rajchenbach-Teller

unread,
Jan 26, 2012, 5:04:36 PM1/26/12
to Benjamin Smedberg, dev-pl...@lists.mozilla.org, Dave Townsend
The problem with this kind of design is that, if a library needs to know
which on OS it is running (e.g. OS.Path), there is no way to implement
it so that it works both on the main thread and in a worker.

Cheers,
David
signature.asc

Philipp Kewisch

unread,
Jan 26, 2012, 7:04:57 PM1/26/12
to
On a ChromeWorker you could probably use jsctypes and check the size of
a pointer. Very much a hack though and might not work as expected for
all platforms.

Philipp

David Rajchenbach-Teller

unread,
Jan 27, 2012, 1:08:43 AM1/27/12
to Philipp Kewisch, dev-pl...@lists.mozilla.org
On Fri Jan 27 01:04:57 2012, Philipp Kewisch wrote:
> On a ChromeWorker you could probably use jsctypes and check the size
> of a pointer. Very much a hack though and might not work as expected
> for all platforms.

As a side-note, I have the impression that most uses of jsctypes,
regardless of the thread, require some OS information, to determine the
name of the library (e.g. libc vs. libc.so.6 vs. libSystem).

Zack Weinberg

unread,
Jan 27, 2012, 11:26:42 AM1/27/12
to
On 2012-01-26 10:08 PM, David Rajchenbach-Teller wrote:
> On Fri Jan 27 01:04:57 2012, Philipp Kewisch wrote:
>> On a ChromeWorker you could probably use jsctypes and check the size
>> of a pointer. Very much a hack though and might not work as expected
>> for all platforms.
>
> As a side-note, I have the impression that most uses of jsctypes,
> regardless of the thread, require some OS information, to determine the
> name of the library (e.g. libc vs. libc.so.6 vs. libSystem).

We could eliminate many of those cases by providing access to
dlsym(RTLD_DEFAULT, "whatever").

zw

Mike Hommey

unread,
Jan 27, 2012, 11:51:57 AM1/27/12
to Zack Weinberg, dev-pl...@lists.mozilla.org
If you do, please file a dependent bug for our new linker on android to
support that.

Mike

Dave Townsend

unread,
Jan 27, 2012, 11:11:25 PM1/27/12
to
On 01/26/12 22:08, David Rajchenbach-Teller wrote:
> On Fri Jan 27 01:04:57 2012, Philipp Kewisch wrote:
>> On a ChromeWorker you could probably use jsctypes and check the size
>> of a pointer. Very much a hack though and might not work as expected
>> for all platforms.
>
> As a side-note, I have the impression that most uses of jsctypes,
> regardless of the thread, require some OS information, to determine the
> name of the library (e.g. libc vs. libc.so.6 vs. libSystem).

I think ctypes.libraryName helps resolve a lot of these:
https://developer.mozilla.org/en/js-ctypes/js-ctypes_reference/ctypes#libraryName%28%29

Mike Hommey

unread,
Jan 28, 2012, 2:56:32 AM1/28/12
to Dave Townsend, dev-pl...@lists.mozilla.org
It only helps with libraries with the same basename on all platforms
(like nspr), but doesn't for system libraries, which usually have
completely different names, and completely different functions, for that
matter. And making cross-platform goop with ctypes is all but fun. It's
easier to have a C/C++ layer in between.

Mike

Dave Townsend

unread,
Jan 28, 2012, 3:09:00 AM1/28/12
to
True, using system libraries will require knowing about the system.
0 new messages