All of lore.kernel.org
 help / color / mirror / Atom feed
* c/s 17028: build issue
@ 2008-02-13 16:06 Christoph Egger
  2008-02-13 16:14 ` John Levon
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Egger @ 2008-02-13 16:06 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: xen-devel


Hi Samuel,

Changeset 17028 broke the build on NetBSD in
tools/ioemu/hw/scsi-disk.c and tools/ioemu/hw/ide.c.

NetBSD doesn't have memalign(). Can you change this to use
posix_memalign(), please?

Thanks,

Christoph


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: c/s 17028: build issue
  2008-02-13 16:06 c/s 17028: build issue Christoph Egger
@ 2008-02-13 16:14 ` John Levon
  2008-02-13 16:24   ` Samuel Thibault
  0 siblings, 1 reply; 6+ messages in thread
From: John Levon @ 2008-02-13 16:14 UTC (permalink / raw)
  To: Christoph Egger; +Cc: xen-devel, Samuel Thibault

On Wed, Feb 13, 2008 at 05:06:05PM +0100, Christoph Egger wrote:

> Changeset 17028 broke the build on NetBSD in
> tools/ioemu/hw/scsi-disk.c and tools/ioemu/hw/ide.c.
> 
> NetBSD doesn't have memalign(). Can you change this to use
> posix_memalign(), please?

Solaris doesn't have posix_memalign()...

regards
john

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: c/s 17028: build issue
  2008-02-13 16:14 ` John Levon
@ 2008-02-13 16:24   ` Samuel Thibault
  2008-02-13 16:26     ` John Levon
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2008-02-13 16:24 UTC (permalink / raw)
  To: John Levon; +Cc: Christoph Egger, xen-devel

John Levon, le Wed 13 Feb 2008 16:14:20 +0000, a écrit :
> On Wed, Feb 13, 2008 at 05:06:05PM +0100, Christoph Egger wrote:
> 
> > Changeset 17028 broke the build on NetBSD in
> > tools/ioemu/hw/scsi-disk.c and tools/ioemu/hw/ide.c.
> > 
> > NetBSD doesn't have memalign(). Can you change this to use
> > posix_memalign(), please?
> 
> Solaris doesn't have posix_memalign()...

Does it have memalign() then?

Samuel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: c/s 17028: build issue
  2008-02-13 16:24   ` Samuel Thibault
@ 2008-02-13 16:26     ` John Levon
  2008-02-13 17:15       ` [PATCH] " Samuel Thibault
  0 siblings, 1 reply; 6+ messages in thread
From: John Levon @ 2008-02-13 16:26 UTC (permalink / raw)
  To: Samuel Thibault, Christoph Egger, xen-devel

On Wed, Feb 13, 2008 at 04:24:03PM +0000, Samuel Thibault wrote:

> > > Changeset 17028 broke the build on NetBSD in
> > > tools/ioemu/hw/scsi-disk.c and tools/ioemu/hw/ide.c.
> > > 
> > > NetBSD doesn't have memalign(). Can you change this to use
> > > posix_memalign(), please?
> > 
> > Solaris doesn't have posix_memalign()...
> 
> Does it have memalign() then?

Yes (sorry I wasn't clear)

regards
john

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] c/s 17028: build issue
  2008-02-13 16:26     ` John Levon
@ 2008-02-13 17:15       ` Samuel Thibault
  2008-02-14  8:22         ` Christoph Egger
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel Thibault @ 2008-02-13 17:15 UTC (permalink / raw)
  To: John Levon; +Cc: Christoph Egger, xen-devel

Ok, then this should fix it, backported from upstream.


ioemu: backport upstream's qemu_memalign.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>

