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

Side by Side Diff: skia/ports/SkThread_pthread.cpp

Issue 113827: Remove the remainder of the skia source code from the Chromium repo.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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
« no previous file with comments | « skia/ports/SkThread_none.cpp ('k') | skia/ports/SkThread_win.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "SkThread.h"
2
3 #include <pthread.h>
4 #include <errno.h>
5
6 SkMutex gAtomicMutex;
7
8 int32_t sk_atomic_inc(int32_t* addr)
9 {
10 SkAutoMutexAcquire ac(gAtomicMutex);
11
12 int32_t value = *addr;
13 *addr = value + 1;
14 return value;
15 }
16
17 int32_t sk_atomic_dec(int32_t* addr)
18 {
19 SkAutoMutexAcquire ac(gAtomicMutex);
20
21 int32_t value = *addr;
22 *addr = value - 1;
23 return value;
24 }
25
26 //////////////////////////////////////////////////////////////////////////////
27
28 static void print_pthread_error(int status)
29 {
30 switch (status) {
31 case 0: // success
32 break;
33 case EINVAL:
34 printf("pthread error [%d] EINVAL\n", status);
35 break;
36 case EBUSY:
37 printf("pthread error [%d] EBUSY\n", status);
38 break;
39 default:
40 printf("pthread error [%d] unknown\n", status);
41 break;
42 }
43 }
44
45 SkMutex::SkMutex(bool isGlobal) : fIsGlobal(isGlobal)
46 {
47 if (sizeof(pthread_mutex_t) > sizeof(fStorage))
48 {
49 SkDEBUGF(("pthread mutex size = %d\n", sizeof(pthread_mutex_t)));
50 SkASSERT(!"mutex storage is too small");
51 }
52
53 int status;
54 pthread_mutexattr_t attr;
55
56 status = pthread_mutexattr_init(&attr);
57 print_pthread_error(status);
58 SkASSERT(0 == status);
59
60 status = pthread_mutex_init((pthread_mutex_t*)fStorage, &attr);
61 print_pthread_error(status);
62 SkASSERT(0 == status);
63 }
64
65 SkMutex::~SkMutex()
66 {
67 int status = pthread_mutex_destroy((pthread_mutex_t*)fStorage);
68
69 // only report errors on non-global mutexes
70 if (!fIsGlobal)
71 {
72 print_pthread_error(status);
73 SkASSERT(0 == status);
74 }
75 }
76
77 void SkMutex::acquire()
78 {
79 int status = pthread_mutex_lock((pthread_mutex_t*)fStorage);
80 print_pthread_error(status);
81 SkASSERT(0 == status);
82 }
83
84 void SkMutex::release()
85 {
86 int status = pthread_mutex_unlock((pthread_mutex_t*)fStorage);
87 print_pthread_error(status);
88 SkASSERT(0 == status);
89 }
90
OLDNEW
« no previous file with comments | « skia/ports/SkThread_none.cpp ('k') | skia/ports/SkThread_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698