---
name: "pmem2_config_set_sharing"
section: "3"
platform: "linux"
package: "libpmem2-dev"
version: "1.13.1-1.1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pmem2_config_set_sharing"
---

# pmem2\_config\_set\_sharing(3)

set sharing in the pmem2\_config structure

## NAME

**pmem2\_config\_set\_sharing**() - set sharing in the pmem2\_config structure

## SYNOPSIS

-

  ```
  #include <libpmem2.h>
  struct pmem2_config;
  enum pmem2_sharing_type {
      PMEM2_SHARED,
      PMEM2_PRIVATE,
  };
  int pmem2_config_set_sharing(struct pmem2_config *config, enum pmem2_sharing_type sharing);
  ```

## DESCRIPTION

The **pmem2\_config\_set\_sharing**() function configures the behavior and visibility of writes to the mapping’s pages. The possible values are listed below:

- •

  **PMEM2\_SHARED** - Writes are made directly to the underlying memory, making them visible to other mappings of the same memory region. (default)

- •

  **PMEM2\_PRIVATE** - Writes do not affect the underlying memory and are not visible to other mappings of the same memory region.

## RETURN VALUE

The **pmem2\_config\_set\_sharing**() function returns 0 on success or a negative error code on failure.

## ERRORRS

The **pmem2\_config\_set\_sharing**() can fail with the following errors:

- •

  **PMEM2\_E\_INVALID\_SHARING\_VALUE** - *sharing* value is invalid.

## SEE ALSO

[**libpmem2**(7)](/libpmem2/7.md), [**pmem2\_config\_new**(3)](/pmem2_config_new/3.md), [**pmem2\_map\_new**(3)](/pmem2_map_new/3.md), [**sysconf**(3)](/sysconf/3.md) and **\<https://pmem.io\>**
