Browse Source

enable fvisibility=hidden for our private library

While it is a huge undertaking to enable it for our public libraries as
basically everything we exported so far could be seen as public
interface our private library is new and under our full control, so we
can do whatever we like with it. The benefits are not that big in return
of course, but it reduces the size a bit, so thats great nontheless.

Git-Dch: ignore
David Kalnischkies 10 years ago
parent
commit
63ff420898

+ 4 - 0
apt-pkg/contrib/macros.h

@@ -94,8 +94,12 @@
 
 #if APT_GCC_VERSION >= 0x0400
 	#define APT_SENTINEL	__attribute__((sentinel))
+	#define APT_PUBLIC __attribute__ ((visibility ("default")))
+	#define APT_HIDDEN __attribute__ ((visibility ("hidden")))
 #else
 	#define APT_SENTINEL
+	#define APT_PUBLIC
+	#define APT_HIDDEN
 #endif
 
 // cold functions are unlikely() to be called

+ 5 - 4
apt-private/acqprogress.h

@@ -10,18 +10,19 @@
 #define ACQPROGRESS_H
 
 #include <apt-pkg/acquire.h>
+#include <apt-pkg/macros.h>
 
 #include <string>
 
-class AcqTextStatus : public pkgAcquireStatus
+class APT_PUBLIC AcqTextStatus : public pkgAcquireStatus
 {
    unsigned int &ScreenWidth;
    char BlankLine[1024];
    unsigned long ID;
    unsigned long Quiet;
-   
+
    public:
-   
+
    virtual bool MediaChange(std::string Media,std::string Drive);
    virtual void IMSHit(pkgAcquire::ItemDesc &Itm);
    virtual void Fetch(pkgAcquire::ItemDesc &Itm);
@@ -29,7 +30,7 @@ class AcqTextStatus : public pkgAcquireStatus
    virtual void Fail(pkgAcquire::ItemDesc &Itm);
    virtual void Start();
    virtual void Stop();
-   
+
    bool Pulse(pkgAcquire *Owner);
 
    AcqTextStatus(unsigned int &ScreenWidth,unsigned int const Quiet);

+ 1 - 0
apt-private/makefile

@@ -16,6 +16,7 @@ LIBRARY=apt-private
 MAJOR=0.0
 MINOR=0
 SLIBS=$(PTHREADLIB) -lapt-pkg
+CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
 
 PRIVATES=list install download output cachefile cacheset update upgrade cmndline moo search show main utils sources
 SOURCE += $(foreach private, $(PRIVATES), private-$(private).cc)

+ 4 - 3
apt-private/private-cachefile.h

@@ -5,16 +5,17 @@
 #include <apt-pkg/progress.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
 
 
 // class CacheFile - Cover class for some dependency cache functions	/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-class CacheFile : public pkgCacheFile
+class APT_PUBLIC CacheFile : public pkgCacheFile
 {
    static pkgCache *SortCache;
-   static int NameComp(const void *a,const void *b) APT_PURE;
-   
+   APT_HIDDEN static int NameComp(const void *a,const void *b) APT_PURE;
+
    public:
    pkgCache::Package **List;
    

+ 2 - 1
apt-private/private-cmndline.h

@@ -2,9 +2,10 @@
 #define APT_PRIVATE_CMNDLINE_H
 
 #include <apt-pkg/cmndline.h>
+#include <apt-pkg/macros.h>
 
 #include <vector>
 
-std::vector<CommandLine::Args> getCommandArgs(char const * const Program, char const * const Cmd);
+APT_PUBLIC std::vector<CommandLine::Args> getCommandArgs(char const * const Program, char const * const Cmd);
 
 #endif

+ 4 - 2
apt-private/private-download.h

@@ -1,9 +1,11 @@
 #ifndef APT_PRIVATE_DOWNLOAD_H
 #define APT_PRIVATE_DOWNLOAD_H
 
+#include <apt-pkg/macros.h>
+
 class pkgAcquire;
 
-bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser);
-bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure);
+APT_PUBLIC bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser);
+APT_PUBLIC bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure);
 
 #endif

+ 5 - 3
apt-private/private-install.h

@@ -9,6 +9,9 @@
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/algorithms.h>
+#include <apt-pkg/macros.h>
+
+#include <apt-private/private-output.h>
 
 #include <stddef.h>
 #include <iosfwd>
@@ -17,7 +20,6 @@
 #include <string>
 #include <utility>
 
-#include "private-output.h"
 
 #include <apti18n.h>
 
@@ -26,13 +28,13 @@ class CommandLine;
 
 #define RAMFS_MAGIC     0x858458f6
 
-bool DoInstall(CommandLine &Cmd);
+APT_PUBLIC bool DoInstall(CommandLine &Cmd);
 
 bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
                                         std::map<unsigned short, APT::VersionSet> &verset);
 bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache);
 
-bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
+APT_PUBLIC bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
                         bool Safety = true);
 
 

+ 3 - 1
apt-private/private-list.h

@@ -1,9 +1,11 @@
 #ifndef APT_PRIVATE_LIST_H
 #define APT_PRIVATE_LIST_H
 
+#include <apt-pkg/macros.h>
+
 class CommandLine;
 
-bool List(CommandLine &Cmd);
+APT_PUBLIC bool List(CommandLine &Cmd);
 
 
 #endif

+ 3 - 1
apt-private/private-main.h

@@ -1,8 +1,10 @@
 #ifndef APT_PRIVATE_MAIN_H
 #define APT_PRIVATE_MAIN_H
 
+#include <apt-pkg/macros.h>
+
 class CommandLine;
 
-void CheckSimulateMode(CommandLine &CmdL);
+APT_PUBLIC void CheckSimulateMode(CommandLine &CmdL);
 
 #endif

+ 1 - 1
apt-private/private-moo.h

@@ -3,7 +3,7 @@
 
 class CommandLine;
 
-bool DoMoo(CommandLine &CmdL);
+APT_PUBLIC bool DoMoo(CommandLine &CmdL);
 bool DoMoo1(CommandLine &CmdL);
 bool DoMoo2(CommandLine &CmdL);
 bool DoMoo3(CommandLine &CmdL);

+ 12 - 9
apt-private/private-output.h

@@ -2,6 +2,7 @@
 #define APT_PRIVATE_OUTPUT_H
 
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/macros.h>
 
 #include <fstream>
 #include <string>
@@ -13,22 +14,24 @@ class pkgDepCache;
 class pkgRecords;
 
 
-extern std::ostream c0out;
-extern std::ostream c1out;
-extern std::ostream c2out;
-extern std::ofstream devnull;
-extern unsigned int ScreenWidth;
+APT_PUBLIC extern std::ostream c0out;
+APT_PUBLIC extern std::ostream c1out;
+APT_PUBLIC extern std::ostream c2out;
+APT_PUBLIC extern std::ofstream devnull;
+APT_PUBLIC extern unsigned int ScreenWidth;
 
-bool InitOutput();
-void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, 
+APT_PUBLIC bool InitOutput();
+
+void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
                        pkgCache::VerIterator V, std::ostream &out,
                        bool include_summary=true);
 
 
 // helper to describe global state
-bool ShowList(std::ostream &out, std::string Title, std::string List,
+APT_PUBLIC void ShowBroken(std::ostream &out,CacheFile &Cache,bool Now);
+
+APT_PUBLIC bool ShowList(std::ostream &out, std::string Title, std::string List,
               std::string VersionsList);
-void ShowBroken(std::ostream &out,CacheFile &Cache,bool Now);
 void ShowNew(std::ostream &out,CacheFile &Cache);
 void ShowDel(std::ostream &out,CacheFile &Cache);
 void ShowKept(std::ostream &out,CacheFile &Cache);

+ 3 - 1
apt-private/private-search.h

@@ -1,9 +1,11 @@
 #ifndef APT_PRIVATE_SEARCH_H
 #define APT_PRIVATE_SEARCH_H
 
+#include <apt-pkg/macros.h>
+
 class CommandLine;
 
-bool FullTextSearch(CommandLine &CmdL);
+APT_PUBLIC bool FullTextSearch(CommandLine &CmdL);
 
 
 #endif

+ 3 - 1
apt-private/private-show.h

@@ -1,12 +1,14 @@
 #ifndef APT_PRIVATE_SHOW_H
 #define APT_PRIVATE_SHOW_H
 
+#include <apt-pkg/macros.h>
+
 class CommandLine;
 
 namespace APT {
    namespace Cmd {
 
-      bool ShowPackage(CommandLine &CmdL);
+      APT_PUBLIC bool ShowPackage(CommandLine &CmdL);
    }
 }
 #endif

+ 3 - 1
apt-private/private-sources.h

@@ -1,8 +1,10 @@
 #ifndef APT_PRIVATE_SOURCES_H
 #define APT_PRIVATE_SOURCES_H
 
+#include <apt-pkg/macros.h>
+
 class CommandLine;
 
-bool EditSources(CommandLine &CmdL);
+APT_PUBLIC bool EditSources(CommandLine &CmdL);
 
 #endif

+ 3 - 1
apt-private/private-update.h

@@ -1,8 +1,10 @@
 #ifndef APT_PRIVATE_UPDATE_H
 #define APT_PRIVATE_UPDATE_H
 
+#include <apt-pkg/macros.h>
+
 class CommandLine;
 
-bool DoUpdate(CommandLine &CmdL);
+APT_PUBLIC bool DoUpdate(CommandLine &CmdL);
 
 #endif

+ 4 - 2
apt-private/private-upgrade.h

@@ -1,10 +1,12 @@
 #ifndef APTPRIVATE_PRIVATE_UPGRADE_H
 #define APTPRIVATE_PRIVATE_UPGRADE_H
 
+#include <apt-pkg/macros.h>
+
 class CommandLine;
 
-bool DoDistUpgrade(CommandLine &CmdL);
-bool DoUpgrade(CommandLine &CmdL);
+APT_PUBLIC bool DoDistUpgrade(CommandLine &CmdL);
+APT_PUBLIC bool DoUpgrade(CommandLine &CmdL);
 bool DoUpgradeNoNewPackages(CommandLine &CmdL);
 bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL);
 

+ 5 - 3
apt-private/private-utils.h

@@ -1,9 +1,11 @@
 #ifndef APT_PRIVATE_UTILS_H
 #define APT_PRIVATE_UTILS_H
 
-#include<string>
+#include <apt-pkg/macros.h>
 
-void DisplayFileInPager(std::string filename);
-void EditFileInSensibleEditor(std::string filename);
+#include <string>
+
+APT_PUBLIC void DisplayFileInPager(std::string filename);
+APT_PUBLIC void EditFileInSensibleEditor(std::string filename);
 
 #endif