6
6
#include <string.h>
7
7
#include <math.h>
8
8
#include <mm_malloc.h>
9
+
10
+ #include <alloca.h>
11
+
9
12
/*
10
13
#include <unistd.h>
11
14
#include <sys/uio.h>
12
15
#include <poll.h>
13
16
#include <sched.h>
14
17
#include "threads.h"*/
15
- #ifdef __STDC_VERSION__
16
-
17
- #else
18
- #error "C version too old(< C99), and unsuported"
18
+ #ifndef __SIZEOF_INT128__
19
+ #define __int128 long long
19
20
#endif
20
-
21
21
#define eprintf (...) fprintf(stderr, __VA_ARGS__)
22
- union System_Collections_IDictionary
23
- {
24
- };
25
- union System_Collections_IDictionaryEnumerator
26
- {
27
- };
28
- union System_Collections_DictionaryEntry
29
- {
30
- };
31
- union System_String
32
- {
33
- };
22
+
34
23
int execvp (void * file , void * argv );
35
24
#define System_Runtime_InteropServices_Marshal_AllocHGlobali4is (size ) malloc(size)
36
25
#define System_Runtime_InteropServices_Marshal_AllocHGlobalisis (size ) malloc(size)
37
26
#define System_Runtime_InteropServices_Marshal_ReAllocHGlobalisisis (ptr , new_size ) realloc(ptr, new_size)
38
27
#define System_Runtime_InteropServices_Marshal_FreeHGlobalisv (ptr ) free(ptr)
39
- #define System_Collections_ICollection_get_Count14System_Runtime30System_Collections_IDictionaryi4 ( dict ) 0
28
+
40
29
#define System_Runtime_InteropServices_NativeMemory_AlignedAllocususpv (size , align ) aligned_alloc(align, size)
41
30
#define System_Runtime_InteropServices_NativeMemory_AlignedFreepvv free
42
31
void * System_Runtime_InteropServices_NativeMemory_AlignedReallocpvususpv (void * ptr , uintptr_t size , uintptr_t align )
@@ -47,17 +36,12 @@ void *System_Runtime_InteropServices_NativeMemory_AlignedReallocpvususpv(void *p
47
36
return new_buff ;
48
37
}
49
38
50
- #define System_Collections_IEnumerator_MoveNext14System_Runtime40System_Collections_IDictionaryEnumeratorb (arg ) false
51
-
52
39
#define System_UInt128_op_Additionu16u16u16 (lhs , rhs ) (lhs + rhs)
53
40
#define System_Int128_op_Additioni16i16i16 (lhs , rhs ) (__int128)((unsigned __int128)lhs + (unsigned __int128)rhs)
54
41
55
42
#define System_UInt128_op_Subtractionu16u16u16 (lhs , rhs ) (lhs - rhs)
56
43
#define System_Int128_op_Subtractioni16i16i16 (lhs , rhs ) (__int128)((unsigned __int128)lhs - (unsigned __int128)rhs)
57
44
58
- #define System_UInt128_op_Equalityu16u16b (lhs , rhs ) (lhs == rhs)
59
- #define System_Int128_op_Equalityi16i16b (lhs , rhs ) (lhs == rhs)
60
-
61
45
#define System_Int128_op_LessThani16i16b (lhs , rhs ) (lhs < rhs)
62
46
#define System_UInt128_op_LessThanu16u16b (lhs , rhs ) (lhs < rhs)
63
47
@@ -158,8 +142,8 @@ void *System_Runtime_InteropServices_NativeMemory_AlignedReallocpvususpv(void *p
158
142
#define System_Buffers_Binary_BinaryPrimitives_ReverseEndiannessi4i4 (val ) (int32_t) __builtin_bswap32((uint32_t)val)
159
143
#define System_Buffers_Binary_BinaryPrimitives_ReverseEndiannessu2u2 __builtin_bswap16
160
144
#define System_Buffers_Binary_BinaryPrimitives_ReverseEndiannessi2i2 (val ) (int16_t) __builtin_bswap16((uint16_t)val)
161
- // Assumes a 64 bit OS.
162
- #define System_Buffers_Binary_BinaryPrimitives_ReverseEndiannessisis (val ) (intptr_t) __builtin_bswap64((ulong )val)
145
+ /* Assumes a 64 bit OS.*/
146
+ #define System_Buffers_Binary_BinaryPrimitives_ReverseEndiannessisis (val ) (intptr_t) __builtin_bswap64((uint64_t )val)
163
147
#define System_Buffers_Binary_BinaryPrimitives_ReverseEndiannessusus __builtin_bswap64
164
148
165
149
#define System_Numerics_BitOperations_TrailingZeroCountusi4 (val ) (int32_t) __builtin_ctzl((uint64_t)val)
@@ -172,51 +156,27 @@ int32_t System_Numerics_BitOperations_LeadingZeroCountusi4(uintptr_t val) { retu
172
156
#define System_Numerics_BitOperations_PopCountu4i4 (val ) __builtin_popcountl((uint32_t)val)
173
157
#define System_Numerics_BitOperations_PopCountu8i4 (val ) __builtin_popcountl((uint64_t)val)
174
158
175
- union System_Collections_IDictionary System_Environment_GetEnvironmentVariables14System_Runtime30System_Collections_IDictionary ()
176
- {
177
- union System_Collections_IDictionary res ;
178
- return res ;
179
- };
180
- union System_Collections_IDictionaryEnumerator System_Collections_IDictionary_GetEnumerator14System_Runtime30System_Collections_IDictionary14System_Runtime40System_Collections_IDictionaryEnumerator (union System_Collections_IDictionary dict )
181
- {
182
- union System_Collections_IDictionaryEnumerator res ;
183
- return res ;
184
- }
185
- union System_Collections_DictionaryEntry System_Collections_IEnumerator_get_Current14System_Runtime40System_Collections_IDictionaryEnumeratoro (union System_Collections_IDictionaryEnumerator dict )
186
- {
187
- union System_Collections_DictionaryEntry res ;
188
- return res ;
189
- }
190
- union System_String System_String_Concat_ ()
191
- {
192
- union System_String res ;
193
- return res ;
194
- }
195
- const char * System_Runtime_InteropServices_Marshal_StringToCoTaskMemUTF8sis (union System_String str )
196
- {
197
- char * res = (char * )malloc (1 );
198
- res [0 ] = '\0' ;
199
- return res ;
200
- }
201
- void System_Console_WriteLineu8v (ulong arg )
159
+ #define System_Console_WriteLinestv (msg ) printf("%s", msg)
160
+ #define System_String_Concatststst (a , b ) a b
161
+ #define System_String_Concatstststst (a , b , c ) a b c
162
+ #define System_String_Concatststststst (a , b , c , d ) a b c d
163
+ void System_Console_WriteLineu8v (uint64_t arg )
202
164
{
203
165
printf ("%lu\n" , arg );
204
166
}
205
- void System_Console_WriteLinei8v (long arg )
167
+ void System_Console_WriteLinei8v (int64_t arg )
206
168
{
207
169
printf ("%ld\n" , arg );
208
170
}
209
- void System_Console_WriteLineu4v (uint arg )
171
+ void System_Console_WriteLineu4v (uint32_t arg )
210
172
{
211
173
printf ("%u\n" , arg );
212
174
}
213
- void System_Console_WriteLinei4v (int arg )
175
+ void System_Console_WriteLinei4v (int32_t arg )
214
176
{
215
177
printf ("%u\n" , arg );
216
178
}
217
179
218
- #define System_String_Concatooos (...) System_String_Concat_()
219
-
220
180
#define System_UIntPtr_get_MaxValueus () UINTPTR_MAX
221
181
#define System_UIntPtr_get_MinValueus () ((uintptr_t)0)
222
182
@@ -279,16 +239,36 @@ float System_Single_FusedMultiplyAddf4f4f4f4(float left, float right, float adde
279
239
float System_Single_CopySignf4f4f4 (float mag , float sign )
280
240
{
281
241
if (sign > 0 )
282
- return fabs (mag );
242
+ {
243
+ if (mag > 0 )
244
+ return mag ;
245
+ else
246
+ return - mag ;
247
+ }
283
248
else
284
- return - fabs (mag );
249
+ {
250
+ if (mag > 0 )
251
+ return - mag ;
252
+ else
253
+ return mag ;
254
+ }
285
255
}
286
256
double System_Double_CopySignf8f8f8 (double mag , double sign )
287
257
{
288
258
if (sign > 0 )
289
- return fabs (mag );
259
+ {
260
+ if (mag > 0 )
261
+ return mag ;
262
+ else
263
+ return - mag ;
264
+ }
290
265
else
291
- return - fabs (mag );
266
+ {
267
+ if (mag > 0 )
268
+ return - mag ;
269
+ else
270
+ return mag ;
271
+ }
292
272
}
293
273
float System_MathF_Truncatef4f4 (float val )
294
274
{
@@ -316,7 +296,7 @@ double fabsf64(double val);
316
296
typedef struct TSWData
317
297
{
318
298
void * start_routine ;
319
- void * arg
299
+ void * arg ;
320
300
} TSWData ;
321
301
void _tcctor ();
322
302
void * thread_start_wrapper (TSWData * data )
@@ -367,36 +347,18 @@ float System_Single_Log10f4f4(float input)
367
347
abort ();
368
348
return 0.0f ;
369
349
}
370
- float System_Math_Floorf8f8 (float input )
371
- {
372
- fprintf (stderr , "Can't System_Math_Floorf8f8 yet.\n" );
373
- abort ();
374
- return 0.0f ;
375
- }
376
- double System_Math_Sqrtf8f8 (double input )
377
- {
378
- fprintf (stderr , "Can't System_Math_Sqrtf8f8 yet.\n" );
379
- abort ();
380
- return 0.0f ;
381
- }
350
+ #define System_Math_Floorf8f8 (input ) floor(input)
351
+ #define System_Math_Sqrtf8f8 (input ) sqrt(input)
352
+
382
353
double System_Double_Log10f8f8 (double input )
383
354
{
384
355
fprintf (stderr , "Can't System_Double_Log10f8f8 yet.\n" );
385
356
abort ();
386
357
return 0.0f ;
387
358
}
388
- double System_Math_Ceilingf8f8 (double input )
389
- {
390
- fprintf (stderr , "Can't System_Math_Ceilingf8f8 yet.\n" );
391
- abort ();
392
- return 0.0f ;
393
- }
394
- double System_Math_Truncatef8f8 (double input )
395
- {
396
- fprintf (stderr , "Can't System_Math_Truncatef8f8 yet.\n" );
397
- abort ();
398
- return 0.0f ;
399
- }
359
+ #define System_Math_Ceilingf8f8 (input ) celi(input)
360
+ #define System_Math_Truncatef8f8 (input ) trunc(input)
361
+
400
362
uint32_t System_UInt32_RotateRightu4i4u4 (uint32_t val , int32_t ammount )
401
363
{
402
364
fprintf (stderr , "Can't System_UInt32_RotateRightu4i4u4 yet.\n" );
@@ -418,7 +380,7 @@ uint32_t System_Threading_Interlocked_CompareExchangeru4u4u4u4(uint32_t *addr, u
418
380
}
419
381
else
420
382
{
421
- // On failure, value is written to comparand.
383
+ /* On failure, value is written to comparand. */
422
384
return comparand ;
423
385
}
424
386
}
@@ -431,7 +393,7 @@ uint64_t System_Threading_Interlocked_CompareExchangeru8u8u8u8(uint64_t *addr, u
431
393
}
432
394
else
433
395
{
434
- // On failure, value is written to comparand.
396
+ /* On failure, value is written to comparand. */
435
397
return comparand ;
436
398
}
437
399
}
@@ -444,7 +406,7 @@ uintptr_t System_Threading_Interlocked_CompareExchangerusususus(uintptr_t *addr,
444
406
}
445
407
else
446
408
{
447
- // On failure, value is written to comparand.
409
+ /* On failure, value is written to comparand. */
448
410
return comparand ;
449
411
}
450
412
}
@@ -457,7 +419,7 @@ intptr_t System_Threading_Interlocked_CompareExchangerisisisis(intptr_t *addr, i
457
419
}
458
420
else
459
421
{
460
- // On failure, value is written to comparand.
422
+ /* On failure, value is written to comparand. */
461
423
return comparand ;
462
424
}
463
425
}
0 commit comments