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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/libraries/pthread/pthread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/pthread/pthread.c
===================================================================
--- native_client_sdk/src/libraries/pthread/pthread.c (revision 0)
+++ native_client_sdk/src/libraries/pthread/pthread.c (revision 0)
@@ -0,0 +1,43 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include <windows.h>
+#include <errno.h>
+#include "pthread.h"
+
+int pthread_mutex_init(pthread_mutex_t* m, void* traits) {
+ *m = (int) CreateMutex(NULL, 0, NULL);
+ return 0;
+}
+
+int pthread_mutex_destroy(pthread_mutex_t* m) {
+ CloseHandle((HANDLE) *m);
+ return 0;
+}
+
+int pthread_mutex_lock(pthread_mutex_t* m) {
+ if (WaitForSingleObject((HANDLE) *m, INFINITE) == WAIT_OBJECT_0)
+ return 0;
+
+ return EINVAL;
+}
+
+int pthread_mutex_unlock(pthread_mutex_t* m) {
+ if (ReleaseMutex((HANDLE) *m)) return 0;
+
+ return EINVAL;
+}
+
+int pthread_mutex_trylock(pthread_mutex_t* m) {
+ int val = WaitForSingleObject((HANDLE) *m, 0);
+
+ if (val == WAIT_OBJECT_0) return 0;
+
+ if (val == WAIT_TIMEOUT) {
+ errno = EBUSY;
+ } else {
+ errno = EINVAL;
+ }
+ return -1;
+}
Property changes on: native_client_sdk\src\libraries\pthread\pthread.c
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « native_client_sdk/src/libraries/pthread/pthread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698