From: Ken Raeburn Date: Wed, 25 Jan 2006 06:21:47 +0000 (+0000) Subject: * threads.c (krb5int_mutex_alloc, krb5int_mutex_free, krb5int_mutex_lock, X-Git-Tag: krb5-1.5-alpha1~209 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=58e2e98200ca8d8f9a9cff9758e11fd860c0046c;p=krb5.git * threads.c (krb5int_mutex_alloc, krb5int_mutex_free, krb5int_mutex_lock, krb5int_mutex_unlock): New functions. (krb5int_mutex_lock_update_stats, krb5int_mutex_unlock_update_stats, krb5int_mutex_report_stats): Always define, even if not doing anything. * libkrb5support.exports: Export the new functions. ticket: 3417 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17607 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/support/ChangeLog b/src/util/support/ChangeLog index 8aa8414c3..d40ec99cd 100644 --- a/src/util/support/ChangeLog +++ b/src/util/support/ChangeLog @@ -1,3 +1,12 @@ +2006-01-25 Ken Raeburn + + * threads.c (krb5int_mutex_alloc, krb5int_mutex_free, + krb5int_mutex_lock, krb5int_mutex_unlock): New functions. + (krb5int_mutex_lock_update_stats, + krb5int_mutex_unlock_update_stats, krb5int_mutex_report_stats): + Always define, even if not doing anything. + * libkrb5support.exports: Export the new functions. + 2005-09-09 Ken Raeburn * fake_addrinfo.c (getaddrinfo): Conditionalize last change on diff --git a/src/util/support/libkrb5support.exports b/src/util/support/libkrb5support.exports index 9607ef822..d06911d53 100644 --- a/src/util/support/libkrb5support.exports +++ b/src/util/support/libkrb5support.exports @@ -11,3 +11,7 @@ krb5int_gai_strerror krb5int_getnameinfo krb5int_in6addr_any krb5int_pthread_loaded +krb5int_mutex_alloc +krb5int_mutex_free +krb5int_mutex_lock +krb5int_mutex_unlock diff --git a/src/util/support/threads.c b/src/util/support/threads.c index 8a00e4c2b..d3b5c1bef 100644 --- a/src/util/support/threads.c +++ b/src/util/support/threads.c @@ -585,7 +585,7 @@ krb5int_mutex_report_stats(k5_mutex_t *m) sd_hold); } } -#elif defined _WIN32 +#else /* On Windows, everything defined in the export list must be defined. The UNIX systems where we're using the export list don't seem to care. */ @@ -606,3 +606,42 @@ krb5int_mutex_report_stats(k5_mutex_t *m) { } #endif + +/* Mutex allocation functions, for use in plugins that may not know + what options a given set of libraries was compiled with. */ +int KRB5_CALLCONV +krb5int_mutex_alloc (k5_mutex_t **m) +{ + k5_mutex_t *ptr; + int err; + + ptr = malloc (sizeof (k5_mutex_t)); + if (ptr == NULL) + return errno; + err = k5_mutex_init (ptr); + if (err) { + free (ptr); + return err; + } + *m = ptr; + return 0; +} + +void KRB5_CALLCONV +krb5int_mutex_free (k5_mutex_t *m) +{ + (void) k5_mutex_destroy (m); + free (m); +} + +/* Callable versions of the various macros. */ +int KRB5_CALLCONV +krb5int_mutex_lock (k5_mutex_t *m) +{ + return k5_mutex_lock (m); +} +int KRB5_CALLCONV +krb5int_mutex_unlock (k5_mutex_t *m) +{ + return k5_mutex_unlock (m); +}