FreeBSD/contrib/ntp/libntp/ntp_calendar.c
/*
 *---------------------------------------------------------------------
 * Get sign extension mask and unsigned 2cpl rep for a signed integer
 *---------------------------------------------------------------------
 */
Get sign extension mask and unsigned 2cpl rep for a signed integer
Get sign extension mask and unsigned 2cpl rep for a signed integer
static inline uint32_t
int32_sflag(
	const int32_t v)
{
#   if TARGET_HAS_2CPL && TARGET_HAS_SAR && SIZEOF_INT >= 4
	return (uint32_t)(v >> 31);
#   else
	return UINT32_C(0) - (uint32_t)(v < 0);
#   endif
}
static inline uint32_t int32_sflag ( const int32_t v ) { #   if TARGET_HAS_2CPL && TARGET_HAS_SAR && SIZEOF_INT >= 4 return ( uint32_t ) ( v >> 31 ) ; #   else return UINT32_C ( 0 ) - ( uint32_t ) ( v < 0 ) ; #   endif }
Get sign extension mask and unsigned 2cpl rep for a signed integer
Get sign extension mask and unsigned 2cpl rep for a signed integer
/* Let's assume that shift is the fastest way to get the sign
	 * extension of of a signed integer. This might not always be
	 * true, though -- On 8bit CPUs or machines without barrel
	 * shifter this will kill the performance. So we make sure
	 * we do this only if 'int' has at least 4 bytes.
	 */ /* This should be a rather generic approach for getting a sign
	 * extension mask...
	 */