Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ HINSTANCE g_thisModule;

extern VOID STDMETHODCALLTYPE TLS_FreeMasterSlotIndex();

DLLEXPORT
EXTERN_C BOOL WINAPI
DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
#if FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
EXTERN_C BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
{
static bool g_procInitialized = false;

Expand Down
6 changes: 4 additions & 2 deletions src/dlls/mscordbi/mscordbi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ extern BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
// The main dll entry point for this module. This routine is called by the
// OS when the dll gets loaded. Control is simply deferred to the main code.
//*****************************************************************************
DLLEXPORT extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Defer to the main debugging code.
return DbgDllMain(hInstance, dwReason, lpReserved);
Expand Down
13 changes: 9 additions & 4 deletions src/dlls/mscoree/mscoree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ extern "C" IExecutionEngine* IEE();
extern "C" BOOL WINAPI _CRT_INIT(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
#endif

extern "C" DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);
extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved);

// For the CoreClr, this is the real DLL entrypoint. We make ourselves the first entrypoint as
// we need to capture coreclr's hInstance before the C runtime initializes. This function
// will capture hInstance, let the C runtime initialize and then invoke the "classic"
// DllMain that initializes everything else.
extern "C" DLLEXPORT BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
{
STATIC_CONTRACT_NOTHROW;

Expand Down Expand Up @@ -115,8 +118,10 @@ extern "C" DLLEXPORT BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, L
return result;
}

extern "C"
DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
{
STATIC_CONTRACT_NOTHROW;

Expand Down
14 changes: 1 addition & 13 deletions src/dlls/mscoree/mscorwks_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CoreDllMain
DllMain
GetCLRRuntimeHost

; Win32 API and other PAL functions used by the mscorlib
; Win32 API and other PAL functions used by the System.Private.CoreLib
CloseHandle
CoTaskMemAlloc
CoTaskMemRealloc
Expand All @@ -31,29 +31,23 @@ CreateMutexW
CreateMutexExW
CreateSemaphoreW
CreateSemaphoreExW
DuplicateHandle
FormatMessageW
FreeEnvironmentStringsW
GetACP
GetCurrentProcessId
GetCurrentThreadId
GetEnvironmentStringsW
GetEnvironmentVariableW
GetProcAddress
GetStdHandle
GetSystemInfo
LocalAlloc
LocalReAlloc
LocalFree
MetaDataGetDispenser
MultiByteToWideChar
OpenEventW
OpenMutexW
OpenSemaphoreW
OutputDebugStringW
QueryPerformanceCounter
QueryPerformanceFrequency
RaiseException
ReleaseMutex
ReleaseSemaphore
ResetEvent
Expand All @@ -62,11 +56,5 @@ SetEvent
SysAllocStringByteLen
SysAllocStringLen
SysFreeString
SysStringByteLen
SysStringLen
VirtualAlloc
VirtualFree
GlobalMemoryStatusEx
VirtualQuery
WideCharToMultiByte
WriteFile
50 changes: 0 additions & 50 deletions src/inc/cortpoolhdr.h

This file was deleted.

7 changes: 4 additions & 3 deletions src/inc/crtwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#include <wchar.h>
#include <stdio.h>

#ifndef DLLEXPORT
// DLLEXPORT is defined to influence method visibility for some compilers.
#ifndef FEATURE_PAL
// CoreCLR.dll uses linker .def files to control the exported symbols.
// Define DLLEXPORT macro as empty on Windows.
#define DLLEXPORT
#endif // !DLLEXPORT
#endif

#endif // __CrtWrap_h__
6 changes: 5 additions & 1 deletion src/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ void jitShutdown(bool processIsTerminating)

#ifndef FEATURE_MERGE_JIT_AND_ENGINE

extern "C" DLLEXPORT BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved)
#ifdef FEATURE_PAL
DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
extern "C" BOOL WINAPI
DllMain(HANDLE hInstance, DWORD dwReason, LPVOID pvReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
Expand Down
14 changes: 8 additions & 6 deletions src/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -4314,6 +4314,7 @@ See MSDN doc for memcpy
--*/
EXTERN_C
PALIMPORT
DLLEXPORT
void *PAL_memcpy (void *dest, const void *src, size_t count);

PALIMPORT void * __cdecl memcpy(void *, const void *, size_t) THROW_DECL;
Expand Down Expand Up @@ -4600,13 +4601,14 @@ PALIMPORT char * __cdecl _strdup(const char *);
PALIMPORT PAL_NORETURN void __cdecl exit(int);
int __cdecl atexit(void (__cdecl *function)(void));

PALIMPORT DLLEXPORT void __cdecl qsort(void *, size_t, size_t, int (__cdecl *)(const void *, const void *));
PALIMPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
int (__cdecl *)(const void *, const void *));

