diff --git a/Makefile b/Makefile
index c139cac..228ebfd 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
 ifeq ($(CC),gcc)
     PG_CPPFLAGS = -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-uninitialized -Wno-implicit-fallthrough -Iinclude -I$(libpq_srcdir)
 else
-    PG_CPPFLAGS = -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Iinclude -I$(libpq_srcdir)
+    PG_CPPFLAGS = -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-missing-variable-declarations -Iinclude -I$(libpq_srcdir)
 endif
 ifeq ($(shell uname -s),SunOS)
     PG_CPPFLAGS += -Wno-sign-compare -D__EXTENSIONS__
diff --git a/include/pg_cron.h b/include/pg_cron.h
index fd5127f..09f7d70 100644
--- a/include/pg_cron.h
+++ b/include/pg_cron.h
@@ -11,6 +11,7 @@
 #ifndef PG_CRON_H
 #define PG_CRON_H
 
+#include "pg_version_compatibility.h"
 
 /* global settings */
 extern char *CronTableDatabaseName;
diff --git a/src/pg_cron.c b/src/pg_cron.c
index 16b8eb8..3a40af4 100644
--- a/src/pg_cron.c
+++ b/src/pg_cron.c
@@ -20,7 +20,6 @@
 #include "miscadmin.h"
 #include "postmaster/bgworker.h"
 #include "storage/ipc.h"
-#include "storage/latch.h"
 #include "storage/lwlock.h"
 #include "storage/proc.h"
 #include "storage/shm_mq.h"
@@ -135,7 +134,7 @@ static bool ShouldRunTask(entry *schedule, TimestampTz currentMinute,
 						  bool doWild, bool doNonWild);
 
 static void WaitForCronTasks(List *taskList);
-static void WaitForLatch(int timeoutMs);
+static void WaitForInterrupt(int timeoutMs);
 static void PollForTasks(List *taskList);
 static bool CanStartTask(CronTask *task);
 static void ManageCronTasks(List *taskList, TimestampTz currentTime);
@@ -349,7 +348,7 @@ _PG_init(void)
 
 /*
  * Signal handler for SIGTERM
- *		Set a flag to let the main loop to terminate, and set our latch to wake
+ *		Set a flag to let the main loop to terminate, and raise interrupt to wake
  *		it up.
  */
 static void
@@ -359,7 +358,7 @@ pg_cron_sigterm(SIGNAL_ARGS)
 
 	if (MyProc != NULL)
 	{
-		SetLatch(&MyProc->procLatch);
+		RaiseInterrupt(INTERRUPT_GENERAL_WAKEUP);
 	}
 }
 
@@ -376,7 +375,7 @@ pg_cron_sighup(SIGNAL_ARGS)
 
 	if (MyProc != NULL)
 	{
-		SetLatch(&MyProc->procLatch);
+		RaiseInterrupt(INTERRUPT_GENERAL_WAKEUP);
 	}
 }
 
@@ -1019,29 +1018,25 @@ WaitForCronTasks(List *taskList)
 	}
 	else
 	{
-		WaitForLatch(MaxWait);
+		WaitForInterrupt(MaxWait);
 	}
 }
 
 
 /*
- * WaitForLatch waits for the given number of milliseconds unless a signal
+ * WaitForInterrupt waits for the given number of milliseconds unless a signal
  * is received or postmaster shuts down.
  */
 static void
-WaitForLatch(int timeoutMs)
+WaitForInterrupt(int timeoutMs)
 {
 	int rc = 0;
-	int waitFlags = WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_TIMEOUT;
+	int waitFlags = WL_INTERRUPT | WL_POSTMASTER_DEATH | WL_TIMEOUT;
 
 	/* nothing to do, wait for new jobs */
-#if (PG_VERSION_NUM >= 100000)
-	rc = WaitLatch(MyLatch, waitFlags, timeoutMs, PG_WAIT_EXTENSION);
-#else
-	rc = WaitLatch(MyLatch, waitFlags, timeoutMs);
-#endif
+	rc = WaitInterrupt(1 << INTERRUPT_GENERAL_WAKEUP, waitFlags, timeoutMs, PG_WAIT_EXTENSION);
 
-	ResetLatch(MyLatch);
+	ClearInterrupt(INTERRUPT_GENERAL_WAKEUP);
 
 	CHECK_FOR_INTERRUPTS();
 
@@ -1212,7 +1207,7 @@ PollForTasks(List *taskList)
 	if (activeTaskCount == 0)
 	{
 		/* turns out there's nothing to do, just wait for something to happen */
-		WaitForLatch(pollTimeout);
+		WaitForInterrupt(pollTimeout);
 
 		pfree(polledTasks);
 		pfree(pollFDs);
