Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 May 2014 14:30:53 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266887 - head/sys/boot/usb
Message-ID:  <201405301430.s4UEUrIu091997@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri May 30 14:30:52 2014
New Revision: 266887
URL: http://svnweb.freebsd.org/changeset/base/266887

Log:
  Resolve issue with resolving malloc() and free() functions at linking time.
  
  Sponsored by:	DARPA, AFRL

Modified:
  head/sys/boot/usb/bsd_kernel.h
  head/sys/boot/usb/bsd_usbloader_test.c

Modified: head/sys/boot/usb/bsd_kernel.h
==============================================================================
--- head/sys/boot/usb/bsd_kernel.h	Fri May 30 14:05:31 2014	(r266886)
+++ head/sys/boot/usb/bsd_kernel.h	Fri May 30 14:30:52 2014	(r266887)
@@ -430,7 +430,6 @@ size_t	strlen(const char *s);
 
 /* MALLOC API */
 
-#ifndef HAVE_MALLOC
 #undef malloc
 #define	malloc(s,x,f) usb_malloc(s)
 void   *usb_malloc(size_t);
@@ -438,15 +437,6 @@ void   *usb_malloc(size_t);
 #undef free
 #define	free(p,x) usb_free(p)
 void	usb_free(void *);
-#else
-#undef malloc
-void *malloc(size_t);
-#define	malloc(s,x,f) malloc(s)
-
-#undef free
-void free(void *);
-#define	free(p,x) free(p)
-#endif
 
 #define	strdup(p,x) usb_strdup(p)
 char   *usb_strdup(const char *str);

Modified: head/sys/boot/usb/bsd_usbloader_test.c
==============================================================================
--- head/sys/boot/usb/bsd_usbloader_test.c	Fri May 30 14:05:31 2014	(r266886)
+++ head/sys/boot/usb/bsd_usbloader_test.c	Fri May 30 14:30:52 2014	(r266887)
@@ -26,6 +26,7 @@
 
 #include <stdio.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <time.h>
 
 extern int usleep(int);
@@ -36,6 +37,18 @@ extern void usb_uninit(void);
 
 #define	hz 1000
 
+void *
+usb_malloc(size_t size)
+{
+	return (malloc(size));
+}
+
+void
+usb_free(void *ptr)
+{
+	free(ptr);
+}
+
 void
 DELAY(unsigned int delay)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405301430.s4UEUrIu091997>