MySQL 8.3.0
Source Code Documentation
my_sharedlib.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MY_SHAREDLIB_INCLUDED
25#define MY_SHAREDLIB_INCLUDED
26
27/**
28 @file include/my_sharedlib.h
29 Functions related to handling of plugins and other dynamically loaded
30 libraries.
31*/
32
33#if defined(_WIN32)
34#define dlsym(lib, name) (void *)GetProcAddress((HMODULE)lib, name)
35#define dlopen(libname, unused) LoadLibraryEx(libname, nullptr, 0)
36#define dlclose(lib) FreeLibrary((HMODULE)lib)
37#define DLERROR_GENERATE(errmsg, error_number) \
38 char win_errormsg[2048]; \
39 if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error_number, 0, \
40 win_errormsg, 2048, nullptr)) { \
41 char *ptr; \
42 for (ptr = &win_errormsg[0] + strlen(win_errormsg) - 1; \
43 ptr >= &win_errormsg[0] && strchr("\r\n\t\0x20", *ptr); ptr--) \
44 *ptr = 0; \
45 errmsg = win_errormsg; \
46 } else \
47 errmsg = ""
48#define dlerror() ""
49#define dlopen_errno GetLastError()
50
51#else /* _WIN32 */
52
53#ifndef MYSQL_ABI_CHECK
54#include <dlfcn.h>
55#include <errno.h>
56#endif
57
58#define DLERROR_GENERATE(errmsg, error_number) errmsg = dlerror()
59#define dlopen_errno errno
60#endif /* _WIN32 */
61
62/*
63 MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
64 (i.e variables) for usage in storage engine loadable plugins.
65 Outside of Windows, it is dummy.
66*/
67#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
68#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
69#else
70#define MYSQL_PLUGIN_IMPORT
71#endif
72
73#endif // MY_SHAREDLIB_INCLUDED