Skip to content

Commit

Permalink
Consolidate visibility control macros
Browse files Browse the repository at this point in the history
There is no need to have one per toolkit.

This also removes the MSVC-specific check because we don't build there
and we don't have any of the visibility compiler switches set for it,
either.
  • Loading branch information
hainest committed May 3, 2024
1 parent 95b6a50 commit 7c69b20
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 183 deletions.
36 changes: 36 additions & 0 deletions common/h/dyninst_visibility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* See the dyninst/COPYRIGHT file for copyright information.
*
* We provide the Paradyn Tools (below described as "Paradyn")
* on an AS IS basis, and do not warrant its validity or performance.
* We reserve the right to update, modify, or discontinue this
* software at any time. We shall have no obligation to supply such
* updates or modifications or any other form of support to you.
*
* By your use of Paradyn, you understand and agree that we (or any
* other person or entity with proprietary rights in Paradyn) are
* under no obligation to provide either maintenance services,
* update services, notices of latent defects, or correction of
* defects for Paradyn.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef DYNINST_COMMON_DYNINST_VISIBILITY_H
#define DYNINST_COMMON_DYNINST_VISIBILITY_H

#define DYNINST_EXPORT __attribute__((visibility ("default")))

#endif
191 changes: 11 additions & 180 deletions common/h/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,201 +28,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/


#if !defined(SYMTAB_EXPORT)
#if defined(_MSC_VER)
#if defined SYMTAB_LIB
#define SYMTAB_EXPORT __declspec(dllexport)
#else
#define SYMTAB_EXPORT __declspec(dllimport)
#endif
#else
#define SYMTAB_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(SYMLITE_EXPORT)
#if defined(_MSC_VER)
#if defined SYMLITE_LIB
#define SYMLITE_EXPORT __declspec(dllexport)
#else
#define SYMLITE_EXPORT __declspec(dllimport)
#endif
#else
#define SYMLITE_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(DYNELF_EXPORT)
#if defined(_MSC_VER)
#if defined DYNELF_LIB
#define DYNELF_EXPORT __declspec(dllexport)
#else
#define DYNELF_EXPORT __declspec(dllimport)
#endif
#else
#define DYNELF_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(DYNDWARF_EXPORT)
#if defined(_MSC_VER)
#if defined DYNDWARF_LIB
#define DYNDWARF_EXPORT __declspec(dllexport)
#else
#define DYNDWARF_EXPORT __declspec(dllimport)
#endif
#else
#define DYNDWARF_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(COMMON_EXPORT)
#if defined (_MSC_VER)
#if defined(COMMON_LIB)
#define COMMON_EXPORT __declspec(dllexport)
#else
#define COMMON_EXPORT __declspec(dllimport)
#endif
#else
#define COMMON_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(COMMON_TEMPLATE_EXPORT)
#if defined (_MSC_VER)
#if defined(COMMON_LIB) || defined(INSTRUCTION_LIB) || \
defined(SYMTAB_LIB) || defined(BPATCH_LIBRARY)
#define COMMON_TEMPLATE_EXPORT __declspec(dllexport)
#else
#define COMMON_TEMPLATE_EXPORT __declspec(dllimport)
#endif
#else
#define COMMON_TEMPLATE_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(INSTRUCTION_EXPORT)
#if defined(_MSC_VER)
#if defined(INSTRUCTION_LIB)
#define INSTRUCTION_EXPORT __declspec(dllexport)
#else
#define INSTRUCTION_EXPORT __declspec(dllimport)
#endif
#else
#define INSTRUCTION_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(PARSER_EXPORT)
#if defined(_MSC_VER)
#if defined(PARSER_LIB)
#define PARSER_EXPORT __declspec(dllexport)
#else
#define PARSER_EXPORT __declspec(dllimport)
#endif
#else
#define PARSER_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(PATCHAPI_EXPORT)
#if defined(_MSC_VER)
#if defined(PATCHAPI_LIB)
#define PATCHAPI_EXPORT __declspec(dllexport)
#else
#define PATCHAPI_EXPORT __declspec(dllimport)
#endif
#else
#define PATCHAPI_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(DATAFLOW_EXPORT)
#if defined(_MSC_VER)
#if defined(DATAFLOW_LIB)
#define DATAFLOW_EXPORT __declspec(dllexport)
#else
#define DATAFLOW_EXPORT __declspec(dllimport)
#endif
#else
#define DATAFLOW_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(PC_EXPORT)
#if defined(_MSC_VER)
#if defined(PROCCONTROL_EXPORTS)
#define PC_EXPORT __declspec(dllexport)
#else
#define PC_EXPORT __declspec(dllimport)
#endif
#else
#define PC_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(SW_EXPORT)
#if defined(_MSC_VER)
#if defined(STACKWALKER_EXPORTS)
#define SW_EXPORT __declspec(dllexport)
#else
#define SW_EXPORT __declspec(dllimport)
#endif
#else
#define SW_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(INJECTOR_EXPORT)
#if defined(_MSC_VER)
#if defined(INJECTOR_EXPORTS)
#define INJECTOR_EXPORT __declspec(dllexport)
#else
#define INJECTOR_EXPORT __declspec(dllimport)
#endif
#else
#define INJECTOR_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#if !defined(SYMEVAL_EXPORT)
#if defined(_MSC_VER)
#if defined(SYMEVAL_LIB)
#define SYMEVAL_EXPORT __declspec(dllexport)
#else
#define SYMEVAL_EXPORT __declspec(dllimport)
#endif
#else
#define SYMEVAL_EXPORT __attribute__((visibility ("default")))
#endif
#endif