PALIMPORT char * __cdecl _fullpath(char *, const char *, size_t);

#ifndef PAL_STDCPP_COMPAT

PALIMPORT DLLEXPORT void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *));
PALIMPORT DLLEXPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
Copy link
Member

@am11 am11 Feb 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be PALIMPORT PALAPI <retunType> bsearch/qsort/getenv/_putenv(.., as PALAPI is defined as DLLEXPORT __cdecl?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern used to export C-runtime APIs is PALIMPORT DLLEXPORT, so I kept this one for consistency.

C-runtime APIs were not PALAPIs originally when we had a thin (just forwarders) PAL layer for Windows as well. On Windows, the C-runtime APIs were cdecl, but PALAPIs were stdcall.

int(__cdecl *)(const void *, const void *));

PALIMPORT time_t __cdecl time(time_t *);

struct tm {
Expand Down Expand Up @@ -4725,8 +4727,8 @@ PALIMPORT DLLEXPORT int * __cdecl PAL_errno(int caller);
#define errno (*PAL_errno(PAL_get_caller))
#endif // PAL_STDCPP_COMPAT

PALIMPORT char * __cdecl getenv(const char *);
PALIMPORT int __cdecl _putenv(const char *);
PALIMPORT DLLEXPORT char * __cdecl getenv(const char *);
PALIMPORT DLLEXPORT int __cdecl _putenv(const char *);

#define ERANGE 34

Expand Down
14 changes: 7 additions & 7 deletions src/pal/inc/rt/palrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ typedef union _ULARGE_INTEGER {

/******************* OLE, BSTR, VARIANT *************************/

STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb);
STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb);
STDAPI_(void) CoTaskMemFree(LPVOID pv);
DLLEXPORT STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb);
DLLEXPORT STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb);
DLLEXPORT STDAPI_(void) CoTaskMemFree(LPVOID pv);

typedef SHORT VARIANT_BOOL;
#define VARIANT_TRUE ((VARIANT_BOOL)-1)
Expand All @@ -386,11 +386,11 @@ typedef const OLECHAR* LPCOLESTR;

typedef WCHAR *BSTR;

STDAPI_(BSTR) SysAllocString(const OLECHAR*);
STDAPI_(BSTR) SysAllocStringLen(const OLECHAR*, UINT);
DLLEXPORT STDAPI_(BSTR) SysAllocString(const OLECHAR*);
DLLEXPORT STDAPI_(BSTR) SysAllocStringLen(const OLECHAR*, UINT);
DLLEXPORT STDAPI_(BSTR) SysAllocStringByteLen(const char *, UINT);
STDAPI_(void) SysFreeString(BSTR);
STDAPI_(UINT) SysStringLen(BSTR);
DLLEXPORT STDAPI_(void) SysFreeString(BSTR);
DLLEXPORT STDAPI_(UINT) SysStringLen(BSTR);
DLLEXPORT STDAPI_(UINT) SysStringByteLen(BSTR);

typedef double DATE;
Expand Down
2 changes: 0 additions & 2 deletions src/pal/src/cruntime/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ PAL_qsort(void *base, size_t nmemb, size_t size,
PERF_EXIT(qsort);
}

DLLEXPORT
PALIMPORT
void * __cdecl
PAL_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
Expand Down Expand Up @@ -299,7 +298,6 @@ PAL_memcpy
Overlapping buffer-safe version of memcpy.
See MSDN doc for memcpy
--*/
DLLEXPORT
EXTERN_C
PALIMPORT
void *PAL_memcpy (void *dest, const void *src, size_t count)
Expand Down
3 changes: 1 addition & 2 deletions src/pal/src/misc/environ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,6 @@ See MSDN for more details.
Note: The BSD implementation can cause
memory leaks. See man pages for more details.
--*/
DLLEXPORT
int
__cdecl
_putenv( const char * envstring )
Expand Down Expand Up @@ -1080,7 +1079,7 @@ Function : PAL_getenv

