forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate native runtime sources (dotnet#20)
From dotnet/corert at commit bb212a9d2083046724f48e206f47b7dfb78d9979.
- Loading branch information
1 parent
bf0076c
commit b08bd73
Showing
320 changed files
with
91,474 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// CppCodeGen.h : Facilities for the C++ code generation backend | ||
|
||
#ifndef __CPP_CODE_GEN_H | ||
#define __CPP_CODE_GEN_H | ||
|
||
#define _CRT_SECURE_NO_WARNINGS | ||
|
||
#ifdef _MSC_VER | ||
// Warnings disabled for generated cpp code | ||
#pragma warning(disable:4200) // zero-sized array | ||
#pragma warning(disable:4101) // unreferenced local variable | ||
#pragma warning(disable:4102) // unreferenced label | ||
#pragma warning(disable:4244) // possible loss of data | ||
#pragma warning(disable:4717) // recursive on all control paths | ||
#pragma warning(disable:4307) // integral constant overflow | ||
#endif | ||
|
||
#ifdef _MSC_VER | ||
#define INT64VAL(x) (x##i64) | ||
#else | ||
#define INT64VAL(x) (x##LL) | ||
#endif | ||
|
||
#ifdef _MSC_VER | ||
#define CORERT_UNREACHABLE __assume(0) | ||
#else | ||
#define CORERT_UNREACHABLE __builtin_unreachable() | ||
#endif | ||
|
||
#ifdef _MSC_VER | ||
#define CORERT_THREAD __declspec(thread) | ||
#else | ||
#define CORERT_THREAD __thread | ||
#endif | ||
|
||
// Use the bit representation of uint64_t `v` as the bit representation of a double. | ||
inline double __uint64_to_double(uint64_t v) | ||
{ | ||
union | ||
{ | ||
uint64_t u64; | ||
double d; | ||
} val; | ||
val.u64 = v; | ||
return val.d; | ||
} | ||
|
||
struct ReversePInvokeFrame | ||
{ | ||
void* m_savedPInvokeTransitionFrame; | ||
void* m_savedThread; | ||
}; | ||
|
||
struct PInvokeTransitionFrame | ||
{ | ||
void* m_RIP; | ||
void* m_pThread; // unused by stack crawler, this is so GetThread is only called once per method | ||
// can be an invalid pointer in universal transition cases (which never need to call GetThread) | ||
uint32_t m_Flags; // PInvokeTransitionFrameFlags | ||
}; | ||
|
||
// Should be synchronized with System.Private.CoreLib/src/System/Runtime/CompilerServices/StaticClassConstructionContext.cs | ||
struct StaticClassConstructionContext | ||
{ | ||
void* m_cctorMethodAddress; | ||
uint32_t m_initialized; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// common.cpp : source file that includes just the standard includes | ||
// testNative.pch will be the pre-compiled header | ||
// common.obj will contain the pre-compiled type information | ||
|
||
#include "common.h" | ||
|
||
// TODO: reference any additional headers you need in common.H | ||
// and not in this file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// common.h : include file for standard system include files, | ||
// or project specific include files that are used frequently, but | ||
// are changed infrequently | ||
// | ||
|
||
#ifndef __COMMON_H | ||
#define __COMMON_H | ||
|
||
#define _CRT_SECURE_NO_WARNINGS | ||
|
||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <wchar.h> | ||
#include <assert.h> | ||
#include <stdarg.h> | ||
#include <stddef.h> | ||
#include <math.h> | ||
|
||
#include <new> | ||
|
||
#ifndef _WIN32 | ||
#include <pthread.h> | ||
#endif | ||
|
||
using namespace std; | ||
|
||
class MethodTable; | ||
class Object; | ||
|
||
#ifdef _MSC_VER | ||
#define __NORETURN __declspec(noreturn) | ||
#else | ||
#define __NORETURN __attribute((noreturn)) | ||
#endif | ||
|
||
int __initialize_runtime(); | ||
void __shutdown_runtime(); | ||
|
||
extern "C" Object * __allocate_object(MethodTable * pMT); | ||
extern "C" Object * __allocate_array(size_t elements, MethodTable * pMT); | ||
extern "C" Object * __castclass(MethodTable * pMT, void * obj); | ||
extern "C" Object * __isinst(MethodTable * pMT, void * obj); | ||
extern "C" __NORETURN void __throw_exception(void * pEx); | ||
extern "C" void __debug_break(); | ||
|
||
Object * __load_string_literal(const char * string); | ||
|
||
extern "C" void __range_check_fail(); | ||
|
||
inline void __range_check(void * a, size_t elem) | ||
{ | ||
if (elem >= *((size_t*)a + 1)) | ||
__range_check_fail(); | ||
} | ||
|
||
Object * __get_commandline_args(int argc, char * argv[]); | ||
|
||
// POD version of EEType to use for static initialization | ||
struct RawEEType | ||
{ | ||
uint16_t m_componentSize; | ||
uint16_t m_flags; | ||
uint32_t m_baseSize; | ||
MethodTable * m_pBaseType; | ||
uint16_t m_usNumVtableSlots; | ||
uint16_t m_usNumInterfaces; | ||
uint32_t m_uHashCode; | ||
}; | ||
|
||
struct ReversePInvokeFrame; | ||
|
||
void __reverse_pinvoke(ReversePInvokeFrame* pRevFrame); | ||
void __reverse_pinvoke_return(ReversePInvokeFrame* pRevFrame); | ||
|
||
struct PInvokeTransitionFrame; | ||
|
||
void __pinvoke(PInvokeTransitionFrame* pFrame); | ||
void __pinvoke_return(PInvokeTransitionFrame* pFrame); | ||
|
||
typedef size_t UIntNative; | ||
|
||
inline bool IS_ALIGNED(UIntNative val, UIntNative alignment) | ||
{ | ||
//ASSERT(0 == (alignment & (alignment - 1))); | ||
return 0 == (val & (alignment - 1)); | ||
} | ||
|
||
template <typename T> | ||
inline bool IS_ALIGNED(T* val, UIntNative alignment) | ||
{ | ||
//ASSERT(0 == (alignment & (alignment - 1))); | ||
return IS_ALIGNED(reinterpret_cast<UIntNative>(val), alignment); | ||
} | ||
|
||
#define RAW_MIN_OBJECT_SIZE (3*sizeof(void*)) | ||
|
||
#define AlignBaseSize(s) ((s < RAW_MIN_OBJECT_SIZE) ? RAW_MIN_OBJECT_SIZE : ((s + (sizeof(void*)-1) & ~(sizeof(void*)-1)))) | ||
|
||
#define ARRAY_BASE (2*sizeof(void*)) | ||
|
||
#endif // __COMMON_H |
Oops, something went wrong.