1 | /*
|
---|
2 | * Copyright (C) 2003 Apple Computer, Inc.
|
---|
3 | *
|
---|
4 | * This library is free software; you can redistribute it and/or
|
---|
5 | * modify it under the terms of the GNU Lesser General Public
|
---|
6 | * License as published by the Free Software Foundation; either
|
---|
7 | * version 2 of the License, or (at your option) any later version.
|
---|
8 | *
|
---|
9 | * This library is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
12 | * Lesser General Public License for more details.
|
---|
13 | *
|
---|
14 | * You should have received a copy of the GNU Lesser General Public
|
---|
15 | * License along with this library; if not, write to the Free Software
|
---|
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | *
|
---|
18 | */
|
---|
19 |
|
---|
20 | #include <config.h>
|
---|
21 |
|
---|
22 | // This file exists because JavaScriptCore needs to define the NaN and Inf globals in a way
|
---|
23 | // that does not use a static initializer so we don't have a framework initialization routine.
|
---|
24 |
|
---|
25 | // The trick is to define the NaN and Inf globals with a different type than the declaration.
|
---|
26 | // This trick works because the mangled name of the globals does not include the type, although
|
---|
27 | // I'm not sure that's guaranteed. There could be alignment issues with this, since arrays of
|
---|
28 | // characters don't necessarily need the same alignment doubles do, but for now it seems to work.
|
---|
29 | // It would be good to figure out a 100% clean way that still avoids code that runs at init time.
|
---|
30 |
|
---|
31 | namespace KJS {
|
---|
32 |
|
---|
33 | #ifdef WORDS_BIGENDIAN
|
---|
34 | extern const unsigned char NaN[sizeof(double)] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
|
---|
35 | extern const unsigned char Inf[sizeof(double)] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
|
---|
36 | #else
|
---|
37 | extern const unsigned char NaN[sizeof(double)] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
|
---|
38 | extern const unsigned char Inf[sizeof(double)] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | };
|
---|