os/ossrv/genericopenlibs/openenvcore/libdl/src/libdl.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Name        : libdl.cpp
    15 // Part of     : libdl library
    16 // Dll entry point functions
    17 //
    18 
    19 
    20 
    21 
    22 // INCLUDE FILES
    23 #include <dlfcn.h>  //RTLD_DEFAULT
    24 #include "libdl_r.h"  //_r functions 
    25 
    26 
    27 
    28 // EXTERNAL FUNCTION PROTOTYPES
    29 
    30 
    31 //-----------------------------------------------------------------------------
    32 //Function Name : void* dlopen(const char* filename, int flag)
    33 //Description   : It takes the filename of the dynamic library to be loaded. 
    34 //				  The dynamic library is loaded and a "handle" to this executable
    35 //				  is returned to the caller.
    36 //Return Value  : valid handle if succesful otherwise NULL and an error message
    37 //				  is logged. The user can retrieve the error message through a 
    38 //				  call to dlerror()
    39 //-----------------------------------------------------------------------------
    40 EXPORT_C void* dlopen(const char* filename, int flag)
    41 	{
    42 	if ( !filename )
    43 		{
    44 		return RTLD_DEFAULT;
    45 		}
    46 	return __dlopen_r(filename, flag);;
    47 	}
    48 
    49 //-----------------------------------------------------------------------------
    50 //Function Name : void* dlsym(void* handle, const char* symbol)
    51 //Description   : It takes the handle (as returned by dlopen or RTLD_DEFAULT/
    52 //				  RTLD_NEXT/RTLD_SELF) and the NULL terminated string for symbol
    53 //				  name or the ordinal number. It locates the symbol corresponding
    54 //				  to this name or ordinal number.
    55 //Return Value  : Symbols address address if the symbol name or ordinal number 
    56 //				  is found, otherwise NULL is returned and an error message is
    57 //				  logged. The user can retrieve the error message through a call
    58 //				  to dlerror().
    59 //-----------------------------------------------------------------------------
    60 EXPORT_C void* dlsym(void* handle, const char* symbol)
    61 	{
    62 	return __dlsym_r(handle, symbol);
    63 	}	
    64 
    65 //-----------------------------------------------------------------------------
    66 //Function Name : char* dlerror(void)
    67 //Description   : Gives the last error that occurred due to any of the dl 
    68 //				  operations.
    69 //Return Value  : a NULL-terminated character string that gives the last error 
    70 //				  that occurred due to any of the dl operations. If no errors 
    71 //				  have occurred since the last call to dlerror(), dlerror() 
    72 //				  returns NULL.
    73 //-----------------------------------------------------------------------------
    74 EXPORT_C char* dlerror(void)
    75 	{
    76 	return (char*) __dlerror_r();
    77 	}
    78 
    79 
    80 //-----------------------------------------------------------------------------
    81 //Function Name : int dlclose(void* handle)
    82 //Description   : Decrements the reference count corresponding to the handle.
    83 //				  If refrence count becomes zero library is unloaded.
    84 //Return Value  : 0 on success otherwise non zero value
    85 //-----------------------------------------------------------------------------
    86 EXPORT_C int dlclose(void* handle)
    87 	{
    88 	return __dlclose_r(handle);
    89 	}
    90