Pancakes:IPC EntryBased: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
Pancakes (talk | contribs)
m added note on inter-thread and inter-process communication
Pancakes (talk | contribs)
m fixed problem
Line 26:
==== Code ====
<source lang="c">
#ifdef B64
typedef unsigned long long uintptr;
#else
typedef unsigned int uintptr;
#endif
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef int int32;
#endif
 
struct _RBE {
uint32int32 w;
uint32int32 r;
uint8 d[];
};
Line 35 ⟶ 47:
struct _RBME {
RB *rb;
uint32int32 sz;
};
typedef struct _RBME RBM;
Line 41 ⟶ 53:
int rb_write_nbio(RBM *rbm, void *p, uint32 sz) {
RB volatile *rb;
uint32int32 r;
uint32int32 w;
uint32 *h;
uint8int32 x, y;
uint32int32 asz;
uint32int32 max;
rb = (RB volatile*)rbm->rb;
Line 68 ⟶ 80:
/* not enough space */
if ((w < r) && (w + asz) >= r) {
//printf("##$#\n");
return 0;
}
Line 74 ⟶ 85:
/* not enough space */
if ((w >= r) && ((rbm->sz - w) + r) < asz) {
//printf("LESS THAN\n");
return 0;
}
/* write length */
if (w == rbm->sz) {
w = 0;
}
rb->d[w++] = sz >> 8;
if (w >= rbm->sz) {
Line 92 ⟶ 99:
/* split write */
ifmax (w >= r && (rbm->sz - w) < sz) {;
if (w =>= rbm->r && max < sz) {
/* copy first part */
max = rbm->sz - w;
for (x = 0; x < max; ++x) {
rb->d[w + x] = ((uint8*)p)[x];
Line 128 ⟶ 135:
int rb_read_nbio(RBM *rbm, void *p, uint32 *sz, uint32 *advance) {
RB volatile *rb;
uint32int32 r;
uint32 volatileint32 w;
uint32int32 h;
intint32 x, y;
uint8 *_p;
uint32int32 max;
_p = (uint8*)p;