Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
examples: explain <pmem-path> in PMEM_USAGE
Browse files Browse the repository at this point in the history
  • Loading branch information
ldorau committed Jan 21, 2022
1 parent 8119e22 commit 218e56a
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 52 deletions.
4 changes: 4 additions & 0 deletions examples/03-read-to-persistent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ an out-of-band or the in-band channel.
```bash
[user@client]$ ./client $server_address $port [<pmem-path>]
```

where `<pmem-path>` can be:
- a Device DAX (`/dev/dax0.0` for example) or
- a file on File System DAX (`/mnt/pmem/file` for example).
9 changes: 4 additions & 5 deletions examples/03-read-to-persistent/client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020-2021, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */

/*
* client.c -- a client of the read-to-persistent example
Expand All @@ -10,17 +10,16 @@
#include <librpma.h>
#include <stdlib.h>
#include <stdio.h>
#include "common-conn.h"
#include "hello.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"
#include "hello.h"

static inline void
write_hello_str(struct hello_t *hello, enum lang_t lang)
{
Expand Down
7 changes: 3 additions & 4 deletions examples/03-read-to-persistent/server.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */
/* Copyright 2021, Fujitsu */

/*
Expand All @@ -12,16 +12,15 @@
#include <librpma.h>
#include <stdlib.h>
#include <stdio.h>
#include "common-conn.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"

int
main(int argc, char *argv[])
{
Expand Down
4 changes: 4 additions & 0 deletions examples/04-write-to-persistent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ an out-of-band or the in-band channel.
```bash
[user@client]$ ./client $server_address $port [<pmem-path>]
```

where `<pmem-path>` can be:
- a Device DAX (`/dev/dax0.0` for example) or
- a file on File System DAX (`/mnt/pmem/file` for example).
9 changes: 4 additions & 5 deletions examples/04-write-to-persistent/client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020-2021, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */
/* Copyright 2021, Fujitsu */

/*
Expand All @@ -11,17 +11,16 @@
#include <librpma.h>
#include <stdlib.h>
#include <stdio.h>
#include "common-conn.h"
#include "hello.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"
#include "hello.h"

static inline void
write_hello_str(struct hello_t *hello, enum lang_t lang)
{
Expand Down
7 changes: 3 additions & 4 deletions examples/04-write-to-persistent/server.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020-2021, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */

/*
* server.c -- a server of the write-to-persistent example
Expand All @@ -11,16 +11,15 @@
#include <librpma.h>
#include <stdlib.h>
#include <stdio.h>
#include "common-conn.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"

#ifdef TEST_USE_CMOCKA
#include "cmocka_headers.h"
#include "cmocka_alloc.h"
Expand Down
4 changes: 4 additions & 0 deletions examples/05-flush-to-persistent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ channel.
```bash
[user@client]$ ./client $server_address $port [<pmem-path>]
```

where `<pmem-path>` can be:
- a Device DAX (`/dev/dax0.0` for example) or
- a file on File System DAX (`/mnt/pmem/file` for example).
9 changes: 4 additions & 5 deletions examples/05-flush-to-persistent/client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */
/* Copyright 2021, Fujitsu */

/*
Expand All @@ -12,17 +12,16 @@
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include "common-conn.h"
#include "hello.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"
#include "hello.h"

#define FLUSH_ID (void *)0xF01D /* a random identifier */

static inline void
Expand Down
8 changes: 4 additions & 4 deletions examples/05-flush-to-persistent/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#include <librpma.h>
#include <stdlib.h>
#include <stdio.h>
#include "common-conn.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>] " \
"[direct-pmem-write]\n"
#define USAGE_STR \
"usage: %s <server_address> <port> [<pmem-path>] [direct-pmem-write]\n"\
PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */
Expand All @@ -24,8 +26,6 @@
#define ON_STR "on"
#endif /* USE_LIBPMEM */

#include "common-conn.h"

