+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
-* *
-* Copyright (C) 2009, International Business Machines *
-* Corporation and others. All Rights Reserved. *
-* *
+*
+* Copyright (C) 2009-2011, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
******************************************************************************
* file name: ucln_imp.h
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* 3) Implementing own automatic cleanup functions
*
* For option 1, ensure that UCLN_NO_AUTO_CLEANUP is set to 0 by using --enable-auto-cleanup
- * configure option or by setting UCLN_NO_AUTO_CLEANUP to 0 in pwin32.h (For Visual Studio
- * solution file builds)
+ * configure option or by otherwise setting UCLN_NO_AUTO_CLEANUP to 0
* For option 2, follow option 1 and also define UCLN_AUTO_ATEXIT
* For option 3, follow option 1 and also define UCLN_AUTO_LOCAL (see below for more information)
*/
*/
/*static void ucln_unRegisterAutomaticCleanup();*/
+#ifdef UCLN_TYPE_IS_COMMON
+# define UCLN_CLEAN_ME_UP u_cleanup()
+#else
+# define UCLN_CLEAN_ME_UP ucln_cleanupOne(UCLN_TYPE)
+#endif
+
/* ------------ automatic cleanup: registration. Choose ONE ------- */
#if defined(UCLN_AUTO_LOCAL)
/* To use:
static void ucln_atexit_handler()
{
- ucln_cleanupOne(UCLN_TYPE);
+ UCLN_CLEAN_ME_UP;
}
static void ucln_registerAutomaticCleanup()
U_CAPI void U_EXPORT2 UCLN_FINI ()
{
/* This function must be defined, if UCLN_FINI is defined, else link error. */
- ucln_cleanupOne(UCLN_TYPE);
-}
-#elif defined(__GNUC__)
-/* GCC - use __attribute((destructor)) */
-static void ucln_destructor() __attribute__((destructor)) ;
-
-static void ucln_destructor()
-{
- ucln_cleanupOne(UCLN_TYPE);
+ UCLN_CLEAN_ME_UP;
}
/* Windows: DllMain */
-#elif defined (U_WINDOWS)
+#elif U_PLATFORM_HAS_WIN32_API
/*
* ICU's own DllMain.
*/
/* READ READ READ READ! Are you getting compilation errors from windows.h?
Any source file which includes this (ucln_imp.h) header MUST
be defined with language extensions ON. */
+#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
+#endif
# define VC_EXTRALEAN
# define NOUSER
# define NOSERVICE
case DLL_PROCESS_DETACH:
/* Here is the one we actually care about. */
- ucln_cleanupOne(UCLN_TYPE);
+ UCLN_CLEAN_ME_UP;
break;
}
return status;
}
+
+#elif defined(__GNUC__)
+/* GCC - use __attribute((destructor)) */
+static void ucln_destructor() __attribute__((destructor)) ;
+
+static void ucln_destructor()
+{
+ UCLN_CLEAN_ME_UP;
+}
+
#endif
#endif /* UCLN_NO_AUTO_CLEANUP */