From 01e48ff392328a0191bf3dba506135451956f0c0 Mon Sep 17 00:00:00 2001
From: Vladislav Vaintroub <wlad@montyprogram.com>
Date: Mon, 26 Dec 2011 01:08:46 +0100
Subject: [PATCH] Fix build on old 32 bit Centos (kernel 2.6.18)

---
 cmake/os/Linux.cmake   | 7 +++++++
 sql/threadpool_unix.cc | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/cmake/os/Linux.cmake b/cmake/os/Linux.cmake
index ccdf7e8d931..108e06cf7b0 100644
--- a/cmake/os/Linux.cmake
+++ b/cmake/os/Linux.cmake
@@ -46,3 +46,10 @@ IF(HAVE_DECL_SHM_HUGETLB)
   SET(HUGETLB_USE_PROC_MEMINFO 1)
   SET(HAVE_LARGE_PAGE_OPTION 1)
 ENDIF()
+
+IF(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR MATCHES "86")
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
+  SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=i686")
+ENDIF()
+
diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc
index 93094f599aa..e0310303020 100644
--- a/sql/threadpool_unix.cc
+++ b/sql/threadpool_unix.cc
@@ -190,6 +190,10 @@ static void set_next_timeout_check(ulonglong abstime);
 */
 
 #if defined (__linux__)
+#ifndef EPOLLRDHUP
+/* Early 2.6 kernel did not have EPOLLRDHUP */
+#define EPOLLRDHUP 0
+#endif
 static int io_poll_create()
 {
   return epoll_create(1);
-- 
2.30.9