0e2b7b238d631946067a9a482c659741e878425b
[bluesky.git] / libs3-1.4 / src / mingw_functions.c
1 /** **************************************************************************
2  * mingw_functions.c
3  * 
4  * Copyright 2008 Bryan Ischo <bryan@ischo.com>
5  * 
6  * This file is part of libs3.
7  * 
8  * libs3 is free software: you can redistribute it and/or modify it under the
9  * terms of the GNU General Public License as published by the Free Software
10  * Foundation, version 3 of the License.
11  *
12  * In addition, as a special exception, the copyright holders give
13  * permission to link the code of this library and its programs with the
14  * OpenSSL library, and distribute linked combinations including the two.
15  *
16  * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
17  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License version 3
22  * along with libs3, in a file named COPYING.  If not, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  ************************************************************************** **/
26
27 #include <pthread.h>
28 #include <sys/utsname.h>
29
30 unsigned long pthread_self()
31 {
32     return (unsigned long) GetCurrentThreadId();
33 }
34
35
36 int pthread_mutex_init(pthread_mutex_t *mutex, void *v)
37 {
38     (void) v;
39
40     InitializeCriticalSection(&(mutex->criticalSection));
41
42     return 0;
43 }
44
45
46 int pthread_mutex_lock(pthread_mutex_t *mutex)
47 {
48     EnterCriticalSection(&(mutex->criticalSection));
49
50     return 0;
51 }
52
53
54 int pthread_mutex_unlock(pthread_mutex_t *mutex)
55 {
56     LeaveCriticalSection(&(mutex->criticalSection));
57
58     return 0;
59 }
60
61
62 int pthread_mutex_destroy(pthread_mutex_t *mutex)
63 {
64     DeleteCriticalSection(&(mutex->criticalSection));
65
66     return 0;
67 }
68
69
70 int uname(struct utsname *u)
71 {
72     OSVERSIONINFO info;
73     info.dwOSVersionInfoSize = sizeof(info);
74
75     if (!GetVersionEx(&info)) {
76         return -1;
77     }
78
79     u->machine = "";
80
81     switch (info.dwMajorVersion) {
82     case 4:
83         switch (info.dwMinorVersion) {
84         case 0:
85             u->sysname = "Microsoft Windows NT 4.0";
86             break;
87         case 10:
88             u->sysname = "Microsoft Windows 98";
89             break;
90         case 90:
91             u->sysname = "Microsoft Windows Me";
92             break;
93         default:
94             return -1;
95         }
96         break;
97
98     case 5:
99         switch (info.dwMinorVersion) {
100         case 0:
101             u->sysname = "Microsoft Windows 2000";
102             break;
103         case 1:
104             u->sysname = "Microsoft Windows XP";
105             break;
106         case 2:
107             u->sysname = "Microsoft Server 2003";
108             break;
109         default:
110             return -1;
111         }
112         break;
113
114     default:
115         return -1;
116     }
117
118     return 0;
119 }