Fix OS X host_create_mach_voucher: UNKNOWN host message [id 222, to mach_host_self(), reply 0x........]
bz#343649

Before:

== 591 tests, 220 stderr failures, 14 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures ==

After:

== 591 tests, 220 stderr failures, 14 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures ==


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15299 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/NEWS b/NEWS
index 164e1d1..789187b 100644
--- a/NEWS
+++ b/NEWS
@@ -168,6 +168,8 @@
 343525  OS X host_get_special_port: UNKNOWN host message [id 412, to 
         mach_host_self(), reply 0x........]
 343597  ppc64le: incorrect use of offseof macro
+343649  OS X host_create_mach_voucher: UNKNOWN host message [id 222, to 
+        mach_host_self(), reply 0x........]
 343732  Unhandled syscall 144 (setgid) on aarch64
 343733  Unhandled syscall 187 (msgctl and related) on aarch64
 343802  s390x: Fix false positives "conditional jump or move depends on
diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h
index 1145ec7..0903179 100644
--- a/coregrind/m_syswrap/priv_syswrap-darwin.h
+++ b/coregrind/m_syswrap/priv_syswrap-darwin.h
@@ -573,6 +573,7 @@
 DECL_TEMPLATE(darwin, host_get_io_master);
 DECL_TEMPLATE(darwin, host_get_clock_service);
 DECL_TEMPLATE(darwin, host_request_notification);
+DECL_TEMPLATE(darwin, host_create_mach_voucher);
 DECL_TEMPLATE(darwin, host_get_special_port);
 DECL_TEMPLATE(darwin, mach_port_type);
 DECL_TEMPLATE(darwin, mach_port_extract_member);
diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c
index cca98dc..de2f7db 100644
--- a/coregrind/m_syswrap/syswrap-darwin.c
+++ b/coregrind/m_syswrap/syswrap-darwin.c
@@ -4963,6 +4963,45 @@
 }
 
 
+PRE(host_create_mach_voucher)
+{
+#pragma pack(4)
+    typedef struct {
+        mach_msg_header_t Head;
+        NDR_record_t NDR;
+        mach_msg_type_number_t recipesCnt;
+        uint8_t recipes[5120];
+    } Request;
+#pragma pack()
+    
+    Request *req = (Request *)ARG1;
+
+    PRINT("host_create_mach_voucher(count %u)",
+          req->recipesCnt);
+    
+    AFTER = POST_FN(host_create_mach_voucher);
+}
+
+
+POST(host_create_mach_voucher)
+{
+#pragma pack(4)
+    typedef struct {
+        mach_msg_header_t Head;
+        /* start of the kernel processed data */
+        mach_msg_body_t msgh_body;
+        mach_msg_port_descriptor_t voucher;
+        /* end of the kernel processed data */
+    } Reply;
+#pragma pack()
+    
+    Reply *reply = (Reply *)ARG1;
+
+    // RK fixme properly parse this return type
+    PRINT("got voucher %#x ", reply->voucher.name);
+}
+
+
 PRE(host_get_special_port)
 {
 #pragma pack(4)
@@ -7848,6 +7887,9 @@
    case 217:
       CALL_PRE(host_request_notification);
       return;
+   case 222:
+      CALL_PRE(host_create_mach_voucher);
+      return;
            
    case 412:
       CALL_PRE(host_get_special_port);