If the size of the space requested is zero, the behavior is implementation-defined; the value returned shall be either a null pointer or a unique pointer.
As per the specification, it has to be a unique pointer.
Being tasked to implement a specification typically means having to pass extensive conformance tests and having to answer for instances of noncompliance. You soon learn to follow the spec to the letter, to the best of your abilities, unless you can make a strong case to your management for each specific deviation.
But the letter is non-specific. It doesn't clarify if unique refers to unique when compared to non-zero allocations, or unique when called multiple times.
The C99 standard[1] seems to have worded it more precisely:
If the size of the space requested is zero, the behavior is implementation- defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object.
Could you please specify what have you meant by Fixed Function blocks on Adreno300+? Did you mean regular Rasterizer, DS and vertex assembler by this, or even portions of old FFP functionality just like lighting and etc from ES 1.x?
Because I think there is no need in HW 1.x support, since even Samsung in their FIMG emulated most of classic FFP functionality like combiners through shades.
I haven't investigated SGX53x drivers yet, but I think it was very same, since PVR MBX architecture was mostly abandoned in 2010.
And second question:
Why so many of early qcom android smartphones lacked GPU drivers at all? For example HTC Dream wasn't shipped with gpu drivers, as well as Magic and many Huawei models? For example, Moto droid has GPU drivers from the start.
> Could you please specify what have you meant by Fixed Function blocks on Adreno300+? Did you mean regular Rasterizer, DS and vertex assembler by this, or even portions of old FFP functionality just like lighting and etc from ES 1.x?
This happened almost 20 years ago and I can't even remember what I had for breakfast yesterday, so take everything I say with a grain of salt.
Re. The switch from Adreno 200 to 300. Both had a unified (vertex+pixel) programmable shader unit. They were completely different, with the 200 sporting a VLIW 4+1 vector unit that AMD used at the time, while the 300 was scalar and based on Qualcomm's unreleased QShader core. This made things a lot easier for the poor compiler team.
Sorry, I don't want to go into details about what features were implemented in hardware vs shaders. Every GPU does things a little differently in that regard and there's always some secret sauce. Sometimes features are fully implemented in hardware, sometimes they are fully based on shaders, and often there's a bit of both.
As for Imagination Technologies' SGX 530, which was the successor to PVR MBX, it also had a scalar unified shader unit. I never worked on the MBX, but I was involved in the development of the SGX family back in 2006-2007. Once again, the details of what features were implemented in hardware vs shaders was complicated and I won't get into the secret sauce.
> Why so many of early qcom android smartphones lacked GPU drivers at all? For example HTC Dream wasn't shipped with gpu drivers, as well as Magic and many Huawei models
The question is puzzling to me. The drivers may not be easy to find, but OpenGL would not work without drivers. The HTC Dream shipped with Adreno 130, which I had the unfortunate experience of having to support circa 2008 even though I had not been involved in its development. It felt ancient even at the time, with a super basic vertex shader that we had to manually program in the most rudimentary assembly. Did it even have a pixel shader? God, I can't remember a thing. It did support user clipping planes and stencils. Oh, the nightmares, they haunt me.
Sorry, going back on topic. Yeah, there were drivers for that clunker. They must be hidden somewhere. Please spare a prayer for the souls of the poor bastards who had to work on that abomination. I can't understand how they were able to hold on to their sanity after going through that experience.
Thanks for refreshing my memory. It was Type II fun, for sure.
Well, sure, standards compliance doesn't matter much on such a small device.
Personally I'd be less worried about uniqueness and more worried about alignment. An address of -1 would violate alignment requirements on most modern targets. But that may have been fine on the target in question; older microcontrollers tended to not have any hardware-level alignment requirements, and the C implementation could have treated all types as having alignment 1.