Lines Matching defs:mmvm
71 #define MMDATA(mmvm) ((Vmuchar_t*)(mmvm)->base + MMHEAD(mmvm->file))
72 #define MMSIZE(mmvm) ((mmvm)->size - MMHEAD(mmvm->file))
101 Mmvm_t* mmvm; /* shared memory data */
119 sprintf(mesg, "Memory: %#010lx\n", mmdc->mmvm); write(fd, mesg, strlen(mesg));
124 sprintf(mesg, "Magic: %10d\n", mmdc->mmvm->magic); write(fd, mesg, strlen(mesg));
125 sprintf(mesg, "Base: %#010lx\n", mmdc->mmvm->base); write(fd, mesg, strlen(mesg));
126 sprintf(mesg, "Size: %10d\n", mmdc->mmvm->size); write(fd, mesg, strlen(mesg));
127 sprintf(mesg, "Busy: %10d\n", mmdc->mmvm->busy); write(fd, mesg, strlen(mesg));
133 static Mmvm_t* mmfix(Mmvm_t* mmvm, Mmdisc_t* mmdc, int fd)
135 Void_t *base = mmvm->base;
136 ssize_t size = mmvm->size;
138 if(base != (Void_t*)mmvm) /* mmvm is not right yet */
141 { munmap((Void_t*)mmvm, size);
142 mmvm = (Mmvm_t*)mmap(base, size, (PROT_READ|PROT_WRITE),
146 { shmdt((Void_t*)mmvm);
147 mmvm = (Mmvm_t*)shmat(mmdc->shmid, base, 0);
149 if(!mmvm || mmvm == (Mmvm_t*)(-1) )
150 mmvm = NIL(Mmvm_t*);
153 return mmvm;
164 Mmvm_t *mmvm = NIL(Mmvm_t*);
167 if(mmdc->mmvm) /* already done this */
190 mmvm = (Mmvm_t*)mmap(NIL(Void_t*), size, (PROT_READ|PROT_WRITE),
201 mmvm = (Mmvm_t*)shmat(mmdc->shmid, NIL(Void_t*), 0);
204 if(!mmvm || mmvm == (Mmvm_t*)(-1) ) /* initial mapping failed */
208 if(asocasint(&mmvm->magic, 0, MM_LETMEDOIT) == 0 ) /* lucky winner: us! */
210 base = (Void_t*)mmvm;
212 mmvm->base = base;
213 mmvm->size = size;
214 mmvm->busy = 0;
215 mmvm->proj = mmdc->proj;
216 strcpy(mmvm->file, mmdc->file);
218 msync((Void_t*)mmvm, MMHEAD(mmvm->file), MS_SYNC);
220 if(mmvm->base != (Void_t*)mmvm) /* not yet at the right address */
221 if(!(mmvm = mmfix(mmvm, mmdc, fd)) )
227 if(mmvm->magic != MM_LETMEDOIT && mmvm->magic != MM_MAGIC)
231 { if(asocasint(&mmvm->magic, MM_MAGIC, MM_MAGIC) == MM_MAGIC )
238 if(mmvm->proj != mmdc->proj || strcmp(mmvm->file, mmdc->file) != 0 )
241 if(mmvm->base != (Void_t*)mmvm) /* not yet at the right address */
242 if(!(mmvm = mmfix(mmvm, mmdc, fd)) )
250 { /**/ASSERT(mmvm && mmvm != (Mmvm_t*)(-1));
251 mmdc->mmvm = mmvm;
253 else if(mmvm && mmvm != (Mmvm_t*)(-1)) /* error, remove map */
255 (void)munmap((Void_t*)mmvm, size);
256 else (void)shmdt((Void_t*)mmvm);
269 Mmvm_t *mmvm;
272 if(!(mmvm = mmdc->mmvm) )
276 { (void)msync(mmvm->base, mmvm->size, MS_ASYNC);
278 { if(mmvm->base )
279 (void)munmap(mmvm->base, mmvm->size);
286 { if(mmvm->base )
287 (void)shmdt(mmvm->base);
295 mmdc->mmvm = NIL(Mmvm_t*);
311 Mmvm_t *mmvm;
314 if(!(mmvm = mmdc->mmvm) ) /* bad data */
319 { if(caddr == MMDATA(mmvm) && nsize <= MMSIZE(mmvm) )
320 { mmvm->busy = nsize;
321 return MMDATA(mmvm);
326 { if(mmvm->busy == 0 )
327 { mmvm->busy = nsize;
328 return MMDATA(mmvm);
354 /**/ASSERT(mmdc->mmvm->magic == MM_LETMEDOIT);
359 /**/ASSERT(mmdc->mmvm->magic == MM_MAGIC);
360 *((Void_t**)data) = MMDATA(mmdc->mmvm);
368 { /**/ASSERT(mmdc->mmvm->magic == MM_LETMEDOIT);
369 asocasint(&mmdc->mmvm->magic, MM_LETMEDOIT, MM_MAGIC);
372 msync((Void_t*)mmdc->mmvm, MMHEAD(mmdc->file), MS_SYNC);
373 } /**/ASSERT(mmdc->mmvm->magic == MM_MAGIC);
410 mmdc->mmvm = NIL(Mmvm_t*);
424 { /**/ASSERT(mmdc->mmvm && mmdc->mmvm->magic == MM_MAGIC);
442 Mmvm_t *mmvm = mmdc->mmvm;
451 for(u = mmvm->user; u; u = u->next)
459 u->next = mmvm->user;
460 mmvm->user = u;