MySQL 8.4.0
Source Code Documentation
my_sharedlib.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25#ifndef MY_SHAREDLIB_INCLUDED
26#define MY_SHAREDLIB_INCLUDED
27
28/**
29 @file include/my_sharedlib.h
30 Functions related to handling of plugins and other dynamically loaded
31 libraries.
32*/
33
34#if defined(_WIN32)
35#define dlsym(lib, name) (void *)GetProcAddress((HMODULE)lib, name)
36#define dlopen(libname, unused) LoadLibraryEx(libname, nullptr, 0)
37#define dlclose(lib) FreeLibrary((HMODULE)lib)
38#define DLERROR_GENERATE(errmsg, error_number) \
39 char win_errormsg[2048]; \
40 if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error_number, 0, \
41 win_errormsg, 2048, nullptr)) { \
42 char *ptr; \
43 for (ptr = &win_errormsg[0] + strlen(win_errormsg) - 1; \
44 ptr >= &win_errormsg[0] && strchr("\r\n\t\0x20", *ptr); ptr--) \
45 *ptr = 0; \
46 errmsg = win_errormsg; \
47 } else \
48 errmsg = ""
49#define dlerror() ""
50#define dlopen_errno GetLastError()
51
52#else /* _WIN32 */
53
54#ifndef MYSQL_ABI_CHECK
55#include <dlfcn.h>
56#include <errno.h>
57#endif
58
59#define DLERROR_GENERATE(errmsg, error_number) errmsg = dlerror()
60#define dlopen_errno errno
61#endif /* _WIN32 */
62
63/*
64 MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
65 (i.e variables) for usage in storage engine loadable plugins.
66 Outside of Windows, it is dummy.
67*/
68#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
69#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
70#else
71#define MYSQL_PLUGIN_IMPORT
72#endif
73
74#endif // MY_SHAREDLIB_INCLUDED