The 32-bit counter eventually wraps to 0 which is a sentinel for invalid id.
Make it 64-bit on LP64 platforms and 0-check otherwise.
Note: Linux counterpart uses id stored per queue instead of a global.
I did not check going that way is feasible with the goal being the minimal fix doing the job.
Once this is sorted out I'll post a review on github.