Skip to content

Commit 8253aef

Browse files
committed
Use UMF_MEM_MAP_SYNC for FSDAX in the FSDAX IPC example
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 885c9d2 commit 8253aef

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

test/ipc_file_prov_consumer.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
*/
77

8+
#include <stdbool.h>
89
#include <stdio.h>
910
#include <stdlib.h>
11+
#include <strings.h>
1012

1113
#include <umf/providers/provider_file_memory.h>
1214

@@ -15,17 +17,30 @@
1517

1618
int main(int argc, char *argv[]) {
1719
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
20+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
21+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
22+
"<file_name> is located on FSDAX \n");
1923
return -1;
2024
}
2125

2226
int port = atoi(argv[1]);
2327
char *file_name = argv[2];
28+
bool is_fsdax = false;
29+
30+
if (argc >= 4) {
31+
if (strncasecmp(argv[3], "FSDAX", strlen("FSDAX")) == 0) {
32+
is_fsdax = true;
33+
}
34+
}
2435

2536
umf_file_memory_provider_params_t file_params;
2637

2738
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
39+
if (is_fsdax) {
40+
file_params.visibility = UMF_MEM_MAP_SYNC;
41+
} else {
42+
file_params.visibility = UMF_MEM_MAP_SHARED;
43+
}
2944

3045
return run_consumer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3146
NULL);

test/ipc_file_prov_producer.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
*/
77

8+
#include <stdbool.h>
89
#include <stdio.h>
910
#include <stdlib.h>
11+
#include <strings.h>
1012

1113
#include <umf/providers/provider_file_memory.h>
1214

@@ -15,17 +17,30 @@
1517

1618
int main(int argc, char *argv[]) {
1719
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
20+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
21+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
22+
"<file_name> is located on FSDAX \n");
1923
return -1;
2024
}
2125

2226
int port = atoi(argv[1]);
2327
char *file_name = argv[2];
28+
bool is_fsdax = false;
29+
30+
if (argc >= 4) {
31+
if (strncasecmp(argv[3], "FSDAX", strlen("FSDAX")) == 0) {
32+
is_fsdax = true;
33+
}
34+
}
2435

2536
umf_file_memory_provider_params_t file_params;
2637

2738
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
39+
if (is_fsdax) {
40+
file_params.visibility = UMF_MEM_MAP_SYNC;
41+
} else {
42+
file_params.visibility = UMF_MEM_MAP_SHARED;
43+
}
2944

3045
return run_producer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3146
NULL);

0 commit comments

Comments
 (0)