[1/4] msvc: Properly specify dllexport for data symbols shared across dll boundaries

Message ID 1503606746-21606-1-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Aug. 24, 2017, 8:32 p.m.
---
The definitions in libavutil/internal.h should maybe be moved into
some libavcodec header, like libavcodec/internal.h?
---
 avbuild/library.mak        |  2 ++
 libavcodec/ac3tab.h        |  2 +-
 libavcodec/dca.h           |  2 +-
 libavcodec/jpegtables.h    | 14 +++++++-------
 libavcodec/mpeg4audio.h    |  2 +-
 libavcodec/mpegaudiodata.h |  4 ++--
 libavutil/internal.h       |  5 +++++
 7 files changed, 19 insertions(+), 12 deletions(-)

Comments

Martin Storsjö Aug. 24, 2017, 8:39 p.m. | #1
On Thu, 24 Aug 2017, Martin Storsjö wrote:

> ---
> The definitions in libavutil/internal.h should maybe be moved into
> some libavcodec header, like libavcodec/internal.h?
> ---
> avbuild/library.mak        |  2 ++
> libavcodec/ac3tab.h        |  2 +-
> libavcodec/dca.h           |  2 +-
> libavcodec/jpegtables.h    | 14 +++++++-------
> libavcodec/mpeg4audio.h    |  2 +-
> libavcodec/mpegaudiodata.h |  4 ++--
> libavutil/internal.h       |  5 +++++
> 7 files changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/avbuild/library.mak b/avbuild/library.mak
> index 3075754..4e4b3f1 100644
> --- a/avbuild/library.mak
> +++ b/avbuild/library.mak
> @@ -31,6 +31,8 @@ define RULES
> $(TOOLS):     THISLIB = $(NAME:%=$(LD_LIB))
> $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
> 
> +$(LIBOBJS): CPPFLAGS += -DBUILDING_$(NAME)
> +
> $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
> 	$$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS)
> 
> diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
> index 83edec5..a4adbd6 100644
> --- a/libavcodec/ac3tab.h
> +++ b/libavcodec/ac3tab.h
> @@ -35,7 +35,7 @@
> 
> extern const uint16_t ff_ac3_frame_size_tab[38][3];
> extern const uint8_t  ff_ac3_channels_tab[8];
> -extern av_export const uint16_t avpriv_ac3_channel_layout_tab[8];
> +extern av_export_avcodec const uint16_t avpriv_ac3_channel_layout_tab[8];
> extern const uint8_t  ff_ac3_enc_channel_map[8][2][6];
> extern const uint8_t  ff_ac3_dec_channel_map[8][2][6];
> extern const uint16_t ff_ac3_sample_rate_tab[3];
> diff --git a/libavcodec/dca.h b/libavcodec/dca.h
> index 787a9c7..77289b7 100644
> --- a/libavcodec/dca.h
> +++ b/libavcodec/dca.h
> @@ -288,7 +288,7 @@ typedef struct DCAContext {
>     FmtConvertContext fmt_conv;
> } DCAContext;
> 
> -extern av_export const uint32_t avpriv_dca_sample_rates[16];
> +extern av_export_avcodec const uint32_t avpriv_dca_sample_rates[16];
> 
> /**
>  * Convert bitstream to one representation based on sync marker
> diff --git a/libavcodec/jpegtables.h b/libavcodec/jpegtables.h
> index 1a909be..65e20f8 100644
> --- a/libavcodec/jpegtables.h
> +++ b/libavcodec/jpegtables.h
> @@ -25,16 +25,16 @@
> 
> #include "libavutil/internal.h"
> 
> -extern av_export const uint8_t avpriv_mjpeg_bits_dc_luminance[];
> -extern av_export const uint8_t avpriv_mjpeg_val_dc[];
> +extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_dc_luminance[];
> +extern av_export_avcodec const uint8_t avpriv_mjpeg_val_dc[];
> 
> -extern av_export const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
> +extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
> 
> -extern av_export const uint8_t avpriv_mjpeg_bits_ac_luminance[];
> -extern av_export const uint8_t avpriv_mjpeg_val_ac_luminance[];
> +extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_luminance[];
> +extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_luminance[];
> 
> -extern av_export const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
> -extern av_export const uint8_t avpriv_mjpeg_val_ac_chrominance[];
> +extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
> +extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_chrominance[];
> 
> void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
>                                   const uint8_t *bits_table,
> diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
> index 01f30c6..d76f000 100644
> --- a/libavcodec/mpeg4audio.h
> +++ b/libavcodec/mpeg4audio.h
> @@ -44,7 +44,7 @@ typedef struct MPEG4AudioConfig {
>     int frame_length_short;
> } MPEG4AudioConfig;
> 
> -extern av_export const int avpriv_mpeg4audio_sample_rates[16];
> +extern av_export_avcodec const int avpriv_mpeg4audio_sample_rates[16];
> extern const uint8_t ff_mpeg4audio_channels[8];
> 
> /**
> diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h
> index 2b8ff65..1ae0ab4 100644
> --- a/libavcodec/mpegaudiodata.h
> +++ b/libavcodec/mpegaudiodata.h
> @@ -34,8 +34,8 @@
> #define MODE_EXT_MS_STEREO 2
> #define MODE_EXT_I_STEREO  1
> 
> -extern av_export const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
> -extern av_export const uint16_t avpriv_mpa_freq_tab[3];
> +extern av_export_avcodec const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
> +extern av_export_avcodec const uint16_t avpriv_mpa_freq_tab[3];
> extern const int ff_mpa_sblimit_table[5];
> extern const int ff_mpa_quant_steps[17];
> extern const int ff_mpa_quant_bits[17];
> diff --git a/libavutil/internal.h b/libavutil/internal.h
> index 8a0076f..d07da59 100644
> --- a/libavutil/internal.h
> +++ b/libavutil/internal.h
> @@ -59,6 +59,11 @@
> 
> #if defined(_MSC_VER) && CONFIG_SHARED
> #    define av_export __declspec(dllimport)
> +#ifdef BUILDING_avcodec
> +#    define av_export_avcodec __declspec(dllexport)
> +#else
> +#    define av_export_avcodec __declspec(dllimport)
> +#endif
> #else
> #    define av_export
> #endif

The else also needs an empty def of av_export_avcodec, and the old one can 
be dropped altogether.

// Martin

Patch

diff --git a/avbuild/library.mak b/avbuild/library.mak
index 3075754..4e4b3f1 100644
--- a/avbuild/library.mak
+++ b/avbuild/library.mak
@@ -31,6 +31,8 @@  define RULES
 $(TOOLS):     THISLIB = $(NAME:%=$(LD_LIB))
 $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
 
+$(LIBOBJS): CPPFLAGS += -DBUILDING_$(NAME)
+
 $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
 	$$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS)
 
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index 83edec5..a4adbd6 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -35,7 +35,7 @@ 
 
 extern const uint16_t ff_ac3_frame_size_tab[38][3];
 extern const uint8_t  ff_ac3_channels_tab[8];
-extern av_export const uint16_t avpriv_ac3_channel_layout_tab[8];
+extern av_export_avcodec const uint16_t avpriv_ac3_channel_layout_tab[8];
 extern const uint8_t  ff_ac3_enc_channel_map[8][2][6];
 extern const uint8_t  ff_ac3_dec_channel_map[8][2][6];
 extern const uint16_t ff_ac3_sample_rate_tab[3];
diff --git a/libavcodec/dca.h b/libavcodec/dca.h
index 787a9c7..77289b7 100644
--- a/libavcodec/dca.h
+++ b/libavcodec/dca.h
@@ -288,7 +288,7 @@  typedef struct DCAContext {
     FmtConvertContext fmt_conv;
 } DCAContext;
 
-extern av_export const uint32_t avpriv_dca_sample_rates[16];
+extern av_export_avcodec const uint32_t avpriv_dca_sample_rates[16];
 
 /**
  * Convert bitstream to one representation based on sync marker
diff --git a/libavcodec/jpegtables.h b/libavcodec/jpegtables.h
index 1a909be..65e20f8 100644
--- a/libavcodec/jpegtables.h
+++ b/libavcodec/jpegtables.h
@@ -25,16 +25,16 @@ 
 
 #include "libavutil/internal.h"
 
-extern av_export const uint8_t avpriv_mjpeg_bits_dc_luminance[];
-extern av_export const uint8_t avpriv_mjpeg_val_dc[];
+extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_dc_luminance[];
+extern av_export_avcodec const uint8_t avpriv_mjpeg_val_dc[];
 
-extern av_export const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
+extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
 
-extern av_export const uint8_t avpriv_mjpeg_bits_ac_luminance[];
-extern av_export const uint8_t avpriv_mjpeg_val_ac_luminance[];
+extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_luminance[];
+extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_luminance[];
 
-extern av_export const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
-extern av_export const uint8_t avpriv_mjpeg_val_ac_chrominance[];
+extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
+extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_chrominance[];
 
 void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
                                   const uint8_t *bits_table,
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index 01f30c6..d76f000 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -44,7 +44,7 @@  typedef struct MPEG4AudioConfig {
     int frame_length_short;
 } MPEG4AudioConfig;
 
-extern av_export const int avpriv_mpeg4audio_sample_rates[16];
+extern av_export_avcodec const int avpriv_mpeg4audio_sample_rates[16];
 extern const uint8_t ff_mpeg4audio_channels[8];
 
 /**
diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h
index 2b8ff65..1ae0ab4 100644
--- a/libavcodec/mpegaudiodata.h
+++ b/libavcodec/mpegaudiodata.h
@@ -34,8 +34,8 @@ 
 #define MODE_EXT_MS_STEREO 2
 #define MODE_EXT_I_STEREO  1
 
-extern av_export const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
-extern av_export const uint16_t avpriv_mpa_freq_tab[3];
+extern av_export_avcodec const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
+extern av_export_avcodec const uint16_t avpriv_mpa_freq_tab[3];
 extern const int ff_mpa_sblimit_table[5];
 extern const int ff_mpa_quant_steps[17];
 extern const int ff_mpa_quant_bits[17];
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 8a0076f..d07da59 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -59,6 +59,11 @@ 
 
 #if defined(_MSC_VER) && CONFIG_SHARED
 #    define av_export __declspec(dllimport)
+#ifdef BUILDING_avcodec
+#    define av_export_avcodec __declspec(dllexport)
+#else
+#    define av_export_avcodec __declspec(dllimport)
+#endif
 #else
 #    define av_export
 #endif