~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to extern/x264/common/osdep.h

  • Committer: theeth
  • Date: 2008-10-14 16:52:04 UTC
  • Revision ID: vcs-imports@canonical.com-20081014165204-r32w2gm6s0osvdhn
copy back trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * common.h: h264 encoder
 
3
 *****************************************************************************
 
4
 * Copyright (C) 2007 x264 project
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 
19
 *****************************************************************************/
 
20
 
 
21
#ifndef _OSDEP_H
 
22
#define _OSDEP_H
 
23
 
 
24
#define _LARGEFILE_SOURCE 1
 
25
#define _FILE_OFFSET_BITS 64
 
26
#include <stdio.h>
 
27
 
 
28
#ifdef HAVE_STDINT_H
 
29
#include <stdint.h>
 
30
#else
 
31
#include <inttypes.h>
 
32
#endif
 
33
 
 
34
#ifdef _MSC_VER
 
35
#include <io.h>    // _setmode()
 
36
#include <fcntl.h> // _O_BINARY
 
37
#define inline __inline
 
38
#define strncasecmp strnicmp
 
39
#define snprintf _snprintf
 
40
#define fseek _fseeki64
 
41
#define ftell _ftelli64
 
42
#define isfinite _finite
 
43
#define _CRT_SECURE_NO_DEPRECATE
 
44
#define X264_VERSION "" // no configure script for msvc
 
45
#endif
 
46
 
 
47
#ifdef SYS_OPENBSD
 
48
#define isfinite finite
 
49
#endif
 
50
#if defined(_MSC_VER) || defined(SYS_SunOS) || defined(SYS_MACOSX)
 
51
#define sqrtf sqrt
 
52
#endif
 
53
#ifdef _WIN32
 
54
#define rename(src,dst) (unlink(dst), rename(src,dst)) // POSIX says that rename() removes the destination, but win32 doesn't.
 
55
#ifndef strtok_r
 
56
#define strtok_r(str,delim,save) strtok(str,delim)
 
57
#endif
 
58
#endif
 
59
 
 
60
#ifdef _MSC_VER
 
61
#define DECLARE_ALIGNED( type, var, n ) __declspec(align(n)) type var
 
62
#else
 
63
#define DECLARE_ALIGNED( type, var, n ) type var __attribute__((aligned(n)))
 
64
#endif
 
65
 
 
66
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
 
67
#define UNUSED __attribute__((unused))
 
68
#define ALWAYS_INLINE __attribute__((always_inline)) inline
 
69
#else
 
70
#define UNUSED
 
71
#define ALWAYS_INLINE inline
 
72
#endif
 
73
 
 
74
/* threads */
 
75
#if defined(SYS_BEOS)
 
76
#include <kernel/OS.h>
 
77
#define x264_pthread_t               thread_id
 
78
#define x264_pthread_create(t,u,f,d) { *(t)=spawn_thread(f,"",10,d); \
 
79
                                       resume_thread(*(t)); }
 
80
#define x264_pthread_join(t,s)       { long tmp; \
 
81
                                       wait_for_thread(t,(s)?(long*)(s):&tmp); }
 
82
#ifndef usleep
 
83
#define usleep(t)                    snooze(t)
 
84
#endif
 
85
#define HAVE_PTHREAD 1
 
86
 
 
87
#elif defined(HAVE_PTHREAD)
 
88
#include <pthread.h>
 
89
#define USE_REAL_PTHREAD
 
90
 
 
91
#else
 
92
#define x264_pthread_t               int
 
93
#define x264_pthread_create(t,u,f,d)
 
94
#define x264_pthread_join(t,s)
 
95
#endif //SYS_*
 
96
 
 
97
#ifdef USE_REAL_PTHREAD
 
98
#define x264_pthread_t               pthread_t
 
99
#define x264_pthread_create          pthread_create
 
100
#define x264_pthread_join            pthread_join
 
101
#define x264_pthread_mutex_t         pthread_mutex_t
 
102
#define x264_pthread_mutex_init      pthread_mutex_init
 
103
#define x264_pthread_mutex_destroy   pthread_mutex_destroy
 
104
#define x264_pthread_mutex_lock      pthread_mutex_lock
 
105
#define x264_pthread_mutex_unlock    pthread_mutex_unlock
 
106
#define x264_pthread_cond_t          pthread_cond_t
 
107
#define x264_pthread_cond_init       pthread_cond_init
 
108
#define x264_pthread_cond_destroy    pthread_cond_destroy
 
109
#define x264_pthread_cond_broadcast  pthread_cond_broadcast
 
110
#define x264_pthread_cond_wait       pthread_cond_wait
 
111
#else
 
112
#define x264_pthread_mutex_t         int
 
113
#define x264_pthread_mutex_init(m,f)
 
114
#define x264_pthread_mutex_destroy(m)
 
115
#define x264_pthread_mutex_lock(m)
 
116
#define x264_pthread_mutex_unlock(m)
 
117
#define x264_pthread_cond_t          int
 
118
#define x264_pthread_cond_init(c,f)
 
119
#define x264_pthread_cond_destroy(c)
 
120
#define x264_pthread_cond_broadcast(c)
 
121
#define x264_pthread_cond_wait(c,m)  usleep(100)
 
122
#endif
 
123
 
 
124
#endif //_OSDEP_H