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
0001106 [1003.1(2016/18)/Issue7+TC2] Base Definitions and Headers Editorial Enhancement Request 2016-12-07 14:11 2018-05-24 15:28
Reporter EdSchouten View Status public  
Assigned To ajosey
Priority normal Resolution Rejected  
Status Closed  
Name Ed Schouten
Organization Nuxi
User Reference
Section <stdlib.h>
Page Number -
Line Number -
Interp Status ---
Final Accepted Text
Summary 0001106: *rand48(): Should this use uint16_t instead of unsigned short?
Description The *rand48() functions implement a 48-bits linear congruential generator PRNG. The state of this PRNG is stored in an array of three values of type unsigned short. For example:

long jrand48(unsigned short xsubi[3]);

POSIX requires that two's-complement is used and unsigned short is at least 16 bits in size, meaning that in our context unsigned short is sufficient. Still, it looks kind of odd. Modern code that would want to model a 48-bit integer this way would use an array of uint16_t's.

I would therefore like to propose that the prototypes of these functions are adjusted. This should have little to no impact on compatibility, as (almost?) all POSIX-like systems define unsigned short and uint16_t equally.
Desired Action Proposed changes:

----------------------------------------------------------------------
In article http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html [^] :

- Under "The <stdlib.h> header shall define the following data types through typedef", add the following:

[XSI]uint16_t
As described in <stdint.h>.[XSI]

- Replace all occurrences of 'unsigned short' with 'uint16_t'.

In article http://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html [^] :

- Replace all occurrences of 'unsigned short' with 'uint16_t'.
----------------------------------------------------------------------

Using the same reasoning, the typing of jrand48(), lrand48(), mrand48() and nrand48() could be improved to return a value of type int32_t. That said, such a change could potentially break compatibility with existing code. Similar problems apply to a64l() and l64a() as well.
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0004039)
Don Cragun (manager)
2018-05-24 15:27

The standard permits uint16_t and unsigned short to be distinct types, even if they
have the same bitwise layout; on such an implementation, changing the signature
would cause a compilation error on existing code due to type mismatch. These
interfaces are intended for backwards compatibility, not for use in new code.
Since changing the signature could break existing code, we have decided to reject
this change request.

- Issue History
Date Modified Username Field Change
2016-12-07 14:11 EdSchouten New Issue
2016-12-07 14:11 EdSchouten Status New => Under Review
2016-12-07 14:11 EdSchouten Assigned To => ajosey
2016-12-07 14:11 EdSchouten Name => Ed Schouten
2016-12-07 14:11 EdSchouten Organization => Nuxi
2016-12-07 14:11 EdSchouten Section => <stdlib.h>
2016-12-07 14:11 EdSchouten Page Number => -
2016-12-07 14:11 EdSchouten Line Number => -
2016-12-08 15:23 geoffclare Project 1003.1(2008)/Issue 7 => 1003.1(2016/18)/Issue7+TC2
2018-05-24 15:27 Don Cragun Note Added: 0004039
2018-05-24 15:28 Don Cragun Interp Status => ---
2018-05-24 15:28 Don Cragun Status Under Review => Closed
2018-05-24 15:28 Don Cragun Resolution Open => Rejected


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