This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge msgsnd, msgrcv with Perl_pp_shmwrite().
authorNicholas Clark <nick@ccl4.org>
Fri, 4 Nov 2005 14:47:49 +0000 (14:47 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 4 Nov 2005 14:47:49 +0000 (14:47 +0000)
"Perfection is achieved not when there's nothing more to add,
 but when there's nothing left to remove" (Antoine de Saint-ExupĂ©ry)

p4raw-id: //depot/perl@25990

mathoms.c
opcode.h
opcode.pl
pp_sys.c

index 9ec80e0..bc355e9 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -971,6 +971,16 @@ PP(pp_fteexec)
     return pp_ftrread();
 }
 
+PP(pp_msgsnd)
+{
+    return pp_shmwrite();
+}
+
+PP(pp_msgrcv)
+{
+    return pp_shmwrite();
+}
+
 U8 *
 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
 {
index e38508e..bd53d0c 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -1070,8 +1070,8 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        MEMBER_TO_FPTR(Perl_pp_shmwrite),
        MEMBER_TO_FPTR(Perl_pp_semget), /* Perl_pp_msgget */
        MEMBER_TO_FPTR(Perl_pp_semctl), /* Perl_pp_msgctl */
-       MEMBER_TO_FPTR(Perl_pp_msgsnd),
-       MEMBER_TO_FPTR(Perl_pp_msgrcv),
+       MEMBER_TO_FPTR(Perl_pp_shmwrite),       /* Perl_pp_msgsnd */
+       MEMBER_TO_FPTR(Perl_pp_shmwrite),       /* Perl_pp_msgrcv */
        MEMBER_TO_FPTR(Perl_pp_semget),
        MEMBER_TO_FPTR(Perl_pp_semctl),
        MEMBER_TO_FPTR(Perl_pp_semop),
index 27f1de9..5b4cd00 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -72,6 +72,7 @@ my @raw_alias = (
                 Perl_pp_link => ['symlink'],
                 Perl_pp_ftrread => [qw(ftrwrite ftrexec fteread ftewrite
                                        fteexec)],
+                Perl_pp_shmwrite => [qw(msgsnd msgrcv)],
                );
 
 while (my ($func, $names) = splice @raw_alias, 0, 2) {
index 9b08cac..1f10882 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4430,40 +4430,27 @@ PP(pp_sleep)
 }
 
 /* Shared memory. */
+/* Merged with some message passing. */
 
 PP(pp_shmwrite)
 {
 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
     dSP; dMARK; dTARGET;
-    I32 value = (I32)(do_shmio(PL_op->op_type, MARK, SP) >= 0);
-    SP = MARK;
-    PUSHi(value);
-    RETURN;
-#else
-    return pp_semget();
-#endif
-}
-
-/* Message passing. */
+    const int op_type = PL_op->op_type;
+    I32 value;
 
-PP(pp_msgsnd)
-{
-#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
-    dSP; dMARK; dTARGET;
-    I32 value = (I32)(do_msgsnd(MARK, SP) >= 0);
-    SP = MARK;
-    PUSHi(value);
-    RETURN;
-#else
-    return pp_semget();
-#endif
-}
+    switch (op_type) {
+    case OP_MSGSND:
+       value = (I32)(do_msgsnd(MARK, SP) >= 0);
+       break;
+    case OP_MSGRCV:
+       value = (I32)(do_msgrcv(MARK, SP) >= 0);
+       break;
+    default:
+       value = (I32)(do_shmio(op_type, MARK, SP) >= 0);
+       break;
+    }
 
-PP(pp_msgrcv)
-{
-#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
-    dSP; dMARK; dTARGET;
-    I32 value = (I32)(do_msgrcv(MARK, SP) >= 0);
     SP = MARK;
     PUSHi(value);
     RETURN;