CXL\_NEW(3) libcxl Manual CXL\_NEW(3)

# [NAME](#NAME)

cxl\_new - Create a new library context object that acts as a handle for all library operations

# [SYNOPSIS](#SYNOPSIS)

```
#include <cxl/libcxl.h>
int cxl_new(struct cxl_ctx **ctx);
```

# [DESCRIPTION](#DESCRIPTION)

Instantiates a new library context, and stores an opaque pointer in ctx. The context is freed by linklibcxl:cxl\_unref\[3], i.e. [cxl\_new(3)](/man/os/ndctl/cxl_new.3) implies an internal linklibcxl:cxl\_ref\[3].

# [RETURN VALUE](#RETURN_VALUE)

Returns 0 on success, and a negative errno on failure. Possible error codes are:

•-ENOMEM

•-ENXIO

# [EXAMPLE](#EXAMPLE)

See example usage in test/libcxl.c

# [COPYRIGHT](#COPYRIGHT)

Copyright © 2016 - 2022, Intel Corporation. License GPLv2: GNU GPL version 2 &lt;http://gnu.org/licenses/gpl.html&gt;. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

# [SEE ALSO](#SEE_ALSO)

linklibcxl:cxl\_ref\[3], linklibcxl:cxl\_unref\[3]

2026-10-30 libcxl

---

Document: cxl_new(3) from ndctl 85-r4 (Chainguard OS)
Source: https://github.com/pmem/ndctl
