~ubuntu-branches/ubuntu/natty/libgcrypt11/natty-proposed

« back to all changes in this revision

Viewing changes to src/ath.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2009-02-21 13:46:58 UTC
  • mto: (1.1.6 upstream) (2.1.3 squeeze)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20090221134658-855twvcr4ezk2ron
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <config.h>
23
23
#endif
24
24
 
25
 
#include <assert.h>
 
25
#include <assert.h>  /* Right: We need to use assert and not gcry_assert.  */
26
26
#include <unistd.h>
27
27
#ifdef HAVE_SYS_SELECT_H
28
28
# include <sys/select.h>
52
52
#define MUTEX_DESTROYED ((ath_mutex_t) 2)
53
53
 
54
54
 
 
55
/* Return the thread type from the option field. */
 
56
#define GET_OPTION(a)    ((a) & 0xff)
 
57
/* Return the version number from the option field.  */
 
58
#define GET_VERSION(a)   (((a) >> 8)& 0xff)
 
59
 
 
60
 
55
61
 
56
62
/* The lock we take while checking for lazy lock initialization.  */
57
63
static ath_mutex_t check_init_lock = ATH_MUTEX_INITIALIZER;
81
87
{
82
88
  if (check_only)
83
89
    {
84
 
      enum ath_thread_option option = ATH_THREAD_OPTION_DEFAULT;
 
90
      unsigned int option = 0;
85
91
      
86
92
      /* Check if the requested thread option is compatible to the
87
93
         thread option we are already committed to.  */
88
94
      if (ath_ops)
89
95
        option = ath_ops->option;
90
96
 
91
 
      if (!ops_set && option)
 
97
      if (!ops_set && GET_OPTION (option))
92
98
        return GPG_ERR_NOT_SUPPORTED;
93
99
 
94
 
      if (ops.option == ATH_THREAD_OPTION_USER
95
 
          || option == ATH_THREAD_OPTION_USER
96
 
          || ops.option != option)
 
100
      if (GET_OPTION (ops.option) == ATH_THREAD_OPTION_USER
 
101
          || GET_OPTION (option) == ATH_THREAD_OPTION_USER
 
102
          || GET_OPTION (ops.option) != GET_OPTION (option)
 
103
          || GET_VERSION (ops.option) != GET_VERSION (option))
97
104
        return GPG_ERR_NOT_SUPPORTED;
98
105
 
99
106
      return 0;