2505N/A# This file adds the code to setup internal mutexes and callback function.
2505N/A# This change was implemented in-house. The issue was brought up to
2505N/A# the upstream engineers, but there was no commitment.
2505N/A #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
4002N/A static double SSLeay_MSVC5_hack = 0.0; /* and for VC1.5 */
4002N/A static STACK_OF(CRYPTO_dynlock) *dyn_locks = NULL;
2505N/A+static pthread_mutex_t *solaris_openssl_locks;
4002N/A static void (MS_FAR *locking_callback) (int mode, int type,
4002N/A const char *file, int line) = 0;
4002N/A static int (MS_FAR *add_lock_callback) (int *pointer, int amount,
4364N/A void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func)
4364N/A (const char *file, int line))
4364N/A- dynlock_create_callback = func;
4364N/A+ * we now setup our own dynamic locking callback, and disallow
4364N/A+ * setting of another locking callback.
4364N/A void CRYPTO_set_dynlock_lock_callback(void (*func) (int mode,
4364N/A- dynlock_lock_callback = func;
4364N/A+ * we now setup our own dynamic locking callback, and disallow
4364N/A+ * setting of another locking callback.
4364N/A void CRYPTO_set_dynlock_destroy_callback(void (*func)
4364N/A (struct CRYPTO_dynlock_value *l,
4364N/A const char *file, int line))
4364N/A- dynlock_destroy_callback = func;
4364N/A+ * we now setup our own dynamic locking callback, and disallow
4364N/A+ * setting of another locking callback.
4364N/A void (*CRYPTO_get_locking_callback(void)) (int mode, int type,
4002N/A return (add_lock_callback);
2505N/A+ * This is the locking callback function which all applications will be
2505N/A+ * using when CRYPTO_lock() is called.
2505N/A+static void solaris_locking_callback(int mode, int type, const char *file,
6858N/A+ (void) pthread_mutex_lock(&solaris_openssl_locks[type]);
6858N/A+ (void) pthread_mutex_unlock(&solaris_openssl_locks[type]);
4364N/A+ * Implement Solaris's own dynamic locking routines.
4364N/A+static struct CRYPTO_dynlock_value *
4364N/A+solaris_dynlock_create(const char *file, int line)
4364N/A+ dynlock = OPENSSL_malloc(sizeof(pthread_mutex_t));
4364N/A+ ret = pthread_mutex_init(dynlock, NULL);
4364N/A+ return ((struct CRYPTO_dynlock_value *)dynlock);
4423N/A+solaris_dynlock_lock(int mode, struct CRYPTO_dynlock_value *dynlock,
4364N/A+ const char *file, int line)
4364N/A+ ret = pthread_mutex_lock((pthread_mutex_t *)dynlock);
4364N/A+ ret = pthread_mutex_unlock((pthread_mutex_t *)dynlock);
4364N/A+solaris_dynlock_destroy(struct CRYPTO_dynlock_value *dynlock,
4364N/A+ const char *file, int line)
4364N/A+ ret = pthread_mutex_destroy((pthread_mutex_t *)dynlock);
6858N/A+static void solaris_fork_prep(void)
6858N/A+ for (i = 0; i < CRYPTO_NUM_LOCKS; i++) {
6858N/A+ (void) pthread_mutex_lock(&solaris_openssl_locks[i]);
6858N/A+static void solaris_fork_post(void)
6858N/A+ for (i = CRYPTO_NUM_LOCKS - 1; i >= 0; i--) {
6858N/A+ (void) pthread_mutex_unlock(&solaris_openssl_locks[i]);
6858N/A+ OPENSSL_assert(dynlock_create_callback == solaris_dynlock_create);
6858N/A+ OPENSSL_assert(dynlock_lock_callback == solaris_dynlock_lock);
6858N/A+ OPENSSL_assert(dynlock_destroy_callback == solaris_dynlock_destroy);
6858N/A+ OPENSSL_assert(locking_callback == solaris_locking_callback);
6858N/A+ * This is called by the _init() function to setup locks used by OpenSSL
6858N/A+ * and locking callback functions.
4364N/A+ /* setup the dynlock callback if not already */
4364N/A+ if (dynlock_create_callback == NULL) {
4364N/A+ dynlock_create_callback = solaris_dynlock_create;
4364N/A+ if (dynlock_lock_callback == NULL) {
4364N/A+ dynlock_lock_callback = solaris_dynlock_lock;
4364N/A+ if (dynlock_destroy_callback == NULL) {
4364N/A+ dynlock_destroy_callback = solaris_dynlock_destroy;
6858N/A+ if (locking_callback == NULL) {
6858N/A+ locking_callback = solaris_locking_callback;
6858N/A+ /* allocate and initialize locks needed by OpenSSL */
6858N/A+ OPENSSL_malloc(sizeof (pthread_mutex_t) * CRYPTO_NUM_LOCKS);
4364N/A+ if (solaris_openssl_locks == NULL) {
4364N/A+ "solaris_locking_setup: memory allocation failure.\n");
6858N/A+ for (i = 0; i < CRYPTO_NUM_LOCKS; i++) {
6858N/A+ (void) pthread_mutex_init(&solaris_openssl_locks[i], NULL);
6858N/A+ (void) pthread_atfork(solaris_fork_prep, solaris_fork_post, solaris_fork_post);
4002N/A void CRYPTO_set_locking_callback(void (*func) (int mode, int type,
4002N/A const char *file, int line))
4364N/A+ * we now setup our own locking callback and mutexes, and disallow
4364N/A+ * setting of another locking callback.
4002N/A void CRYPTO_set_add_lock_callback(int (*func) (int *num, int mount, int type,
4364N/A int CRYPTO_THREADID_set_callback(void (*func) (CRYPTO_THREADID *))
4364N/A+ * Use the backup method (the address of 'errno') to identify the
4364N/A+ * thread and disallow setting the threadid callback.
4364N/A void CRYPTO_set_id_callback(unsigned long (*func) (void))
4364N/A+ * Setting the id callback is disallowed.
4364N/A unsigned long CRYPTO_thread_id(void)
2505N/A void *OPENSSL_stderr(void);
2505N/A extern int OPENSSL_NONPIC_relocated;
2505N/A+void solaris_locking_setup();
4820N/A .size _sparcv9_vis1_instrument_bus2,.-_sparcv9_vis1_instrument_bus2
2505N/A .section ".init",#alloc,#execinstr
2505N/A+ call solaris_locking_setup
2505N/A .extern OPENSSL_cpuid_setup
2505N/A .hidden OPENSSL_cpuid_setup
2505N/A+.extern solaris_locking_setup
2505N/A+.hidden solaris_locking_setup
2505N/A+ call solaris_locking_setup
4820N/A &function_end_B("OPENSSL_ia32_rdseed");
2505N/A+&initseg("solaris_locking_setup");
2505N/A &initseg("OPENSSL_cpuid_setup");
4820N/A+&hidden("solaris_locking_setup");
4820N/A &hidden("OPENSSL_cpuid_setup");
4820N/A &hidden("OPENSSL_ia32cap_P");