shared memory under SysV

Michael Grenier mike at cimcor.UUCP
Sun May 15 23:35:29 AEST 1988


>From article <14379 at brl-adm.ARPA>, by Ed at mead.scrc.symbolics.com (Ed Schwalenberg):
>     Under uPort sysV/AT (a system V, rev. 2 port to IBM AT and clones [swapping,
>     not paging:-) ]) shared memory is supported for, among other things, using
>     the memory-mapped video RAM. 
...
>     much physical memory).  My initial temptation was to assume the
>     documentation was wrong and that a NULL pointer should be returned if
>     shmat fails; however, the doc'n went out of its way to indicate that it
>     should be -1 (presumably -1L) on failure.
> 
>     So, the questions are:
> 	    1) what is the proper return value of shmat on failure;



This is what my graphics package does under Microport Unix V/AT
for the shared memory attach. Using a cast you don't worry if its
long or not.
   
-Mike Grenier    {ihnp4, rutgers, amdahl}!bungia!cimcor!mike

void g_herc_open()
{
	if ((shm_id = shmget ((key_t)Herc_loc, SCREEN_SIZE*2L-1 , 0)) == -1) 
	{
		perror(" gplot:herc_open() - ");
		fprintf(stderr, "Unable to locate shared memory segment \n");
		fprintf(stderr, "Did you execute /etc/shmcreate as found in /etc/rc.d/shm.rc \n");
		fprintf(stderr, "i.e. /etc/shmcreate 0xb0000 b0000 32768\n");
		exit(1);
	};
		
    
    	if ((video_buf = shmat (shm_id, (char *) 0, 0)) == (char *) -1)
    	{
		perror(" gplot:herc_open() - ");
		fprintf(stderr, "Unable to attach shared memory segment \n");
		fprintf(stderr, "Did you execute /etc/shmcreate as found in /etc/rc.d/shm.rc \n");
		exit(1);
	};
	init_io();
}



More information about the Comp.unix.wizards mailing list