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

Side by Side Diff: openssl/crypto/threads/mttest.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 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 | « openssl/crypto/symhacks.h ('k') | openssl/crypto/tmdiff.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* crypto/threads/mttest.c */ 1 /* crypto/threads/mttest.c */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs); 110 int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs);
111 void thread_setup(void); 111 void thread_setup(void);
112 void thread_cleanup(void); 112 void thread_cleanup(void);
113 void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx); 113 void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx);
114 114
115 void irix_locking_callback(int mode,int type,char *file,int line); 115 void irix_locking_callback(int mode,int type,char *file,int line);
116 void solaris_locking_callback(int mode,int type,char *file,int line); 116 void solaris_locking_callback(int mode,int type,char *file,int line);
117 void win32_locking_callback(int mode,int type,char *file,int line); 117 void win32_locking_callback(int mode,int type,char *file,int line);
118 void pthreads_locking_callback(int mode,int type,char *file,int line); 118 void pthreads_locking_callback(int mode,int type,char *file,int line);
119 void netware_locking_callback(int mode,int type,char *file,int line); 119 void netware_locking_callback(int mode,int type,char *file,int line);
120 void beos_locking_callback(int mode,int type,const char *file,int line);
120 121
121 unsigned long irix_thread_id(void ); 122 unsigned long irix_thread_id(void );
122 unsigned long solaris_thread_id(void ); 123 unsigned long solaris_thread_id(void );
123 unsigned long pthreads_thread_id(void ); 124 unsigned long pthreads_thread_id(void );
124 unsigned long netware_thread_id(void ); 125 unsigned long netware_thread_id(void );
126 unsigned long beos_thread_id(void );
125 127
126 #if defined(OPENSSL_SYS_NETWARE) 128 #if defined(OPENSSL_SYS_NETWARE)
127 static MPKMutex *lock_cs; 129 static MPKMutex *lock_cs;
128 static MPKSema ThreadSem; 130 static MPKSema ThreadSem;
129 static long *lock_count; 131 static long *lock_count;
130 #endif 132 #endif
131 133
132 BIO *bio_err=NULL; 134 BIO *bio_err=NULL;
133 BIO *bio_stdout=NULL; 135 BIO *bio_stdout=NULL;
134 136
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1204 }
1203 1205
1204 unsigned long netware_thread_id(void) 1206 unsigned long netware_thread_id(void)
1205 { 1207 {
1206 unsigned long ret; 1208 unsigned long ret;
1207 1209
1208 ret=(unsigned long)GetThreadID(); 1210 ret=(unsigned long)GetThreadID();
1209 return(ret); 1211 return(ret);
1210 } 1212 }
1211 #endif /* NETWARE */ 1213 #endif /* NETWARE */
1214
1215 #ifdef BEOS_THREADS
1216
1217 #include <Locker.h>
1218
1219 static BLocker** lock_cs;
1220 static long* lock_count;
1221
1222 void thread_setup(void)
1223 {
1224 int i;
1225
1226 lock_cs=(BLocker**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(BLocker*)) ;
1227 lock_count=(long*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
1228 for (i=0; i<CRYPTO_num_locks(); i++)
1229 {
1230 lock_count[i]=0;
1231 lock_cs[i] = new BLocker(CRYPTO_get_lock_name(i));
1232 }
1233
1234 CRYPTO_set_id_callback((unsigned long (*)())beos_thread_id);
1235 CRYPTO_set_locking_callback(beos_locking_callback);
1236 }
1237
1238 void thread_cleanup(void)
1239 {
1240 int i;
1241
1242 CRYPTO_set_locking_callback(NULL);
1243 fprintf(stderr,"cleanup\n");
1244 for (i=0; i<CRYPTO_num_locks(); i++)
1245 {
1246 delete lock_cs[i];
1247 fprintf(stderr,"%8ld:%s\n",lock_count[i],
1248 CRYPTO_get_lock_name(i));
1249 }
1250 OPENSSL_free(lock_cs);
1251 OPENSSL_free(lock_count);
1252
1253 fprintf(stderr,"done cleanup\n");
1254 }
1255
1256 void beos_locking_callback(int mode, int type, const char *file, int line)
1257 {
1258 #if 0
1259 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
1260 CRYPTO_thread_id(),
1261 (mode&CRYPTO_LOCK)?"l":"u",
1262 (type&CRYPTO_READ)?"r":"w",file,line);
1263 #endif
1264 if (mode & CRYPTO_LOCK)
1265 {
1266 lock_cs[type]->Lock();
1267 lock_count[type]++;
1268 }
1269 else
1270 {
1271 lock_cs[type]->Unlock();
1272 }
1273 }
1274
1275 void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
1276 {
1277 SSL_CTX *ssl_ctx[2];
1278 thread_id thread_ctx[MAX_THREAD_NUMBER];
1279 int i;
1280
1281 ssl_ctx[0]=s_ctx;
1282 ssl_ctx[1]=c_ctx;
1283
1284 for (i=0; i<thread_number; i++)
1285 {
1286 thread_ctx[i] = spawn_thread((thread_func)ndoit,
1287 NULL, B_NORMAL_PRIORITY, (void *)ssl_ctx);
1288 resume_thread(thread_ctx[i]);
1289 }
1290
1291 printf("waiting...\n");
1292 for (i=0; i<thread_number; i++)
1293 {
1294 status_t result;
1295 wait_for_thread(thread_ctx[i], &result);
1296 }
1297
1298 printf("beos threads done (%d,%d)\n",
1299 s_ctx->references,c_ctx->references);
1300 }
1301
1302 unsigned long beos_thread_id(void)
1303 {
1304 unsigned long ret;
1305
1306 ret=(unsigned long)find_thread(NULL);
1307 return(ret);
1308 }
1309
1310 #endif /* BEOS_THREADS */
OLDNEW
« no previous file with comments | « openssl/crypto/symhacks.h ('k') | openssl/crypto/tmdiff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698