#ifndef __UTIL_H__
#define __UTIL_H__

#include <string>
#include "dyntypes.h"
#include "dyninst_visibility.h"


namespace Dyninst {

COMMON_EXPORT unsigned addrHashCommon(const Address &addr);
COMMON_EXPORT unsigned ptrHash(const void * addr);
COMMON_EXPORT unsigned ptrHash(void * addr);
DYNINST_EXPORT unsigned addrHashCommon(const Address &addr);
DYNINST_EXPORT unsigned ptrHash(const void * addr);
DYNINST_EXPORT unsigned ptrHash(void * addr);

COMMON_EXPORT unsigned addrHash(const Address &addr);
COMMON_EXPORT unsigned addrHash4(const Address &addr);
COMMON_EXPORT unsigned addrHash16(const Address &addr);
DYNINST_EXPORT unsigned addrHash(const Address &addr);
DYNINST_EXPORT unsigned addrHash4(const Address &addr);
DYNINST_EXPORT unsigned addrHash16(const Address &addr);

COMMON_EXPORT unsigned stringhash(const std::string &s);
COMMON_EXPORT std::string itos(int);
COMMON_EXPORT std::string utos(unsigned);
DYNINST_EXPORT unsigned stringhash(const std::string &s);
DYNINST_EXPORT std::string itos(int);
DYNINST_EXPORT std::string utos(unsigned);

#define WILDCARD_CHAR '?'
#define MULTIPLE_WILDCARD_CHAR '*'

COMMON_EXPORT bool wildcardEquiv(const std::string &us, const std::string &them, bool checkCase = false );
DYNINST_EXPORT bool wildcardEquiv(const std::string &us, const std::string &them, bool checkCase = false );

const char *platform_string();
}
Expand Down
6 changes: 3 additions & 3 deletions symlite/h/SymLite-elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@

namespace Dyninst {

struct SYMLITE_EXPORT SymCacheEntry {
struct DYNINST_EXPORT SymCacheEntry {
Dyninst::Offset symaddress;
void *symloc;
const char *demangled_name;
};

class SYMLITE_EXPORT SymElf : public Dyninst::SymReader
class DYNINST_EXPORT SymElf : public Dyninst::SymReader
{
friend class SymElfFactory;
private:
Expand Down Expand Up @@ -107,7 +107,7 @@ class SYMLITE_EXPORT SymElf : public Dyninst::SymReader

};

class SYMLITE_EXPORT SymElfFactory : public Dyninst::SymbolReaderFactory
class DYNINST_EXPORT SymElfFactory : public Dyninst::SymbolReaderFactory
{
private:
std::map<std::string, SymElf *> *open_symelfs;
Expand Down

0 comments on commit 7c69b20

Please sign in to comment.