Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 19 Nov 2014 18:43:23 -0800
From: "Weiming Zhao" <weimingz@...eaurora.org>
To: <musl@...ts.openwall.com>
Cc: <weimingz@...eaurora.org>
Subject: question about malloc's bin_index

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

 


Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.