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

Commite04a805

Browse files
committed
Simplify declaring variables exported from libpgcommon and libpgport.
This reverts commitsc2d1eea and11b5000, as well as similar hackselsewhere, in favor of setting up the PGDLLIMPORT macro so that it canjust be used unconditionally. That can work because in frontend code,we need no marking in either the defining or consuming files for avariable exported from these libraries; and frontend code has no needto access variables exported from the core backend, either.While at it, write some actual documentation about the PGDLLIMPORTand PGDLLEXPORT macros.Patch by me, based on a suggestion from Robert Haas.Discussion:https://postgr.es/m/1160385.1638165449@sss.pgh.pa.us
1 parent11b5000 commite04a805

File tree

6 files changed

+33
-21
lines changed

6 files changed

+33
-21
lines changed

‎src/include/c.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,10 +1312,22 @@ extern long long strtoll(const char *str, char **endptr, int base);
13121312
externunsigned long longstrtoull(constchar*str,char**endptr,intbase);
13131313
#endif
13141314

1315-
/* no special DLL markers on most ports */
1315+
/*
1316+
* Use "extern PGDLLIMPORT ..." to declare variables that are defined
1317+
* in the core backend and need to be accessible by loadable modules.
1318+
* No special marking is required on most ports.
1319+
*/
13161320
#ifndefPGDLLIMPORT
13171321
#definePGDLLIMPORT
13181322
#endif
1323+
1324+
/*
1325+
* Use "extern PGDLLEXPORT ..." to declare functions that are defined in
1326+
* loadable modules and need to be callable by the core backend. (Usually,
1327+
* this is not necessary because our build process automatically exports
1328+
* such symbols, but sometimes manual marking is required.)
1329+
* No special marking is required on most ports.
1330+
*/
13191331
#ifndefPGDLLEXPORT
13201332
#definePGDLLEXPORT
13211333
#endif

‎src/include/common/keywords.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@
2222
#defineTYPE_FUNC_NAME_KEYWORD2
2323
#defineRESERVED_KEYWORD3
2424

25-
#ifndefFRONTEND
2625
externPGDLLIMPORTconstScanKeywordListScanKeywords;
2726
externPGDLLIMPORTconstuint8ScanKeywordCategories[];
2827
externPGDLLIMPORTconstboolScanKeywordBareLabel[];
29-
#else
30-
externconstScanKeywordListScanKeywords;
31-
externconstuint8ScanKeywordCategories[];
32-
externconstboolScanKeywordBareLabel[];
33-
#endif
3428

3529
#endif/* KEYWORDS_H */

‎src/include/common/pg_prng.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ typedef struct pg_prng_state
2626
* Callers not needing local PRNG series may use this global state vector,
2727
* after initializing it with one of the pg_prng_...seed functions.
2828
*/
29-
#ifndefFRONTEND
3029
externPGDLLIMPORTpg_prng_statepg_global_prng_state;
31-
#else
32-
externpg_prng_statepg_global_prng_state;
33-
#endif
3430

3531
externvoidpg_prng_seed(pg_prng_state*state,uint64seed);
3632
externvoidpg_prng_fseed(pg_prng_state*state,doublefseed);

‎src/include/port/cygwin.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
/* src/include/port/cygwin.h */
22

3+
/*
4+
* Variables declared in the core backend and referenced by loadable
5+
* modules need to be marked "dllimport" in the core build, but
6+
* "dllexport" when the declaration is read in a loadable module.
7+
* No special markings should be used when compiling frontend code.
8+
*/
9+
#ifndefFRONTEND
310
#ifdefBUILDING_DLL
411
#definePGDLLIMPORT __declspec (dllexport)
512
#else
613
#definePGDLLIMPORT __declspec (dllimport)
714
#endif
8-
9-
#definePGDLLEXPORT
15+
#endif
1016

1117
/*
1218
* Cygwin has a strtof() which is literally just (float)strtod(), which means

‎src/include/port/pg_bitutils.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313
#ifndefPG_BITUTILS_H
1414
#definePG_BITUTILS_H
1515

16-
#ifndefFRONTEND
1716
externPGDLLIMPORTconstuint8pg_leftmost_one_pos[256];
1817
externPGDLLIMPORTconstuint8pg_rightmost_one_pos[256];
1918
externPGDLLIMPORTconstuint8pg_number_of_ones[256];
20-
#else
21-
externconstuint8pg_leftmost_one_pos[256];
22-
externconstuint8pg_rightmost_one_pos[256];
23-
externconstuint8pg_number_of_ones[256];
24-
#endif
2519

2620
/*
2721
* pg_leftmost_one_pos32

‎src/include/port/win32.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,26 @@
4545
* defines for dynamic linking on Win32 platform
4646
*/
4747

48+
/*
49+
* Variables declared in the core backend and referenced by loadable
50+
* modules need to be marked "dllimport" in the core build, but
51+
* "dllexport" when the declaration is read in a loadable module.
52+
* No special markings should be used when compiling frontend code.
53+
*/
54+
#ifndefFRONTEND
4855
#ifdefBUILDING_DLL
4956
#definePGDLLIMPORT __declspec (dllexport)
5057
#else
5158
#definePGDLLIMPORT __declspec (dllimport)
5259
#endif
60+
#endif
5361

62+
/*
63+
* Under MSVC, functions exported by a loadable module must be marked
64+
* "dllexport". Other compilers don't need that.
65+
*/
5466
#ifdef_MSC_VER
5567
#definePGDLLEXPORT __declspec (dllexport)
56-
#else
57-
#definePGDLLEXPORT
5868
#endif
5969

6070
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp