blob: ca7552f49bad691ea915316141c1c7f0f49b58e1 [file] [log] [blame]
Radek Krejci968d7552021-03-26 20:33:51 +01001/**
Michal Vasko8f702ee2024-02-20 15:44:24 +01002 * @file ly_config.h
Radek Krejci968d7552021-03-26 20:33:51 +01003 * @author Radek Krejci <rkrejci@cesnet.cz>
Michal Vasko8f702ee2024-02-20 15:44:24 +01004 * @uathor Michal Vasko <mvasko@cesnet.cz>
Radek Krejci968d7552021-03-26 20:33:51 +01005 * @brief Various variables provided by cmake and compile time options.
6 *
Michal Vasko8f702ee2024-02-20 15:44:24 +01007 * Copyright (c) 2021 - 2024 CESNET, z.s.p.o.
Radek Krejci968d7552021-03-26 20:33:51 +01008 *
9 * This source code is licensed under BSD 3-Clause License (the "License").
10 * You may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * https://opensource.org/licenses/BSD-3-Clause
14 */
15
16#ifndef LY_CONFIG_H_
17#define LY_CONFIG_H_
18
Jan Kundráta3d248e2021-12-14 18:05:26 +010019#ifdef _WIN32
20/* headers are broken on Windows, which means that some of them simply *have* to come first */
21# include <winsock2.h>
22# include <ws2tcpip.h>
23#endif
24
Michal Vaskoaa0ee622021-05-11 09:29:25 +020025/** size of fixed_mem in lyd_value, minimum is 8 (B) */
26#define LYD_VALUE_FIXED_MEM_SIZE @LYD_VALUE_SIZE@
27
Michal Vaskobabf0bd2021-08-31 14:55:39 +020028/** plugins */
Radek Krejci968d7552021-03-26 20:33:51 +010029#define LYPLG_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@"
30#define LYPLG_SUFFIX_LEN (sizeof LYPLG_SUFFIX - 1)
Michal Vaskobbea05f2021-11-24 11:06:11 +010031#define LYPLG_TYPE_DIR "@PLUGINS_DIR_TYPES@"
32#define LYPLG_EXT_DIR "@PLUGINS_DIR_EXTENSIONS@"
Radek Krejci968d7552021-03-26 20:33:51 +010033
Michal Vasko080064b2021-08-31 15:20:44 +020034/** atomic compiler operations, to be able to use uint32_t */
Jan Kundrát12cd9aa2021-12-10 01:50:26 +010035#ifndef _WIN32
36# define LY_ATOMIC_INC_BARRIER(var) __sync_fetch_and_add(&(var), 1)
37# define LY_ATOMIC_DEC_BARRIER(var) __sync_fetch_and_sub(&(var), 1)
38#else
39# include <windows.h>
40# define LY_ATOMIC_INC_BARRIER(var) InterlockedExchangeAdd(&(var), 1)
41# define LY_ATOMIC_DEC_BARRIER(var) InterlockedExchangeAdd(&(var), -1)
42#endif
Michal Vaskobabf0bd2021-08-31 14:55:39 +020043
44/** printf compiler attribute */
Michal Vasko5f201412021-11-24 11:06:38 +010045#ifdef __GNUC__
aPiecek6d618552021-06-18 10:02:59 +020046# define _FORMAT_PRINTF(FORM, ARGS) __attribute__((format (printf, FORM, ARGS)))
47#else
48# define _FORMAT_PRINTF(FORM, ARGS)
49#endif
50
Jan Kundrátc53a7ec2021-12-09 16:01:19 +010051/** Exporting symbols to a shared library and importing back afterwards
52 *
53 * - use LIBYANG_API_DECL to mark a declaration in the public header
54 * - use LIBYANG_API_DEF to mark a definition (in the source code for the actual implementaiton)
55 * */
56#ifdef _MSC_VER
57# ifndef STATIC
58# define LIBYANG_API_DEF __declspec(dllexport)
59# ifdef LIBYANG_BUILD
60# define LIBYANG_API_DECL __declspec(dllexport)
61# else
62# define LIBYANG_API_DECL __declspec(dllimport)
63# endif
64# endif
65#else
66/*
67 * If the compiler supports attribute to mark objects as hidden, mark all
68 * objects as hidden and export only objects explicitly marked to be part of
69 * the public API.
70 */
71# define LIBYANG_API_DEF __attribute__((visibility("default")))
72# define LIBYANG_API_DECL
73#endif
74
Radek Krejci968d7552021-03-26 20:33:51 +010075#endif /* LY_CONFIG_H_ */