PERFORCE change 109712 for review

Jung-uk Kim jkim at FreeBSD.org
Sat Nov 11 00:37:18 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=109712

Change 109712 by jkim at jkim_hammer on 2006/11/11 00:37:12

	Fix 32-bit msgsnd/msgrcv emulation for amd64 while I am here.
	Tested with 32-bit binary of src/tools/regression/sysvmsg/msgtest.

Affected files ...

.. //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_misc.c#4 edit
.. //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_proto.h#8 edit
.. //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_syscall.h#8 edit
.. //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_syscalls.c#8 edit
.. //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_sysent.c#8 edit
.. //depot/projects/linuxolator/src/sys/compat/freebsd32/syscalls.master#8 edit

Differences ...

==== //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_misc.c#4 (text+ko) ====

@@ -91,6 +91,10 @@
 #include <compat/freebsd32/freebsd32_signal.h>
 #include <compat/freebsd32/freebsd32_proto.h>
 
+/* XXX This should not be here. */
+int do_msgsnd(struct thread *, struct msgsnd_args *, size_t);
+int do_msgrcv(struct thread *, struct msgrcv_args *, size_t);
+
 CTASSERT(sizeof(struct timeval32) == 8);
 CTASSERT(sizeof(struct timespec32) == 8);
 CTASSERT(sizeof(struct statfs32) == 256);
@@ -1335,10 +1339,57 @@
 int
 freebsd32_msgsys(struct thread *td, struct freebsd32_msgsys_args *uap)
 {
-	/*
-	 * Vector through to msgsys if it is loaded.
-	 */
-	return sysent[SYS_msgsys].sy_call(td, uap);
+	switch (uap->which) {
+	case 2:
+		return (freebsd32_msgsnd(td,
+		    (struct freebsd32_msgsnd_args *)&uap->a2));
+		break;
+	case 3:
+		return (freebsd32_msgrcv(td,
+		    (struct freebsd32_msgrcv_args *)&uap->a2));
+		break;
+	default:
+		/*
+		 * Vector through to msgsys if it is loaded.
+		 */
+		return (sysent[SYS_msgsys].sy_call(td, uap));
+		break;
+	}
+}
+
+int
+freebsd32_msgsnd(struct thread *td, struct freebsd32_msgsnd_args *uap)
+{
+	struct msgsnd_args ap;
+
+	if (sysent[SYS_msgsnd].sy_call == (sy_call_t *)lkmnosys ||
+	    sysent[SYS_msgsnd].sy_call == (sy_call_t *)lkmressys)
+		return (nosys(td, (struct nosys_args *)uap));
+
+	ap.msqid = uap->msqid;
+	ap.msgp = PTRIN(uap->msgp);
+	ap.msgsz = uap->msgsz;
+	ap.msgflg = uap->msgflg;
+
+	return (do_msgsnd(td, &ap, sizeof(int32_t)));
+}
+
+int
+freebsd32_msgrcv(struct thread *td, struct freebsd32_msgrcv_args *uap)
+{
+	struct msgrcv_args ap;
+
+	if (sysent[SYS_msgrcv].sy_call == (sy_call_t *)lkmnosys ||
+	    sysent[SYS_msgrcv].sy_call == (sy_call_t *)lkmressys)
+		return (nosys(td, (struct nosys_args *)uap));
+
+	ap.msqid = uap->msqid;
+	ap.msgp = PTRIN(uap->msgp);
+	ap.msgsz = uap->msgsz;
+	ap.msgtyp = uap->msgtyp;
+	ap.msgflg = uap->msgflg;
+
+	return (do_msgrcv(td, &ap, sizeof(int32_t)));
 }
 
 int

==== //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_proto.h#8 (text+ko) ====

@@ -203,6 +203,19 @@
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
 	char tptr_l_[PADL_(struct timeval32 *)]; struct timeval32 * tptr; char tptr_r_[PADR_(struct timeval32 *)];
 };
+struct freebsd32_msgsnd_args {
+	char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)];
+	char msgp_l_[PADL_(void *)]; void * msgp; char msgp_r_[PADR_(void *)];
+	char msgsz_l_[PADL_(size_t)]; size_t msgsz; char msgsz_r_[PADR_(size_t)];
+	char msgflg_l_[PADL_(int)]; int msgflg; char msgflg_r_[PADR_(int)];
+};
+struct freebsd32_msgrcv_args {
+	char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)];
+	char msgp_l_[PADL_(void *)]; void * msgp; char msgp_r_[PADR_(void *)];
+	char msgsz_l_[PADL_(size_t)]; size_t msgsz; char msgsz_r_[PADR_(size_t)];
+	char msgtyp_l_[PADL_(long)]; long msgtyp; char msgtyp_r_[PADR_(long)];
+	char msgflg_l_[PADL_(int)]; int msgflg; char msgflg_r_[PADR_(int)];
+};
 struct freebsd32_shmctl_args {
 	char shmid_l_[PADL_(int)]; int shmid; char shmid_r_[PADR_(int)];
 	char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)];
@@ -339,6 +352,8 @@
 int	freebsd32_ftruncate(struct thread *, struct freebsd32_ftruncate_args *);
 int	freebsd32_sysctl(struct thread *, struct freebsd32_sysctl_args *);
 int	freebsd32_futimes(struct thread *, struct freebsd32_futimes_args *);
