Mercurial > projects > ldc
comparison lphobos/gc/gclinux.d @ 94:61615fa85940 trunk
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
Added support for array .sort and .reverse properties.
Fixed some bugs with pointer arithmetic.
Disabled some DMD AST optimizations that was messing things up, destroying valuable information.
Added a KDevelop project file, this is what I use for coding LLVMDC now :)
Other minor stuff.
author | lindquist |
---|---|
date | Mon, 12 Nov 2007 06:32:46 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
93:08508eebbb3e | 94:61615fa85940 |
---|---|
1 | |
2 // Copyright (C) 2001-2004 by Digital Mars, www.digitalmars.com | |
3 // All Rights Reserved | |
4 // Written by Walter Bright | |
5 | |
6 import std.c.linux.linuxextern; | |
7 import std.c.linux.linux; | |
8 | |
9 /+ | |
10 extern (C) | |
11 { | |
12 // from <sys/mman.h> | |
13 void* mmap(void* addr, uint len, int prot, int flags, int fd, uint offset); | |
14 int munmap(void* addr, uint len); | |
15 const void* MAP_FAILED = cast(void*)-1; | |
16 | |
17 // from <bits/mman.h> | |
18 enum { PROT_NONE = 0, PROT_READ = 1, PROT_WRITE = 2, PROT_EXEC = 4 } | |
19 enum { MAP_SHARED = 1, MAP_PRIVATE = 2, MAP_TYPE = 0x0F, | |
20 MAP_FIXED = 0x10, MAP_FILE = 0, MAP_ANON = 0x20 } | |
21 } | |
22 +/ | |
23 | |
24 /*********************************** | |
25 * Map memory. | |
26 */ | |
27 | |
28 void *os_mem_map(uint nbytes) | |
29 { void *p; | |
30 | |
31 //errno = 0; | |
32 p = mmap(null, nbytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); | |
33 return (p == MAP_FAILED) ? null : p; | |
34 } | |
35 | |
36 /*********************************** | |
37 * Commit memory. | |
38 * Returns: | |
39 * 0 success | |
40 * !=0 failure | |
41 */ | |
42 | |
43 int os_mem_commit(void *base, uint offset, uint nbytes) | |
44 { | |
45 return 0; | |
46 } | |
47 | |
48 | |
49 /*********************************** | |
50 * Decommit memory. | |
51 * Returns: | |
52 * 0 success | |
53 * !=0 failure | |
54 */ | |
55 | |
56 int os_mem_decommit(void *base, uint offset, uint nbytes) | |
57 { | |
58 return 0; | |
59 } | |
60 | |
61 /*********************************** | |
62 * Unmap memory allocated with os_mem_map(). | |
63 * Returns: | |
64 * 0 success | |
65 * !=0 failure | |
66 */ | |
67 | |
68 int os_mem_unmap(void *base, uint nbytes) | |
69 { | |
70 return munmap(base, nbytes); | |
71 } | |
72 | |
73 | |
74 /********************************************** | |
75 * Determine "bottom" of stack (actually the top on x86 systems). | |
76 */ | |
77 | |
78 void *os_query_stackBottom() | |
79 { | |
80 version (none) | |
81 { // See discussion: http://autopackage.org/forums/viewtopic.php?t=22 | |
82 static void** libc_stack_end; | |
83 | |
84 if (libc_stack_end == libc_stack_end.init) | |
85 { | |
86 void* handle = dlopen(null, RTLD_NOW); | |
87 libc_stack_end = cast(void **)dlsym(handle, "__libc_stack_end"); | |
88 dlclose(handle); | |
89 } | |
90 return *libc_stack_end; | |
91 } | |
92 else | |
93 { // This doesn't resolve on all versions of Linux | |
94 return __libc_stack_end; | |
95 } | |
96 } | |
97 | |
98 | |
99 /********************************************** | |
100 * Determine base address and size of static data segment. | |
101 */ | |
102 | |
103 void os_query_staticdataseg(void **base, uint *nbytes) | |
104 { | |
105 *base = cast(void *)&__data_start; | |
106 *nbytes = cast(byte *)&_end - cast(byte *)&__data_start; | |
107 } |