You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/08 13:48:57 UTC
svn commit: r763196 -
/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
Author: mturk
Date: Wed Apr 8 11:48:56 2009
New Revision: 763196
URL: http://svn.apache.org/viewvc?rev=763196&view=rev
Log:
Use APR late dll macros and extend them with defalt return value
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=763196&r1=763195&r2=763196&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Wed Apr 8 11:48:56 2009
@@ -48,12 +48,14 @@
JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_platform_windows_##CL##_##FN
typedef enum {
- SYSDLL_KERNEL32 = 0, // kernel32 From WinBase.h
- SYSDLL_NTDLL = 1, // ntdll From our real kernel
- SYSDLL_USER32 = 2, // user32 From WinUser.h
- SYSDLL_IPHLPAPI = 3, // iphlpapi From Iphlpapi.h
- SYSDLL_JVM = 4, // jvm From our own jvm.dll
- SYSDLL_defined = 5 // must define as last idx_ + 1
+ SYSDLL_KERNEL32 = 0, // kernel32 From WinBase.h
+ SYSDLL_NTDLL = 1, // ntdll From our real kernel
+ SYSDLL_USER32 = 2, // user32 From WinUser.h
+ SYSDLL_IPHLPAPI = 3, // iphlpapi From Iphlpapi.h
+ SYSDLL_WINSOCKAPI = 4, // mswsock From WinSock.h
+ SYSDLL_WINSOCK2API = 5, // ws2_32 From WinSock2.h
+ SYSDLL_JVM = 6, // jvm From our own jvm.dll
+ SYSDLL_defined = 6 // must define as last idx_ + 1
} acr_dlltoken_e;
/* Copied from http://source.winehq.org/source/include/winternl.h */
@@ -193,33 +195,44 @@
/* The acr_load_dll_func call WILL return def if the function cannot be loaded */
-#define ACR_DECLARE_LATE_DLL_FUNC(lib, rettype, def, \
- calltype, fn, ord, args, names) \
- typedef rettype (calltype *acr_late_fpt_##fn) args; \
- static acr_late_fpt_##fn acr_late_pfn_##fn = NULL; \
- static APR_INLINE rettype acr_late_##fn args \
- { if (!acr_late_pfn_##fn) \
- acr_late_pfn_##fn = (acr_late_fpt_##fn) \
+#define ACR_DECLARE_LATE_DLL_FUNC(lib, rettype, def, calltype, \
+ fn, ord, args, names) \
+ typedef rettype (calltype *acr_winapi_fpt_##fn) args; \
+ static acr_winapi_fpt_##fn acr_winapi_pfn_##fn = NULL; \
+ static int acr_winapi_chk_##fn = 0; \
+ static __inline int acr_winapi_ld_##fn() \
+ { if (acr_winapi_pfn_##fn) return 1; \
+ if (acr_winapi_chk_##fn ++) return 0; \
+ if (!acr_winapi_pfn_##fn) \
+ acr_winapi_pfn_##fn = (acr_winapi_fpt_##fn) \
acr_load_dll_func(lib, #fn, ord); \
- if (acr_late_pfn_##fn) \
- return (*(acr_late_pfn_##fn)) names; \
- else return def; } //
-
-#define ACR_DECLARE_LATE_DLL_CALL(lib, rettype, \
- calltype, fn, fnx, ord, args, names) \
- typedef rettype (calltype *acr_late_fpt_##fn) args; \
- static acr_late_fpt_##fn acr_late_pfn_##fn = NULL; \
- static APR_INLINE rettype acr_late_##fn args \
- { if (!acr_late_pfn_##fn) \
- acr_late_pfn_##fn = (acr_late_fpt_##fn) \
+ if (acr_winapi_pfn_##fn) return 1; else return 0; }; \
+ static __inline rettype acr_winapi_##fn args \
+ { if (acr_winapi_ld_##fn()) \
+ return (*(acr_winapi_pfn_##fn)) names; \
+ else { SetLastError(ERROR_INVALID_FUNCTION); return def;} \
+ } //
+
+#define ACR_DECLARE_LATE_DLL_VOID(lib, def, calltype, \
+ fn, ord, args, names) \
+ typedef void (calltype *acr_winapi_fpt_##fn) args; \
+ static acr_winapi_fpt_##fn acr_winapi_pfn_##fn = NULL; \
+ static int acr_winapi_chk_##fn = 0; \
+ static __inline int acr_winapi_ld_##fn() \
+ { if (acr_winapi_pfn_##fn) return 1; \
+ if (acr_winapi_chk_##fn ++) return 0; \
+ if (!acr_winapi_pfn_##fn) \
+ acr_winapi_pfn_##fn = (acr_winapi_fpt_##fn) \
acr_load_dll_func(lib, #fn, ord); \
- if (!acr_late_pfn_##fn) \
- acr_late_pfn_##fn = (acr_late_fpt_##fn) \
- acr_load_dll_func(lib, #fnx, ord); \
- if (acr_late_pfn_##fn) \
- (*(acr_late_pfn_##fn)) names; \
+ if (acr_winapi_pfn_##fn) return 1; else return 0; }; \
+ static __inline void acr_winapi_##fn args \
+ { if (acr_winapi_ld_##fn()) \
+ (*(acr_winapi_pfn_##fn)) names; \
+ else { SetLastError(ERROR_INVALID_FUNCTION); } \
} //
+#define ACR_HAVE_LATE_DLL_FUNC(fn) acr_winapi_ld_##fn()
+
#ifdef ACR_WANT_LATE_DLL
@@ -230,7 +243,7 @@
OUT LPFILETIME lpUserTime),
(lpIdleTime, lpKernelTime, lpUserTime));
#undef GetSystemTimes
-#define GetSystemTimes acr_late_GetSystemTimes
+#define GetSystemTimes acr_winapi_GetSystemTimes
ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_KERNEL32, BOOL, FALSE,
WINAPI, IsWow64Process, 0, (
@@ -238,7 +251,7 @@
OUT PBOOL Wow64Process),
(hProcess, Wow64Process));
#undef IsWow64Process
-#define IsWow64Process acr_late_IsWow64Process
+#define IsWow64Process acr_winapi_IsWow64Process
ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_NTDLL, NTSTATUS, 1,
WINAPI, NtQuerySystemInformation, 0, (
@@ -248,7 +261,7 @@
OUT PULONG ReturnLength),
(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength));
#undef NtQuerySystemInformation
-#define NtQuerySystemInformation acr_late_NtQuerySystemInformation
+#define NtQuerySystemInformation acr_winapi_NtQuerySystemInformation
ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_NTDLL, NTSTATUS, 1,
WINAPI, NtQueryInformationProcess, 0, (
@@ -259,7 +272,7 @@
OUT PULONG ReturnLength),
(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength));
#undef NtQueryInformationProcess
-#define NtQueryInformationProcess acr_late_NtQueryInformationProcess
+#define NtQueryInformationProcess acr_winapi_NtQueryInformationProcess
ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_KERNEL32, BOOL, FALSE,
WINAPI, GetPerformanceInfo, 0, (
@@ -267,7 +280,7 @@
DWORD cb),
(pPerformanceInformation, cb));
#undef GetPerformanceInfo
-#define GetPerformanceInfo acr_late_GetPerformanceInfo
+#define GetPerformanceInfo acr_winapi_GetPerformanceInfo
ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_IPHLPAPI, DWORD, ERROR_INVALID_FUNCTION,
WINAPI, GetExtendedTcpTable, 0, (
@@ -279,7 +292,7 @@
ULONG Reserved),
(pTcpTable, pdwSize, bOrder, ulAf, TableClass, Reserved));
#undef GetExtendedTcpTable
-#define GetExtendedTcpTable acr_late_GetExtendedTcpTable
+#define GetExtendedTcpTable acr_winapi_GetExtendedTcpTable
ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_IPHLPAPI, DWORD, ERROR_INVALID_FUNCTION,
WINAPI, GetExtendedUdpTable, 0, (
@@ -291,16 +304,63 @@
ULONG Reserved),
(pUdpTable, pdwSize, bOrder, ulAf, TableClass, Reserved));
#undef GetExtendedUdpTable
-#define GetExtendedUdpTable acr_late_GetExtendedUdpTable
+#define GetExtendedUdpTable acr_winapi_GetExtendedUdpTable
+
+#if !defined(POLLERR)
+/* Event flag definitions for WSAPoll(). */
+#define POLLRDNORM 0x0100
+#define POLLRDBAND 0x0200
+#define POLLIN (POLLRDNORM | POLLRDBAND)
+#define POLLPRI 0x0400
+
+#define POLLWRNORM 0x0010
+#define POLLOUT (POLLWRNORM)
+#define POLLWRBAND 0x0020
+
+#define POLLERR 0x0001
+#define POLLHUP 0x0002
+#define POLLNVAL 0x0004
+
+typedef struct pollfd {
+ SOCKET fd;
+ SHORT events;
+ SHORT revents;
+
+} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD;
+
+#endif /* !defined(POLLERR) */
+#ifdef WSAPoll
+#undef WSAPoll
+#endif
+ACR_DECLARE_LATE_DLL_FUNC(SYSDLL_IPHLPAPI, DWORD, ERROR_INVALID_FUNCTION,
+ WINAPI, GetExtendedUdpTable, 0, (
+
+APR_DECLARE_LATE_DLL_FUNC(SYSDLL_WINSOCK2API, int, ERROR_INVALID_FUNCTION,
+ WSAAPI, WSAPoll, 0, (
+ IN OUT LPWSAPOLLFD fdArray,
+ IN ULONG fds,
+ IN INT timeout),
+ (fdArray, fds, timeout));
+#define WSAPoll acr_winapi_WSAPoll
+#define HAVE_POLL 1
+
+#ifdef SetDllDirectoryW
+#undef SetDllDirectoryW
+#endif
+APR_DECLARE_LATE_DLL_FUNC(SYSDLL_KERNEL32, BOOL, FALSE,
+ WINAPI, SetDllDirectoryW, 0, (
+ IN LPCWSTR lpPathName),
+ (lpPathName));
+#define SetDllDirectoryW acr_winapi_SetDllDirectoryW
ACR_DECLARE_LATE_DLL_CALL(SYSDLL_JVM, void, JNICALL,
JVM_DumpAllStacks,
- _JVM_DumpAllStacks@8, 0, (
+ _JVM_DumpAllStacks@8, 0, (
JNIEnv *lpEnv,
jclass jClazz),
(lpEnv, jClazz));
#undef JVM_DumpAllStacks
-#define JVM_DumpAllStacks acr_late_JVM_DumpAllStacks
+#define JVM_DumpAllStacks acr_winapi_JVM_DumpAllStacks
#undef ACR_WANT_LATE_DLL
#endif
Re: svn commit: r763196 - /commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
Posted by sebb <se...@gmail.com>.
On 08/04/2009, Mladen Turk <mt...@apache.org> wrote:
> sebb wrote:
>
> >
> > > + SYSDLL_JVM = 6, // jvm From our own jvm.dll
> > > + SYSDLL_defined = 6 // must define as last idx_ + 1
> > >
> >
> > Shouldn't that be 7 then? Or does the JVM value not count?
> >
> >
>
> Yes. Thanks for keeping an eye ;)
>
> However this is still in early stage of merging
> few existing code bases, so it'll take at least
> two weeks before someone should take a serious look ;)
Point taken, but it jumped out at me as a possible error so I thought
I'd record it in case it got forgotten.
> I could dump all at once, but then the cleanup
> would be needed, and this approach gives more
> sense to SVN log thought.
>
> Regards
> --
> ^(TM)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r763196 - /commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
Posted by Mladen Turk <mt...@apache.org>.
sebb wrote:
>> + SYSDLL_JVM = 6, // jvm From our own jvm.dll
>> + SYSDLL_defined = 6 // must define as last idx_ + 1
>
> Shouldn't that be 7 then? Or does the JVM value not count?
>
Yes. Thanks for keeping an eye ;)
However this is still in early stage of merging
few existing code bases, so it'll take at least
two weeks before someone should take a serious look ;)
I could dump all at once, but then the cleanup
would be needed, and this approach gives more
sense to SVN log thought.
Regards
--
^(TM)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r763196 - /commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
Posted by sebb <se...@gmail.com>.
On 08/04/2009, mturk@apache.org <mt...@apache.org> wrote:
> Author: mturk
> Date: Wed Apr 8 11:48:56 2009
> New Revision: 763196
>
> URL: http://svn.apache.org/viewvc?rev=763196&view=rev
> Log:
> Use APR late dll macros and extend them with defalt return value
>
> Modified:
> commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
>
> Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
> URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=763196&r1=763195&r2=763196&view=diff
> ==============================================================================
> --- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original)
> +++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Wed Apr 8 11:48:56 2009
> @@ -48,12 +48,14 @@
> JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_platform_windows_##CL##_##FN
>
> typedef enum {
> - SYSDLL_KERNEL32 = 0, // kernel32 From WinBase.h
> - SYSDLL_NTDLL = 1, // ntdll From our real kernel
> - SYSDLL_USER32 = 2, // user32 From WinUser.h
> - SYSDLL_IPHLPAPI = 3, // iphlpapi From Iphlpapi.h
> - SYSDLL_JVM = 4, // jvm From our own jvm.dll
> - SYSDLL_defined = 5 // must define as last idx_ + 1
> + SYSDLL_KERNEL32 = 0, // kernel32 From WinBase.h
> + SYSDLL_NTDLL = 1, // ntdll From our real kernel
> + SYSDLL_USER32 = 2, // user32 From WinUser.h
> + SYSDLL_IPHLPAPI = 3, // iphlpapi From Iphlpapi.h
> + SYSDLL_WINSOCKAPI = 4, // mswsock From WinSock.h
> + SYSDLL_WINSOCK2API = 5, // ws2_32 From WinSock2.h
> + SYSDLL_JVM = 6, // jvm From our own jvm.dll
> + SYSDLL_defined = 6 // must define as last idx_ + 1
Shouldn't that be 7 then? Or does the JVM value not count?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org