PERFORCE change 143063 for review
Alexander Kabaev
kan at FreeBSD.org
Fri Jun 6 23:20:31 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143063
Change 143063 by kan at kan_valgrind on 2008/06/06 23:19:55
Add handlers for shmget, shmat, shmdt, semget, semop and
semctl syscalls.
Affected files ...
.. //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#8 edit
.. //depot/projects/valgrind/include/vki-freebsd.h#4 edit
Differences ...
==== //depot/projects/valgrind/coregrind/m_syswrap/syswrap-freebsd.c#8 (text+ko) ====
@@ -2184,6 +2184,107 @@
PRE_REG_READ0(long, "lkmnosys8");
}
+PRE(sys_shmget)
+{
+ PRINT("sys_shmget ( %d, %d, %d )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "shmget", vki_key_t, key, vki_size_t, size, int, shmflg);
+}
+
+PRE(sys_shmat)
+{
+ UWord arg2tmp;
+ PRINT("sys_shmat ( %d, %p, %d )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "shmat",
+ int, shmid, const void *, shmaddr, int, shmflg);
+ arg2tmp = ML_(generic_PRE_sys_shmat)(tid, ARG1,ARG2,ARG3);
+ if (arg2tmp == 0)
+ SET_STATUS_Failure( VKI_EINVAL );
+ else
+ ARG2 = arg2tmp;
+}
+
+POST(sys_shmat)
+{
+ ML_(generic_POST_sys_shmat)(tid, RES,ARG1,ARG2,ARG3);
+}
+
+PRE(sys_shmdt)
+{
+ PRINT("sys_shmdt ( %p )",ARG1);
+ PRE_REG_READ1(long, "shmdt", const void *, shmaddr);
+ if (!ML_(generic_PRE_sys_shmdt)(tid, ARG1))
+ SET_STATUS_Failure( VKI_EINVAL );
+}
+
+POST(sys_shmdt)
+{
+ ML_(generic_POST_sys_shmdt)(tid, RES,ARG1);
+}
+
+PRE(sys_shmctl)
+{
+ PRINT("sys_shmctl ( %d, %d, %p )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "shmctl",
+ int, shmid, int, cmd, struct shmid_ds *, buf);
+ ML_(generic_PRE_sys_shmctl)(tid, ARG1,ARG2,ARG3);
+}
+
+POST(sys_shmctl)
+{
+ ML_(generic_POST_sys_shmctl)(tid, RES,ARG1,ARG2,ARG3);
+}
+
+PRE(sys_semget)
+{
+ PRINT("sys_semget ( %d, %d, %d )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "semget", vki_key_t, key, int, nsems, int, semflg);
+}
+
+PRE(sys_semop)
+{
+ *flags |= SfMayBlock;
+ PRINT("sys_semop ( %d, %p, %u )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "semop",
+ int, semid, struct sembuf *, sops, unsigned, nsoops);
+ ML_(generic_PRE_sys_semop)(tid, ARG1,ARG2,ARG3);
+}
+
+PRE(sys___semctl)
+{
+ switch (ARG3) {
+ case VKI_IPC_INFO:
+ case VKI_SEM_INFO:
+ PRINT("sys_semctl ( %d, %d, %d, %p )",ARG1,ARG2,ARG3,ARG4);
+ PRE_REG_READ4(long, "semctl",
+ int, semid, int, semnum, int, cmd, struct seminfo *, arg);
+ break;
+ case VKI_IPC_STAT:
+ case VKI_SEM_STAT:
+ case VKI_IPC_SET:
+ PRINT("sys_semctl ( %d, %d, %d, %p )",ARG1,ARG2,ARG3,ARG4);
+ PRE_REG_READ4(long, "semctl",
+ int, semid, int, semnum, int, cmd, struct semid_ds *, arg);
+ break;
+ case VKI_GETALL:
+ case VKI_SETALL:
+ PRINT("sys_semctl ( %d, %d, %d, %p )",ARG1,ARG2,ARG3,ARG4);
+ PRE_REG_READ4(long, "semctl",
+ int, semid, int, semnum, int, cmd, unsigned short *, arg);
+ break;
+ default:
+ PRINT("sys_semctl ( %d, %d, %d )",ARG1,ARG2,ARG3);
+ PRE_REG_READ3(long, "semctl",
+ int, semid, int, semnum, int, cmd);
+ break;
+ }
+ ML_(generic_PRE_sys_semctl)(tid, ARG1,ARG2,ARG3,ARG4);
+}
+
+POST(sys___semctl)
+{
+ ML_(generic_POST_sys_semctl)(tid, RES,ARG1,ARG2,ARG3,ARG4);
+}
+
#undef PRE
#undef POST
@@ -2463,9 +2564,9 @@
BSDX_(__NR_lkmnosys8, sys_lkmnosys8), // 218
// BSDXY(__NR_nfs_fhopen, sys_nfs_fhopen), // 219
-// BSDXY(__NR___semctl, sys___semctl), // 220
-// BSDX_(__NR_semget, sys_semget), // 221
-// BSDX_(__NR_semop, sys_semop), // 222
+ BSDXY(__NR___semctl, sys___semctl), // 220
+ BSDX_(__NR_semget, sys_semget), // 221
+ BSDX_(__NR_semop, sys_semop), // 222
// unimpl semconfig 223
// BSDXY(__NR_msgctl, sys_msgctl), // 224
@@ -2473,10 +2574,10 @@
// BSDX_(__NR_msgsnd, sys_msgsnd), // 226
// BSDXY(__NR_msgrcv, sys_msgrcv), // 227
-// BSDXY(__NR_shmat, sys_shmat), // 228
-// BSDXY(__NR_shmctl, sys_shmctl), // 229
-// BSDXY(__NR_shmdt, sys_shmdt), // 230
-// BSDX_(__NR_shmget, sys_shmget), // 231
+ BSDXY(__NR_shmat, sys_shmat), // 228
+ BSDXY(__NR_shmctl, sys_shmctl), // 229
+ BSDXY(__NR_shmdt, sys_shmdt), // 230
+ BSDX_(__NR_shmget, sys_shmget), // 231
BSDXY(__NR_clock_gettime, sys_clock_gettime), // 232
BSDX_(__NR_clock_settime, sys_clock_settime), // 233
==== //depot/projects/valgrind/include/vki-freebsd.h#4 (text+ko) ====
@@ -1152,7 +1152,7 @@
//#define VKI_IPC_RMID 0 /* remove resource */
#define VKI_IPC_SET 1 /* set ipc_perm options */
#define VKI_IPC_STAT 2 /* get ipc_perm options */
-// not here #define VKI_IPC_INFO 3 /* see ipcs */
+#define VKI_IPC_INFO 3 /* see ipcs */
// not here #define VKI_IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger message sizes, etc. */
@@ -1170,6 +1170,8 @@
#define VKI_GETALL 6 /* get all semval's */
#define VKI_SETVAL 8 /* set semval */
#define VKI_SETALL 9 /* set all semval's */
+#define VKI_SEM_STAT 10
+#define VKI_SEM_INFO 11
/* Obsolete, used only for backwards compatibility and libc5 compiles */
struct vki_semid_ds {
@@ -1184,7 +1186,7 @@
};
struct vki_sembuf {
- vki_uint32_t sem_num; /* semaphore index in array */
+ vki_uint16_t sem_num; /* semaphore index in array */
vki_int16_t sem_op; /* semaphore operation */
vki_int16_t sem_flg; /* operation flags */
};
More information about the p4-projects
mailing list