Mercurial > hg > Members > Moririn
annotate src/allocate/allocate.c @ 171:747067fe46bd
Fix selected Queue
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 24 Nov 2016 16:29:46 +0900 |
parents | 1eb599acffe4 |
children |
rev | line source |
---|---|
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h> |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include <stdlib.h> |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 |
15 | 4 #include "allocateContext.h" |
10 | 5 |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 #include "allocate.h" |
10 | 7 #include "origin_cs.h" |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 #ifdef CLANG |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 #define _CbC_retrun __return |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 #define _CbC_environment __environment |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 #endif |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 #define NUM 100 |
17 | 15 #define ALLOCATE_SIZE 1024 |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 |
16 | 17 extern __code initAllocateContext(struct Context* context); |
14 | 18 /* |
19 __code code1(Allocate allocate) { | |
20 allocate.size = sizeof(long); | |
21 allocate.next = Code2; | |
22 goto Allocate(allocate); | |
23 } | |
24 */ | |
25 | |
15 | 26 __code code1(struct Context* context) { |
27 context->data[0]->allocate.size = sizeof(long); | |
28 context->data[0]->allocate.next = Code2; | |
14 | 29 goto meta(context, Allocate); |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 } |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 |
15 | 32 __code meta(struct Context* context, enum Code next) { |
14 | 33 goto (context->code[next])(context); |
11 | 34 } |
35 | |
14 | 36 /* |
37 __code code2(Allocate allocate, Count count) { | |
38 count.count = 0; | |
39 goto code3(count); | |
40 } | |
41 */ | |
42 | |
15 | 43 __code code2(struct Context* context) { |
14 | 44 context->data[1]->count = 0; |
45 goto meta(context, Code3); | |
11 | 46 } |
47 | |
15 | 48 __code code3(struct Context* context) { |
14 | 49 long loop = context->data[1]->count; |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 if (loop == NUM) { |
14 | 51 goto meta(context, Exit); |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 } |
15 | 53 printf("%ld\n", loop); |
14 | 54 context->data[1]->count++; |
55 goto meta(context, Code3); | |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 } |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
57 |
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 int main() { |
15 | 59 struct Context* context = (struct Context*)malloc(sizeof(struct Context)); |
17 | 60 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); |
61 context->data = malloc(sizeof(union Data**)*ALLOCATE_SIZE); | |
62 context->heap = malloc(sizeof(union Data*)*ALLOCATE_SIZE); | |
15 | 63 initAllocateContext(context); |
64 goto start_code(context, Code1); | |
8
714d0ce1efd7
change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 } |