diff -r 889b6b7d306f tools/ioemu/block-vbd.c
--- a/tools/ioemu/block-vbd.c	Wed Feb 13 17:02:05 2008 +0000
+++ b/tools/ioemu/block-vbd.c	Wed Feb 13 17:12:59 2008 +0000
@@ -223,7 +223,7 @@ static int vbd_read(BlockDriverState *bs
      * copying */
     if (!((uintptr_t)buf & (SECTOR_SIZE-1)))
 	return vbd_aligned_io(bs, sector_num, buf, nb_sectors, 0);
-    iobuf = memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
+    iobuf = qemu_memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
     ret = vbd_aligned_io(bs, sector_num, iobuf, nb_sectors, 0);
     memcpy(buf, iobuf, nb_sectors * SECTOR_SIZE);
     free(iobuf);
@@ -242,7 +242,7 @@ static int vbd_write(BlockDriverState *b
     int ret;
     if (!((uintptr_t)buf & (SECTOR_SIZE-1)))
 	return vbd_aligned_io(bs, sector_num, (uint8_t*) buf, nb_sectors, 1);
-    iobuf = memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
+    iobuf = qemu_memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
     memcpy(iobuf, buf, nb_sectors * SECTOR_SIZE);
     ret = vbd_aligned_io(bs, sector_num, iobuf, nb_sectors, 1);
     free(iobuf);
diff -r 889b6b7d306f tools/ioemu/hw/fdc.c
--- a/tools/ioemu/hw/fdc.c	Wed Feb 13 17:02:05 2008 +0000
+++ b/tools/ioemu/hw/fdc.c	Wed Feb 13 17:12:59 2008 +0000
@@ -378,7 +378,7 @@ struct fdctrl_t {
     uint8_t cur_drv;
     uint8_t bootsel;
     /* Command FIFO */
-    uint8_t fifo[FD_SECTOR_LEN];
+    uint8_t *fifo;
     uint32_t data_pos;
     uint32_t data_len;
     uint8_t data_state;
@@ -497,6 +497,11 @@ fdctrl_t *fdctrl_init (int irq_lvl, int 
     fdctrl = qemu_mallocz(sizeof(fdctrl_t));
     if (!fdctrl)
         return NULL;
+    fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
+    if (fdctrl->fifo == NULL) {
+        qemu_free(fdctrl);
+        return NULL;
+    }
     fdctrl->result_timer = qemu_new_timer(vm_clock, 
                                           fdctrl_result_timer, fdctrl);
 
diff -r 889b6b7d306f tools/ioemu/hw/ide.c
--- a/tools/ioemu/hw/ide.c	Wed Feb 13 17:02:05 2008 +0000
+++ b/tools/ioemu/hw/ide.c	Wed Feb 13 17:12:59 2008 +0000
@@ -2306,7 +2306,7 @@ static void ide_init2(IDEState *ide_stat
 
     for(i = 0; i < 2; i++) {
         s = ide_state + i;
-        s->io_buffer = memalign(getpagesize(), MAX_MULT_SECTORS*512 + 4);
+        s->io_buffer = qemu_memalign(getpagesize(), MAX_MULT_SECTORS*512 + 4);
         if (i == 0)
             s->bs = hd0;
         else
diff -r 889b6b7d306f tools/ioemu/hw/scsi-disk.c
--- a/tools/ioemu/hw/scsi-disk.c	Wed Feb 13 17:02:05 2008 +0000
+++ b/tools/ioemu/hw/scsi-disk.c	Wed Feb 13 17:12:59 2008 +0000
@@ -81,7 +81,7 @@ static SCSIRequest *scsi_new_request(SCS
         free_requests = r->next;
     } else {
         r = qemu_malloc(sizeof(SCSIRequest));
-	r->dma_buf = memalign(getpagesize(), SCSI_DMA_BUF_SIZE);
+	r->dma_buf = qemu_memalign(getpagesize(), SCSI_DMA_BUF_SIZE);
     }
     r->dev = s;
     r->tag = tag;
diff -r 889b6b7d306f tools/ioemu/osdep.c
--- a/tools/ioemu/osdep.c	Wed Feb 13 17:02:05 2008 +0000
+++ b/tools/ioemu/osdep.c	Wed Feb 13 17:12:59 2008 +0000
@@ -61,6 +61,10 @@ void *qemu_malloc(size_t size)
 }
 
 #if defined(_WIN32)
+void *qemu_memalign(size_t alignment, size_t size)
+{
+    return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
+}
 
 void *qemu_vmalloc(size_t size)
 {
@@ -172,6 +176,22 @@ void kqemu_vfree(void *ptr)
 
 #endif
 
+void *qemu_memalign(size_t alignment, size_t size)
+{
+#if defined(_POSIX_C_SOURCE)
+    int ret;
+    void *ptr;
+    ret = posix_memalign(&ptr, alignment, size);
+    if (ret != 0)
+        return NULL;
+    return ptr;
+#elif defined(_BSD)
+    return valloc(size);
+#else
+    return memalign(alignment, size);
+#endif
+}
+
 /* alloc shared memory pages */
 void *qemu_vmalloc(size_t size)
 {
diff -r 889b6b7d306f tools/ioemu/osdep.h
--- a/tools/ioemu/osdep.h	Wed Feb 13 17:02:05 2008 +0000
+++ b/tools/ioemu/osdep.h	Wed Feb 13 17:12:59 2008 +0000
@@ -14,6 +14,7 @@ void qemu_free(void *ptr);
 void qemu_free(void *ptr);
 char *qemu_strdup(const char *str);
 
+void *qemu_memalign(size_t alignment, size_t size);
 void *qemu_vmalloc(size_t size);
 void qemu_vfree(void *ptr);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] c/s 17028: build issue
  2008-02-13 17:15       ` [PATCH] " Samuel Thibault
@ 2008-02-14  8:22         ` Christoph Egger
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Egger @ 2008-02-14  8:22 UTC (permalink / raw)
  To: xen-devel; +Cc: John Levon, Samuel Thibault


This patch makes ioemu build again on NetBSD.
Thanks Samuel.

Christoph

On Wednesday 13 February 2008 18:15:14 Samuel Thibault wrote:
> Ok, then this should fix it, backported from upstream.
>
>
> ioemu: backport upstream's qemu_memalign.
>
> Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
>
> diff -r 889b6b7d306f tools/ioemu/block-vbd.c
> --- a/tools/ioemu/block-vbd.c	Wed Feb 13 17:02:05 2008 +0000
> +++ b/tools/ioemu/block-vbd.c	Wed Feb 13 17:12:59 2008 +0000
> @@ -223,7 +223,7 @@ static int vbd_read(BlockDriverState *bs
>       * copying */
>      if (!((uintptr_t)buf & (SECTOR_SIZE-1)))
>  	return vbd_aligned_io(bs, sector_num, buf, nb_sectors, 0);
> -    iobuf = memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
> +    iobuf = qemu_memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
>      ret = vbd_aligned_io(bs, sector_num, iobuf, nb_sectors, 0);
>      memcpy(buf, iobuf, nb_sectors * SECTOR_SIZE);
>      free(iobuf);
> @@ -242,7 +242,7 @@ static int vbd_write(BlockDriverState *b
>      int ret;
>      if (!((uintptr_t)buf & (SECTOR_SIZE-1)))
>  	return vbd_aligned_io(bs, sector_num, (uint8_t*) buf, nb_sectors, 1);
> -    iobuf = memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
> +    iobuf = qemu_memalign(PAGE_SIZE, nb_sectors * SECTOR_SIZE);
>      memcpy(iobuf, buf, nb_sectors * SECTOR_SIZE);
>      ret = vbd_aligned_io(bs, sector_num, iobuf, nb_sectors, 1);
>      free(iobuf);
> diff -r 889b6b7d306f tools/ioemu/hw/fdc.c
> --- a/tools/ioemu/hw/fdc.c	Wed Feb 13 17:02:05 2008 +0000
> +++ b/tools/ioemu/hw/fdc.c	Wed Feb 13 17:12:59 2008 +0000
> @@ -378,7 +378,7 @@ struct fdctrl_t {
>      uint8_t cur_drv;
>      uint8_t bootsel;
>      /* Command FIFO */
> -    uint8_t fifo[FD_SECTOR_LEN];
> +    uint8_t *fifo;
>      uint32_t data_pos;
>      uint32_t data_len;
>      uint8_t data_state;
> @@ -497,6 +497,11 @@ fdctrl_t *fdctrl_init (int irq_lvl, int
>      fdctrl = qemu_mallocz(sizeof(fdctrl_t));
>      if (!fdctrl)
>          return NULL;
> +    fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
> +    if (fdctrl->fifo == NULL) {
> +        qemu_free(fdctrl);
> +        return NULL;
> +    }
>      fdctrl->result_timer = qemu_new_timer(vm_clock,
>                                            fdctrl_result_timer, fdctrl);
>
> diff -r 889b6b7d306f tools/ioemu/hw/ide.c
> --- a/tools/ioemu/hw/ide.c	Wed Feb 13 17:02:05 2008 +0000
> +++ b/tools/ioemu/hw/ide.c	Wed Feb 13 17:12:59 2008 +0000
> @@ -2306,7 +2306,7 @@ static void ide_init2(IDEState *ide_stat
>
>      for(i = 0; i < 2; i++) {
>          s = ide_state + i;
> -        s->io_buffer = memalign(getpagesize(), MAX_MULT_SECTORS*512 + 4);
> +        s->io_buffer = qemu_memalign(getpagesize(), MAX_MULT_SECTORS*512 +
> 4); if (i == 0)
>              s->bs = hd0;
>          else
> diff -r 889b6b7d306f tools/ioemu/hw/scsi-disk.c
> --- a/tools/ioemu/hw/scsi-disk.c	Wed Feb 13 17:02:05 2008 +0000
> +++ b/tools/ioemu/hw/scsi-disk.c	Wed Feb 13 17:12:59 2008 +0000
> @@ -81,7 +81,7 @@ static SCSIRequest *scsi_new_request(SCS
>          free_requests = r->next;
>      } else {
>          r = qemu_malloc(sizeof(SCSIRequest));
> -	r->dma_buf = memalign(getpagesize(), SCSI_DMA_BUF_SIZE);
> +	r->dma_buf = qemu_memalign(getpagesize(), SCSI_DMA_BUF_SIZE);
>      }
>      r->dev = s;
>      r->tag = tag;
> diff -r 889b6b7d306f tools/ioemu/osdep.c
> --- a/tools/ioemu/osdep.c	Wed Feb 13 17:02:05 2008 +0000
> +++ b/tools/ioemu/osdep.c	Wed Feb 13 17:12:59 2008 +0000
> @@ -61,6 +61,10 @@ void *qemu_malloc(size_t size)
>  }
>
>  #if defined(_WIN32)
> +void *qemu_memalign(size_t alignment, size_t size)
> +{
> +    return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
> +}
>
>  void *qemu_vmalloc(size_t size)
>  {
> @@ -172,6 +176,22 @@ void kqemu_vfree(void *ptr)
>
>  #endif
>
> +void *qemu_memalign(size_t alignment, size_t size)
> +{
> +#if defined(_POSIX_C_SOURCE)
> +    int ret;
> +    void *ptr;
> +    ret = posix_memalign(&ptr, alignment, size);
> +    if (ret != 0)
> +        return NULL;
> +    return ptr;
> +#elif defined(_BSD)
> +    return valloc(size);
> +#else
> +    return memalign(alignment, size);
> +#endif
> +}
> +
>  /* alloc shared memory pages */
>  void *qemu_vmalloc(size_t size)
>  {
> diff -r 889b6b7d306f tools/ioemu/osdep.h
> --- a/tools/ioemu/osdep.h	Wed Feb 13 17:02:05 2008 +0000
> +++ b/tools/ioemu/osdep.h	Wed Feb 13 17:12:59 2008 +0000
> @@ -14,6 +14,7 @@ void qemu_free(void *ptr);
>  void qemu_free(void *ptr);
>  char *qemu_strdup(const char *str);
>
> +void *qemu_memalign(size_t alignment, size_t size);
>  void *qemu_vmalloc(size_t size);
>  void qemu_vfree(void *ptr);



-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-14  8:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-13 16:06 c/s 17028: build issue Christoph Egger
2008-02-13 16:14 ` John Levon
2008-02-13 16:24   ` Samuel Thibault
2008-02-13 16:26     ` John Levon
2008-02-13 17:15       ` [PATCH] " Samuel Thibault
2008-02-14  8:22         ` Christoph Egger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.