WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / libhb / ports.h
blob5e039809e64cc4c5c3afb72764d0f84709718cb9
1 /* ports.h
3 Copyright (c) 2003-2015 HandBrake Team
4 This file is part of the HandBrake source code
5 Homepage: <http://handbrake.fr/>.
6 It may be used under the terms of the GNU General Public License v2.
7 For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
8 */
10 #ifndef HB_PORTS_H
11 #define HB_PORTS_H
13 #if ARCH_X86_64 || ARCH_X86_32
14 #define ARCH_X86
15 #endif
17 #if defined(_WIN32)
18 #define DIR_SEP_STR "\\"
19 #define DIR_SEP_CHAR '\\'
20 #define IS_DIR_SEP(c) (c == '\\' || c == '/')
21 #else
22 #define DIR_SEP_STR "/"
23 #define DIR_SEP_CHAR '/'
24 #define IS_DIR_SEP(c) (c == '/')
25 #endif
28 /************************************************************************
29 * CPU info utilities
30 ***********************************************************************/
31 enum hb_cpu_platform
33 // list of microarchitecture codenames
34 HB_CPU_PLATFORM_UNSPECIFIED = 0,
35 HB_CPU_PLATFORM_INTEL_BNL,
36 HB_CPU_PLATFORM_INTEL_SNB,
37 HB_CPU_PLATFORM_INTEL_IVB,
38 HB_CPU_PLATFORM_INTEL_SLM,
39 HB_CPU_PLATFORM_INTEL_HSW,
40 HB_CPU_PLATFORM_INTEL_BDW,
41 HB_CPU_PLATFORM_INTEL_CHT,
43 int hb_get_cpu_count();
44 int hb_get_cpu_platform();
45 const char* hb_get_cpu_name();
46 const char* hb_get_cpu_platform_name();
48 /************************************************************************
49 * Utils
50 ***********************************************************************/
51 // provide time in ms
52 uint64_t hb_get_date();
53 // provide time in us
54 uint64_t hb_get_time_us();
56 void hb_snooze( int delay );
57 int hb_platform_init();
59 #ifdef SYS_MINGW
60 typedef struct
62 _WDIR *wdir;
63 struct dirent entry;
64 } HB_DIR;
65 #else
66 typedef DIR HB_DIR;
67 #endif
69 #ifdef SYS_MINGW
70 typedef struct _stat64 hb_stat_t;
71 #else
72 typedef struct stat hb_stat_t;
73 #endif
75 HB_DIR* hb_opendir(char *path);
76 int hb_closedir(HB_DIR *dir);
77 void hb_rewinddir(HB_DIR *dir);
78 struct dirent * hb_readdir(HB_DIR *dir);
79 int hb_mkdir(char * name);
80 int hb_stat(const char *path, hb_stat_t *sb);
81 FILE * hb_fopen(const char *path, const char *mode);
82 char * hb_strr_dir_sep(const char *path);
84 #ifdef __LIBHB__
86 // Convert utf8 string to current code page.
87 char * hb_utf8_to_cp(const char *src);
89 /* Everything from now is only used internally and hidden to the UI */
91 /************************************************************************
92 * DVD utils
93 ***********************************************************************/
94 int hb_dvd_region(char *device, int *region_mask);
96 /************************************************************************
97 * File utils
98 ***********************************************************************/
99 void hb_get_temporary_directory( char path[512] );
100 void hb_get_tempory_filename( hb_handle_t *, char name[1024],
101 char * fmt, ... );
103 #if defined( SYS_DARWIN )
104 int osx_get_user_config_directory( char path[512] );
105 #endif
106 void hb_get_user_config_directory( char path[512] );
107 void hb_get_user_config_filename( char name[1024], char *fmt, ... );
108 /************************************************************************
109 * Threads
110 ***********************************************************************/
111 typedef struct hb_thread_s hb_thread_t;
113 #if defined( SYS_BEOS )
114 # define HB_LOW_PRIORITY 5
115 # define HB_NORMAL_PRIORITY 10
116 #elif defined( SYS_DARWIN )
117 # define HB_LOW_PRIORITY 0
118 # define HB_NORMAL_PRIORITY 31
119 #elif defined( SYS_LINUX ) || defined( SYS_FREEBSD ) || defined ( SYS_SunOS ) || defined ( __FreeBSD_kernel__ )
120 # define HB_LOW_PRIORITY 0
121 # define HB_NORMAL_PRIORITY 0
122 #elif defined( SYS_CYGWIN )
123 # define HB_LOW_PRIORITY 0
124 # define HB_NORMAL_PRIORITY 1
125 #elif defined( SYS_MINGW )
126 # define HB_LOW_PRIORITY 0
127 # define HB_NORMAL_PRIORITY 0
128 #endif
130 typedef void (thread_func_t)(void *);
131 hb_thread_t * hb_thread_init( const char * name, thread_func_t *function,
132 void * arg, int priority );
133 void hb_thread_close( hb_thread_t ** );
134 int hb_thread_has_exited( hb_thread_t * );
136 void hb_yield(void);
138 /************************************************************************
139 * Mutexes
140 ***********************************************************************/
142 hb_lock_t * hb_lock_init();
143 void hb_lock_close( hb_lock_t ** );
144 void hb_lock( hb_lock_t * );
145 void hb_unlock( hb_lock_t * );
147 /************************************************************************
148 * Condition variables
149 ***********************************************************************/
150 typedef struct hb_cond_s hb_cond_t;
152 hb_cond_t * hb_cond_init();
153 void hb_cond_wait( hb_cond_t *, hb_lock_t * );
154 void hb_cond_timedwait( hb_cond_t * c, hb_lock_t * lock, int msec );
155 void hb_cond_signal( hb_cond_t * );
156 void hb_cond_broadcast( hb_cond_t * c );
157 void hb_cond_close( hb_cond_t ** );
159 /************************************************************************
160 * Network
161 ***********************************************************************/
162 typedef struct hb_net_s hb_net_t;
164 hb_net_t * hb_net_open( char * address, int port );
165 int hb_net_send( hb_net_t *, char * );
166 int hb_net_recv( hb_net_t *, char *, int );
167 void hb_net_close( hb_net_t ** );
169 /************************************************************************
170 * OS Sleep Allow / Prevent
171 ***********************************************************************/
172 void* hb_system_sleep_opaque_init();
173 void hb_system_sleep_opaque_close(void **opaque);
174 void hb_system_sleep_private_enable(void *opaque);
175 void hb_system_sleep_private_disable(void *opaque);
177 #endif /* __LIBHB__ */
179 #endif