diff -Naur mysql-5.0.83/configure.in mysql-5.0.83-haiku/configure.in
--- mysql-5.0.83/configure.in	2009-05-29 18:15:45.000000000 +0000
+++ mysql-5.0.83-haiku/configure.in	2012-12-04 18:14:48.000000000 +0000
@@ -884,7 +884,8 @@
   AC_CHECK_LIB(nsl, gethostbyname_r))
 AC_CHECK_FUNC(gethostbyname_r)
 
-AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
+AC_SEARCH_LIBS(socket, [socket network])
+AC_SEARCH_LIBS(setsockopt,[socket network])
 AC_CHECK_FUNC(yp_get_default_domain, ,
   AC_CHECK_LIB(nsl, yp_get_default_domain))
 AC_CHECK_FUNC(p2open, , AC_CHECK_LIB(gen, p2open))
@@ -893,7 +894,7 @@
 # Check if crypt() exists in libc or libcrypt, sets LIBS if needed
 AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT, 1, [crypt]))
 # See if we need a library for address lookup.
-AC_SEARCH_LIBS(inet_aton, [socket nsl resolv])
+AC_SEARCH_LIBS(inet_aton, [socket nsl resolv network])
 
 # For the sched_yield() function on Solaris
 AC_CHECK_FUNC(sched_yield, , AC_CHECK_LIB(posix4, sched_yield))
@@ -1939,6 +1940,13 @@
 MYSQL_CHECK_TIME_T
 
 
+
+AC_CHECK_MEMBERS([struct rusage.ru_maxrss, struct rusage.ru_idrss, struct rusage.ru_minflt, struct rusage.ru_majflt, 
+struct rusage.ru_nswap, struct rusage.ru_inblock, struct rusage.ru_oublock, struct rusage.ru_msgsnd, struct rusage.ru_msgrcv, 
+struct rusage.ru_nsignals, struct rusage.ru_nvcsw, struct rusage.ru_nivcsw ],[AC_DEFINE([ADDITIONAL_RUSAGE_MEMBERS],[1],[
+Define 1 if structure have this members])],,)
+
+
 # do we need #pragma interface/#pragma implementation ?
 # yes if it's gcc 2.x, and not icc pretending to be gcc, and not cygwin
 AC_MSG_CHECKING(the need for @%:@pragma interface/implementation)
diff -Naur mysql-5.0.83/dbug/dbug_analyze.c mysql-5.0.83-haiku/dbug/dbug_analyze.c
--- mysql-5.0.83/dbug/dbug_analyze.c	2009-05-29 18:15:46.000000000 +0000
+++ mysql-5.0.83-haiku/dbug/dbug_analyze.c	2012-12-02 12:17:35.000000000 +0000
@@ -100,13 +100,13 @@
 	while(0)
 
 
-struct stack_t {
+struct my_stack_t {
     unsigned int pos;			/* which function? */
     unsigned long time;			/* Time that this was entered */
     unsigned long children;		/* Time spent in called funcs */
 };
 
-static struct stack_t fn_stack[STACKSIZ+1];
+static struct my_stack_t fn_stack[STACKSIZ+1];
 
 static unsigned int stacktop = 0;	/* Lowest stack position is a dummy */
 
@@ -130,7 +130,7 @@
 register unsigned int name_pos;
 register unsigned long time_entered;
 {
-    register struct stack_t *t;
+    register struct my_stack_t *t;
 
     DBUG_ENTER("push");
     if (++stacktop > STACKSIZ) {
@@ -157,7 +157,7 @@
 register unsigned long *time_entered;
 register unsigned long *child_time;
 {
-    register struct stack_t *temp;
+    register struct my_stack_t *temp;
     register unsigned int rtnval;
 
     DBUG_ENTER ("pop");
@@ -313,7 +313,7 @@
   unsigned int oldpos;
   unsigned long oldtime;
   unsigned long oldchild;
-  struct stack_t *t;
+  struct my_stack_t *t;
 
   DBUG_ENTER ("process");
   while (fgets (buf,BUFSIZ,inf) != NULL) {
diff -Naur mysql-5.0.83/mysys/my_init.c mysql-5.0.83-haiku/mysys/my_init.c
--- mysql-5.0.83/mysys/my_init.c	2009-05-29 18:18:19.000000000 +0000
+++ mysql-5.0.83-haiku/mysys/my_init.c	2012-12-04 18:16:27.368050176 +0000
@@ -162,6 +162,7 @@
     /* Purify assumes that rus is uninitialized after getrusage call */
     bzero((char*) &rus, sizeof(rus));
 #endif
+#ifdef ADDITIONAL_RUSAGE_MEMBERS
     if (!getrusage(RUSAGE_SELF, &rus))
       fprintf(info_file,"\n\
 User time %.2f, System time %.2f\n\
@@ -179,6 +180,7 @@
 	      rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
 	      rus.ru_nvcsw, rus.ru_nivcsw);
 #endif
+#endif
 #if ( defined(MSDOS) || defined(__NETWARE__) ) && !defined(__WIN__)
     fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC);
 #endif
