I am working on a project with the XINU OS and while adding pipes to the system I get a compiler error when trying to add and use a new member to a struct I made earlier. I honestly can not see what is wrong with my code, especially when I compare it to working pieces that vary by a variable name.
"/pipcreate.c:21: error: 'struct pipent' has no member named 'owner'"
As for the two lines commented out (reader = PR_CURR, writer = PR_CURR) if I uncomment those, and comment out the 'owner' line, it does compile fine.
Does anything stand out as the obvious problem, and I am just completely overlooking it?
pipe.h
/*typedef int32 pipid32 inside of kernel.h*/
/* Max number of pipes in the system */
#ifndef NPIP
#define NPIP 10
#endif
/* Pipe state constants */
#define PIPE_FREE 0 /* pipe table entry is unused */
#define PIPE_USED 1 /* pipe is currently used */
#define PIPE_CONNECTED 2 /* pipe is currently connected */
/* Misc pipe definitions */
#define isbadpipid(x) ( ((pid32)(x) < 0) || \
((pid32)(x) >= NPIP) || \
(piptab[(x)].pipstate == PIPE_FREE))
/* Definition of pipe table */
struct pipent { /* entry in the pipe table */
uint32 pipstate; /* pipe state: PIP_FREE, ect. */
uint32 pipid; /* pipe ID in table */
char buffer[256]; /* buffer to write to */
pid32 writer; /* pid for writer */
pid32 reader; /* pid for reader */
pid32 owner; /* CURR_PID upon pipe being created */
};
extern struct pipent piptab[];
extern int32 pipcount;
pipcreate.c
#include <xinu.h>
#include <string.h>
static pipid32 newpipid(void);
/*------------------------------------------------------------------------
* pipcreate -
*------------------------------------------------------------------------
*/
syscall pipcreate(void){
intmask mask; /* saved interrupt mask */
//struct pipent piptab[];
struct pipent *piptr; /* ptr to pipe's table entry */
pipid32 pipid; /* ID of newly created pipe */
mask = disable();
pipid = newpipid(); /* pipid to return */
piptr->pipstate = PIPE_USED;
piptr->owner = PR_CURR;
//piptr->writer = PR_CURR;
//piptr->reader = PR_CURR;
pipcount++; /* increment number of pipes */
piptr = &piptab[pipid];
restore(mask);
return pipid;
}
//newpipid - obtain a new (free) pipe ID
local pipid32 newpipid(void)
{
uint32 i;
static pipid32 nextpipid = 1;
/* Check all NPIP slots */
for(i = 0; i < NPIP; i++){
nextpipid %= NPIP; /* wrap around to beginning */
if(piptab[nextpipid].pipstate == PIPE_FREE){
return nextpipid++;
} else {
nextpipid++;
}
}
return (pid32) SYSERR;
}
struct pipent
. - jamesdlin