Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit811be89

Browse files
committed
Add compat file for dynamically loading the functions that MinGW is missing
the imports for. Add RegisterWaitForSingleObject() to the list of suchfunctions, which should take care of the current buildfarm breakage.
1 parent6f14eff commit811be89

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

‎src/backend/port/win32/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for backend/port/win32
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/port/win32/Makefile,v 1.10 2007/03/21 14:39:23 mha Exp $
7+
# $PostgreSQL: pgsql/src/backend/port/win32/Makefile,v 1.11 2007/10/29 12:35:41 mha Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/port/win32
1212
top_builddir = ../../../..
1313
include$(top_builddir)/src/Makefile.global
1414

15-
OBJS = timer.o socket.o signal.o security.o
15+
OBJS = timer.o socket.o signal.o security.o mingwcompat.o
1616

1717
all: SUBSYS.o
1818

‎src/backend/port/win32/mingwcompat.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* mingwcompat.c
4+
* MinGW compatibility functions
5+
*
6+
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
7+
*
8+
* IDENTIFICATION
9+
* $PostgreSQL: pgsql/src/backend/port/win32/mingwcompat.c,v 1.1 2007/10/29 12:35:41 mha Exp $
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
14+
#include"postgres.h"
15+
16+
/*
17+
* This file contains loaders for functions that are missing in the MinGW
18+
* import libraries. It's only for actual Win32 API functions, so they are
19+
* all present in proper Win32 compilers.
20+
*/
21+
#ifndefWIN32_ONLY_COMPILER
22+
23+
staticHMODULEkernel32=NULL;
24+
25+
/*
26+
* Load DLL file just once regardless of how many functions
27+
* we load/call in it.
28+
*/
29+
staticvoid
30+
LoadKernel32()
31+
{
32+
if (kernel32!=NULL)
33+
return;
34+
35+
kernel32=LoadLibraryEx("kernel32.dll",NULL,0);
36+
if (kernel32==NULL)
37+
ereport(FATAL,
38+
(errmsg_internal("could not load kernel32.dll: %d",
39+
(int)GetLastError())));
40+
}
41+
42+
43+
/*
44+
* Replacement for RegisterWaitForSingleObject(), which lives in
45+
* kernel32.dll·
46+
*/
47+
typedefBOOL (WINAPI*__RegisterWaitForSingleObject)
48+
(PHANDLE,HANDLE,WAITORTIMERCALLBACK,PVOID,ULONG,ULONG);
49+
__RegisterWaitForSingleObject_RegisterWaitForSingleObject=NULL;
50+
51+
BOOLWINAPI
52+
RegisterWaitForSingleObject(PHANDLEphNewWaitObject,
53+
HANDLEhObject,
54+
WAITORTIMERCALLBACKCallback,
55+
PVOIDContext,
56+
ULONGdwMilliseconds,
57+
ULONGdwFlags)
58+
{
59+
if (_RegisterWaitForSingleObject==NULL)
60+
{
61+
LoadKernel32();
62+
63+
_RegisterWaitForSingleObject= (__RegisterWaitForSingleObject)
64+
GetProcAddress(kernel32,"RegisterWaitForSingleObject");
65+
66+
if (_RegisterWaitForSingleObject==NULL)
67+
ereport(FATAL,
68+
(errmsg_internal("could not locate RegisterWaitForSingleObject in kernel32.dll: %d",
69+
(int)GetLastError())));
70+
}
71+
72+
return (_RegisterWaitForSingleObject)
73+
(phNewWaitObject,hObject,Callback,Context,dwMilliseconds,dwFlags);
74+
}
75+
76+
#endif
77+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp