/[jscoverage]/trunk/js/build/autoconf/moznbytetype.m4
ViewVC logotype

Contents of /trunk/js/build/autoconf/moznbytetype.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 460 - (show annotations)
Sat Sep 26 23:15:22 2009 UTC (11 years, 2 months ago) by siliconforks
File size: 4972 byte(s)
Upgrade to SpiderMonkey from Firefox 3.5.3.

1 dnl ***** BEGIN LICENSE BLOCK *****
2 dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 dnl
4 dnl The contents of this file are subject to the Mozilla Public License Version
5 dnl 1.1 (the "License"); you may not use this file except in compliance with
6 dnl the License. You may obtain a copy of the License at
7 dnl http://www.mozilla.org/MPL/
8 dnl
9 dnl Software distributed under the License is distributed on an "AS IS" basis,
10 dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 dnl for the specific language governing rights and limitations under the
12 dnl License.
13 dnl
14 dnl The Original Code is mozilla.org code.
15 dnl
16 dnl The Initial Developer of the Original Code is
17 dnl The Mozilla Foundation
18 dnl Portions created by the Initial Developer are Copyright (C) 2008
19 dnl the Initial Developer. All Rights Reserved.
20 dnl
21 dnl Contributor(s):
22 dnl Jim Blandy
23 dnl
24 dnl Alternatively, the contents of this file may be used under the terms of
25 dnl either of the GNU General Public License Version 2 or later (the "GPL"),
26 dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 dnl in which case the provisions of the GPL or the LGPL are applicable instead
28 dnl of those above. If you wish to allow use of your version of this file only
29 dnl under the terms of either the GPL or the LGPL, and not to allow others to
30 dnl use your version of this file under the terms of the MPL, indicate your
31 dnl decision by deleting the provisions above and replace them with the notice
32 dnl and other provisions required by the GPL or the LGPL. If you do not delete
33 dnl the provisions above, a recipient may use your version of this file under
34 dnl the terms of any one of the MPL, the GPL or the LGPL.
35 dnl
36 dnl ***** END LICENSE BLOCK *****
37
38 dnl MOZ_N_BYTE_TYPE(VARIABLE, SIZE, POSSIBLE-TYPES)
39 dnl
40 dnl Check to see which of POSSIBLE-TYPES has a size of SIZE. If we
41 dnl find one, define VARIABLE to be the size-BYTE type. If no type
42 dnl matches, exit the configure script with an error message. Types
43 dnl whose written form contains spaces should appear in POSSIBLE-TYPES
44 dnl enclosed by shell quotes.
45 dnl
46 dnl The cache variable moz_cv_n_byte_type_VARIABLE gets set to the
47 dnl type, if found.
48 dnl
49 dnl for example:
50 dnl MOZ_N_BYTE_TYPE([JS_INT32_T], [4], [int long 'long long' short])
51 dnl
52 AC_DEFUN(MOZ_N_BYTE_TYPE,
53 [
54 dnl The simplest approach would simply be to run a program that says
55 dnl printf ("%d\n", sizeof ($type));
56 dnl But that won't work when cross-compiling; this will.
57 AC_CACHE_CHECK([for a $2-byte type], moz_cv_n_byte_type_$1, [
58 moz_cv_n_byte_type_$1=
59 for type in $3; do
60 AC_TRY_COMPILE([],
61 [
62 int a[sizeof ($type) == $2 ? 1 : -1];
63 return;
64 ],
65 [moz_cv_n_byte_type_$1=$type; break], [])
66 done
67 if test ! "$moz_cv_n_byte_type_$1"; then
68 AC_MSG_ERROR([Couldn't find a $2-byte type])
69 fi
70 ])
71 AC_DEFINE_UNQUOTED($1, [$moz_cv_n_byte_type_$1],
72 [a $2-byte type on the target machine])
73 ])
74
75 dnl MOZ_SIZE_OF_TYPE(VARIABLE, TYPE, POSSIBLE-SIZES)
76 dnl
77 dnl Check to see which of POSSIBLE-SIZES is the sizeof(TYPE). If we find one,
78 dnl define VARIABLE SIZE. If no size matches, exit the configure script with
79 dnl an error message.
80 dnl
81 dnl The cache variable moz_cv_size_of_VARIABLE gets set to the size, if
82 dnl found.
83 dnl
84 dnl for example:
85 dnl MOZ_SIZE_OF_TYPE([JS_BYTES_PER_WORD], [void*], [4 8])
86 AC_DEFUN(MOZ_SIZE_OF_TYPE,
87 [
88 AC_CACHE_CHECK([for the size of $2], moz_cv_size_of_$1, [
89 moz_cv_size_of_$1=
90 for size in $3; do
91 AC_TRY_COMPILE([],
92 [
93 int a[sizeof ($2) == $size ? 1 : -1];
94 return;
95 ],
96 [moz_cv_size_of_$1=$size; break], [])
97 done
98 if test ! "$moz_cv_size_of_$1"; then
99 AC_MSG_ERROR([No size found for $2])
100 fi
101 ])
102 AC_DEFINE_UNQUOTED($1, [$moz_cv_size_of_$1])
103 ])
104
105 dnl MOZ_ALIGN_OF_TYPE(VARIABLE, TYPE, POSSIBLE-ALIGNS)
106 dnl
107 dnl Check to see which of POSSIBLE-ALIGNS is the necessary alignment of TYPE.
108 dnl If we find one, define VARIABLE ALIGNMENT. If no alignment matches, exit
109 dnl the configure script with an error message.
110 dnl
111 dnl The cache variable moz_cv_align_of_VARIABLE gets set to the size, if
112 dnl found.
113 dnl
114 dnl for example:
115 dnl MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
116 AC_DEFUN(MOZ_ALIGN_OF_TYPE,
117 [
118 AC_CACHE_CHECK([for the alignment of $2], moz_cv_align_of_$1, [
119 moz_cv_align_of_$1=
120 for align in $3; do
121 AC_TRY_COMPILE([
122 #include <stddef.h>
123 struct aligner { char c; $2 a; };
124 ],
125 [
126 int a[offsetof(struct aligner, a) == $align ? 1 : -1];
127 return;
128 ],
129 [moz_cv_align_of_$1=$align; break], [])
130 done
131 if test ! "$moz_cv_align_of_$1"; then
132 AC_MSG_ERROR([No alignment found for $2])
133 fi
134 ])
135 AC_DEFINE_UNQUOTED($1, [$moz_cv_align_of_$1])
136 ])

  ViewVC Help
Powered by ViewVC 1.1.24