More for input buffer checks
[rtmpdump.git] / thread.c
blob0913c9879512a1b4fb3d46395f5078a12026ef56
1 /* Thread compatibility glue
2 * Copyright (C) 2009 Howard Chu
4 * This Program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
9 * This Program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with RTMPDump; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #include "thread.h"
23 #include "librtmp/log.h"
25 #ifdef WIN32
27 #include <errno.h>
29 HANDLE
30 ThreadCreate(thrfunc *routine, void *args)
32 HANDLE thd;
34 thd = (HANDLE) _beginthread(routine, 0, args);
35 if (thd == -1L)
36 RTMP_LogPrintf("%s, _beginthread failed with %d\n", __FUNCTION__, errno);
38 return thd;
40 #else
41 pthread_t
42 ThreadCreate(thrfunc *routine, void *args)
44 pthread_t id = 0;
45 pthread_attr_t attributes;
46 int ret;
48 pthread_attr_init(&attributes);
49 pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_DETACHED);
51 ret =
52 pthread_create(&id, &attributes, routine, args);
53 if (ret != 0)
54 RTMP_LogPrintf("%s, pthread_create failed with %d\n", __FUNCTION__, ret);
56 return id;
58 #endif