aboutsummaryrefslogtreecommitdiff
path: root/system/kernel
diff options
context:
space:
mode:
authorTom Schouten <doelie@users.sourceforge.net>2006-09-01 13:45:31 +0000
committerTom Schouten <doelie@users.sourceforge.net>2006-09-01 13:45:31 +0000
commit7591a024f184bd385d35583d19d86c1d5f2531ba (patch)
tree77aa0c44ccb700eb9a2b16e1b246e3c8026c40ed /system/kernel
parent91dd6b68f0f209ad015a303095bb1df018dca71e (diff)
pdp current darcs merge
svn path=/trunk/externals/pdp/; revision=5816
Diffstat (limited to 'system/kernel')
-rw-r--r--system/kernel/pdp_list.c4
-rw-r--r--system/kernel/pdp_mem.c19
-rw-r--r--system/kernel/pdp_packet.c38
-rw-r--r--system/kernel/pdp_post.c4
-rw-r--r--system/kernel/pdp_type.c2
5 files changed, 62 insertions, 5 deletions
diff --git a/system/kernel/pdp_list.c b/system/kernel/pdp_list.c
index deeb7f1..8558e35 100644
--- a/system/kernel/pdp_list.c
+++ b/system/kernel/pdp_list.c
@@ -760,10 +760,10 @@ void pdp_list_pop_push(t_pdp_list *source, t_pdp_list *dest)
/* return element at index */
-t_pdp_word pdp_list_index(t_pdp_list *l, int index)
+t_pdp_word pdp_list_index(t_pdp_list *l, int indx)
{
t_pdp_atom *a;
- for (a = l->first; index--; a = a->next);
+ for (a = l->first; indx--; a = a->next);
return a->w;
}
diff --git a/system/kernel/pdp_mem.c b/system/kernel/pdp_mem.c
index 33822ef..93c7122 100644
--- a/system/kernel/pdp_mem.c
+++ b/system/kernel/pdp_mem.c
@@ -19,9 +19,14 @@
*/
#include <stdlib.h>
+#include <stdio.h>
#include "pdp_mem.h"
#include "pdp_debug.h"
+// defined here so we don't need to rebuild when changing it (deps for headers are broken)
+#define PDP_FASTALLOC_BLOCK_ELEMENTS 4096
+//#define PDP_FASTALLOC_BLOCK_ELEMENTS 1
+#define D if (0)
/* malloc wrapper that calls garbage collector */
void *pdp_alloc(int size)
@@ -30,6 +35,8 @@ void *pdp_alloc(int size)
PDP_ASSERT(ptr);
+ D fprintf(stderr, "alloc %p %d\n", ptr, size);
+
return ptr;
//TODO: REPAIR THIS
@@ -41,6 +48,7 @@ void *pdp_alloc(int size)
void pdp_dealloc(void *stuff)
{
+ D fprintf(stderr, "dealloc %p\n", stuff);
free (stuff);
}
@@ -87,6 +95,10 @@ static void _pdp_fastalloc_refill_freelist(t_pdp_fastalloc *x)
}
+#define USE_FASTALLOC 1
+
+#if USE_FASTALLOC
+
void *pdp_fastalloc_new_atom(t_pdp_fastalloc *x)
{
t_fastalloc *atom;
@@ -127,3 +139,10 @@ t_pdp_fastalloc *pdp_fastalloc_new(unsigned int size)
return x;
}
+#else
+
+void *pdp_fastalloc_new_atom(t_pdp_fastalloc *x) {return pdp_alloc(12);}
+void pdp_fastalloc_save_atom(t_pdp_fastalloc *x, void *atom) {pdp_dealloc(atom);}
+t_pdp_fastalloc *pdp_fastalloc_new(unsigned int size) {return 0;}
+
+#endif
diff --git a/system/kernel/pdp_packet.c b/system/kernel/pdp_packet.c
index 0eb569a..e5f1a1f 100644
--- a/system/kernel/pdp_packet.c
+++ b/system/kernel/pdp_packet.c
@@ -32,6 +32,8 @@
#include "pdp_debug.h"
+#define D if(0)
+
/* packet implementation. contains class and packet (instance) handling
some notes on packet operations.
@@ -152,6 +154,7 @@ int pdp_factory_newpacket(t_pdp_symbol *type)
/* call class constructor */
while(a){
+ D pdp_post("new: %s", type->s_name);
c = (t_pdp_class *)(a->w.w_pointer);
if (c->type && pdp_type_description_match(type, c->type)){
//pdp_post("method %x, type %s", c->create, type->s_name);
@@ -287,6 +290,15 @@ pdp_packet_create(unsigned int datatype, unsigned int datasize /*without header*
*/
+/* NEW DOES NOT USE THE REUSE FIFO !!!!
+ this is a true and genuine mess:
+ the reuse fifo can grow indefinitely with garbage elements if it's never used,
+ while it points to stale packets.. backdoor access = BAD.
+
+ if i recall, this is mainly a compatibility issue..
+
+*/
+
int
pdp_packet_new(unsigned int datatype, unsigned int datasize)
{
@@ -327,6 +339,9 @@ pdp_packet_new(unsigned int datatype, unsigned int datasize)
void
_pdp_packet_save_nolock(int packet)
{
+
+
+
t_pdp *header = pdp_packet_header(packet);
t_pdp_symbol *s;
PDP_ASSERT(header);
@@ -334,7 +349,30 @@ _pdp_packet_save_nolock(int packet)
PDP_ASSERT(header->desc);
s = header->desc;
if (!s->s_reusefifo) s->s_reusefifo = pdp_list_new(0);
+
+
+ /* big o hack: since pdp_packet_new can reap packets behind our back,
+ we won't add a packet if it's already in here */
+
+ if (1) {
+ t_pdp_atom *a = s->s_reusefifo->first;
+ while (a){
+ if (a->w.w_packet == packet) goto found;
+ a = a->next;
+ }
+ }
+
pdp_list_add(s->s_reusefifo, a_packet, (t_pdp_word)packet);
+
+ found:
+
+
+
+ if (PDP_DEBUG){
+ int el = s->s_reusefifo->elements;
+ int maxel = 100;
+ if (el > maxel) pdp_post("WARNING: %s reuse fifo has %d elements.", s->s_name, el);
+ }
}
/* this will revive a packet matching a certain type description
diff --git a/system/kernel/pdp_post.c b/system/kernel/pdp_post.c
index fb761d0..b75283b 100644
--- a/system/kernel/pdp_post.c
+++ b/system/kernel/pdp_post.c
@@ -29,14 +29,14 @@
/* list printing should be moved here too */
/* write a message to log (console) */
-void pdp_post_n(char *fmt, ...)
+void _pdp_post_n(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
-void pdp_post(char *fmt, ...)
+void _pdp_post(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
diff --git a/system/kernel/pdp_type.c b/system/kernel/pdp_type.c
index 0216d07..57edc00 100644
--- a/system/kernel/pdp_type.c
+++ b/system/kernel/pdp_type.c
@@ -342,7 +342,7 @@ int _pdp_packet_convert(int packet, t_pdp_symbol *dest_template)
return -1;
}
if (program_last == program_tail){
- pdp_post("ERROR: pdp_packet_convert: conversion loop detected");
+ //pdp_post("ERROR: pdp_packet_convert: conversion loop detected");
}
program_last = program_tail;