From 4f531b6d33d75ea748ca66261a1f74b75c60498b Mon Sep 17 00:00:00 2001
From: William Brown <wibrown@redhat.com>
Date: Thu, 12 May 2016 16:42:35 +1000
Subject: [PATCH 3/8] Ticket 48797 - Add freebsd support to ns-slapd: Header
 files

Description: Add header file support for freeBSD

https://fedorahosted.org/389/ticket/48797

Author: wibrown

Reviewed by: ???
---
 include/base/systems.h                   | 26 ++++++++++++++++++++++++++
 include/public/base/systems.h            |  9 +++++++++
 ldap/include/portable.h                  |  8 ++++----
 ldap/servers/slapd/back-ldbm/back-ldbm.h |  4 ++++
 ldap/servers/slapd/tools/ldclt/ldclt.h   |  5 +++++
 5 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/include/base/systems.h b/include/base/systems.h
index 5f14969..1597359 100644
--- a/include/base/systems.h
+++ b/include/base/systems.h
@@ -142,6 +142,32 @@
 #define NET_SOCKETS
 #define SHMEM_MMAP_FLAGS MAP_SHARED
 
+#elif defined(__FreeBSD__)
+
+#define ACCELERATOR_CACHE
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define DAEMON_UNIX_MOBRULE
+#define BSD_RLIMIT
+#define BSD_SIGNALS
+#define FILE_UNIX_MMAP
+#define FILE_MMAP_FLAGS (MAP_FILE | MAP_SHARED)
+#define SHMEM_UNIX_MMAP
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+#define AUTH_DBM
+#define SEM_FLOCK
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define HAVE_ATEXIT
+#define HAS_STATFS
+#define JAVA_STATIC_LINK
+#undef NEED_CRYPT_PROTO
+#define NET_SOCKETS
+#ifndef NO_DOMAINNAME
+#define NO_DOMAINNAME
+#endif
+
 #else
 #error "Missing defines in ns/netsite/include/base/systems.h"
 #endif
diff --git a/include/public/base/systems.h b/include/public/base/systems.h
index 535a35c..ba36502 100644
--- a/include/public/base/systems.h
+++ b/include/public/base/systems.h
@@ -65,6 +65,15 @@
 #define SHMEM_UNIX_MMAP
 #define ZERO(ptr,len) memset(ptr,0,len)
 
+#elif defined(__FreeBSD__)
+
+#define FILE_UNIX
+#define FILE_UNIX_MMAP
+#define MALLOC_POOLS
+#define SEM_FLOCK
+#define SHMEM_UNIX_MMAP
+#define ZERO(ptr,len) memset(ptr,0,len)
+
 #else
 #error "Missing defines in ns/netsite/include/public/base/systems.h"
 #endif
diff --git a/ldap/include/portable.h b/ldap/include/portable.h
index ea164c0..0f454ce 100644
--- a/ldap/include/portable.h
+++ b/ldap/include/portable.h
@@ -124,7 +124,7 @@
  * Are sys_errlist and sys_nerr declared in stdio.h?
  */
 #ifndef SYSERRLIST_IN_STDIO
-#if defined( freebsd ) || defined(Linux)
+#if defined( __FreeBSD__ ) || defined(Linux)
 #define SYSERRLIST_IN_STDIO
 #endif
 #endif
@@ -250,7 +250,7 @@ int strncasecmp(const char *, const char *, size_t);
     defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \
     defined(NCR) || defined(OSF1) || defined(NEC) || \
     ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \
-    defined(UnixWare) || defined(LINUX2_0)
+    defined(UnixWare) || defined(LINUX2_0) || defined (__FreeBSD__)
 #define GETHOSTBYNAME( n, r, b, l, e )  gethostbyname( n )
 #elif defined(AIX)
 #define GETHOSTBYNAME_BUF_T struct hostent_data
@@ -282,7 +282,7 @@ typedef char GETHOSTBYADDR_buf_t [BUFSIZ];
 
 
 #if defined(HPUX9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \
-    defined(SCOOS) || defined(BSDI) || defined(NCR) || \
+    defined(SCOOS) || defined(BSDI) || defined(NCR) || defined (__FreeBSD__) || \
     defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT)) 
 #define CTIME( c, b, l )		ctime( c )
 #elif defined( hpux10 )
@@ -312,7 +312,7 @@ char *strtok_r(char *, const char *, char **);
 extern char *strdup();
 #endif /* ultrix || nextstep */
 
-#if defined( sunos4 ) || defined( OSF1 )
+#if defined( sunos4 ) || defined( OSF1 ) || defined (__FreeBSD__)
 #define	BSD_TIME	1	/* for servers/slapd/log.h */
 #endif /* sunos4 || osf */
 
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h
index 9499292..a6ef730 100644
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
@@ -16,6 +16,10 @@
 #ifndef _BACK_LDBM_H_
 #define _BACK_LDBM_H_
 
+/* This is used in _entryrdn_open_index only, and not checked */
+/* So it's not a problem to make our own! */
+#define E_NOENTRYRDN -2
+
 #if defined(HPUX11) || defined(OS_solaris) || defined(linux)
 /* built-in 64-bit file I/O support */
 #define DB_USE_64LFS
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.h b/ldap/servers/slapd/tools/ldclt/ldclt.h
index 4f8f485..2a950aa 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.h
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.h
@@ -172,6 +172,11 @@ dd/mm/yy | Author	| Comments
 #if defined(USE_OPENLDAP)
 #define ABS(x) ((x > 0) ? (x) : (-x))
 #endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
 /*
  * Misc constant definitions
  */
-- 
2.6.4

