blob: 4f53f2e8163c0dbc2b37b4a314be0df4b67b1916 [file] [log] [blame]
Radek Krejci968d7552021-03-26 20:33:51 +01001/**
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
Michal Vaskoaa0ee622021-05-11 09:29:25 +020018/** size of fixed_mem in lyd_value, minimum is 8 (B) */
19#define LYD_VALUE_FIXED_MEM_SIZE @LYD_VALUE_SIZE@
20
Michal Vaskobabf0bd2021-08-31 14:55:39 +020021/** plugins */
Radek Krejci968d7552021-03-26 20:33:51 +010022#define LYPLG_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@"
23#define LYPLG_SUFFIX_LEN (sizeof LYPLG_SUFFIX - 1)
Michal Vaskobbea05f2021-11-24 11:06:11 +010024#define LYPLG_TYPE_DIR "@PLUGINS_DIR_TYPES@"
25#define LYPLG_EXT_DIR "@PLUGINS_DIR_EXTENSIONS@"
Radek Krejci968d7552021-03-26 20:33:51 +010026
Michal Vasko080064b2021-08-31 15:20:44 +020027/** atomic compiler operations, to be able to use uint32_t */
Jan Kundrát12cd9aa2021-12-10 01:50:26 +010028#ifndef _WIN32
29# define LY_ATOMIC_INC_BARRIER(var) __sync_fetch_and_add(&(var), 1)
30# define LY_ATOMIC_DEC_BARRIER(var) __sync_fetch_and_sub(&(var), 1)
31#else
32# include <windows.h>
33# define LY_ATOMIC_INC_BARRIER(var) InterlockedExchangeAdd(&(var), 1)
34# define LY_ATOMIC_DEC_BARRIER(var) InterlockedExchangeAdd(&(var), -1)
35#endif
Michal Vaskobabf0bd2021-08-31 14:55:39 +020036
37/** printf compiler attribute */
Michal Vasko5f201412021-11-24 11:06:38 +010038#ifdef __GNUC__
aPiecek6d618552021-06-18 10:02:59 +020039# define _FORMAT_PRINTF(FORM, ARGS) __attribute__((format (printf, FORM, ARGS)))
40#else
41# define _FORMAT_PRINTF(FORM, ARGS)
42#endif
43
Jan Kundrátc53a7ec2021-12-09 16:01:19 +010044/** Exporting symbols to a shared library and importing back afterwards
45 *
46 * - use LIBYANG_API_DECL to mark a declaration in the public header
47 * - use LIBYANG_API_DEF to mark a definition (in the source code for the actual implementaiton)
48 * */
49#ifdef _MSC_VER
50# ifndef STATIC
51# define LIBYANG_API_DEF __declspec(dllexport)
52# ifdef LIBYANG_BUILD
53# define LIBYANG_API_DECL __declspec(dllexport)
54# else
55# define LIBYANG_API_DECL __declspec(dllimport)
56# endif
57# endif
58#else
59/*
60 * If the compiler supports attribute to mark objects as hidden, mark all
61 * objects as hidden and export only objects explicitly marked to be part of
62 * the public API.
63 */
64# define LIBYANG_API_DEF __attribute__((visibility("default")))
65# define LIBYANG_API_DECL
66#endif
67
Radek Krejci968d7552021-03-26 20:33:51 +010068#endif /* LY_CONFIG_H_ */