Radek Krejci | 968d755 | 2021-03-26 20:33:51 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @file config.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief Various variables provided by cmake and compile time options. |
| 5 | * |
| 6 | * Copyright (c) 2021 CESNET, z.s.p.o. |
| 7 | * |
| 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 |
| 11 | * |
| 12 | * https://opensource.org/licenses/BSD-3-Clause |
| 13 | */ |
| 14 | |
| 15 | #ifndef LY_CONFIG_H_ |
| 16 | #define LY_CONFIG_H_ |
| 17 | |
Jan Kundrát | a3d248e | 2021-12-14 18:05:26 +0100 | [diff] [blame] | 18 | #ifdef _WIN32 |
| 19 | /* headers are broken on Windows, which means that some of them simply *have* to come first */ |
| 20 | # include <winsock2.h> |
| 21 | # include <ws2tcpip.h> |
| 22 | #endif |
| 23 | |
Michal Vasko | aa0ee62 | 2021-05-11 09:29:25 +0200 | [diff] [blame] | 24 | /** size of fixed_mem in lyd_value, minimum is 8 (B) */ |
| 25 | #define LYD_VALUE_FIXED_MEM_SIZE @LYD_VALUE_SIZE@ |
| 26 | |
Michal Vasko | babf0bd | 2021-08-31 14:55:39 +0200 | [diff] [blame] | 27 | /** plugins */ |
Radek Krejci | 968d755 | 2021-03-26 20:33:51 +0100 | [diff] [blame] | 28 | #define LYPLG_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@" |
| 29 | #define LYPLG_SUFFIX_LEN (sizeof LYPLG_SUFFIX - 1) |
Michal Vasko | bbea05f | 2021-11-24 11:06:11 +0100 | [diff] [blame] | 30 | #define LYPLG_TYPE_DIR "@PLUGINS_DIR_TYPES@" |
| 31 | #define LYPLG_EXT_DIR "@PLUGINS_DIR_EXTENSIONS@" |
Radek Krejci | 968d755 | 2021-03-26 20:33:51 +0100 | [diff] [blame] | 32 | |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 33 | /** atomic compiler operations, to be able to use uint32_t */ |
Jan Kundrát | 12cd9aa | 2021-12-10 01:50:26 +0100 | [diff] [blame] | 34 | #ifndef _WIN32 |
| 35 | # define LY_ATOMIC_INC_BARRIER(var) __sync_fetch_and_add(&(var), 1) |
| 36 | # define LY_ATOMIC_DEC_BARRIER(var) __sync_fetch_and_sub(&(var), 1) |
| 37 | #else |
| 38 | # include <windows.h> |
| 39 | # define LY_ATOMIC_INC_BARRIER(var) InterlockedExchangeAdd(&(var), 1) |
| 40 | # define LY_ATOMIC_DEC_BARRIER(var) InterlockedExchangeAdd(&(var), -1) |
| 41 | #endif |
Michal Vasko | babf0bd | 2021-08-31 14:55:39 +0200 | [diff] [blame] | 42 | |
| 43 | /** printf compiler attribute */ |
Michal Vasko | 5f20141 | 2021-11-24 11:06:38 +0100 | [diff] [blame] | 44 | #ifdef __GNUC__ |
aPiecek | 6d61855 | 2021-06-18 10:02:59 +0200 | [diff] [blame] | 45 | # define _FORMAT_PRINTF(FORM, ARGS) __attribute__((format (printf, FORM, ARGS))) |
| 46 | #else |
| 47 | # define _FORMAT_PRINTF(FORM, ARGS) |
| 48 | #endif |
| 49 | |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 50 | /** Exporting symbols to a shared library and importing back afterwards |
| 51 | * |
| 52 | * - use LIBYANG_API_DECL to mark a declaration in the public header |
| 53 | * - use LIBYANG_API_DEF to mark a definition (in the source code for the actual implementaiton) |
| 54 | * */ |
| 55 | #ifdef _MSC_VER |
| 56 | # ifndef STATIC |
| 57 | # define LIBYANG_API_DEF __declspec(dllexport) |
| 58 | # ifdef LIBYANG_BUILD |
| 59 | # define LIBYANG_API_DECL __declspec(dllexport) |
| 60 | # else |
| 61 | # define LIBYANG_API_DECL __declspec(dllimport) |
| 62 | # endif |
| 63 | # endif |
| 64 | #else |
| 65 | /* |
| 66 | * If the compiler supports attribute to mark objects as hidden, mark all |
| 67 | * objects as hidden and export only objects explicitly marked to be part of |
| 68 | * the public API. |
| 69 | */ |
| 70 | # define LIBYANG_API_DEF __attribute__((visibility("default"))) |
| 71 | # define LIBYANG_API_DECL |
| 72 | #endif |
| 73 | |
Radek Krejci | 968d755 | 2021-03-26 20:33:51 +0100 | [diff] [blame] | 74 | #endif /* LY_CONFIG_H_ */ |