Skip to content

Commit e743e7a

Browse files
committed
libavutil: Make avpriv_open a library-internal function on msvcrt
Add one copy of the function into each of the libraries, similarly to what we do for log2_tab. When using static libs, only one copy of the file_open.o object file gets included, while when using shared libraries, each of them get a copy of its own. This fixes DLL builds with a statically linked C runtime, where each DLL effectively has got its own instance of the C runtime, where file descriptors can't be shared across runtimes. On systems not using msvcrt, the function is not duplicated. Signed-off-by: Martin Storsjö <[email protected]>
1 parent a76d0cd commit e743e7a

File tree

7 files changed

+13
-0
lines changed

7 files changed

+13
-0
lines changed

libavcodec/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ OBJS = allcodecs.o \
2626
raw.o \
2727
utils.o \
2828

29+
OBJS-$(HAVE_MSVCRT) += file_open.o
30+
2931
# parts needed for many different codecs
3032
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
3133
OBJS-$(CONFIG_AC3DSP) += ac3dsp.o

libavcodec/file_open.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "libavutil/file_open.c"

libavdevice/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ HEADERS = avdevice.h \
77
OBJS = alldevices.o \
88
avdevice.o \
99

10+
OBJS-$(HAVE_MSVCRT) += file_open.o
11+
1012
# input/output devices
1113
OBJS-$(CONFIG_ALSA_INDEV) += alsa-audio-common.o \
1214
alsa-audio-dec.o

libavdevice/file_open.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "libavutil/file_open.c"

libavformat/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ OBJS = allformats.o \
2323
url.o \
2424
utils.o \
2525

26+
OBJS-$(HAVE_MSVCRT) += file_open.o
27+
2628
OBJS-$(CONFIG_NETWORK) += network.o
2729
OBJS-$(CONFIG_RIFFDEC) += riffdec.o
2830
OBJS-$(CONFIG_RIFFENC) += riffenc.o

libavformat/file_open.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "libavutil/file_open.c"

libavutil/internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ void avpriv_report_missing_feature(void *avc,
196196
void avpriv_request_sample(void *avc,
197197
const char *msg, ...) av_printf_format(2, 3);
198198

199+
#if HAVE_MSVCRT
200+
#define avpriv_open ff_open
201+
#endif
202+
199203
/**
200204
* A wrapper for open() setting O_CLOEXEC.
201205
*/

0 commit comments

Comments
 (0)