blob: a018f3f735e88ac222d5d14dab15160f20ad5c2a [file] [log] [blame]
Radek Krejcid0d19522015-09-02 13:49:25 +02001/**
2 * \file config.h
3 * \author Radek Krejci <rkrejci@cesnet.cz>
4 * \brief libnetconf2 various configuration settings.
5 *
Michal Vaskof471fa02017-02-15 10:48:12 +01006 * Copyright (c) 2015 - 2017 CESNET, z.s.p.o.
Radek Krejcid0d19522015-09-02 13:49:25 +02007 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01008 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
Michal Vaskoafd416b2016-02-25 14:51:46 +010011 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010012 * https://opensource.org/licenses/BSD-3-Clause
Radek Krejcid0d19522015-09-02 13:49:25 +020013 */
14
15#ifndef NC_CONFIG_H_
16#define NC_CONFIG_H_
17
18/*
David Sedlákaae4df32018-10-08 22:27:22 +020019 * Mark all objects as hidden and export only objects explicitly marked to be part of the public API or
20 * those marked as mock objects for testing purpose
Radek Krejcid0d19522015-09-02 13:49:25 +020021 */
22#define API __attribute__((visibility("default")))
David Sedlákddde4492018-09-30 21:34:38 +020023#define MOCK __attribute__((visibility("default")))
24
Michal Vasko05ba9df2016-01-13 14:40:27 +010025#ifdef __GNUC__
26# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
27#else
28# define UNUSED(x) UNUSED_ ## x
29#endif
30
Radek Krejci14b14032015-10-21 15:19:43 +020031/*
Michal Vasko7ae909a2018-11-09 09:51:42 +010032 * Support for atomic variables
Radek Krejci32898d52016-07-14 17:37:02 +020033 */
Michal Vasko7ae909a2018-11-09 09:51:42 +010034#cmakedefine HAVE_STDATOMIC
35#ifdef HAVE_STDATOMIC
36# include <stdatomic.h>
37
38# define ATOMIC_UINT32_T atomic_uint_fast32_t
Michal Vasko7f1fa3c2020-09-08 16:30:41 +020039# define ATOMIC_PTR atomic_uintptr_t
40# define ATOMIC_STORE(x, val) atomic_store(&(x), (atomic_uintptr_t)(val))
41# define ATOMIC_LOAD(x) ((void *)atomic_load(&(x)))
42# define ATOMIC_INC(x) atomic_fetch_add(&(x), 1)
Michal Vasko7ae909a2018-11-09 09:51:42 +010043#else
44# define ATOMIC_UINT32_T uint32_t
Michal Vasko7f1fa3c2020-09-08 16:30:41 +020045# define ATOMIC_PTR void *
46# define ATOMIC_STORE(x, val) (x) = (void *)(val)
47# define ATOMIC_LOAD(x) ((void *)(x))
48# define ATOMIC_INC(x) __sync_add_and_fetch(&(x), 1)
Radek Krejci32898d52016-07-14 17:37:02 +020049#endif
50
51/*
Radek Krejci28472922016-07-15 11:51:16 +020052 * support for pthread_mutex_timedlock
53 */
54#cmakedefine HAVE_PTHREAD_MUTEX_TIMEDLOCK
55
56/*
apropp-molex4e903c32020-04-20 03:06:58 -040057 * Support for getpeereid
58 */
59#cmakedefine HAVE_GETPEEREID
60
61/*
62 * Support for shadow file manipulation
63 */
64#cmakedefine HAVE_SHADOW
65
66/*
67 * Support for crypt.h
68 */
69#cmakedefine HAVE_CRYPT
70
71/*
Michal Vasko5a446472020-05-06 12:43:42 +020072 * Location of installed basic YANG modules on the system
Radek Krejci14b14032015-10-21 15:19:43 +020073 */
Michal Vasko5a446472020-05-06 12:43:42 +020074#define NC_YANG_DIR "@YANG_MODULE_DIR@"
Radek Krejci14b14032015-10-21 15:19:43 +020075
Michal Vasko6b7c42e2016-03-02 15:46:41 +010076/*
Michal Vaskof471fa02017-02-15 10:48:12 +010077 * Inactive read timeout
Michal Vasko6b7c42e2016-03-02 15:46:41 +010078 */
Michal Vaskof471fa02017-02-15 10:48:12 +010079#define NC_READ_INACT_TIMEOUT @READ_INACTIVE_TIMEOUT@
80
81/*
82 * Active read timeout in seconds
83 * (also used for internal <get-schema> RPC reply timeout)
84 */
85#define NC_READ_ACT_TIMEOUT @READ_ACTIVE_TIMEOUT@
Michal Vasko6b7c42e2016-03-02 15:46:41 +010086
Michal Vaskoafdb8ec2017-02-15 11:25:36 +010087/*
88 * pspoll structure queue size (also found in nc_server.h)
89 */
90#define NC_PS_QUEUE_SIZE @MAX_PSPOLL_THREAD_COUNT@
91
Michal Vasko5a9bd9c2019-08-16 15:50:09 +020092/* Microseconds after which tasks are repeated until the full timeout elapses.
93 * A millisecond (1000) should be divisible by this number without remain.
94 */
95#define NC_TIMEOUT_STEP @TIMEOUT_STEP@
96
Rosen Penevef2f3ac2019-07-15 18:15:28 -070097/* Portability feature-check macros. */
98#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP
99
Radek Krejcid0d19522015-09-02 13:49:25 +0200100#endif /* NC_CONFIG_H_ */