changeset 606:32a7260fad2f

32bit/64bit ABI (64 bit is not tested yet). 64bit ABI requires 64bit SDL library etc.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 07 Nov 2009 18:05:52 +0900
parents 90c61fe2b109
children 6b865e046710
files Renderer/Engine/Makefile.def Renderer/Engine/Makefile.macosx Renderer/Engine/Tapestry.h Renderer/Engine/lindaapi.cc Renderer/Engine/lindaapi.h Renderer/Engine/main.cc Renderer/Test/Makefile.def Renderer/Test/Makefile.macosx TaskManager/Makefile.def TaskManager/Makefile.fifo
diffstat 10 files changed, 46 insertions(+), 208 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Engine/Makefile.def	Sat Nov 07 18:05:52 2009 +0900
@@ -2,8 +2,9 @@
 
 CERIUM = ../..
 
+ABI = -m32
 CC      = g++
-CFLAGS  = -g -Wall -DUSE_MEMLIST=1 -DUSE_MEMHASH=1 # -O9 -DDEBUG
+CFLAGS  = -g -Wall $(ABI) # -O9 -DDEBUG
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I.
-LIBS = -L$(CERIUM)/TaskManager
+LIBS = -L$(CERIUM)/TaskManager $(ABI)
--- a/Renderer/Engine/Makefile.macosx	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Engine/Makefile.macosx	Sat Nov 07 18:05:52 2009 +0900
@@ -13,8 +13,8 @@
 
 LIBS += -lFifoManager
 
-CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
-LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags` 
+LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL 
 
 .SUFFIXES: .cc .o
 
--- a/Renderer/Engine/Tapestry.h	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Engine/Tapestry.h	Sat Nov 07 18:05:52 2009 +0900
@@ -71,15 +71,7 @@
 
 };
 
-#ifdef USE_MEMLIST
 typedef MemorySegment Tile, *TilePtr;
-#else
-typedef struct {
-    uint32 data[TEXTURE_BLOCK_SIZE]; // 8*8
-    uint32 *address;
-    int pad[3];
-} Tile, *TilePtr;
-#endif
 
 #define MAX_TILE 128
 
@@ -88,7 +80,6 @@
  * これは汎用のサイズ別 freelist に置き換える
  * freelist は double linked list で、LRU をサポートする
 */
-#ifdef USE_MEMLIST
 class TileList : public MemList {
     TileList(MemorySegment* ms) : MemList(ms) {}
 
@@ -96,41 +87,6 @@
   中身は同じ
  */
 };
-#else
-class TileList {
-public:
-    int curIndex;
-    int pad[3];
-    Tile tile[MAX_TILE];
-
-    TileList(void) {
-        curIndex = 0;
-    }
-
-    /**
-     * 次に扱う tile を取得する
-     *
-     * @return tile
-     *
-     * tile[] をリングバスっぽく扱うことで
-     * FIFO を実現することに。
-     */
-    TilePtr nextTile(void) {
-        TilePtr t = &tile[curIndex];
-        curIndex = (curIndex + 1) % MAX_TILE;
-        return t;
-    }
-
-    /**
-     * TileList のクリア
-     * //tile 自体は clear する必要は無い
-     * あるかもしれない
-     */
-    void clear(void) {
-        curIndex = 0;
-    }
-};
-#endif
 
 typedef TileList* TileListPtr;
 
--- a/Renderer/Engine/lindaapi.cc	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Engine/lindaapi.cc	Sat Nov 07 18:05:52 2009 +0900
@@ -20,7 +20,7 @@
 #include <arpa/inet.h>
 
 #include "lindaapi.h"
-#if 0
+
 
 #if 0
 #define PSX_Debug(deb)    (putchar(PS_DEB)),\
@@ -42,7 +42,7 @@
 /* Static Functions */
 static void unix_chkserv(int ps);
 void psx_free(void *);
-static int psx_queue(unsigned int tspace_id, unsigned int id,
+static long psx_queue(unsigned int tspace_id, unsigned int id,
               unsigned int size, unsigned char *data, char mode,
               void(*callback)(unsigned char *,void *),void * obj);
 
@@ -314,10 +314,10 @@
   返り値:
       シーケンス番号
 /-------------------------------------------------------------------*/
-int
+long
 psx_out(unsigned int tspace_id, unsigned int id,
         unsigned char *data, unsigned int size){
-    int r;
+    long r;
     if ((r = psx_queue(tspace_id, id, size, data, 'o', NULL, NULL)) == FAIL) {
         return(FAIL);
     }
@@ -343,10 +343,10 @@
   返り値:
       psx_queue内でmallocされたREPLY構造体へのポインタ
 /-------------------------------------------------------------------*/
-int
+long
 psx_ld(unsigned int tspace_id, unsigned int id,
        char mode, void(*callback)(unsigned char *,void *), void * obj){
-    int r;
+    long r;
     if ((r = psx_queue(tspace_id, id, 0, NULL, mode, callback, obj)) == FAIL) {
         return(FAIL);
     }
@@ -371,7 +371,6 @@
     
     DEB(fprintf(stdout, "psx_reply: search of seq = %d\n", seq));
     PSX_Debug(("psx_reply: seq %d", seq)); 
-    // linear search なの?
     for(q = NULL,p = reply; p; q = p,p = p->next){
         if (p->seq == seq){
             DEB(fprintf(stdout, "psx_reply: match of seq = %d\n", seq));
@@ -450,7 +449,7 @@
 }
 
 /*-------------------------------------------------------------------/
-  static long
+  static int
   psx_queue (unsigned int tspace_id, unsigned int id,
              unsigned int size, unsigned char *data, char mode,
              void(*callback)(char*,void*), void * obj):
@@ -472,7 +471,7 @@
                      0が返る。
       失敗した場合 - FAIL(-1)が返る。
 /-------------------------------------------------------------------*/
-static int
+static long
 psx_queue(unsigned int tspace_id, unsigned int id,
           unsigned int size, unsigned char *data, char mode,
           void(*callback)(unsigned char *,void *), void * obj){
@@ -507,14 +506,18 @@
     /* データ受け取り要求(in,rd,wait)なら受け取り用の箱を用意 */
     if (mode != 'o') {  
         if (reply == NULL){
-            reply = new_reply();
+            if ((reply = (REPLY *) malloc (sizeof(REPLY))) == NULL){
+                return(FAIL);
+            }
             p = r_end = reply; p->next = NULL;
         } else {
-            r_end->next = new_reply();
+            if ((r_end->next = (REPLY *) malloc (sizeof(REPLY))) == NULL){
+                return(FAIL);
+            }
             p = r_end->next; r_end = p; p->next = NULL;
         }
         p->mode = '?';
-        p->seq = p->reply_id;  
+        p->seq = (long)p;  // 構造体のアドレスで識別
         p->callback = callback;
         p->obj = obj;
         PSX_Debug(("psx_queue: seq %d reply %x p %x r_end %x",seq,reply,p,r_end));
@@ -530,7 +533,11 @@
     q_end->command[LINDA_SEQ_OFFSET+1] = ((long)p>>16) & 0xff;
     q_end->command[LINDA_SEQ_OFFSET+2] = ((long)p>>8)  & 0xff;
     q_end->command[LINDA_SEQ_OFFSET+3] = ((long)p)     & 0xff;
-
+    
+    q_end->command[LINDA_DATA_LENGTH_OFFSET]   = (size>>24) & 0xff;
+    q_end->command[LINDA_DATA_LENGTH_OFFSET+1] = (size>>16) & 0xff;
+    q_end->command[LINDA_DATA_LENGTH_OFFSET+2] = (size>>8)  & 0xff;
+    q_end->command[LINDA_DATA_LENGTH_OFFSET+3] = (size)     & 0xff;
     
     q_end->size = size+LINDA_HEADER_SIZE;       /* command size */
     q_end->tspace_id = tspace_id;  /* destination id */
@@ -713,139 +720,4 @@
 
 
 
-
-static ReplyPtr freeReply;   /* Free Pool of Reply */
-static ReplyPtr replyPool;   /* List of malloced free Reply */
-
-static ReplyPtr extend_reply_pool(int num);
-
-static const int QUEUE_MALLOC_ERROR =   10;
-static const int POOL_SIZE_OVER_ERROR = 11;
-
-static int reply_errno;
-
-//
-// Initialize Reply Pool
-//    return NULL on error
-//
-
-static ReplyPtr
-init_reply(int num)
-{
-    ReplyPtr q;
-    if (! replyPool) {
-	return extend_reply_pool(num);
-    }
-    return replyPool;
-}
-
-static ReplyPtr
-extend_reply_pool(int num)
-{
-    ReplyPtr q;
-    // Keep malloc history in ReplyPool
-    q =  (ReplyPtr) malloc(sizeof(Reply) * (num+1));
-    if (!q) {
-	reply_errno = QUEUE_MALLOC_ERROR;
-	retrun q;
-    }
-    q->next = replyPool;
-    replyPool = q;
-    // Connect all free reply in the pool
-    q = queeuePool + 1;
-    for(q = replyPool+1; num-->0;  q++) q->next = q+1;
-    q->next = freeReply;
-    freeReply = replyPool+1;
-    return replyPool;
-}
-
-static void
-destory_reply()
-{
-    ReplyPtr q;
-    for(q = replyPool ;q; q = q->next) {
-	free(q);
-    }
-    freeReply = replyPool = NULL;
-}
-
-static ReplyPtr
-new_reply(int priority, int task)
-{
-    ReplyPtr q;
-    if (!freeReply) {
-	pool_size *= 2;
-	if (pool_size > MAX_POOL_SIZE) {
-	    reply_errno = POOL_SIZE_OVER_ERROR;
-	    return NULL;
-	}
-	if (!extend_reply_pool(pool_size)) {
-	    return NULL;
-	}
-    }
-    q = freeReply;
-    freeReply = freeReply->next;
-    q->next = NULL;
-    q->priority = priority;
-    q->task = task;
-    return q;
-}
-
-static void
-free_reply(ReplyPtr q)
-{
-    q->next = freeReply;
-    freeReply = q;
-}
-
-static TaskListPtr
-new_task_list(char *name)
-{
-    TaskLilstPtr task;
-    task =  (TaskListPtr) malloc(sizeof(TaskList));
-    task->reply = NULL;
-    task->name = name;
-}
-
-static void
-free_task_list(TaskListPtr task)
-{
-    free(task);
-}
-
-static void
-insert_reply(TaskListPtr list,ReplyPtr q)
-{
-    q->next = list->reply;
-    list->reply = q; 
-}
-
-static void
-qppend_reply(TaskListPtr list,ReplyPtr q)
-{
-    ReplyPtr p = list->reply;
-    while(p->next) p = p->next;
-    p->next = q;
-}
-
-static void
-remove_reply(TaskListPtr list,ReplyPtr q)
-{
-    ReplyPtr p = list->reply;
-    ReplyPtr p1 = p->next;
-
-    while(p1 && p1 != q) { p1 = p1->next; p = p->next; }
-    if (p1) {
-	p->next = p1->next;
-    }
-}
-
-#else
-
-void
-psx_sync_n(){
-}
-
-#endif
-
 /* end */
--- a/Renderer/Engine/lindaapi.h	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Engine/lindaapi.h	Sat Nov 07 18:05:52 2009 +0900
@@ -2,6 +2,8 @@
 
 #define _LINDAAPI_H 1
 
+#include "types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -24,9 +26,9 @@
 
 /*----------------------------------------------------------------------
  パケットフォーマット
- char     short  8byte    int
+ char     short  int    int
  Mode +   ID   + Seq  + Data_len + Padding + Data
- 0        1      3      7        11        12
+ 0        1      3      7          11        12
 ----------------------------------------------------------------------*/
 
 #define LINDA_MODE_OFFSET          0
@@ -45,7 +47,7 @@
     char mode;
     void(*callback)(unsigned char * tuple, void * obj);
     void * obj;
-} REPLY, Reply, *ReplyPtr;
+} REPLY;
           
 typedef struct command_queue{
     struct command_queue *next;
@@ -75,9 +77,9 @@
 extern unsigned char psx_get_mode(unsigned char *);
 extern unsigned char * psx_get_data(unsigned char *);
 
-extern int psx_out(unsigned int tspace_id, unsigned int id,
+extern long psx_out(unsigned int tspace_id, unsigned int id,
                    unsigned char *data, unsigned int size);
-extern int psx_ld(unsigned int tspace_id, unsigned int id,
+extern long psx_ld(unsigned int tspace_id, unsigned int id,
                   char mode, void(*callback)(unsigned char *,void *),void * obj);
 
 #define psx_in(tid, id)      psx_ld(tid, id, 'i', NULL, NULL)
--- a/Renderer/Engine/main.cc	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Engine/main.cc	Sat Nov 07 18:05:52 2009 +0900
@@ -6,7 +6,6 @@
 
 /* prototype */
 extern int init(TaskManager *manager, int argc, char *argv[]);
-static void TMend(TaskManager *manager);
 
 extern void task_initialize();
 extern Application *application();
@@ -79,6 +78,9 @@
 }
 
 #if 0
+
+// These are defined in Application
+
 int
 TMmain(TaskManager *manager, int argc, char *argv[])
 {
@@ -95,3 +97,5 @@
 }
 
 #endif
+
+/* end */
--- a/Renderer/Test/Makefile.def	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Test/Makefile.def	Sat Nov 07 18:05:52 2009 +0900
@@ -1,9 +1,10 @@
 
 CERIUM = ../..
 
+ABI = -m32
 CC      = g++
-CFLAGS  = -g -Wall  # -O -DDEBUG
+CFLAGS  = -g -Wall $(ABI)  # -O -DDEBUG
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I. -I$(CERIUM)/include/Cerium
-LIBS = -L$(CERIUM)/TaskManager -L$(CERIUM)/Renderer/Engine
+LIBS = -L$(CERIUM)/TaskManager -L$(CERIUM)/Renderer/Engine $(ABI)
 TOOL = $(CERIUM)/bin
--- a/Renderer/Test/Makefile.macosx	Sat Nov 07 17:42:21 2009 +0900
+++ b/Renderer/Test/Makefile.macosx	Sat Nov 07 18:05:52 2009 +0900
@@ -2,8 +2,8 @@
 
 LIBS += -lCerium -lFifoManager 
 
-CFLAGS += `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)
-LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags` $(INCLUDE)  
+LIBS   += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL 
 
 .SUFFIXES: .cc .o  .xml .xml.h .xml.cc
 
--- a/TaskManager/Makefile.def	Sat Nov 07 17:42:21 2009 +0900
+++ b/TaskManager/Makefile.def	Sat Nov 07 18:05:52 2009 +0900
@@ -27,8 +27,10 @@
 IMPL_CELL_SRCS = $(IMPL_FIFO_SRCS) $(wildcard $(IMPL_CELL_DIR)/*.cc)
 IMPL_CELL_OBJS = $(IMPL_CELL_SRCS:.cc=.o)
 
+ABI = -m32
+
 CC     = g++   
-CFLAGS = -Wall `sdl-config --cflags` -g # -O9 
+CFLAGS = -Wall `sdl-config --cflags` -g $(ABI) # -O9 
 LIBS   = 
 
 INCLUDE = -I../include/TaskManager
--- a/TaskManager/Makefile.fifo	Sat Nov 07 17:42:21 2009 +0900
+++ b/TaskManager/Makefile.fifo	Sat Nov 07 18:05:52 2009 +0900
@@ -20,4 +20,4 @@
 fifodistclean: fifoclean
 	rm -f $(TARGET)
 
-fifoclean:
\ No newline at end of file
+fifoclean: