nanogui: GrShmCmdsFlushWrapper() and HAVE_SHAREDMEM_SUPPORT


Previous by date: 23 Jun 2000 05:57:24 -0000 Re: Linux example binaries, 曾昭明
Next by date: 23 Jun 2000 05:57:24 -0000 Re: Linux example binaries, Kyle Harris
Previous in thread:
Next in thread:

Subject: GrShmCmdsFlushWrapper() and HAVE_SHAREDMEM_SUPPORT
From: Jamie Guinan ####@####.####
Date: 23 Jun 2000 05:57:24 -0000
Message-Id: <Pine.LNX.4.21.0006230141320.29499-200000@gemini.home.net>

Building nanox with HAVE_SHAREDMEM_SUPPORT breaks srvnet.c.

GrShmCmdsFlushWrapper() references GrFunctions[] which is not
defined until after the function.   Fixed by prototyping 
GrShmCmdsFlushWrapper() then moving it below the table 
declaration.

[ Admitted trivial ] patch attached.

-Jamie

*** microwin/src/nanox/srvnet.c~	Sun Jun 18 16:56:08 2000
--- microwin/src/nanox/srvnet.c	Fri Jun 23 01:10:28 2000
***************
*** 921,972 ****
  #endif /* HAVE_SHAREDMEM_SUPPORT*/
  }
  
! void
! GrShmCmdsFlushWrapper(void *r)
! {
! 	nxShmCmdsFlushReq *req = r;
! 	unsigned char 	reply;
! #if HAVE_SHAREDMEM_SUPPORT
! 	nxReq 		*pr;
! 	int 		length;
! 	unsigned char 	*do_req, *do_req_last;
! 
! 	if ( current_shm_cmds == 0 || current_shm_cmds_size < req->size ) {
! 		/* No or short shm present serverside, bug or mischief */
! 		EPRINTF("nano-X: Ill behaved client assumes shm ok\n");
! 		if ( req->reply ) {
! 			reply = 0;
! 			GsWrite(current_fd, &reply, 1);
! 		}
! 		return;
! 	}
! 
! 	do_req = current_shm_cmds;
! 	do_req_last = current_shm_cmds + req->size;
! 
! 	while ( do_req < do_req_last ) {
! 		pr = (nxReq *)do_req;
! 		length = GetReqAlignedLen(pr);
! 		if ( pr->reqType < GrTotalNumCalls ) {
! 			GrFunctions[pr->reqType].func(pr);
! 		} else {
! 			EPRINTF("Error bad shm function!\n");
! 		}
! 		do_req += length;
! 	}
! 
! 	if ( req->reply ) {
! 		reply = 1;
! 		GsWrite(current_fd, &reply, 1);
! 	}
! #else
! 	/* no shared memory support*/
! 	if ( req->reply ) {
! 		reply = 0;
! 		GsWrite(current_fd, &reply, 1);
! 	}
! #endif /* HAVE_SHAREDMEM_SUPPORT*/
! }
  
  /*
   * Handler functions, ordered by reqType
--- 921,927 ----
  #endif /* HAVE_SHAREDMEM_SUPPORT*/
  }
  
! void GrShmCmdsFlushWrapper(void *);
  
  /*
   * Handler functions, ordered by reqType
***************
*** 1058,1063 ****
--- 1013,1066 ----
  	/*  80 */ {GrCloseWindowWrapper, "GrCloseWindow"},
  	/*  81 */ {GrKillWindowWrapper, "GrKillWindow"},
  };
+ 
+ void
+ GrShmCmdsFlushWrapper(void *r)
+ {
+ 	nxShmCmdsFlushReq *req = r;
+ 	unsigned char 	reply;
+ #if HAVE_SHAREDMEM_SUPPORT
+ 	nxReq 		*pr;
+ 	int 		length;
+ 	unsigned char 	*do_req, *do_req_last;
+ 
+ 	if ( current_shm_cmds == 0 || current_shm_cmds_size < req->size ) {
+ 		/* No or short shm present serverside, bug or mischief */
+ 		EPRINTF("nano-X: Ill behaved client assumes shm ok\n");
+ 		if ( req->reply ) {
+ 			reply = 0;
+ 			GsWrite(current_fd, &reply, 1);
+ 		}
+ 		return;
+ 	}
+ 
+ 	do_req = current_shm_cmds;
+ 	do_req_last = current_shm_cmds + req->size;
+ 
+ 	while ( do_req < do_req_last ) {
+ 		pr = (nxReq *)do_req;
+ 		length = GetReqAlignedLen(pr);
+ 		if ( pr->reqType < GrTotalNumCalls ) {
+ 			GrFunctions[pr->reqType].func(pr);
+ 		} else {
+ 			EPRINTF("Error bad shm function!\n");
+ 		}
+ 		do_req += length;
+ 	}
+ 
+ 	if ( req->reply ) {
+ 		reply = 1;
+ 		GsWrite(current_fd, &reply, 1);
+ 	}
+ #else
+ 	/* no shared memory support*/
+ 	if ( req->reply ) {
+ 		reply = 0;
+ 		GsWrite(current_fd, &reply, 1);
+ 	}
+ #endif /* HAVE_SHAREDMEM_SUPPORT*/
+ }
+ 
  
  /*
   * This function is used to bind to the named socket which is used to

Previous by date: 23 Jun 2000 05:57:24 -0000 Re: Linux example binaries, 曾昭明
Next by date: 23 Jun 2000 05:57:24 -0000 Re: Linux example binaries, Kyle Harris
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.