mailing list of musl libc
 help / color / mirror / code / Atom feed
* question about malloc's bin_index
@ 2014-11-20  2:43 Weiming Zhao
  2014-11-20  4:06 ` Rich Felker
  2014-11-20  4:47 ` weimingz
  0 siblings, 2 replies; 4+ messages in thread
From: Weiming Zhao @ 2014-11-20  2:43 UTC (permalink / raw)
  To: musl; +Cc: weimingz

[-- Attachment #1: Type: text/plain, Size: 760 bytes --]

Hi,

 

I'm trying to use MUSL on a hardware without floating point unit, however,
the "union" in the bin_index brings some issues.

I'm using -mgeneral-regs-only and gcc refuses to compile it due to the
floating point conversion.

 

I'm wondering what's the purpose of the union? How should I rewrite it to
use integer only?

 

static int bin_index(size_t x)

{

                x = x / SIZE_ALIGN - 1;

                if (x <= 32) return x;

                if (x > 0x1c00) return 63;

                return ((union { float v; uint32_t r; }){(int)x}.r>>21) -
496;  

}

 

Thanks a lot,

Weiming

 

Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, 
a Linux Foundation Collaborative Project

 


[-- Attachment #2: Type: text/html, Size: 3856 bytes --]

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

end of thread, other threads:[~2014-11-20  6:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-20  2:43 question about malloc's bin_index Weiming Zhao
2014-11-20  4:06 ` Rich Felker
2014-11-20  6:32   ` Szabolcs Nagy
2014-11-20  4:47 ` weimingz

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).