IO-SocketAlarm
view release on metacpan or search on metacpan
pollfd_rbhash.h view on Meta::CPAN
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
/* MAX_TREE_HEIGHT is the maximum number of nodes from root to leaf in any
* correctly balanced tree. The exact formula for the maximum height (including
* root node) is floor(2*log2(N/2+1)) for a tree of N nodes.
*/
#define POLLFD_RBHASH_MAX_ELEMENTS_8 0x7F
#define POLLFD_RBHASH_MAX_TREE_HEIGHT_8 12
#define POLLFD_RBHASH_MAX_ELEMENTS_16 0x7FFF
#define POLLFD_RBHASH_MAX_TREE_HEIGHT_16 28
/* This macro tells you the word offset (treating rbhash as an array of words)
* of the first hash bucket.
*/
rbhash.cpppp view on Meta::CPAN
#define ${NAMESPACE}_ASSERT(x) if (!(x)) return 0
#else
#define ${NAMESPACE}_ASSERT(x) assert(x)
#endif
#endif
## my $assert= "${NAMESPACE}_ASSERT";
## section PUBLIC;
/* MAX_TREE_HEIGHT is the maximum number of nodes from root to leaf in any
* correctly balanced tree. The exact formula for the maximum height (including
* root node) is floor(2*log2(N/2+1)) for a tree of N nodes.
*/
## for my $bits (@bits) {
#define ${NAMESPACE}_MAX_ELEMENTS_$bits 0x${{ sprintf "%X", (1<<($bits-1))-1 }}
#define ${NAMESPACE}_MAX_TREE_HEIGHT_$bits ${{ int(2*log2((2**($bits-1)-1)/2+1)) }}
## }
/* This macro tells you the word offset (treating rbhash as an array of words)
* of the first hash bucket.
*/
( run in 0.234 second using v1.01-cache-2.11-cpan-26ccb49234f )