- Timestamp:
- May 12, 2005, 1:16:54 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/InnoTekLIBC/backend.h
-
Property cvs2svn:cvs-rev
changed from
1.24
to1.25
r1986 r1987 35 35 #include <sys/wait.h> 36 36 #include <sys/sem.h> 37 #include <sys/shm.h> 37 38 #include <signal.h> 38 39 #include <emx/io.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/sem.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1986 r1987 11 11 * FreeBSD 5.3 12 12 * @changed bird: no padding in semid_ds. seminfo and semexit are static in our 'kernel'. 13 * @changed bird: added time_t, size_t and pid_t as per POSIX. 13 14 */ 14 15 … … 17 18 18 19 #include <sys/ipc.h> 20 #include <sys/_types.h> 21 22 #if !defined(_TIME_T_DECLARED) && !defined(_TIME_T) /* bird: EMX */ 23 typedef __time_t time_t; 24 #define _TIME_T_DECLARED 25 #define _TIME_T /* bird: EMX */ 26 #endif 27 28 #include <sys/_types.h> 29 #if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: emx */ 30 typedef __size_t size_t; 31 #define _SIZE_T_DECLARED 32 #define _SIZE_T /* bird: emx */ 33 #endif 34 35 #if !defined(_PID_T_DECLARED) && !defined(_PID_T) /* bird:emx */ 36 typedef __pid_t pid_t; /* process id */ 37 #define _PID_T_DECLARED 38 #define _PID_T /* bird: emx */ 39 #endif 40 19 41 20 42 struct sem; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/shm.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1986 r1987 39 39 /** @file 40 40 * FreeBSD 5.3 41 * @changed the SHMLBA to 64KB. 41 * @changed bird: the SHMLBA to 64KB. 42 * @changed bird: added pid_t, time_t and size_t (POSIX). 42 43 */ 43 44 … … 46 47 47 48 #include <sys/ipc.h> 49 50 #include <sys/_types.h> 51 52 #if !defined(_TIME_T_DECLARED) && !defined(_TIME_T) 53 typedef __time_t time_t; 54 #define _TIME_T_DECLARED 55 #define _TIME_T 56 #endif 57 58 #include <sys/_types.h> 59 #if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) 60 typedef __size_t size_t; 61 #define _SIZE_T_DECLARED 62 #define _SIZE_T 63 #endif 64 65 #if !defined(_PID_T_DECLARED) && !defined(_PID_T) 66 typedef __pid_t pid_t; 67 #define _PID_T_DECLARED 68 #define _PID_T 69 #endif 48 70 49 71 #define SHM_RDONLY 010000 /* Attach read-only (else read-write) */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sysv_sem.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1986 r1987 562 562 uid_t uid; 563 563 uintptr_t hmtx; 564 564 int semid_in = semid; 565 565 566 566 /* … … 608 608 case IPC_RMID: 609 609 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 610 if ((error = semvalid(semid , semaptr)) != 0)610 if ((error = semvalid(semid_in, semaptr)) != 0) 611 611 goto done2; 612 612 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_M))) … … 634 634 goto done2; 635 635 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 636 if ((error = semvalid(semid , semaptr)) != 0)636 if ((error = semvalid(semid_in, semaptr)) != 0) 637 637 goto done2; 638 638 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_M))) … … 647 647 case IPC_STAT: 648 648 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 649 if ((error = semvalid(semid , semaptr)) != 0)649 if ((error = semvalid(semid_in, semaptr)) != 0) 650 650 goto done2; 651 651 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R))) … … 659 659 case GETNCNT: 660 660 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 661 if ((error = semvalid(semid , semaptr)) != 0)661 if ((error = semvalid(semid_in, semaptr)) != 0) 662 662 goto done2; 663 663 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R))) … … 672 672 case GETPID: 673 673 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 674 if ((error = semvalid(semid , semaptr)) != 0)674 if ((error = semvalid(semid_in, semaptr)) != 0) 675 675 goto done2; 676 676 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R))) … … 685 685 case GETVAL: 686 686 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 687 if ((error = semvalid(semid , semaptr)) != 0)687 if ((error = semvalid(semid_in, semaptr)) != 0) 688 688 goto done2; 689 689 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R))) … … 699 699 array = _hmalloc(sizeof(*array) * semaptr->u.sem_nsems); 700 700 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 701 if ((error = semvalid(semid , semaptr)) != 0)701 if ((error = semvalid(semid_in, semaptr)) != 0) 702 702 goto done2; 703 703 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R))) … … 712 712 case GETZCNT: 713 713 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 714 if ((error = semvalid(semid , semaptr)) != 0)714 if ((error = semvalid(semid_in, semaptr)) != 0) 715 715 goto done2; 716 716 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R))) … … 725 725 case SETVAL: 726 726 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 727 if ((error = semvalid(semid , semaptr)) != 0)727 if ((error = semvalid(semid_in, semaptr)) != 0) 728 728 goto done2; 729 729 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_W))) … … 747 747 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 748 748 raced: 749 if ((error = semvalid(semid , semaptr)) != 0)749 if ((error = semvalid(semid_in, semaptr)) != 0) 750 750 goto done2; 751 751 count = semaptr->u.sem_nsems; … … 756 756 break; 757 757 __libc_Back_safesemMtxLock(hmtx = semaptr->hmtx); 758 if ((error = semvalid(semid , semaptr)) != 0)758 if ((error = semvalid(semid_in, semaptr)) != 0) 759 759 goto done2; 760 760 /* we could have raced? */ … … 894 894 895 895 found: 896 err no= -IXSEQ_TO_IPCID(semid, sema[semid].u.sem_perm);896 error = -IXSEQ_TO_IPCID(semid, sema[semid].u.sem_perm); 897 897 done2: 898 898 __libc_Back_safesemMtxUnlock(gpGlobals->hmtx); … … 948 948 int error; 949 949 int do_wakeup, do_undos; 950 int semid_in = semid; 950 951 951 952 /* … … 996 997 goto done2; 997 998 } 998 if (semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid )) {999 if (semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid_in)) { 999 1000 error = EINVAL; 1000 1001 goto done2; … … 1115 1116 */ 1116 1117 if ((semaptr->u.sem_perm.mode & SEM_ALLOC) == 0 || 1117 semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid )) {1118 semaptr->u.sem_perm.seq != IPCID_TO_SEQ(semid_in)) { 1118 1119 error = EIDRM; 1119 1120 goto done2; … … 1221 1222 { 1222 1223 LIBCLOG_ENTER("\n"); 1224 static volatile int fDone = 0; 1223 1225 struct sem_undo *suptr; 1224 1226 struct sem_undo **supptr; … … 1227 1229 * If no pointer to globals then there is nothing to do (nearly impossible). 1228 1230 */ 1229 if (!gpGlobals )1231 if (!gpGlobals || fDone) 1230 1232 LIBCLOG_RETURN_VOID(); 1233 fDone = 1; 1231 1234 1232 1235 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sysv_shm.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1986 r1987 122 122 #define SHMSEG_ALLOCATED 0x0800 123 123 //#define SHMSEG_WANTED 0x1000 - cannot happen with our locking policy. 124 /** Set when the segment is captured by the server. 125 * if cleared it equals the SHMSEG_REMOVED when shm_nattch <= 0. */ 126 #define SHMSEG_SERVER 0x1000 124 127 125 128 static void shm_deallocate_segment(struct shmid_ds *); … … 127 130 static struct shmid_ds *shm_find_segment_by_shmid(int); 128 131 static struct shmid_ds *shm_find_segment_by_shmidx(int); 129 static int shm_delete_mapping(struct shmmap_state * );132 static int shm_delete_mapping(struct shmmap_state *, int); 130 133 static int shminit(void); 131 134 static void shmexit_myhook(void); … … 287 290 288 291 static int 289 shm_delete_mapping(struct shmmap_state *shmmap_s )292 shm_delete_mapping(struct shmmap_state *shmmap_s, int fExitting) 290 293 { 291 294 struct __libc_SysV_Shm *pGlobals = gpGlobals; … … 306 309 shmseg->shm_dtime = fibGetUnixSeconds(); 307 310 if ((--shmseg->shm_nattch <= 0) && 308 (shmseg->shm_perm.mode & SHMSEG_REMOVED)) { 311 ( (shmseg->shm_perm.mode & SHMSEG_REMOVED) 312 || (fExitting && !(shmseg->shm_perm.mode & SHMSEG_SERVER)))) { 309 313 shm_deallocate_segment(shmseg); 310 314 pGlobals->shm_last_free = segnum; … … 359 363 goto done2; 360 364 } 361 error = shm_delete_mapping(shmmap_s );365 error = shm_delete_mapping(shmmap_s, 0); 362 366 done2: 363 367 __libc_Back_safesemMtxUnlock(gpGlobals->hmtx); … … 825 829 shmexit_myhook(void) 826 830 { 831 static volatile int fDone = 0; 827 832 struct __libc_SysV_Shm *pGlobals = gpGlobals; 828 if (pGlobals) { 829 gpGlobals = NULL; 833 if (pGlobals && !fDone) { 834 fDone = 1; 835 __libc_Back_safesemMtxLock(pGlobals->hmtx); 830 836 struct shmmap_state *shm = g_vm_shm; 831 837 if (shm) { 832 838 g_vm_shm = NULL; 833 __libc_Back_safesemMtxLock(pGlobals->hmtx);834 839 int c = shminfo.shmseg; 835 840 while (c-- > 0) { 836 if (shm->shmid != -1) 837 shm_delete_mapping(shm); 841 if (shm->shmid != -1) { 842 shm_delete_mapping(shm, 1); 843 } 838 844 shm++; 839 845 } 840 __libc_Back_safesemMtxUnlock(pGlobals->hmtx);841 846 } 847 848 /* Clean out non-referenced objects when the server isn't around for them. */ 849 int c = pGlobals->shm_nused; 850 if (c > 0) 851 { 852 int i = pGlobals->shmalloced; 853 struct shmid_ds *shmseg = pGlobals->shmsegs; 854 while (i-- > 0) 855 { 856 if (shmseg->shm_perm.mode & SHMSEG_ALLOCATED) 857 { 858 if ( shmseg->shm_nattch <= 0 859 && ( !(shmseg->shm_perm.mode & SHMSEG_SERVER) 860 || (shmseg->shm_perm.mode & SHMSEG_REMOVED))) 861 shm_deallocate_segment(shmseg); 862 if (c-- <= 0) 863 break; 864 } 865 866 /* next */ 867 shmseg++; 868 } 869 } 870 __libc_Back_safesemMtxUnlock(pGlobals->hmtx); 842 871 __atomic_decrement_u32(&pGlobals->cUsers); 872 gpGlobals = NULL; 843 873 } 844 874 } … … 890 920 if (rc) 891 921 LIBCLOG_RETURN_INT(rc); 892 if (!pSPMHdr->pSysVS em)922 if (!pSPMHdr->pSysVShm) 893 923 { 894 924 pGlobals = (struct __libc_SysV_Shm *)__libc_spmAllocLocked(cb); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.