Commit da619d5d authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Fix static pthreads + dynamically linked x264 on win32

Add the necessary static pthread initialization code to a new DLLmain function.
parent 229d8d76
......@@ -16,6 +16,8 @@ SRCCLI = x264.c input/yuv.c input/y4m.c output/raw.c \
output/matroska.c output/matroska_ebml.c \
output/flv.c output/flv_bytestream.c
SRCSO =
MUXERS := $(shell grep -E "(IN|OUT)PUT" config.h)
# Optional muxer module sources
......@@ -99,8 +101,15 @@ ifneq ($(HAVE_GETOPT_LONG),1)
SRCS += extras/getopt.c
endif
ifneq ($(SONAME),)
ifeq ($(SYS),MINGW)
SRCSO += x264dll.c
endif
endif
OBJS = $(SRCS:%.c=%.o)
OBJCLI = $(SRCCLI:%.c=%.o)
OBJSO = $(SRCSO:%.c=%.o)
DEP = depend
.PHONY: all default fprofiled clean distclean install uninstall dox test testclean
......@@ -111,8 +120,8 @@ libx264.a: .depend $(OBJS) $(OBJASM)
$(AR) rc libx264.a $(OBJS) $(OBJASM)
$(RANLIB) libx264.a
$(SONAME): .depend $(OBJS) $(OBJASM)
$(CC) -shared -o $@ $(OBJS) $(OBJASM) $(SOFLAGS) $(LDFLAGS)
$(SONAME): .depend $(OBJS) $(OBJASM) $(OBJSO)
$(CC) -shared -o $@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
x264$(EXE): $(OBJCLI) libx264.a
$(CC) -o $@ $+ $(LDFLAGS) $(LDFLAGSCLI)
......@@ -130,7 +139,7 @@ checkasm: tools/checkasm.o libx264.a
.depend: config.mak
rm -f .depend
$(foreach SRC, $(SRCS) $(SRCCLI), $(CC) $(CFLAGS) $(ALTIVECFLAGS) $(SRC) -MT $(SRC:%.c=%.o) -MM -g0 1>> .depend;)
$(foreach SRC, $(SRCS) $(SRCCLI) $(SRCSO), $(CC) $(CFLAGS) $(ALTIVECFLAGS) $(SRC) -MT $(SRC:%.c=%.o) -MM -g0 1>> .depend;)
config.mak:
./configure
......@@ -171,7 +180,7 @@ fprofiled:
endif
clean:
rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS
rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a x264 x264.exe .depend TAGS
rm -f checkasm checkasm.exe tools/checkasm.o tools/checkasm-a.o
rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
- sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
......
/*****************************************************************************
* x264dll: x264 DLLMain for win32
*****************************************************************************
* Copyright (C) 2009 x264 project
*
* Authors: Anton Mitrofanov <BugMaster@narod.ru>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*****************************************************************************/
#include "common/common.h"
#include <windows.h>
/* Callback for our DLL so we can initialize pthread */
BOOL WINAPI DllMain( HANDLE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
#ifdef PTW32_STATIC_LIB
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
pthread_win32_process_attach_np();
case DLL_THREAD_ATTACH:
pthread_win32_thread_attach_np();
break;
case DLL_THREAD_DETACH:
pthread_win32_thread_detach_np();
break;
case DLL_PROCESS_DETACH:
pthread_win32_thread_detach_np();
pthread_win32_process_detach_np();
break;
}
#endif
return TRUE;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment