Print this page
NEX-5010 Fix for NEX-4680 introduced cstyle issues
Reviewed by: Jean McCormack <jean.mccormack@nexenta.com>
NEX-4680 NEF needs Sun_HBA_* API to be working after library reload
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>


  27  *
  28  *************************************************************************
  29  */
  30 
  31 #ifdef WIN32
  32 #include <windows.h>
  33 #include <string.h>
  34 /*
  35  * Next define forces entry points in the dll to be exported
  36  * See hbaapi.h to see what it does.
  37  */
  38 #define HBAAPI_EXPORTS
  39 #else
  40 #include <dlfcn.h>
  41 #include <strings.h>
  42 #endif
  43 #include <stdio.h>
  44 #include <time.h>
  45 #include "hbaapi.h"
  46 #include "vendorhbaapi.h"

  47 #include <stdlib.h>
  48 #ifdef USESYSLOG
  49 #include <syslog.h>
  50 #endif
  51 
  52 /*
  53  * LIBRARY_NUM is a shortcut to figure out which library we need to call.
  54  *  The top 16 bits of handle are the library index
  55  */
  56 #define LIBRARY_NUM(handle)     ((handle)>>16)
  57 
  58 /*
  59  * VENDOR_HANDLE turns a global library handle into a vendor specific handle,
  60  * with all upper 16 bits set to 0
  61  */
  62 #define VENDOR_HANDLE(handle)   ((handle)&0xFFFF)
  63 
  64 #define HBA_HANDLE_FROM_LOCAL(library, vendor) \
  65                                 (((library)<<16) | ((vendor)&0x0000FFFF))
  66 


 953     /* this will unlock them as well, but who cares */
 954     pthread_mutex_destroy(&_hbaapi_LE_mutex);
 955     pthread_mutex_destroy(&_hbaapi_TE_mutex);
 956     pthread_mutex_destroy(&_hbaapi_APSE_mutex);
 957     pthread_mutex_destroy(&_hbaapi_APE_mutex);
 958     pthread_mutex_destroy(&_hbaapi_AE_mutex);
 959     pthread_mutex_destroy(&_hbaapi_AAE_mutex);
 960     pthread_mutex_destroy(&_hbaapi_AL_mutex);
 961     pthread_mutex_destroy(&_hbaapi_LL_mutex);
 962 #elif defined(WIN32)
 963     DeleteCriticalSection(&_hbaapi_LL_mutex);
 964     DeleteCriticalSection(&_hbaapi_AL_mutex);
 965     DeleteCriticalSection(&_hbaapi_AAE_mutex);
 966     DeleteCriticalSection(&_hbaapi_AE_mutex);
 967     DeleteCriticalSection(&_hbaapi_APE_mutex);
 968     DeleteCriticalSection(&_hbaapi_APSE_mutex);
 969     DeleteCriticalSection(&_hbaapi_TE_mutex);
 970     DeleteCriticalSection(&_hbaapi_LE_mutex);
 971 #endif
 972     
 973     return HBA_STATUS_OK;
 974 }
 975 
 976 /*
 977  * The API used to use fixed size tables as its primary data structure.
 978  * Indexing from 1 to N identified each adapters.  Now the adapters are
 979  * on a linked list.  There is a unique "index" foreach each adapter.
 980  * Adapters always keep their index, even if they are removed from the
 981  * hardware.  The only time the indexing is reset is on HBA_FreeLibrary
 982  */
 983 HBA_UINT32
 984 HBA_GetNumberOfAdapters(void) {
 985     int j=0;
 986     HBA_LIBRARY_INFO    *lib_infop;
 987     HBAGetNumberOfAdaptersFunc
 988                         GetNumberOfAdaptersFunc;
 989     HBAGetAdapterNameFunc
 990                         GetAdapterNameFunc;
 991     HBA_BOOLEAN         found_name;
 992     HBA_ADAPTER_INFO    *adapt_infop;
 993     HBA_STATUS          status;




  27  *
  28  *************************************************************************
  29  */
  30 
  31 #ifdef WIN32
  32 #include <windows.h>
  33 #include <string.h>
  34 /*
  35  * Next define forces entry points in the dll to be exported
  36  * See hbaapi.h to see what it does.
  37  */
  38 #define HBAAPI_EXPORTS
  39 #else
  40 #include <dlfcn.h>
  41 #include <strings.h>
  42 #endif
  43 #include <stdio.h>
  44 #include <time.h>
  45 #include "hbaapi.h"
  46 #include "vendorhbaapi.h"
  47 #include "hbaapi-sun.h"
  48 #include <stdlib.h>
  49 #ifdef USESYSLOG
  50 #include <syslog.h>
  51 #endif
  52 
  53 /*
  54  * LIBRARY_NUM is a shortcut to figure out which library we need to call.
  55  *  The top 16 bits of handle are the library index
  56  */
  57 #define LIBRARY_NUM(handle)     ((handle)>>16)
  58 
  59 /*
  60  * VENDOR_HANDLE turns a global library handle into a vendor specific handle,
  61  * with all upper 16 bits set to 0
  62  */
  63 #define VENDOR_HANDLE(handle)   ((handle)&0xFFFF)
  64 
  65 #define HBA_HANDLE_FROM_LOCAL(library, vendor) \
  66                                 (((library)<<16) | ((vendor)&0x0000FFFF))
  67 


 954     /* this will unlock them as well, but who cares */
 955     pthread_mutex_destroy(&_hbaapi_LE_mutex);
 956     pthread_mutex_destroy(&_hbaapi_TE_mutex);
 957     pthread_mutex_destroy(&_hbaapi_APSE_mutex);
 958     pthread_mutex_destroy(&_hbaapi_APE_mutex);
 959     pthread_mutex_destroy(&_hbaapi_AE_mutex);
 960     pthread_mutex_destroy(&_hbaapi_AAE_mutex);
 961     pthread_mutex_destroy(&_hbaapi_AL_mutex);
 962     pthread_mutex_destroy(&_hbaapi_LL_mutex);
 963 #elif defined(WIN32)
 964     DeleteCriticalSection(&_hbaapi_LL_mutex);
 965     DeleteCriticalSection(&_hbaapi_AL_mutex);
 966     DeleteCriticalSection(&_hbaapi_AAE_mutex);
 967     DeleteCriticalSection(&_hbaapi_AE_mutex);
 968     DeleteCriticalSection(&_hbaapi_APE_mutex);
 969     DeleteCriticalSection(&_hbaapi_APSE_mutex);
 970     DeleteCriticalSection(&_hbaapi_TE_mutex);
 971     DeleteCriticalSection(&_hbaapi_LE_mutex);
 972 #endif
 973 
 974     return (Sun_HBA_FreeLibrary());
 975 }
 976 
 977 /*
 978  * The API used to use fixed size tables as its primary data structure.
 979  * Indexing from 1 to N identified each adapters.  Now the adapters are
 980  * on a linked list.  There is a unique "index" foreach each adapter.
 981  * Adapters always keep their index, even if they are removed from the
 982  * hardware.  The only time the indexing is reset is on HBA_FreeLibrary
 983  */
 984 HBA_UINT32
 985 HBA_GetNumberOfAdapters(void) {
 986     int j=0;
 987     HBA_LIBRARY_INFO    *lib_infop;
 988     HBAGetNumberOfAdaptersFunc
 989                         GetNumberOfAdaptersFunc;
 990     HBAGetAdapterNameFunc
 991                         GetAdapterNameFunc;
 992     HBA_BOOLEAN         found_name;
 993     HBA_ADAPTER_INFO    *adapt_infop;
 994     HBA_STATUS          status;