Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file config.h |
| 3 | * \author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * \brief libnetconf2 various configuration settings. |
| 5 | * |
Michal Vasko | f471fa0 | 2017-02-15 10:48:12 +0100 | [diff] [blame] | 6 | * Copyright (c) 2015 - 2017 CESNET, z.s.p.o. |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 7 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 8 | * 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 Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 11 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 12 | * https://opensource.org/licenses/BSD-3-Clause |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef NC_CONFIG_H_ |
| 16 | #define NC_CONFIG_H_ |
| 17 | |
| 18 | /* |
David Sedlák | aae4df3 | 2018-10-08 22:27:22 +0200 | [diff] [blame] | 19 | * 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 Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 21 | */ |
| 22 | #define API __attribute__((visibility("default"))) |
David Sedlák | ddde449 | 2018-09-30 21:34:38 +0200 | [diff] [blame] | 23 | #define MOCK __attribute__((visibility("default"))) |
| 24 | |
Michal Vasko | 05ba9df | 2016-01-13 14:40:27 +0100 | [diff] [blame] | 25 | #ifdef __GNUC__ |
| 26 | # define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) |
| 27 | #else |
| 28 | # define UNUSED(x) UNUSED_ ## x |
| 29 | #endif |
| 30 | |
Radek Krejci | 14b1403 | 2015-10-21 15:19:43 +0200 | [diff] [blame] | 31 | /* |
Michal Vasko | 7ae909a | 2018-11-09 09:51:42 +0100 | [diff] [blame] | 32 | * Support for atomic variables |
Radek Krejci | 32898d5 | 2016-07-14 17:37:02 +0200 | [diff] [blame] | 33 | */ |
Michal Vasko | 7ae909a | 2018-11-09 09:51:42 +0100 | [diff] [blame] | 34 | #cmakedefine HAVE_STDATOMIC |
| 35 | #ifdef HAVE_STDATOMIC |
| 36 | # include <stdatomic.h> |
Michal Vasko | e201015 | 2020-09-09 08:29:12 +0200 | [diff] [blame] | 37 | # include <stdint.h> |
Michal Vasko | 7ae909a | 2018-11-09 09:51:42 +0100 | [diff] [blame] | 38 | |
| 39 | # define ATOMIC_UINT32_T atomic_uint_fast32_t |
Michal Vasko | 7f1fa3c | 2020-09-08 16:30:41 +0200 | [diff] [blame] | 40 | # define ATOMIC_PTR atomic_uintptr_t |
Michal Vasko | b639e9c | 2020-09-09 09:51:48 +0200 | [diff] [blame] | 41 | # define ATOMIC_STORE(x, val) atomic_store(&(x), (val)) |
| 42 | # define ATOMIC_LOAD(x) atomic_load((atomic_uintptr_t *)&(x)) |
Michal Vasko | 7f1fa3c | 2020-09-08 16:30:41 +0200 | [diff] [blame] | 43 | # define ATOMIC_INC(x) atomic_fetch_add(&(x), 1) |
Michal Vasko | 7ae909a | 2018-11-09 09:51:42 +0100 | [diff] [blame] | 44 | #else |
| 45 | # define ATOMIC_UINT32_T uint32_t |
Michal Vasko | 7f1fa3c | 2020-09-08 16:30:41 +0200 | [diff] [blame] | 46 | # define ATOMIC_PTR void * |
Michal Vasko | b639e9c | 2020-09-09 09:51:48 +0200 | [diff] [blame] | 47 | # define ATOMIC_STORE(x, val) (x) = (val) |
| 48 | # define ATOMIC_LOAD(x) (x) |
Michal Vasko | 7f1fa3c | 2020-09-08 16:30:41 +0200 | [diff] [blame] | 49 | # define ATOMIC_INC(x) __sync_add_and_fetch(&(x), 1) |
Radek Krejci | 32898d5 | 2016-07-14 17:37:02 +0200 | [diff] [blame] | 50 | #endif |
| 51 | |
| 52 | /* |
Radek Krejci | 2847292 | 2016-07-15 11:51:16 +0200 | [diff] [blame] | 53 | * support for pthread_mutex_timedlock |
| 54 | */ |
| 55 | #cmakedefine HAVE_PTHREAD_MUTEX_TIMEDLOCK |
| 56 | |
| 57 | /* |
apropp-molex | 4e903c3 | 2020-04-20 03:06:58 -0400 | [diff] [blame] | 58 | * Support for getpeereid |
| 59 | */ |
| 60 | #cmakedefine HAVE_GETPEEREID |
| 61 | |
| 62 | /* |
| 63 | * Support for shadow file manipulation |
| 64 | */ |
| 65 | #cmakedefine HAVE_SHADOW |
| 66 | |
| 67 | /* |
| 68 | * Support for crypt.h |
| 69 | */ |
| 70 | #cmakedefine HAVE_CRYPT |
| 71 | |
| 72 | /* |
Michal Vasko | 5a44647 | 2020-05-06 12:43:42 +0200 | [diff] [blame] | 73 | * Location of installed basic YANG modules on the system |
Radek Krejci | 14b1403 | 2015-10-21 15:19:43 +0200 | [diff] [blame] | 74 | */ |
Michal Vasko | 5a44647 | 2020-05-06 12:43:42 +0200 | [diff] [blame] | 75 | #define NC_YANG_DIR "@YANG_MODULE_DIR@" |
Radek Krejci | 14b1403 | 2015-10-21 15:19:43 +0200 | [diff] [blame] | 76 | |
Michal Vasko | 6b7c42e | 2016-03-02 15:46:41 +0100 | [diff] [blame] | 77 | /* |
Michal Vasko | f471fa0 | 2017-02-15 10:48:12 +0100 | [diff] [blame] | 78 | * Inactive read timeout |
Michal Vasko | 6b7c42e | 2016-03-02 15:46:41 +0100 | [diff] [blame] | 79 | */ |
Michal Vasko | f471fa0 | 2017-02-15 10:48:12 +0100 | [diff] [blame] | 80 | #define NC_READ_INACT_TIMEOUT @READ_INACTIVE_TIMEOUT@ |
| 81 | |
| 82 | /* |
| 83 | * Active read timeout in seconds |
| 84 | * (also used for internal <get-schema> RPC reply timeout) |
| 85 | */ |
| 86 | #define NC_READ_ACT_TIMEOUT @READ_ACTIVE_TIMEOUT@ |
Michal Vasko | 6b7c42e | 2016-03-02 15:46:41 +0100 | [diff] [blame] | 87 | |
Michal Vasko | afdb8ec | 2017-02-15 11:25:36 +0100 | [diff] [blame] | 88 | /* |
| 89 | * pspoll structure queue size (also found in nc_server.h) |
| 90 | */ |
| 91 | #define NC_PS_QUEUE_SIZE @MAX_PSPOLL_THREAD_COUNT@ |
| 92 | |
Michal Vasko | 5a9bd9c | 2019-08-16 15:50:09 +0200 | [diff] [blame] | 93 | /* Microseconds after which tasks are repeated until the full timeout elapses. |
| 94 | * A millisecond (1000) should be divisible by this number without remain. |
| 95 | */ |
| 96 | #define NC_TIMEOUT_STEP @TIMEOUT_STEP@ |
| 97 | |
Rosen Penev | ef2f3ac | 2019-07-15 18:15:28 -0700 | [diff] [blame] | 98 | /* Portability feature-check macros. */ |
| 99 | #cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP |
| 100 | |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 101 | #endif /* NC_CONFIG_H_ */ |