]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
stub out isc/mem.c using NTP-local /include/isc/mem.h (leaving
authorDave Hart <hart@ntp.org>
Tue, 27 Oct 2009 21:53:59 +0000 (21:53 +0000)
committerDave Hart <hart@ntp.org>
Tue, 27 Oct 2009 21:53:59 +0000 (21:53 +0000)
  /lib/isc/include/isc/mem.h untouched).

bk: 4ae76bf7uTw-L8b_x0cill-jemIRHg

12 files changed:
configure.ac
include/Makefile.am
include/isc/Makefile.am [new file with mode: 0644]
include/isc/mem.h [new file with mode: 0644]
libntp/Makefile.am
libntp/emalloc.c
ntpd/ntp_io.c
ports/winnt/vc6/libntp.dsp
ports/winnt/vs2003/libntp.vcproj
ports/winnt/vs2005/libntp.vcproj
ports/winnt/vs2008/libntp/libntp.vcproj
util/ntptime.c

index 04beef61f880682e033025d2e7350b83c975b569..02a1bb2947bc84347a76d9dbc7377bed7c4b7bb9 100644 (file)
@@ -4844,6 +4844,7 @@ AC_CONFIG_FILES(ElectricFence/Makefile)
 AC_CONFIG_FILES(adjtimed/Makefile)
 AC_CONFIG_FILES(clockstuff/Makefile)
 AC_CONFIG_FILES(include/Makefile)
+AC_CONFIG_FILES(include/isc/Makefile)
 AC_CONFIG_FILES(kernel/Makefile)
 AC_CONFIG_FILES(kernel/sys/Makefile)
 AC_CONFIG_FILES(libntp/Makefile)
index 289427962bc673f9a9050c8d1e3fdfe16a4376c1..f563ba96dd3e886fdf2f85c266c501f33c5b9ce7 100644 (file)
@@ -1,9 +1,10 @@
-#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+NULL =
 AUTOMAKE_OPTIONS = 
 ETAGS_ARGS = $(srcdir)/Makefile.am
 EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def
 
-NULL=
+SUBDIRS = isc
+
 noinst_HEADERS =       \
        adjtime.h       \
        audio.h         \
diff --git a/include/isc/Makefile.am b/include/isc/Makefile.am
new file mode 100644 (file)
index 0000000..14aa708
--- /dev/null
@@ -0,0 +1,7 @@
+NULL =
+AUTOMAKE_OPTIONS = 
+ETAGS_ARGS = $(srcdir)/Makefile.am
+
+noinst_HEADERS =       \
+       mem.h           \
+       $(NULL)
diff --git a/include/isc/mem.h b/include/isc/mem.h
new file mode 100644 (file)
index 0000000..21cbda1
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * libntp local override of isc/mem.h to stub it out.
+ *
+ * include/isc is searched before any of the lib/isc include
+ * directories and should be used only for replacement NTP headers
+ * overriding headers of the same name under lib/isc.
+ *
+ * NOTE: this assumes the system malloc is thread-safe and does
+ *      not use any normal lib/isc locking.
+ */
+
+/*
+ * Copyright (C) 2004-2009  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1997-2001  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $Id: mem.h,v 1.78.120.3 2009/02/11 03:07:01 jinmei Exp $ */
+
+#ifndef ISC_MEM_H
+#define ISC_MEM_H 1
+
+#include <stdio.h>
+
+#include <isc/lang.h>
+#include <isc/mutex.h>
+#include <isc/platform.h>
+#include <isc/types.h>
+#include <isc/xml.h>
+
+#include <ntp_stdlib.h>
+
+
+#define isc_mem_get(c, cnt)            emalloc((cnt))
+#define isc_mem_allocate(c, cnt)       emalloc((cnt))
+#define isc_mem_reallocate(c, mem, cnt)        erealloc((mem), (cnt))
+#define isc_mem_put(c, mem, cnt)       free((mem))
+#define isc_mem_free(c, mem)           free((mem))
+#define isc_mem_strdup(c, str)         estrdup((str))
+#define isc_mem_attach(src, ptgt)      do { *(ptgt) = (src); } while (0)
+#define isc_mem_detach(c)              ((void)(c))
+
+#endif /* ISC_MEM_H */
index 5ec437791ab6ca7323e3f979f19714ee874ee22b..50f40c5fa9afa550215ffe8559f2e2345ee57238 100644 (file)
@@ -30,7 +30,6 @@ libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \
        $(srcdir)/../lib/isc/lib.c                      \
        $(srcdir)/../lib/isc/log.c                      \
        $(srcdir)/../lib/isc/md5.c                      \
-       $(srcdir)/../lib/isc/mem.c                      \
        $(srcdir)/../lib/isc/nls/msgcat.c               \
        $(srcdir)/../lib/isc/unix/net.c                 \
        $(srcdir)/../lib/isc/netaddr.c                  \
index 8798a31934f062f902e416b4d3e60004f2932ab9..5c40f4ee041017bb2e513c226886634f39b3e65e 100644 (file)
@@ -19,7 +19,7 @@ erealloc(
 {
        void *  mem;
 
-       mem = realloc(prev, size);
+       mem = realloc(prev, size ? size : 1);
 
        if (NULL == mem) {
                msyslog(LOG_ERR,
@@ -86,7 +86,8 @@ debug_erealloc(
 {
        void *  mem;
 
-       mem = _realloc_dbg(prev, size, _NORMAL_BLOCK, file, line);
+       mem = _realloc_dbg(prev, size ? size : 1,
+                          _NORMAL_BLOCK, file, line);
 
        if (NULL == mem) {
                msyslog(LOG_ERR,
index 8f0c220a43a9a15856882e600b7a4315523e440e..af46281aea5dc4ee00c32ba3057ec6dfbeabc2c8 100644 (file)
@@ -283,12 +283,6 @@ struct interface * inter_list;
 static struct interface *wildipv4 = NULL;
 static struct interface *wildipv6 = NULL;
 
-/*
- * allocate/free in libisc form, using emalloc/free.
- */
-void *                 ntp_memalloc            (void *, size_t);
-void                   ntp_memfree             (void *, void *);
-
 static void            add_fd_to_list          (SOCKET, 
                                                 enum desc_type);
 static struct interface *find_addr_in_list     (sockaddr_u *);
@@ -321,30 +315,6 @@ static inline int     read_refclock_packet (SOCKET, struct refclockio *, l_fp);
 #endif
 
 
-void *
-ntp_memalloc(
-       void *  ntpcontext,
-       size_t  octets
-       )
-{
-       UNUSED_ARG(ntpcontext);
-
-       return emalloc(octets);
-}
-
-
-void
-ntp_memfree(
-       void *  ntpcontext,
-       void *  p
-       )
-{
-       UNUSED_ARG(ntpcontext);
-
-       free(p);
-}
-
-
 #ifdef SYS_WINNT
 /*
  * Windows 2000 systems incorrectly cause UDP sockets using WASRecvFrom
@@ -1546,7 +1516,7 @@ update_interfaces(
        void *                  data
        )
 {
-       static isc_mem_t *      mctx;
+       isc_mem_t *             mctx = (void *)-1;
        interface_info_t        ifi;
        isc_interfaceiter_t *   iter;
        isc_result_t            result;
@@ -1559,12 +1529,6 @@ update_interfaces(
 
        DPRINTF(3, ("update_interfaces(%d)\n", port));
 
-       if (NULL == mctx) {
-               result = isc_mem_createx(0, 0, &ntp_memalloc,
-                   &ntp_memfree, NULL, &mctx);
-               NTP_INSIST(ISC_R_SUCCESS == result);
-       }
-
        /*
         * phase one - scan interfaces
         * - create those that are not found
index 87c1e7c26690be00e0ec6d551f0728fd53fafe24..9f1a15f008dca2e47eb318b6d0dd832bda7cd851 100644 (file)
@@ -266,10 +266,6 @@ SOURCE=..\..\..\lib\isc\md5.c
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\..\lib\isc\mem.c\r
-# End Source File\r
-# Begin Source File\r
-\r
 SOURCE=..\..\..\libntp\memmove.c\r
 # End Source File\r
 # Begin Source File\r
index d6a5e70606f02ba46a9657ababa8716ba841cba2..e96127e1df48512a9e2b7e69698e4ff6a2e039ff 100644 (file)
                                                PreprocessorDefinitions=""/>
                                </FileConfiguration>
                        </File>
-                       <File
-                               RelativePath="..\..\..\lib\isc\mem.c">
-                       </File>
                        <File
                                RelativePath="..\..\..\libntp\memmove.c">
                                <FileConfiguration
                                RelativePath="..\..\..\include\md5.h">
                        </File>
                        <File
-                               RelativePath="..\..\..\lib\isc\include\isc\mem.h">
+                               RelativePath="..\..\..\include\isc\mem.h">
                        </File>
                        <File
                                RelativePath="..\..\..\lib\isc\include\isc\net.h">
index 02d3b6874230bb5e0ac760e2197bf52997f3d51a..69e39edd851fc97713e58eefc9ffa79b5d5225db 100644 (file)
                                        />
                                </FileConfiguration>
                        </File>
-                       <File
-                               RelativePath="..\..\..\lib\isc\mem.c"
-                               >
-                       </File>
                        <File
                                RelativePath="..\..\..\libntp\memmove.c"
                                >
                                >
                        </File>
                        <File
-                               RelativePath="..\..\..\lib\isc\include\isc\mem.h"
+                               RelativePath="..\..\..\include\isc\mem.h"
                                >
                        </File>
                        <File
index c47c2663e752c00e8b031bfaab1376b4bc62375c..a7b68e1186e0c7821ec2de76dba7861dfc268789 100644 (file)
                                RelativePath="..\..\..\..\lib\isc\md5.c"
                                >
                        </File>
-                       <File
-                               RelativePath="..\..\..\..\lib\isc\mem.c"
-                               >
-                       </File>
                        <File
                                RelativePath="..\..\..\..\libntp\memmove.c"
                                >
                                >
                        </File>
                        <File
-                               RelativePath="..\..\..\..\lib\isc\include\isc\mem.h"
+                               RelativePath="..\..\..\..\include\isc\mem.h"
                                >
                        </File>
                        <File
index 4ca823492240a14dc4f7f581903f3503c8e53998..7202dfb5855e954bf4468acd13edabf55832d8f2 100644 (file)
@@ -67,6 +67,7 @@ static volatile int pll_control; /* (0) daemon, (1) kernel loop */
 static volatile int status;    /* most recent status bits */
 static volatile int flash;     /* most recent ntp_adjtime() bits */
 char* progname;
+volatile int debug;            /* for libntp */
 static char optargs[] = "MNT:cde:f:hm:o:rs:t:";
 
 int