Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000617 [1003.1(2008)/Issue 7] System Interfaces Objection Enhancement Request 2012-09-27 01:11 2024-06-11 08:52
Reporter eblake View Status public  
Assigned To ajosey
Priority normal Resolution Accepted  
Status Closed  
Name Eric Blake
Organization Red Hat
User Reference ebb.ffsl
Section ffs
Page Number 847
Line Number 28126
Interp Status ---
Final Accepted Text
Summary 0000617: add ffsl() and ffsll()
Description Many hardware implementations have primitives for finding the first set bit on integers larger than 'int', and it would be handy to expose this to users in Issue 8. At least glibc has already implemented ffsl() and ffsll(), and it is relatively easy to find applications using these extensions.

Note that several compilers have implementation extension primitives that can easily be used to compute the longer variants of ffs; for example, with gcc, an implementation would use the builtin for counting trailing zeros, as in:
int ffsl(long i) { return i ? __builtin_ctzl(i) + 1 : 0; }

Note that current glibc chooses to expose ffsl() via <string.h> when extensions are requested, due to historical accident; but this proposal will mandate <strings.h> for symmetry with ffs(). This should not be a hardship for glibc, which already has experience with conditionally exposing symbols based on which version of the standard is requested. However, while I did not list it as part of my desired action, perhaps we should consider additional changes to allow <string.h> to expose symbols from <strings.h>, and/or allow <strings.h> to expose symbols from <string.h>. (For that matter, in glibc, strcasecmp and friends are also exposed through <string.h> when extensions are in use, so for Issue 8, perhaps it is time to consider ditching <strings.h> altogether and mandating that <string.h> provide all of the ffs and strcasecmp functions.)

Other common bit-twiddling primitives that might be worth exposing include population count (returning the number of bits set to 1 within the argument), as well as finding the position of the most significant bit (sometimes called clz). However, while gcc has primitives for these operations in the implementation namespace, glibc does not expose them via handy wrappers in the user namespace, so I have not tried to add them here.
Desired Action After line 12167 [XBD <strings.h>], add two lines with XSI shading:
int ffsl(long);
int ffsll(long long);

At line 28126 [XSH ffs NAME], change "ffs" to "ffs, ffsl, ffsll"

After line 28129, add two lines with XSI shading:
int ffsl(long i);
int ffsll(long long i);

At line 28131, change "ffs( ) function" to "ffs( ), ffsl( ), and ffsll( ) functions"

At line 28134, change:

The ffs( ) function shall return the index of the first bit set. If i is 0, then ffs( ) shall return 0.

to:

The ffs( ), ffsl( ), and ffsll( ) functions shall return the index of the first bit set. If i is 0, then these functions shall return 0.

At line 126458 [XRAT E.1 XSI_C_LANG_SUPPORT], add ffsl() and ffsll() in the list after ffs().
Tags issue8
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2012-09-27 01:11 eblake New Issue
2012-09-27 01:11 eblake Status New => Under Review
2012-09-27 01:11 eblake Assigned To => ajosey
2012-09-27 01:11 eblake Name => Eric Blake
2012-09-27 01:11 eblake Organization => Red Hat
2012-09-27 01:11 eblake User Reference => ebb.ffsl
2012-09-27 01:11 eblake Section => ffs
2012-09-27 01:11 eblake Page Number => 847
2012-09-27 01:11 eblake Line Number => 28126
2012-09-27 01:11 eblake Interp Status => ---
2014-04-03 15:47 nick Tag Attached: issue8
2014-04-03 15:48 Don Cragun Status Under Review => Resolved
2014-04-03 15:48 Don Cragun Resolution Open => Accepted
2020-03-23 10:34 geoffclare Status Resolved => Applied
2024-06-11 08:52 agadmin Status Applied => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker