Skip to content

Commit 13421e0

Browse files
authored
feat(10.15): improve workq_ops support (#133)
1 parent 2de07b9 commit 13421e0

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

coregrind/m_syswrap/syswrap-darwin.c

+21-2
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,7 @@ static const HChar *workqop_name(int op)
24572457
case VKI_WQOPS_SET_EVENT_MANAGER_PRIORITY: return "SET_EVENT_MANAGER_PRIORITY";
24582458
case VKI_WQOPS_THREAD_WORKLOOP_RETURN: return "THREAD_WORKLOOP_RETURN";
24592459
case VKI_WQOPS_SHOULD_NARROW: return "SHOULD_NARROW";
2460+
case VKI_WQOPS_SETUP_DISPATCH: return "SETUP_DISPATCH";
24602461
default: return "?";
24612462
}
24622463
}
@@ -2514,11 +2515,29 @@ PRE(workq_ops)
25142515
// RK fixme need anything here?
25152516
// RK fixme may block?
25162517
break;
2517-
case VKI_WQOPS_SETUP_DISPATCH:
2518+
case VKI_WQOPS_SETUP_DISPATCH: {
25182519
// docs says: setup pthread workqueue-related operations
2520+
#if DARWIN_VERS >= DARWIN_10_15
2521+
#pragma pack(4)
2522+
struct workq_dispatch_config {
2523+
uint32_t wdc_version;
2524+
uint32_t wdc_flags;
2525+
uint64_t wdc_queue_serialno_offs;
2526+
uint64_t wdc_queue_label_offs;
2527+
};
2528+
#pragma pack()
2529+
PRE_MEM_READ("workq_ops(item)", ARG2, MIN(sizeof(struct workq_dispatch_config), SARG3));
2530+
struct workq_dispatch_config* cfg = (struct workq_dispatch_config*)ARG2;
2531+
if (cfg->wdc_flags & ~VKI_WORKQ_DISPATCH_SUPPORTED_FLAGS ||
2532+
cfg->wdc_version < VKI_WORKQ_DISPATCH_MIN_SUPPORTED_VERSION) {
2533+
SET_STATUS_Failure( VKI_ENOTSUP );
2534+
}
2535+
#endif
25192536
break;
2537+
}
25202538
default:
2521-
VG_(printf)("UNKNOWN workq_ops option %ld\n", ARG1);
2539+
PRINT("workq_ops ( %lu [??], ... )", ARG1);
2540+
log_decaying("UNKNOWN workq_ops option %lu!", ARG1);
25222541
break;
25232542
}
25242543
}

include/vki/vki-darwin.h

+4
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,10 @@ struct ByteRangeLockPB2
10221022
#define VKI_WQOPS_SHOULD_NARROW 512 /* checks whether we should narrow our concurrency */
10231023
#define VKI_WQOPS_SETUP_DISPATCH 1024 /* setup pthread workqueue-related operations */
10241024

1025+
#define VKI_WORKQ_DISPATCH_CONFIG_VERSION 2
1026+
#define VKI_WORKQ_DISPATCH_MIN_SUPPORTED_VERSION 1
1027+
#define VKI_WORKQ_DISPATCH_SUPPORTED_FLAGS 0
1028+
10251029

10261030
#include <sys/ttycom.h>
10271031

0 commit comments

Comments
 (0)