Debian Codegraph @

docs/core_api.rst

raw
1 ..
2 SPDX-License-Identifier: CC-BY-SA-4.0
3 SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <[email protected]>
4
5 ..
6 This file is part of libgpiod.
7
8 libgpiod core API documentation
9
10 libgpiod core API
11 =================
12
13 This is the complete documentation of the public API made available to users of
14 **libgpiod**.
15
16 The API is logically split into several sections. For each opaque data class,
17 there's a set of functions for manipulating it. Together they can be thought
18 of as objects and their methods in OOP parlance.
19
20 .. note::
21 General note on error handling: all functions exported by libgpiod that can
22 fail, set errno to one of the error values defined in errno.h upon failure.
23 The way of notifying the caller that an error occurred varies between
24 functions, but in general a function that returns an ``int``, returns ``-1``
25 on error, while a function returning a pointer indicates an error condition
26 by returning a **NULL pointer**. It's not practical to list all possible
27 error codes for every function as they propagate errors from the underlying
28 libc functions.
29
30 In general libgpiod functions are **NULL-aware**. For functions that are
31 logically methods of data classes - ones that take a pointer to the object of
32 that class as the first argument - passing a NULL-pointer will result in the
33 program aborting the execution. For non-methods, init functions and methods
34 that take a pointer as any of the subsequent arguments, the handling of a
35 NULL-pointer depends on the implementation and may range from gracefully
36 handling it, ignoring it or returning an error.
37
38 **libgpiod** is **thread-aware** but does not provide any further thread-safety
39 guarantees. This requires the user to ensure that at most one thread may work
40 with an object at any time. Sharing objects across threads is allowed if
41 a suitable synchronization mechanism serializes the access. Different,
42 standalone objects can safely be used concurrently.
43
44 .. note::
45 Most libgpiod objects are standalone. Exceptions - such as events allocated
46 in buffers - exist and are noted in the documentation.
47
48 .. toctree::
49 :maxdepth: 1
50 :caption: Contents
51
52 core_chips
53 core_chip_info
54 core_line_defs
55 core_line_info
56 core_line_watch
57 core_line_settings
58 core_line_config
59 core_request_config
60 core_line_request
61 core_edge_event
62 core_misc