annotate TaskManager/kernel/ppe/SymTable.cc @ 47:8266445bdac2

*** empty log message ***
author gongo
date Fri, 15 Feb 2008 13:09:58 +0900
parents 31a7ff27ee20
children 3e331f7576a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
1 #include <string.h>
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
2 #include "SymTable.h"
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
3
20
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
4 SymTable::~SymTable(void)
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
5 {
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
6 SymTbPtr tb;
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
7
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
8 for (int i = 0; i < symtb_index; i++) {
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
9 tb = &symtb[i];
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
10 delete [] tb->sym;
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
11 }
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
12
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
13 delete [] symtb;
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
14 }
31a7ff27ee20 *** empty log message ***
gongo
parents: 14
diff changeset
15
14
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
16 void
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
17 SymTable::init(void)
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
18 {
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
19 symtb = new SymTb[SYM_MAX_SIZE];
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
20 symtb_index = 0;
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
21 }
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
22
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
23 void
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
24 SymTable::set_symbol(const char *sym, void *addr)
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
25 {
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
26 SymTbPtr tb = &symtb[symtb_index++];
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
27
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
28 tb->sym = new char[strlen(sym)+1];
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
29 memcpy(tb->sym, sym, strlen(sym)+1);
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
30 tb->address = addr;
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
31 }
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
32
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
33 void*
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
34 SymTable::get_address(int fd)
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
35 {
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
36 if (fd >= symtb_index) {
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
37 // Fix me
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
38 // error process
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
39 }
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
40
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
41 return symtb[fd].address;
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
42 }
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
43
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
44
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
45 int
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
46 SymTable::get_fd(const char *sym)
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
47 {
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
48 SymTbPtr tb;
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
49
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
50 for (int i = 0; i < SYM_MAX_SIZE; i++) {
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
51 tb = &symtb[i];
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
52 if (strcmp(tb->sym, sym) == 0) {
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
53 return i;
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
54 }
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
55 }
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
56
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
57 return -1;
41ccd4b38184 *** empty log message ***
gongo
parents:
diff changeset
58 }