Skip to content

Commit

Permalink
For consistency, replace some existing extern "C" with __PTW32_* macros
Browse files Browse the repository at this point in the history
used elsewhere.
  • Loading branch information
rocso committed Aug 11, 2018
1 parent 12b7a1d commit 5af3810
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
2018-08-10 Ross Johnson <ross dot johnson at homemail dot com dot au>

* Makefile (clean): remove *.idb files.
* dll.c: replace 'extern "C"' with macros __PTW32_BEGIN_C_DECLS/__PTW32_BEGIN_C_DECLS
for consistency tidy-up; add comment re __ptw32_autostatic_anchor() function.
* implement.h (__ptw32_autostatic_anchor): add __PTW32_BEGIN_C_DECLS/__PTW32_BEGIN_C_DECLS
envelope.

2018-08-08 Ross Johnson <ross dot johnson at homemail dot com dot au>

Expand Down
20 changes: 13 additions & 7 deletions dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@
#pragma warning( disable : 4100 )
#endif

#if defined(__cplusplus)
/*
* Dear c++: Please don't mangle this name. -thanks
*/
extern "C"
#endif /* __cplusplus */
BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
__PTW32_BEGIN_C_DECLS

BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
{
BOOL result = __PTW32_TRUE;

Expand Down Expand Up @@ -90,6 +86,8 @@ extern "C"

} /* DllMain */

__PTW32_END_C_DECLS

#endif /* !PTW32_STATIC_LIB */

#if ! defined (__PTW32_BUILD_INLINED)
Expand Down Expand Up @@ -157,11 +155,19 @@ static int (*msc_dtor)(void) = on_process_exit;

#endif /* defined(__MINGW32__) || defined(_MSC_VER) */

__PTW32_BEGIN_C_DECLS

/* This dummy function exists solely to be referenced by other modules
* (specifically, in implement.h), so that the linker can't optimize away
* this module. Don't call it.
*
* Shouldn't work if we are compiling via pthreads.c
* (whole library single translation unit)
* Leaving it here in case it affects small-static builds.
*/
void __ptw32_autostatic_anchor(void) { abort(); }

__PTW32_END_C_DECLS

#endif /* __PTW32_STATIC_LIB */

2 changes: 2 additions & 0 deletions implement.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ static void __ptw32_set_errno(int err) { errno = err; SetLastError(err); }
* Don't allow the linker to optimize away dll.obj (dll.o) in static builds.
*/
#if defined (__PTW32_STATIC_LIB) && defined (__PTW32_BUILD) && !defined (__PTW32_TEST_SNEAK_PEEK)
__PTW32_BEGIN_C_DECLS
void __ptw32_autostatic_anchor(void);
# if defined(__GNUC__)
__attribute__((unused, used))
# endif
static void (*local_autostatic_anchor)(void) = __ptw32_autostatic_anchor;
__PTW32_END_C_DECLS
#endif

typedef enum
Expand Down

0 comments on commit 5af3810

Please sign in to comment.