Browse Source

Cleaned up what symbols are exported from the library.

Ryan C. Gordon 8 năm trước cách đây
mục cha
commit
19b15d34a1
4 tập tin đã thay đổi với 34 bổ sung11 xóa
  1. 1 1
      CMakeLists.txt
  2. 2 2
      src/archiver_vdf.c
  3. 0 1
      src/physfs.c
  4. 31 7
      src/physfs_internal.h

+ 1 - 1
CMakeLists.txt

@@ -25,7 +25,7 @@ endif()
 include_directories(./src)
 
 if(APPLE)
-    set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-fno-common -framework CoreFoundation -framework IOKit")
+    set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework CoreFoundation -framework IOKit")
 endif()
 
 if(CMAKE_COMPILER_IS_GNUCC)

+ 2 - 2
src/archiver_vdf.c

@@ -25,8 +25,8 @@
 #define VDF_CRC16 0x8005
 #define VDF_HASHTABLE_SIZE 65536
 
-const char* VDF_SIGNATURE_G1 = "PSVDSC_V2.00\r\n\r\n";
-const char* VDF_SIGNATURE_G2 = "PSVDSC_V2.00\n\r\n\r";
+static const char* VDF_SIGNATURE_G1 = "PSVDSC_V2.00\r\n\r\n";
+static const char* VDF_SIGNATURE_G2 = "PSVDSC_V2.00\n\r\n\r";
 
 typedef union
 {

+ 0 - 1
src/physfs.c

@@ -1123,7 +1123,6 @@ static int doRegisterArchiver(const PHYSFS_Archiver *_archiver);
 static int initStaticArchivers(void)
 {
     #define REGISTER_STATIC_ARCHIVER(arc) { \
-        extern const PHYSFS_Archiver __PHYSFS_Archiver_##arc; \
         if (!doRegisterArchiver(&__PHYSFS_Archiver_##arc)) { \
             return 0; \
         } \

+ 31 - 7
src/physfs_internal.h

@@ -14,13 +14,6 @@
 #error Do not include this header from your applications.
 #endif
 
-/* Make sure everything that includes this header exports no symbols by
-   default. physfs.h uses function attributes to mark only the public API as
-   visible. */
-#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
-#pragma GCC visibility push(hidden)
-#endif
-
 /* Turn off MSVC warnings that are aggressively anti-portability. */
 #ifdef _MSC_VER
 #define _CRT_SECURE_NO_WARNINGS 1
@@ -69,6 +62,33 @@ extern "C" {
 #define _FILE_OFFSET_BITS 64
 #endif
 
+/* All public APIs need to be in physfs.h with a PHYSFS_DECL.
+   All file-private symbols need to be marked "static".
+   Everything shared between PhysicsFS sources needs to be in this
+   file between the visibility pragma blocks. */
+#if PHYSFS_MINIMUM_GCC_VERSION(4,0) || defined(__clang__)
+#define PHYSFS_HAVE_PRAGMA_VISIBILITY 1
+#endif
+
+#if PHYSFS_HAVE_PRAGMA_VISIBILITY
+#pragma GCC visibility push(hidden)
+#endif
+
+/* These are the build-in archivers. We list them all as "extern" here without
+   #ifdefs to keep it tidy, but obviously you need to make sure these are
+   wrapped in PHYSFS_SUPPORTS_* checks before actually referencing them. */
+extern const PHYSFS_Archiver __PHYSFS_Archiver_DIR;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_ZIP;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_LZMA;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_GRP;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_QPAK;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_HOG;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_MVL;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_WAD;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_SLB;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_ISO9660;
+extern const PHYSFS_Archiver __PHYSFS_Archiver_VDF;
+
 /* a real C99-compliant snprintf() is in Visual Studio 2015,
    but just use this everywhere for binary compatibility. */
 #if defined(_MSC_VER)
@@ -655,6 +675,10 @@ int __PHYSFS_platformGrabMutex(void *mutex);
  */
 void __PHYSFS_platformReleaseMutex(void *mutex);
 
+#if PHYSFS_HAVE_PRAGMA_VISIBILITY
+#pragma GCC visibility pop
+#endif
+
 #ifdef __cplusplus
 }
 #endif