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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
4 #include "allocateContext.h"
10
88a4a95f5485 create list
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
5
8
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "allocate.h"
10
88a4a95f5485 create list
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 9
diff changeset
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
1eb599acffe4 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
15 #define ALLOCATE_SIZE 1024
8
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
16
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
17 extern __code initAllocateContext(struct Context* context);
14
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
18 /*
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
19 __code code1(Allocate allocate) {
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
20 allocate.size = sizeof(long);
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
21 allocate.next = Code2;
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
22 goto Allocate(allocate);
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
23 }
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
24 */
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
25
15
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
26 __code code1(struct Context* context) {
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
27 context->data[0]->allocate.size = sizeof(long);
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
28 context->data[0]->allocate.next = Code2;
14
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
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
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
32 __code meta(struct Context* context, enum Code next) {
14
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
33 goto (context->code[next])(context);
11
a4f351b66544 implement appned
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
34 }
a4f351b66544 implement appned
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
35
14
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
36 /*
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
37 __code code2(Allocate allocate, Count count) {
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
38 count.count = 0;
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
39 goto code3(count);
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
40 }
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
41 */
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
42
15
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
43 __code code2(struct Context* context) {
14
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
44 context->data[1]->count = 0;
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
45 goto meta(context, Code3);
11
a4f351b66544 implement appned
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
46 }
a4f351b66544 implement appned
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 10
diff changeset
47
15
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
48 __code code3(struct Context* context) {
14
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
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
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
51 goto meta(context, Exit);
8
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 }
15
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
53 printf("%ld\n", loop);
14
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
54 context->data[1]->count++;
d98961bfd0f2 Code linkage information
innparusu
parents: 11
diff changeset
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
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
59 struct Context* context = (struct Context*)malloc(sizeof(struct Context));
17
1eb599acffe4 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
60 context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE);
1eb599acffe4 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
61 context->data = malloc(sizeof(union Data**)*ALLOCATE_SIZE);
1eb599acffe4 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 16
diff changeset
62 context->heap = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
15
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
63 initAllocateContext(context);
907c69e21e56 modify allocate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 14
diff changeset
64 goto start_code(context, Code1);
8
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 }