Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / nanojit / VMPI.h
1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is [Open Source Virtual Machine].
17  *
18  * The Initial Developer of the Original Code is
19  * Adobe System Incorporated.
20  * Portions created by the Initial Developer are Copyright (C) 2004-2007
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *   Adobe AS3 Team
25  *
26  * Alternatively, the contents of this file may be used under the terms of
27  * either the GNU General Public License Version 2 or later (the "GPL"), or
28  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29  * in which case the provisions of the GPL or the LGPL are applicable instead
30  * of those above. If you wish to allow use of your version of this file only
31  * under the terms of either the GPL or the LGPL, and not to allow others to
32  * use your version of this file under the terms of the MPL, indicate your
33  * decision by deleting the provisions above and replace them with the notice
34  * and other provisions required by the GPL or the LGPL. If you do not delete
35  * the provisions above, a recipient may use your version of this file under
36  * the terms of any one of the MPL, the GPL or the LGPL.
37  *
38  * ***** END LICENSE BLOCK ***** */
39
40 /*
41  * Stub VMPI implementation to support standalone nanojit repository.
42  *
43  * Really only works if you *don't* have a busted-up C library.
44  */
45
46 #ifndef __VMPI_h__
47 #define __VMPI_h__
48
49 #if defined(HAVE_CONFIG_H) && defined(NANOJIT_CENTRAL)
50 #include "config.h"
51 #endif
52
53 #include <assert.h>
54 #include <string.h>
55 #include <stdio.h>
56 #include <ctype.h>
57 #include <stdlib.h>
58 #include <stddef.h>
59 #include <stdarg.h>
60
61 #if defined(AVMPLUS_UNIX) || defined(AVMPLUS_OS2)
62 #include <unistd.h>
63 #include <sys/mman.h>
64 #endif
65
66 #ifdef AVMPLUS_WIN32
67 #if ! defined(_STDINT_H)
68 typedef signed char int8_t;
69 typedef signed short int16_t;
70 typedef signed int int32_t;
71 typedef signed __int64 int64_t;
72 typedef unsigned char uint8_t;
73 typedef unsigned short uint16_t;
74 typedef unsigned int uint32_t;
75 typedef unsigned __int64 uint64_t;
76 #endif
77 #else
78 #include <stdint.h>
79 #include <inttypes.h>
80 #endif
81
82 #define VMPI_strlen strlen
83 #define VMPI_strcat strcat
84 #define VMPI_strcmp strcmp
85 #define VMPI_strncat strncat
86 #define VMPI_strcpy strcpy
87 #define VMPI_sprintf sprintf
88 #ifdef _MSC_VER
89 #   define VMPI_snprintf sprintf_s
90 #else
91 #   define VMPI_snprintf snprintf
92 #endif
93 #define VMPI_vfprintf vfprintf
94 #define VMPI_memset memset
95 #define VMPI_isdigit isdigit
96 #define VMPI_getDate()
97
98 extern size_t VMPI_getVMPageSize();
99
100 extern void VMPI_setPageProtection(void *address,
101                                    size_t size,
102                                    bool executableFlag,
103                                    bool writeableFlag);
104
105 //  Keep this warning-set relatively in sync with platform/win32/win32-platform.h in tamarin.
106
107 #ifdef _MSC_VER
108     #pragma warning(disable:4201) // nonstandard extension used : nameless struct/union
109     #pragma warning(disable:4512) // assignment operator could not be generated
110     #pragma warning(disable:4511) // can't generate copy ctor
111     #pragma warning(disable:4127) // conditional expression is constant - appears to be compiler noise primarily
112     #pragma warning(disable:4611) // interaction between _setjmp and destruct
113     #pragma warning(disable:4725) // instruction may be inaccurate on some Pentiums
114     #pragma warning(disable:4611) // interaction between '_setjmp' and C++ object destruction is non-portable
115     #pragma warning(disable:4251) // X needs to have dll-interface to be used by clients of class Y
116
117     // enable some that are off even in /W4 mode, but are still handy
118     #pragma warning(default:4265)   // 'class' : class has virtual functions, but destructor is not virtual
119     #pragma warning(default:4905)   // wide string literal cast to 'LPSTR'
120     #pragma warning(default:4906)   // string literal cast to 'LPWSTR'
121     #pragma warning(default:4263)   // 'function' : member function does not override any base class virtual member function
122     #pragma warning(default:4264)   // 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
123     #pragma warning(default:4266)   // 'function' : no override available for virtual member function from base 'type'; function is hidden
124     #pragma warning(default:4242)   // 'identifier' : conversion from 'type1' to 'type2', possible loss of data
125     #pragma warning(default:4263)   // member function does not override any base class virtual member function
126     #pragma warning(default:4296)   // expression is always true (false) (Generally, an unsigned variable was used in a comparison operation with zero.)
127 #endif
128
129 // This part defined in avmshell.h but similarly required for a warning-free nanojit experience.
130 #ifdef _MSC_VER
131 #pragma warning(disable:4996)       // 'scanf' was declared deprecated
132 #endif
133
134 // This part is inhibited manually by the CFLAGS in the tamarin configury.
135 #ifdef _MSC_VER
136 #pragma warning(disable:4291)       // presence of a 'new' operator in nanojit/Allocator.h without matching 'delete'
137 #endif
138
139 #endif