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