Commit 2e52e7df authored by Matt Caswell's avatar Matt Caswell
Browse files

Remove the old threading API



All OpenSSL code has now been transferred to use the new threading API,
so the old one is no longer used and can be removed. We provide some compat
macros for removed functions which are all no-ops.

There is now no longer a need to set locking callbacks!!

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent 4fc4faa7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -274,7 +274,6 @@ my @disablables = (
    "hmac",
    "hw(-.+)?",
    "idea",
    "locking",
    "makedepend",
    "md2",
    "md4",
+0 −50
Original line number Diff line number Diff line
@@ -207,55 +207,6 @@ static char *make_config_name()
    return p;
}

static void lock_dbg_cb(int mode, int type, const char *file, int line)
{
    static int modes[CRYPTO_NUM_LOCKS];
    const char *errstr = NULL;
    int rw = mode & (CRYPTO_READ | CRYPTO_WRITE);

    if (rw != CRYPTO_READ && rw != CRYPTO_WRITE) {
        errstr = "invalid mode";
        goto err;
    }

    if (type < 0 || type >= CRYPTO_NUM_LOCKS) {
        errstr = "type out of bounds";
        goto err;
    }

    if (mode & CRYPTO_LOCK) {
        if (modes[type]) {
            errstr = "already locked";
            /* must not happen in a single-threaded program --> deadlock! */
            goto err;
        }
        modes[type] = rw;
    } else if (mode & CRYPTO_UNLOCK) {
        if (!modes[type]) {
            errstr = "not locked";
            goto err;
        }

        if (modes[type] != rw) {
            errstr = (rw == CRYPTO_READ) ?
                "CRYPTO_r_unlock on write lock" :
                "CRYPTO_w_unlock on read lock";
        }

        modes[type] = 0;
    } else {
        errstr = "invalid mode";
        goto err;
    }

 err:
    if (errstr) {
        BIO_printf(bio_err,
                   "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
                   errstr, mode, type, file, line);
    }
}

#if defined( OPENSSL_SYS_VMS)
extern char **copy_argv(int *argc, char **argv);
#endif
@@ -288,7 +239,6 @@ int main(int argc, char *argv[])
    if (p != NULL && strcmp(p, "on") == 0)
        CRYPTO_set_mem_debug(1);
    CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
    CRYPTO_set_locking_callback(lock_dbg_cb);

    if (getenv("OPENSSL_FIPS")) {
#ifdef OPENSSL_FIPS
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ GENERAL=Makefile README crypto-lib.com install.com
LIB= $(TOP)/libcrypto.a
SHARED_LIB= libcrypto$(SHLIB_EXT)
LIBSRC=	cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
	ebcdic.c uid.c o_time.c o_str.c o_dir.c thr_id.c lock.c \
	ebcdic.c uid.c o_time.c o_str.c o_dir.c \
	threads_pthread.c threads_win.c threads_none.c \
	o_init.c o_fips.c mem_sec.c init.c
LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o cpt_err.o \
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
LIBS=../libcrypto
SOURCE[../libcrypto]=\
        cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c cpt_err.c \
        ebcdic.c uid.c o_time.c o_str.c o_dir.c thr_id.c lock.c \
        ebcdic.c uid.c o_time.c o_str.c o_dir.c \
        threads_pthread.c threads_win.c threads_none.c \
        o_init.c o_fips.c mem_sec.c init.c {- $target{cpuid_asm_src} -} \
        {- $target{uplink_aux_src} -}
+13 −5
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@

#include <stdio.h>
#include "internal/cryptlib.h"
#include "internal/threads.h"
#include <openssl/lhash.h>
#include <openssl/crypto.h>
#include <openssl/buffer.h>
@@ -70,14 +71,21 @@ void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
    char buf2[4096];
    const char *file, *data;
    int line, flags;
    unsigned long es;
    CRYPTO_THREADID cur;
    /*
     * We don't know what kind of thing CRYPTO_THREAD_ID is. Here is our best
     * attempt to convert it into something we can print.
     */
    union {
        CRYPTO_THREAD_ID tid;
        unsigned long ltid;
    } tid;

    tid.ltid = 0;
    tid.tid = CRYPTO_THREAD_get_current_id();

    CRYPTO_THREADID_current(&cur);
    es = CRYPTO_THREADID_hash(&cur);
    while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) {
        ERR_error_string_n(l, buf, sizeof buf);
        BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf,
        BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", tid.ltid, buf,
                     file, line, (flags & ERR_TXT_STRING) ? data : "");
        if (cb(buf2, strlen(buf2), u) <= 0)
            break;              /* abort outputting the error report */
Loading