summaryrefslogtreecommitdiffstats
path: root/include/ntp_malloc.h
diff options
context:
space:
mode:
authorroberto <roberto@FreeBSD.org>2013-12-04 21:33:17 +0000
committerroberto <roberto@FreeBSD.org>2013-12-04 21:33:17 +0000
commitd54cfbdce4a9878ef65216dea36b62cf6646b84b (patch)
treea618007bb41d13153794a598e3d904ace2976324 /include/ntp_malloc.h
parentfd23eea016bd30c806a3ee90eb6f397470c2fa46 (diff)
downloadFreeBSD-src-d54cfbdce4a9878ef65216dea36b62cf6646b84b.zip
FreeBSD-src-d54cfbdce4a9878ef65216dea36b62cf6646b84b.tar.gz
Virgin import of ntpd 4.2.6p5.
When the series of commits is complete, things like https://cert.litnet.lt/en/docs/ntp-distributed-reflection-dos-attacks should be fixed. PR: bin/148836 (except that we import a newer version) Asked by: Too many MFC after: 2 weeks
Diffstat (limited to 'include/ntp_malloc.h')
-rw-r--r--include/ntp_malloc.h60
1 files changed, 51 insertions, 9 deletions
diff --git a/include/ntp_malloc.h b/include/ntp_malloc.h
index 099c83e..4cde62e 100644
--- a/include/ntp_malloc.h
+++ b/include/ntp_malloc.h
@@ -1,19 +1,61 @@
/*
* Define malloc and friends.
*/
-#ifndef _ntp_malloc_h
-#define _ntp_malloc_h
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#ifndef NTP_MALLOC_H
+#define NTP_MALLOC_H
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
-#else /* HAVE_STDLIB_H */
+#else
# ifdef HAVE_MALLOC_H
# include <malloc.h>
# endif
-#endif /* HAVE_STDLIB_H */
+#endif
+
+/*
+ * Deal with platform differences declaring alloca()
+ * This comes nearly verbatim from:
+ *
+ * http://www.gnu.org/software/autoconf/manual/autoconf.html#Particular-Functions
+ *
+ * The only modifications were to remove C++ support and guard against
+ * redefining alloca.
+ */
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#elif defined __GNUC__
+# ifndef alloca
+# define alloca __builtin_alloca
+# endif
+#elif defined _AIX
+# ifndef alloca
+# define alloca __alloca
+# endif
+#elif defined _MSC_VER
+# include <malloc.h>
+# ifndef alloca
+# define alloca _alloca
+# endif
+#else
+# include <stddef.h>
+void * alloca(size_t);
+#endif
+
+#ifdef EREALLOC_IMPL
+# define EREALLOC_CALLSITE /* preserve __FILE__ and __LINE__ */
+#else
+# define EREALLOC_IMPL(ptr, newsz, filenm, loc) \
+ realloc(ptr, (newsz))
+#endif
+
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+# define zero_mem(p, s) bzero(p, s)
+#endif
+
+#ifndef zero_mem
+# define zero_mem(p, s) memset(p, 0, s)
+#endif
+#define ZERO(var) zero_mem(&(var), sizeof(var))
-#endif /* _ntp_malloc_h */
+#endif /* NTP_MALLOC_H */
OpenPOWER on IntegriCloud