Rev 1906 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1906 | Rev 3065 | ||
---|---|---|---|
1 | /* default reentrant pointer when multithread enabled */ |
1 | /* default reentrant pointer when multithread enabled */ |
2 | 2 | ||
3 | #include <_ansi.h> |
3 | #include <_ansi.h> |
4 | #include |
4 | #include |
5 | #include |
5 | #include |
6 | 6 | ||
7 | static inline |
7 | static inline |
8 | void *user_alloc(int size) |
8 | void *user_alloc(int size) |
9 | { |
9 | { |
10 | void *val; |
10 | void *val; |
11 | __asm__ __volatile__( |
11 | __asm__ __volatile__( |
12 | "int $0x40" |
12 | "int $0x40" |
13 | :"=eax"(val) |
13 | :"=eax"(val) |
14 | :"a"(68),"b"(12),"c"(size)); |
14 | :"a"(68),"b"(12),"c"(size)); |
15 | return val; |
15 | return val; |
16 | } |
16 | } |
17 | 17 | ||
18 | void init_reent() |
18 | void init_reent() |
19 | { |
19 | { |
20 | struct _reent *ent; |
20 | struct _reent *ent; |
21 | 21 | ||
22 | ent = user_alloc(sizeof(struct _reent)); |
22 | ent = user_alloc(sizeof(struct _reent)); |
23 | 23 | ||
24 | _REENT_INIT_PTR(ent); |
24 | _REENT_INIT_PTR(ent); |
25 | 25 | ||
26 | __asm__ __volatile__( |
26 | __asm__ __volatile__( |
27 | "movl %0, %%fs:12" |
27 | "movl %0, %%fs:12" |
28 | ::"r"(ent)); |
28 | ::"r"(ent)); |
29 | __sinit(ent); |
29 | __sinit(ent); |
30 | } |
30 | } |
- | 31 | ||
- | 32 | void init_global_reent() |
|
- | 33 | { |
|
- | 34 | struct _reent *ent; |
|
- | 35 | ||
- | 36 | ent =_GLOBAL_REENT; |
|
- | 37 | ||
- | 38 | _REENT_INIT_PTR(ent); |
|
- | 39 | ||
- | 40 | __asm__ __volatile__( |
|
- | 41 | "movl %0, %%fs:12" |
|
- | 42 | ::"r"(ent)); |
|
- | 43 | __sinit(ent); |
|
31 | 44 | } |
|
32 | 45 | ||
33 | 46 | ||
34 | void __mutex_lock(volatile int *val) |
47 | void __mutex_lock(volatile int *val) |
35 | { |
48 | { |
36 | int tmp; |
49 | int tmp; |
37 | 50 | ||
38 | __asm__ __volatile__ ( |
51 | __asm__ __volatile__ ( |
39 | "0:\n\t" |
52 | "0:\n\t" |
40 | "mov %0, %1\n\t" |
53 | "mov %0, %1\n\t" |
41 | "testl %1, %1\n\t" |
54 | "testl %1, %1\n\t" |
42 | "jz 1f\n\t" |
55 | "jz 1f\n\t" |
43 | 56 | ||
44 | "movl $68, %%eax\n\t" |
57 | "movl $68, %%eax\n\t" |
45 | "movl $1, %%ebx\n\t" |
58 | "movl $1, %%ebx\n\t" |
46 | "int $0x40\n\t" |
59 | "int $0x40\n\t" |
47 | "jmp 0b\n\t" |
60 | "jmp 0b\n\t" |
48 | "1:\n\t" |
61 | "1:\n\t" |
49 | "incl %1\n\t" |
62 | "incl %1\n\t" |
50 | "xchgl %0, %1\n\t" |
63 | "xchgl %0, %1\n\t" |
51 | "testl %1, %1\n\t" |
64 | "testl %1, %1\n\t" |
52 | "jnz 0b\n" |
65 | "jnz 0b\n" |
53 | : "+m" (*val), "=&r"(tmp) |
66 | : "+m" (*val), "=&r"(tmp) |
54 | ::"eax","ebx" ); |
67 | ::"eax","ebx" ); |
55 | } |
68 | } |