OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE.md file. | |
4 | |
5 // This file contains all the missing pieces that LK should implement soon | |
6 // but currently does not. | |
7 | |
8 #include <stdio.h> | |
9 | |
10 // LK currently lacks an implementation for abort. | |
11 void abort(void) { | |
12 printf("Aborted (c-call).\n"); | |
13 while (1) {} | |
14 } | |
15 | |
16 // Guard implementation from libcxx. See | |
17 // http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/cxa_guard.cpp | |
18 | |
19 // A 32-bit, 4-byte-aligned static data value. The least significant 2 bits must | |
20 // be statically initialized to 0. | |
21 typedef unsigned guard_type; | |
22 | |
23 int __cxa_guard_acquire(guard_type* guard_object) { | |
24 return !((*guard_object) & 1); | |
25 } | |
26 | |
27 void __cxa_guard_release(guard_type* guard_object) { | |
28 *guard_object = 0x1; | |
29 } | |
30 | |
31 void __cxa_guard_abort(guard_type* guard_object) { | |
32 *guard_object = 0; | |
33 } | |
34 | |
35 // signbit implementation form FreeBSD // | |
36 | |
37 /*- | |
38 * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG> | |
39 * All rights reserved. | |
40 * | |
41 * Redistribution and use in source and binary forms, with or without | |
42 * modification, are permitted provided that the following conditions | |
43 * are met: | |
44 * 1. Redistributions of source code must retain the above copyright | |
45 * notice, this list of conditions and the following disclaimer. | |
46 * 2. Redistributions in binary form must reproduce the above copyright | |
47 * notice, this list of conditions and the following disclaimer in the | |
48 * documentation and/or other materials provided with the distribution. | |
49 * | |
50 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
60 * SUCH DAMAGE. | |
61 */ | |
62 | |
63 union IEEEl2bits { | |
64 long double e; | |
65 struct { | |
66 #if LITTLE_ENDIAN | |
67 unsigned int manl :32; | |
68 unsigned int manh :20; | |
69 unsigned int exp :11; | |
70 unsigned int sign :1; | |
71 #else | |
72 unsigned int sign :1; | |
73 unsigned int exp :11; | |
74 unsigned int manh :20; | |
75 unsigned int manl :32; | |
76 #endif | |
77 } bits; | |
78 }; | |
79 | |
80 int __signbit(double val) { | |
81 union IEEEl2bits as_bits; | |
82 as_bits.e = val; | |
83 return as_bits.bits.sign; | |
84 } | |
85 | |
OLD | NEW |