See MSDN for more details.
--*/
DLLEXPORT char * __cdecl PAL_getenv(const char *varname)
char * __cdecl PAL_getenv(const char *varname)
{
char *retval;

Expand Down
6 changes: 3 additions & 3 deletions src/palrt/bstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ inline HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result)
* return value = BSTR, NULL if the allocation failed.
*
***********************************************************************/
DLLEXPORT STDAPI_(BSTR) SysAllocStringLen(const OLECHAR *psz, UINT len)
STDAPI_(BSTR) SysAllocStringLen(const OLECHAR *psz, UINT len)
{

BSTR bstr;
Expand Down Expand Up @@ -168,7 +168,7 @@ SysAllocStringByteLen(const char FAR* psz, unsigned int len)
* None
*
***********************************************************************/
DLLEXPORT STDAPI_(void) SysFreeString(BSTR bstr)
STDAPI_(void) SysFreeString(BSTR bstr)
{
if(bstr == NULL)
return;
Expand All @@ -187,7 +187,7 @@ DLLEXPORT STDAPI_(void) SysFreeString(BSTR bstr)
* return value = unsigned int, length in characters.
*
***********************************************************************/
DLLEXPORT STDAPI_(unsigned int)
STDAPI_(unsigned int)
SysStringLen(BSTR bstr)
{
if(bstr == NULL)
Expand Down
6 changes: 3 additions & 3 deletions src/palrt/comem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

#include "common.h"

DLLEXPORT STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb)
STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb)
{
return LocalAlloc(LMEM_FIXED, cb);
}

DLLEXPORT STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb)
STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb)
{
return LocalReAlloc(pv, cb, LMEM_MOVEABLE);
}

DLLEXPORT STDAPI_(void) CoTaskMemFree(LPVOID pv)
STDAPI_(void) CoTaskMemFree(LPVOID pv)
{
LocalFree(pv);
}
2 changes: 1 addition & 1 deletion src/vm/appdomain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ class PEFileListLock : public ListLock
pThis->Enter();
}

DLLEXPORT DEBUG_NOINLINE static void HolderLeave(PEFileListLock *pThis)
DEBUG_NOINLINE static void HolderLeave(PEFileListLock *pThis)
{
WRAPPER_NO_CONTRACT;
ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
Expand Down
6 changes: 3 additions & 3 deletions src/vm/crst.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ friend class Crst;
c->Enter();
}

DLLEXPORT DEBUG_NOINLINE static void ReleaseLock(CrstBase *c) {
DEBUG_NOINLINE static void ReleaseLock(CrstBase *c) {
WRAPPER_NO_CONTRACT;
ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
c->Leave();
Expand All @@ -202,7 +202,7 @@ friend class Crst;
// Argument:
// input: c - the lock to be checked.
// Note: Throws
DLLEXPORT static void AcquireLock(CrstBase * c)
static void AcquireLock(CrstBase * c)
{
SUPPORTS_DAC;
if (c->GetEnterCount() != 0)
Expand All @@ -211,7 +211,7 @@ friend class Crst;
}
};

DLLEXPORT static void ReleaseLock(CrstBase *c)
static void ReleaseLock(CrstBase *c)
{
SUPPORTS_DAC;
};
Expand Down
4 changes: 2 additions & 2 deletions src/vm/listlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ class ListLockEntryBase

// LockHolder holds the lock of the element, not the element itself

DLLEXPORT DEBUG_NOINLINE static void LockHolderEnter(Entry_t *pThis)
DEBUG_NOINLINE static void LockHolderEnter(Entry_t *pThis)
{
WRAPPER_NO_CONTRACT;
ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
pThis->Enter();
}

DLLEXPORT DEBUG_NOINLINE static void LockHolderLeave(Entry_t *pThis)
DEBUG_NOINLINE static void LockHolderLeave(Entry_t *pThis)
{
WRAPPER_NO_CONTRACT;
ANNOTATION_SPECIAL_HOLDER_CALLER_NEEDS_DYNAMIC_CONTRACT;
Expand Down