Add support for dynamically created and destroyed mutexes. This will
[openssl.git] / crypto / crypto.h
index 84894af56ce2f6453cd22c45d2544637b62cc4ff..9e5f2e29226b325df0dd580ac0a3eff881ecf3da 100644 (file)
@@ -150,6 +150,12 @@ extern "C" {
 #define CRYPTO_add(a,b,c)      ((*(a))+=(b))
 #endif
 
+/* Some applications as well as some parts of OpenSSL need to allocate
+   and deallocate locks in a dynamic fashion.  The following typedef
+   makes this possible in a type-safe manner.  */
+typedef struct CRYPTO_dynlock_value CRYPTO_dynlock;
+
+
 /* The following can be used to detect memory leaks in the SSLeay library.
  * It used, it turns on malloc checking */
 
@@ -250,16 +256,17 @@ int CRYPTO_is_mem_check_on(void);
 #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
 #define is_MemCheck_on() CRYPTO_is_mem_check_on()
 
-#define Malloc(num)    CRYPTO_malloc((int)num,__FILE__,__LINE__)
-#define Realloc(addr,num) \
+#define OPENSSL_malloc(num)    CRYPTO_malloc((int)num,__FILE__,__LINE__)
+#define OPENSSL_realloc(addr,num) \
        CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
-#define Remalloc(addr,num) \
+#define OPENSSL_remalloc(addr,num) \
        CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
-#define FreeFunc       CRYPTO_free
-#define Free(addr)     CRYPTO_free(addr)
+#define OPENSSL_freeFunc       CRYPTO_free
+#define OPENSSL_free(addr)     CRYPTO_free(addr)
 
-#define Malloc_locked(num) CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
-#define Free_locked(addr) CRYPTO_free_locked(addr)
+#define OPENSSL_malloc_locked(num) \
+       CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
+#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
 
 
 /* Case insensiteve linking causes problems.... */
@@ -298,6 +305,16 @@ unsigned long CRYPTO_thread_id(void);
 const char *CRYPTO_get_lock_name(int type);
 int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
                    int line);
+void CRYPTO_set_dynlock_create_callback(CRYPTO_dynlock *(*dyn_create_function)
+       (char *file, int line));
+void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)
+       (int mode, CRYPTO_dynlock *l, const char *file, int line));
+void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)
+       (CRYPTO_dynlock *l, const char *file, int line));
+void CRYPTO_set_dynlock_size(int dynlock_size);
+int CRYPTO_get_new_dynlockid(void);
+void CRYPTO_destroy_dynlockid(int i);
+CRYPTO_dynlock *CRYPTO_get_dynlock_value(int i);
 
 /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
  * call the latter last if you need different functions */
@@ -370,12 +387,15 @@ void ERR_load_CRYPTO_strings(void);
 
 /* Function codes. */
 #define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX                100
+#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID               103
 #define CRYPTO_F_CRYPTO_GET_NEW_LOCKID                  101
 #define CRYPTO_F_CRYPTO_SET_EX_DATA                     102
 
 /* Reason codes. */
+#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK             100
 
 #ifdef  __cplusplus
 }
 #endif
 #endif
+