Commits

Stanislav Sedov  committed 33d2d1b

- Add missing umtx_op handlers.
- Tell valgrind that sched_yield might block.

  • Participants
  • Parent commits 82211a8

Comments (0)

Files changed (2)

File coregrind/m_syswrap/syswrap-freebsd.c

 
 PRE(sys_sched_yield)
 {
+   *flags |= SfMayBlock;
    PRINT("sched_yield()");
 }
 
                     void *, zero, struct vki_timespec *, timeout);
       PRE_MEM_READ( "_umtx_op_wait_private(uint)", ARG1, sizeof(int) );
       if (ARG5)
-	 PRE_MEM_READ( "_umtx_op_wait_private(timespec)", ARG5, sizeof(struct vki_timespec) );
+	 PRE_MEM_READ( "_umtx_op_wait_private(umtx_time)", ARG5, sizeof(struct vki_umtx_time) );
       *flags |= SfMayBlock;
       break;
    case VKI_UMTX_OP_WAKE_PRIVATE:
       PRE_MEM_READ( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) );
       PRE_MEM_WRITE( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) );
       break;
+   case VKI_UMTX_OP_SEM_WAIT:
+      PRINT( "sys__umtx_op ( %#lx, SEM_WAIT, %ld, %#lx, %#lx)", ARG1, ARG3, ARG4, ARG5);
+      PRE_REG_READ5(long, "_umtx_op_sem_wait",
+                    struct usem *, obj, int, op, unsigned long, id,
+                    void *, zero, struct vki_timespec *, timeout);
+      PRE_MEM_READ( "_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem) );
+      PRE_MEM_WRITE( "_umtx_op_sem_wait(usem)", ARG1, sizeof(struct vki_usem) );
+      if (ARG5)
+	 PRE_MEM_READ( "_umtx_op_sem_wait(umtx_time)", ARG5, sizeof(struct vki_umtx_time) );
+      *flags |= SfMayBlock;
+      break;
+   case VKI_UMTX_OP_SEM_WAKE:
+      PRINT( "sys__umtx_op ( %#lx, SEM_WAKE, %ld, %#lx, %#lx)", ARG1, ARG3, ARG4, ARG5);
+      PRE_REG_READ2(long, "_umtx_op_sem_wake",
+                    struct umutex *, obj, int, op);
+      PRE_MEM_READ( "_umtx_op_sem_wake(mutex)", ARG1, sizeof(struct vki_usem) );
+      PRE_MEM_WRITE( "_umtx_op_sem_wake(mutex)", ARG1, sizeof(struct vki_usem) );
+      break;
+   case VKI_UMTX_OP_NWAKE_PRIVATE:
+      PRINT( "sys__umtx_op ( %#lx, NWAKE_PRIVATE, %ld, %#lx, %#lx)", ARG1, ARG3, ARG4, ARG5);
+      PRE_REG_READ3(long, "_umtx_op_nwake_private",
+                    struct umutex *, obj, int, op, int, count);
+      PRE_MEM_READ( "_umtx_op_nwake_private(mtxs)", ARG1, ARG3 * sizeof(void *) );
+      PRE_MEM_WRITE( "_umtx_op_mutex_wake(mtxs)", ARG1, sizeof(struct vki_umutex) );
+      break;
+   case VKI_UMTX_OP_MUTEX_WAKE2:
+      PRINT( "sys__umtx_op ( %#lx, MUTEX_WAKE2, %ld, %#lx, %#lx)", ARG1, ARG3, ARG4, ARG5);
+      PRE_REG_READ3(long, "_umtx_op_mutex_wake2",
+                    struct umutex *, obj, int, op, unsigned long, flags);
+      PRE_MEM_READ( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) );
+      PRE_MEM_WRITE( "_umtx_op_mutex_wake(mutex)", ARG1, sizeof(struct vki_umutex) );
+      break;
    default:
       PRINT( "sys__umtx_op ( %#lx, %ld(UNKNOWN), %ld, %#lx, %#lx )", ARG1, ARG2, ARG3, ARG4, ARG5);
       break;
    }
 //   tst = VG_(get_ThreadState)(tid);
-//PRINT(" [[ UMTX_OP: me=%d arg1 %#lx = %#lx (%ld) ]]", tst->os_state.lwpid, ARG1, *(UWord *)ARG1, *(UWord *)ARG1 & 0x7fffffff);
+//PRINT(" [[ UMTX_OP %d: me=%d arg1 %#lx = %#lx (%ld) ]]", ARG2, tst->os_state.lwpid, ARG1, *(UWord *)ARG1, *(UWord *)ARG1 & 0x7fffffff);
 }
 
 POST(sys__umtx_op)
 {
-//VG_(printf)("[[ POST_UMTX_OP: arg1 %#lx = %#lx (%ld) ]]\n", ARG1, *(UWord *)ARG1, *(UWord *)ARG1 & 0x7fffffff);
+//PRINT("[[ POST_UMTX_OP %d: arg1 %#lx = %#lx (%ld) ]]\n", ARG2, ARG1, *(UWord *)ARG1, *(UWord *)ARG1 & 0x7fffffff);
    switch(ARG2) {
    case VKI_UMTX_OP_LOCK:
       if (SUCCESS)

File include/vki/vki-freebsd.h

 	vki_uint32_t	rw_spare[4];
 };
 
+struct vki_usem {
+	vki_uint32_t	has_waiters;
+	vki_uint32_t	count;
+	vki_uint32_t	flags;
+};
+
+struct vki_umtx_time {
+	struct vki_timespec	timeout;
+	vki_uint32_t		flags;
+	vki_uint32_t		clockid;
+};
+
 #define	VKI_UMTX_OP_LOCK		0
 #define	VKI_UMTX_OP_UNLOCK		1
 #define	VKI_UMTX_OP_WAIT		2
 #define	VKI_UMTX_OP_WAIT_UINT_PRIVATE	15
 #define	VKI_UMTX_OP_WAKE_PRIVATE	16
 #define	VKI_UMTX_OP_MUTEX_WAIT		17
-#define	VKI_UMTX_OP_MUTEX_WAKE		18
-#define	VKI_UMTX_OP_MAX			19
+#define	VKI_UMTX_OP_MUTEX_WAKE		18 /* deprecated */
+#define	VKI_UMTX_OP_SEM_WAIT		19
+#define	VKI_UMTX_OP_SEM_WAKE		20
+#define	VKI_UMTX_OP_NWAKE_PRIVATE	21
+#define	VKI_UMTX_OP_MUTEX_WAKE2		22
+#define	VKI_UMTX_OP_MAX			23
 
 
 //----------------------------------------------------------------------