diff --git a/configure b/configure
index a90be03821..e304074a2b 100755
--- a/configure
+++ b/configure
@@ -7342,6 +7342,13 @@ if test "$PORTNAME" = "solaris"; then
   CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
 fi
 
+# On Solaris, we need this #define to access memset_s function
+if test "$PORTNAME" = "solaris"; then
+
+$as_echo "#define __STDC_WANT_LIB_EXT1__ 1" >>confdefs.h
+
+fi
+
 # We already have this in Makefile.win32, but configure needs it too
 if test "$PORTNAME" = "win32"; then
   CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
diff --git a/configure.ac b/configure.ac
index 7fbfb6795f..63e577a245 100644
--- a/configure.ac
+++ b/configure.ac
@@ -649,6 +649,11 @@ if test "$PORTNAME" = "solaris"; then
   CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
 fi
 
+# On Solaris, we need this #define to access mem*_s functions
+if test "$PORTNAME" = "solaris"; then
+  AC_DEFINE(__STDC_WANT_LIB_EXT1__, 1, [Define to 1 to access mem*_s functions in solaris])
+fi
+
 # We already have this in Makefile.win32, but configure needs it too
 if test "$PORTNAME" = "win32"; then
   CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32"
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 7133c3dc66..c2179c4be6 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -988,6 +988,9 @@
 /* Define for large files, on AIX-style hosts. */
 #undef _LARGE_FILES
 
+/* Define to 1 to access mem*_s functions in solaris */
+#undef __STDC_WANT_LIB_EXT1__
+
 /* Define to `__inline__' or `__inline' if that's what the C compiler
    calls it, or to nothing if 'inline' is not supported under any name.  */
 #ifndef __cplusplus