+int	freebsd32_msgsnd(struct thread *, struct freebsd32_msgsnd_args *);
+int	freebsd32_msgrcv(struct thread *, struct freebsd32_msgrcv_args *);
 int	freebsd32_shmctl(struct thread *, struct freebsd32_shmctl_args *);
 int	freebsd32_clock_gettime(struct thread *, struct freebsd32_clock_gettime_args *);
 int	freebsd32_clock_settime(struct thread *, struct freebsd32_clock_settime_args *);
@@ -481,6 +496,8 @@
 #define	FREEBSD32_SYS_AUE_freebsd32_ftruncate	AUE_FTRUNCATE
 #define	FREEBSD32_SYS_AUE_freebsd32_sysctl	AUE_SYSCTL
 #define	FREEBSD32_SYS_AUE_freebsd32_futimes	AUE_FUTIMES
+#define	FREEBSD32_SYS_AUE_freebsd32_msgsnd	AUE_MSGSND
+#define	FREEBSD32_SYS_AUE_freebsd32_msgrcv	AUE_MSGRCV
 #define	FREEBSD32_SYS_AUE_freebsd32_shmctl	AUE_SHMCTL
 #define	FREEBSD32_SYS_AUE_freebsd32_clock_gettime	AUE_NULL
 #define	FREEBSD32_SYS_AUE_freebsd32_clock_settime	AUE_CLOCK_SETTIME

==== //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_syscall.h#8 (text+ko) ====

@@ -195,8 +195,8 @@
 #define	FREEBSD32_SYS_semop	222
 #define	FREEBSD32_SYS_msgctl	224
 #define	FREEBSD32_SYS_msgget	225
-#define	FREEBSD32_SYS_msgsnd	226
-#define	FREEBSD32_SYS_msgrcv	227
+#define	FREEBSD32_SYS_freebsd32_msgsnd	226
+#define	FREEBSD32_SYS_freebsd32_msgrcv	227
 #define	FREEBSD32_SYS_shmat	228
 #define	FREEBSD32_SYS_freebsd32_shmctl	229
 #define	FREEBSD32_SYS_shmdt	230

==== //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_syscalls.c#8 (text+ko) ====

@@ -233,8 +233,8 @@
 	"#223",			/* 223 = semconfig */
 	"msgctl",			/* 224 = msgctl */
 	"msgget",			/* 225 = msgget */
-	"msgsnd",			/* 226 = msgsnd */
-	"msgrcv",			/* 227 = msgrcv */
+	"freebsd32_msgsnd",			/* 226 = freebsd32_msgsnd */
+	"freebsd32_msgrcv",			/* 227 = freebsd32_msgrcv */
 	"shmat",			/* 228 = shmat */
 	"freebsd32_shmctl",			/* 229 = freebsd32_shmctl */
 	"shmdt",			/* 230 = shmdt */

==== //depot/projects/linuxolator/src/sys/compat/freebsd32/freebsd32_sysent.c#8 (text+ko) ====

@@ -258,8 +258,8 @@
 	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 },			/* 223 = semconfig */
 	{ AS(msgctl_args), (sy_call_t *)msgctl, AUE_MSGCTL, NULL, 0, 0 },	/* 224 = msgctl */
 	{ AS(msgget_args), (sy_call_t *)msgget, AUE_MSGGET, NULL, 0, 0 },	/* 225 = msgget */
-	{ AS(msgsnd_args), (sy_call_t *)msgsnd, AUE_MSGSND, NULL, 0, 0 },	/* 226 = msgsnd */
-	{ AS(msgrcv_args), (sy_call_t *)msgrcv, AUE_MSGRCV, NULL, 0, 0 },	/* 227 = msgrcv */
+	{ AS(freebsd32_msgsnd_args), (sy_call_t *)freebsd32_msgsnd, AUE_MSGSND, NULL, 0, 0 },	/* 226 = freebsd32_msgsnd */
+	{ AS(freebsd32_msgrcv_args), (sy_call_t *)freebsd32_msgrcv, AUE_MSGRCV, NULL, 0, 0 },	/* 227 = freebsd32_msgrcv */
 	{ AS(shmat_args), (sy_call_t *)shmat, AUE_SHMAT, NULL, 0, 0 },	/* 228 = shmat */
 	{ AS(freebsd32_shmctl_args), (sy_call_t *)freebsd32_shmctl, AUE_SHMCTL, NULL, 0, 0 },	/* 229 = freebsd32_shmctl */
 	{ AS(shmdt_args), (sy_call_t *)shmdt, AUE_SHMDT, NULL, 0, 0 },	/* 230 = shmdt */

==== //depot/projects/linuxolator/src/sys/compat/freebsd32/syscalls.master#8 (text+ko) ====

@@ -406,9 +406,9 @@
 224	AUE_MSGCTL	NOPROTO	{ int msgctl(int msqid, int cmd, \
 				    struct msqid_ds *buf); }
 225	AUE_MSGGET	NOPROTO	{ int msgget(key_t key, int msgflg); }
-226	AUE_MSGSND	NOPROTO	{ int msgsnd(int msqid, void *msgp, \
+226	AUE_MSGSND	STD	{ int freebsd32_msgsnd(int msqid, void *msgp, \
 				    size_t msgsz, int msgflg); }
-227	AUE_MSGRCV	NOPROTO	{ int msgrcv(int msqid, void *msgp, \
+227	AUE_MSGRCV	STD	{ int freebsd32_msgrcv(int msqid, void *msgp, \
 				    size_t msgsz, long msgtyp, int msgflg); }
 228	AUE_SHMAT	NOPROTO	{ int shmat(int shmid, void *shmaddr, \
 				    int shmflg); }


More information about the p4-projects mailing list