summaryrefslogtreecommitdiff
path: root/crypto/cryptlib.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2008-07-03 19:59:25 +0000
committerGeoff Thorpe <geoff@openssl.org>2008-07-03 19:59:25 +0000
commit5f834ab123af6444b7cffe21849e434ad6479f8a (patch)
tree0cc48f4fc085f781606cb118b715781651487cb3 /crypto/cryptlib.c
parent8528128b2a740d34d3ae1d43c525d7e6ea6d7f37 (diff)
downloadopenssl-new-5f834ab123af6444b7cffe21849e434ad6479f8a.tar.gz
Revert my earlier CRYPTO_THREADID commit, I will commit a reworked
version some time soon.
Diffstat (limited to 'crypto/cryptlib.c')
-rw-r--r--crypto/cryptlib.c97
1 files changed, 34 insertions, 63 deletions
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index b8c2ee80f6..b89bd7a6fa 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -414,60 +414,14 @@ void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
add_lock_callback=func;
}
-/* Thread IDs. So ... if we build without OPENSSL_NO_DEPRECATED, then we leave
- * the existing implementations and just layer CRYPTO_THREADID_[get|cmp]
- * harmlessly on top. Otherwise, we only use 'id_callback' or 'idptr_callback'
- * if they're non-NULL, ie. we ignore CRYPTO_thread_id()'s fallbacks and we
- * move CRYPTO_thread_idptr()'s "&errno" fallback trick into
- * CRYPTO_THREADID_set(). */
-
-void CRYPTO_set_id_callback(unsigned long (*func)(void))
- {
- id_callback=func;
- }
-
-void CRYPTO_set_idptr_callback(void *(*func)(void))
- {
- idptr_callback=func;
- }
-
-void CRYPTO_THREADID_set(CRYPTO_THREADID *id)
- {
- if (id_callback)
- id->ulong = id_callback();
- else
- id->ulong = 0;
-
- if (idptr_callback)
- id->ptr = idptr_callback();
- else
- id->ptr = &errno;
- }
-
-int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *id1, const CRYPTO_THREADID *id2)
- {
- if (id1->ulong != id2->ulong)
- return ((id1->ulong < id2->ulong) ? -1 : 1);
- if (id1->ptr != id2->ptr)
- return ((id1->ptr < id2->ptr) ? -1 : 1);
- return 0;
- }
-
-unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id)
- {
- /* will need further processing to arrive at a good hash (mem_dbg.c uses this) */
- return id->ulong + (unsigned long)id->ptr;
- }
-
-void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dst, const CRYPTO_THREADID *src)
+unsigned long (*CRYPTO_get_id_callback(void))(void)
{
- memcpy(dst, src, sizeof(*src));
+ return(id_callback);
}
-#ifndef OPENSSL_NO_DEPRECATED
-unsigned long (*CRYPTO_get_id_callback(void))(void)
+void CRYPTO_set_id_callback(unsigned long (*func)(void))
{
- return(id_callback);
+ id_callback=func;
}
unsigned long CRYPTO_thread_id(void)
@@ -492,14 +446,34 @@ unsigned long CRYPTO_thread_id(void)
ret=id_callback();
return(ret);
}
-#endif
+
+void *(*CRYPTO_get_idptr_callback(void))(void)
+ {
+ return(idptr_callback);
+ }
+
+void CRYPTO_set_idptr_callback(void *(*func)(void))
+ {
+ idptr_callback=func;
+ }
+
+void *CRYPTO_thread_idptr(void)
+ {
+ void *ret=NULL;
+
+ if (idptr_callback == NULL)
+ ret = &errno;
+ else
+ ret = idptr_callback();
+
+ return ret;
+ }
void CRYPTO_lock(int mode, int type, const char *file, int line)
{
#ifdef LOCK_DEBUG
{
char *rw_text,*operation_text;
- CRYPTO_THREADID tid;
if (mode & CRYPTO_LOCK)
operation_text="lock ";
@@ -515,9 +489,8 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
else
rw_text="ERROR";
- CRYPTO_THREADID_set(&tid);
- fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n",
- CRYPTO_THREADID_hash(&tid), rw_text, operation_text,
+ fprintf(stderr,"lock:%08lx/%08p:(%s)%s %-18s %s:%d\n",
+ CRYPTO_thread_id(), CRYPTO_thread_idptr(), rw_text, operation_text,
CRYPTO_get_lock_name(type), file, line);
}
#endif
@@ -544,10 +517,6 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
int line)
{
int ret = 0;
-#ifdef LOCK_DEBUG
- CRYPTO_THREADID tid;
- CRYPTO_THREADID_set(&tid);
-#endif
if (add_lock_callback != NULL)
{
@@ -557,8 +526,9 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
ret=add_lock_callback(pointer,amount,type,file,line);
#ifdef LOCK_DEBUG
- fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
- CRYPTO_THREADID_hash(&tid), before,amount,ret,
+ fprintf(stderr,"ladd:%08lx/%0xp:%2d+%2d->%2d %-18s %s:%d\n",
+ CRYPTO_thread_id(), CRYPTO_thread_idptr(),
+ before,amount,ret,
CRYPTO_get_lock_name(type),
file,line);
#endif
@@ -569,8 +539,9 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
ret= *pointer+amount;
#ifdef LOCK_DEBUG
- fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
- CRYPTO_THREADID_hash(&tid), *pointer,amount,ret,
+ fprintf(stderr,"ladd:%08lx/%0xp:%2d+%2d->%2d %-18s %s:%d\n",
+ CRYPTO_thread_id(), CRYPTO_thread_idptr(),
+ *pointer,amount,ret,
CRYPTO_get_lock_name(type),
file,line);
#endif