LCOV - code coverage report
Current view: directory - gcore - gdaldllmain.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 7 2 28.6 %
Date: 2012-12-26 Functions: 2 1 50.0 %

       1                 : /******************************************************************************
       2                 :  * $Id$
       3                 :  *
       4                 :  * Project:  GDAL Core
       5                 :  * Purpose:  The library set-up/clean-up routines.
       6                 :  * Author:   Mateusz Loskot <mateusz@loskot.net>
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2010, Mateusz Loskot <mateusz@loskot.net>
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #include "gdal.h"
      31                 : #include "ogr_api.h"
      32                 : #include "cpl_multiproc.h"
      33                 : 
      34                 : 
      35                 : /************************************************************************/
      36                 : /*  The library set-up/clean-up routines implemented with               */
      37                 : /*  GNU C/C++ extensions.                                               */
      38                 : /*  TODO: Is it Linux-only solution or Unix portable?                   */
      39                 : /************************************************************************/
      40                 : #ifdef __GNUC__
      41                 : 
      42                 : static void GDALInitialize(void) __attribute__ ((constructor)) ;
      43                 : static void GDALDestroy(void)    __attribute__ ((destructor)) ;
      44                 : 
      45                 : /************************************************************************/
      46                 : /* Called when GDAL is loaded by loader or by dlopen(),                 */
      47                 : /* and before dlopen() returns.                                         */
      48                 : /************************************************************************/
      49                 : 
      50             713 : static void GDALInitialize(void)
      51                 : {
      52                 :     // nothing to do
      53                 :     //CPLDebug("GDAL", "Library loaded");
      54             713 : }
      55                 : 
      56                 : /************************************************************************/
      57                 : /* Called when GDAL is unloaded by loader or by dlclose(),              */
      58                 : /* and before dlclose() returns.                                        */
      59                 : /************************************************************************/
      60                 : 
      61               0 : static void GDALDestroy(void)
      62                 : {
      63                 :     // TODO: Confirm if calling CPLCleanupTLS here is safe
      64                 :     //CPLCleanupTLS();
      65                 : 
      66               0 :     CPLDebug("GDAL", "In GDALDestroy - unloading GDAL shared library.");
      67               0 :     GDALDestroyDriverManager();
      68                 : 
      69                 : #ifdef OGR_ENABLED
      70               0 :     OGRCleanupAll();
      71                 : #endif
      72               0 : }
      73                 : 
      74                 : #endif // __GNUC__
      75                 : 
      76                 : 
      77                 : /************************************************************************/
      78                 : /*  The library set-up/clean-up routine implemented as DllMain entry    */
      79                 : /*  point specific for Windows.                                         */
      80                 : /************************************************************************/
      81                 : #ifdef _MSC_VER
      82                 : 
      83                 : #include <windows.h>
      84                 : 
      85                 : extern "C" int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
      86                 : {
      87                 :     UNREFERENCED_PARAMETER(hInstance);
      88                 :     UNREFERENCED_PARAMETER(lpReserved);
      89                 : 
      90                 :     if (dwReason == DLL_PROCESS_ATTACH)
      91                 :     {
      92                 :         // nothing to do
      93                 :     }
      94                 :     else if (dwReason == DLL_THREAD_ATTACH)
      95                 :     {
      96                 :         // nothing to do
      97                 :     }
      98                 :     else if (dwReason == DLL_THREAD_DETACH)
      99                 :     {
     100                 :         ::CPLCleanupTLS();
     101                 :     }
     102                 :     else if (dwReason == DLL_PROCESS_DETACH)
     103                 :     {
     104                 :         ::GDALDestroyDriverManager();
     105                 : 
     106                 : #ifdef OGR_ENABLED
     107                 :         ::OGRCleanupAll();
     108                 : #endif
     109                 :     }
     110                 : 
     111                 :   return 1; // ignroed for all reasons but DLL_PROCESS_ATTACH
     112                 : }
     113                 : 
     114                 : #endif // _MSC_VER
     115                 : 

Generated by: LCOV version 1.7