int
main(int argc, char *argv[])
{
Expand Down
4 changes: 4 additions & 0 deletions examples/07-atomic-write/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ an out-of-band or the in-band channel.
```bash
[user@client]$ ./client $server_address $port $word1 [<word2>] [<...>]
```

where `<pmem-path>` can be:
- a Device DAX (`/dev/dax0.0` for example) or
- a file on File System DAX (`/mnt/pmem/file` for example).
11 changes: 4 additions & 7 deletions examples/07-atomic-write/server.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020-2021, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */

/*
* server.c -- a server of the atomic-write example
Expand All @@ -12,19 +12,16 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "common-conn.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#define LOG_HDR_SIGNATURE "LOG"
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"

#ifdef USE_LIBPMEM
#define LOG_HDR_SIGNATURE "LOG"
#endif
#define LOG_SIGNATURE_SIZE 8
#define LOG_DATA_SIZE 1024

Expand Down
4 changes: 4 additions & 0 deletions examples/09-flush-to-persistent-GPSPM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ via an out-of-band or the in-band channel.
```bash
[user@client]$ ./client $server_address $port [<pmem-path>]
```

where `<pmem-path>` can be:
- a Device DAX (`/dev/dax0.0` for example) or
- a file on File System DAX (`/mnt/pmem/file` for example).
17 changes: 8 additions & 9 deletions examples/09-flush-to-persistent-GPSPM/client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */
/* Copyright 2021, Fujitsu */

/*
Expand All @@ -12,21 +12,20 @@
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"
#include "flush-to-persistent-GPSPM.h"

/* Generated by the protocol buffer compiler from: GPSPM_flush.proto */
#include "GPSPM_flush.pb-c.h"
#include "hello.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#define FLUSH_ID (void *)0xF01D /* a random identifier */

static inline void
Expand Down
15 changes: 7 additions & 8 deletions examples/09-flush-to-persistent-GPSPM/server.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020-2021, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */
/* Copyright 2021, Fujitsu */

/*
Expand All @@ -12,20 +12,19 @@
#include <librpma.h>
#include <stdlib.h>
#include <stdio.h>
#include "common-conn.h"
#include "flush-to-persistent-GPSPM.h"

/* Generated by the protocol buffer compiler from: GPSPM_flush.proto */
#include "GPSPM_flush.pb-c.h"

#ifdef USE_LIBPMEM
#include <libpmem.h>
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"
#define USAGE_STR "usage: %s <server_address> <port> [<pmem-path>]\n"PMEM_USAGE
#else
#define USAGE_STR "usage: %s <server_address> <port>\n"
#endif /* USE_LIBPMEM */

#include "common-conn.h"
#include "flush-to-persistent-GPSPM.h"

/* Generated by the protocol buffer compiler from: GPSPM_flush.proto */
#include "GPSPM_flush.pb-c.h"

int
main(int argc, char *argv[])
{
Expand Down
7 changes: 6 additions & 1 deletion examples/common/common-conn.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2020-2021, Intel Corporation */
/* Copyright 2020-2022, Intel Corporation */

/*
* common-conn.h -- a common connection functions declarations for examples
Expand All @@ -13,12 +13,17 @@

#ifdef USE_LIBPMEM

#define PMEM_USAGE \
"where <pmem-path> can be:\n\
- a Device DAX (/dev/dax0.0 for example) or\n\
- a file on File System DAX (/mnt/pmem/file for example)\n"
/* signature marking the persistent contents as valid */
#define SIGNATURE_STR "RPMA_EXAMPLE_SIG"
#define SIGNATURE_LEN (strlen(SIGNATURE_STR) + 1)

#define NO_PMEM_MSG "No <pmem-path> provided. Using DRAM instead.\n"
#else
#define PMEM_USAGE ""
#define NO_PMEM_MSG \
"The example is unable to use libpmem. If unintended please check the build log. Using DRAM instead.\n"
#endif
Expand Down

0 comments on commit 218e56a

Please sign in to comment.