1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* osutil
*
* Copyright (C) 2012-2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* SeokYeon Hwang <syeon.hwang@samsung.com>
* MunKyu Im <munkyu.im@samsung.com>
*
* 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 02110-1301, USA.
*
* Contributors:
* - S-Core Co., Ltd
*
*/
#ifndef __OSUTIL_H__
#define __OSUTIL_H__
#include "qemu/osdep.h"
#include "emulator_common.h"
#ifdef CONFIG_WIN32
#include "sysemu/os-win32.h"
#else
#include "sysemu/os-posix.h"
#endif
#define ERR_SUCCESS 0
#define ERR_NODEV 4 /* ACT_SDCARD_DETACH_FAIL. No sdcard attached. */
#define ERR_BUSY 5 /* ACT_SDCARD_ATTACH_FAIL. Already sdcard attached. */
#define ERR_NOENT 6 /* ACT_SDCARD_NO_ATTACH_FOUND. Other sdcard attached. */
extern const char *pac_tempfile;
void make_vm_lock_os(void);
bool make_sdcard_lock_os(char *sdcard);
int remove_sdcard_lock_os(char *sdcard);
#ifndef CONFIG_WIN32
void make_vm_lock_posix(void);
bool make_sdcard_lock_posix(char *sdcard);
int remove_sdcard_lock_posix(char *sdcard);
#else
void get_java_path_win32(const char **java_path);
#endif
void set_bin_path_os(char const *const);
typedef struct sdcard_info
{
#ifndef CONFIG_WIN32
int fd;
#else
HANDLE handle;
#endif
char* lock_file; /* reserved for future use */
} sdcard_info;
void print_system_info_os(void);
int get_number_of_processors(void);
static inline int get_timeofday(char *buf, size_t size)
{
qemu_timeval tv;
time_t ti;
struct tm *ptm = NULL;
int ret;
qemu_gettimeofday(&tv);
ti = tv.tv_sec;
/* In this case, localtime_r() function is not necessary. */
ptm = localtime(&ti);
ret = strftime(buf, size, "%H:%M:%S", ptm);
return ret + g_snprintf(buf + ret, size - ret, ".%03ld", (long)tv.tv_usec/1000);
}
static inline void get_java_path(const char **java_path)
{
#ifdef CONFIG_WIN32
get_java_path_win32(java_path);
#else
*java_path = "java";
#endif
}
#endif // __OS_UTIL_H__
|