Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: native_client_sdk/src/libraries/pthread/pthread.c

Issue 10815039: Make use of -lppapi explicit to allow for correct library order. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5 #include <windows.h>
6 #include <errno.h>
7 #include "pthread.h"
8
9 int pthread_mutex_init(pthread_mutex_t* m, void* traits) {
10 *m = (int) CreateMutex(NULL, 0, NULL);
11 return 0;
12 }
13
14 int pthread_mutex_destroy(pthread_mutex_t* m) {
15 CloseHandle((HANDLE) *m);
16 return 0;
17 }
18
19 int pthread_mutex_lock(pthread_mutex_t* m) {
20 if (WaitForSingleObject((HANDLE) *m, INFINITE) == WAIT_OBJECT_0)
21 return 0;
22
23 return EINVAL;
24 }
25
26 int pthread_mutex_unlock(pthread_mutex_t* m) {
27 if (ReleaseMutex((HANDLE) *m)) return 0;
28
29 return EINVAL;
30 }
31
32 int pthread_mutex_trylock(pthread_mutex_t* m) {
33 int val = WaitForSingleObject((HANDLE) *m, 0);
34
35 if (val == WAIT_OBJECT_0) return 0;
36
37 if (val == WAIT_TIMEOUT) {
38 errno = EBUSY;
39 }
binji 2012/07/23 18:47:14 nit: } else { or in this case, could just remove t
noelallen1 2012/07/23 21:44:54 Done.
40 else {
41 errno = EINVAL;
42 }
43 return -1;
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698