Skip to content

Commit 3c180cf

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 3c180cf

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

test/ipc_file_prov_consumer.c

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

8+
#include <stdbool.h>
89
#include <stdio.h>
910
#include <stdlib.h>
1011

@@ -15,17 +16,30 @@
1516

1617
int main(int argc, char *argv[]) {
1718
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
19+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
20+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
21+
"<file_name> is located on FSDAX \n");
1922
return -1;
2023
}
2124

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

2535
umf_file_memory_provider_params_t file_params;
2636

2737
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
38+
if (is_fsdax) {
39+
file_params.visibility = UMF_MEM_MAP_SYNC;
40+
} else {
41+
file_params.visibility = UMF_MEM_MAP_SHARED;
42+
}
2943

3044
return run_consumer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3145
NULL);

test/ipc_file_prov_producer.c

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

8+
#include <stdbool.h>
89
#include <stdio.h>
910
#include <stdlib.h>
1011

@@ -15,17 +16,30 @@
1516

1617
int main(int argc, char *argv[]) {
1718
if (argc < 3) {
18-
fprintf(stderr, "usage: %s <port> <file_name>\n", argv[0]);
19+
fprintf(stderr, "usage: %s <port> <file_name> <fsdax>\n", argv[0]);
20+
fprintf(stderr, " <fsdax> should be \"FSDAX\" or \"fsdax\" if "
21+
"<file_name> is located on FSDAX \n");
1922
return -1;
2023
}
2124

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

2535
umf_file_memory_provider_params_t file_params;
2636

2737
file_params = umfFileMemoryProviderParamsDefault(file_name);
28-
file_params.visibility = UMF_MEM_MAP_SHARED;
38+
if (is_fsdax) {
39+
file_params.visibility = UMF_MEM_MAP_SYNC;
40+
} else {
41+
file_params.visibility = UMF_MEM_MAP_SHARED;
42+
}
2943

3044
return run_producer(port, umfFileMemoryProviderOps(), &file_params, memcopy,
3145
NULL);

0 commit comments

Comments
 (0)