@@ -65,6 +65,28 @@ namespace std {
6565#endif
6666#endif // __APPLE__ ?
6767
68+ #ifdef __ANDROID__
69+ #define S_IREAD 0000400
70+ #define S_IWRITE 0000200
71+ #define S_IEXEC 0000100
72+
73+ #ifndef CC_AND_TAG
74+ #define CC_AND_TAG " chakracore-log"
75+ #endif
76+ #include < android/log.h>
77+ #include < stdarg.h>
78+ #define PRINT_LOG (...) \
79+ __android_log_print (ANDROID_LOG_INFO, CC_AND_TAG, __VA_ARGS__)
80+ #define PRINT_ERROR (...) \
81+ __android_log_print (ANDROID_LOG_ERROR, CC_AND_TAG, __VA_ARGS__)
82+ #else
83+ typedef __builtin_va_list va_list;
84+ #define PRINT_LOG (...) \
85+ swprintf (stdout, __VA_ARGS__)
86+ #define PRINT_ERROR (...) \
87+ swprintf (stderr, __VA_ARGS__)
88+ #endif
89+
6890#ifdef __cplusplus
6991extern " C" {
7092#endif
@@ -187,36 +209,12 @@ extern "C" {
187209
188210/* ****************** Compiler-specific glue *******************************/
189211
190- #ifndef _MSC_VER
191212#define FEATURE_PAL_SXS 1
192- #endif // !_MSC_VER
193-
194- #if defined(_MSC_VER) || defined(__llvm__)
195213#define DECLSPEC_ALIGN (x ) __declspec(align(x))
196- #else
197- #define DECLSPEC_ALIGN (x )
198- #endif
199-
200214#define DECLSPEC_NORETURN PAL_NORETURN
201-
202- #ifndef _MSC_VER
203215#define __assume (x ) (void )0
204216#define __annotation (x )
205- #endif // !MSC_VER
206-
207- #ifdef _MSC_VER
208-
209- #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64)
210- #define UNALIGNED __unaligned
211- #else
212217#define UNALIGNED
213- #endif
214-
215- #else // _MSC_VER
216-
217- #define UNALIGNED
218-
219- #endif // _MSC_VER
220218
221219#ifndef FORCEINLINE
222220#if _MSC_VER < 1200
@@ -226,122 +224,7 @@ extern "C" {
226224#endif
227225#endif
228226
229- #ifndef PAL_STDCPP_COMPAT
230-
231- #ifdef _M_ALPHA
232-
233- typedef struct {
234- char *a0; /* pointer to first homed integer argument */
235- int offset; /* byte offset of next parameter */
236- } va_list;
237-
238- #define va_start (list, v ) __builtin_va_start(list, v, 1 )
239- #define va_end (list )
240-
241- #elif __GNUC__
242-
243- #if defined(_AIX)
244-
245- typedef __builtin_va_list __gnuc_va_list;
246- typedef __builtin_va_list va_list;
247- #define va_start (v,l ) __builtin_va_start(v,l)
248- #define va_end __builtin_va_end
249- #define va_arg __builtin_va_arg
250-
251- #else // _AIX
252-
253- #if __GNUC__ == 2
254- typedef void * va_list;
255- #else
256- typedef __builtin_va_list va_list;
257- #endif // __GNUC__
258-
259- /* We should consider if the va_arg definition here is actually necessary.
260- Could we use the standard va_arg definition? */
261-
262- #if __GNUC__ == 2
263- #if defined(_SPARC_) || defined(_PARISC_) // ToDo: is this the right thing for PARISC?
264- #define va_start (list, v ) (__builtin_next_arg(v), list = (char *) __builtin_saveregs())
265- #define __va_rounded_size (TYPE ) \
266- (((sizeof (TYPE) + sizeof (int ) - 1 ) / sizeof (int )) * sizeof (int ))
267- #define __record_type_class 12
268- #define __real_type_class 8
269- #define va_arg (pvar,TYPE ) \
270- __extension__ \
271- (*({((__builtin_classify_type (*(TYPE*) 0 ) >= __record_type_class \
272- || (__builtin_classify_type (*(TYPE*) 0 ) == __real_type_class \
273- && sizeof (TYPE) == 16 )) \
274- ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *), \
275- *(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
276- : __va_rounded_size (TYPE) == 8 \
277- ? ({ union {char __d[sizeof (TYPE)]; int __i[2 ];} __u; \
278- __u.__i [0 ] = ((int *) (void *) (pvar))[0 ]; \
279- __u.__i [1 ] = ((int *) (void *) (pvar))[1 ]; \
280- (pvar) = (char *)(pvar) + 8 ; \
281- (TYPE *) (void *) __u.__d ; }) \
282- : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE), \
283- ((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));}))
284- #else // _SPARC_ or _PARISC_
285- // GCC 2.95.3 on non-SPARC
286- #define __va_size (type ) (((sizeof (type) + sizeof (int ) - 1 ) / sizeof (int )) * sizeof (int ))
287- #define va_start (list, v ) ((list) = (va_list) __builtin_next_arg(v))
288- #define va_arg (ap, type ) (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
289- #endif // _SPARC_ or _PARISC_
290- #else // __GNUC__ == 2
291- #define va_start __builtin_va_start
292- #define va_arg __builtin_va_arg
293- #endif // __GNUC__ == 2
294-
295- #define va_copy __builtin_va_copy
296- #define va_end __builtin_va_end
297-
298- #endif // _AIX
299-
300- #define VOID void
301-
302- #define PUB __attribute__ ((visibility(" default" )))
303-
304- #else // __GNUC__
305-
306- typedef char * va_list;
307-
308- #define _INTSIZEOF (n ) ( (sizeof (n) + sizeof (int ) - 1 ) & ~(sizeof (int ) - 1 ) )
309-
310- #if _MSC_VER >= 1400
311-
312- #ifdef __cplusplus
313- #define _ADDRESSOF (v ) ( &reinterpret_cast <const char &>(v) )
314- #else
315- #define _ADDRESSOF (v ) ( &(v) )
316- #endif
317-
318- #define _crt_va_start (ap,v ) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
319- #define _crt_va_arg (ap,t ) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
320- #define _crt_va_end (ap ) ( ap = (va_list)0 )
321-
322- #define va_start _crt_va_start
323- #define va_arg _crt_va_arg
324- #define va_end _crt_va_end
325-
326- #else // _MSC_VER
327-
328- #define va_start (ap,v ) (ap = (va_list) (&(v)) + _INTSIZEOF(v))
329- #define va_arg (ap,t ) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
330- #define va_end (ap )
331-
332- #endif // _MSC_VER
333-
334- #define va_copy (dest,src ) (dest = src)
335-
336- #endif // __GNUC__
337-
338- #endif // !PAL_STDCPP_COMPAT
339-
340- #if defined(__CLANG__) || defined(__GNUC__)
341227#define PAL_GLOBAL __attribute__ ((init_priority(200 )))
342- #else
343- #define PAL_GLOBAL
344- #endif
345228/* ****************** PAL-Specific Entrypoints *****************************/
346229
347230#define IsDebuggerPresent PAL_IsDebuggerPresent
@@ -525,26 +408,6 @@ typedef long time_t;
525408typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
526409typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
527410
528-
529- /* ****************** Tracing Initialization *******************************/
530-
531- #if defined(__LINUX__)
532-
533- // Constructor priority is set to 200, which allows for constructors to
534- // guarantee that they run before or after this constructor by setting
535- // their priority appropriately.
536-
537- // Priority values must be greater than 100. The lower the value,
538- // the higher the priority.
539- static
540- void
541- __attribute__ ((__unused__))
542- __attribute__((constructor (200 )))
543- PAL_InitializeTracing(void );
544-
545- #endif
546-
547-
548411/* ****************** PAL-Specific Entrypoints *****************************/
549412
550413PALIMPORT
559422PALAPI
560423PAL_InitializeDLL ();
561424
562- PALIMPORT
563- DWORD
564- PALAPI
565- PAL_InitializeCoreCLR (
566- const char *szExePath);
567-
568425PALIMPORT
569426DWORD
570427PALAPI
0 commit comments