Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!gatech!ncar!oddjob!uwvax!umn-d-ub!umn-cs!bungia!cimcor!mike From: mike@cimcor.UUCP (Michael Grenier) Newsgroups: comp.unix.wizards Subject: Re: shared memory under SysV Message-ID: <483@cimcor.UUCP> Date: 15 May 88 13:35:29 GMT References: <14379@brl-adm.ARPA> Organization: Grenier & friends, Forest Lake, MN Lines: 42 Posted: Sun May 15 08:35:29 1988 From article <14379@brl-adm.ARPA>, by Ed@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(); }