Everything: Update lots of code to use B_COUNT_OF macro

* Likely not everything, but the obvious uses of B_COUNT_OF
This commit is contained in:
Alexander von Gluck IV
2014-11-09 14:52:19 -06:00
parent f2b20f8804
commit 57bc65034a
35 changed files with 56 additions and 116 deletions
@@ -24,10 +24,6 @@
#define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog
#define ARRAY_SIZE(a) (int(sizeof(a) / sizeof(a[0]))) // get number of elements in an array
struct Benaphore {
sem_id sem;
int32 count;
@@ -24,8 +24,6 @@
#define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog
#define ARRAY_SIZE(a) (int(sizeof(a) / sizeof(a[0]))) // get number of elements in an array
struct Benaphore {
sem_id sem;
int32 count;
@@ -22,8 +22,6 @@
#define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog
#define ARRAY_SIZE(a) (int(sizeof(a) / sizeof(a[0]))) // get number of elements in an array
struct Benaphore {
sem_id sem;
@@ -23,8 +23,6 @@
#define ENABLE_DEBUG_TRACE // if defined, turns on debug output to syslog
#define NUM_ELEMENTS(a) ((int)(sizeof(a) / sizeof(a[0]))) // for computing number of elements in an array
struct Benaphore {
sem_id sem;
int32 count;
+1 -3
View File
@@ -19,8 +19,6 @@
#include <unistd.h>
struct DisplayParams {
// CRTC registers
uint32 crtc_gen_cntl;
@@ -225,7 +223,7 @@ CalculatePLLRegisters(const DisplayModeEx& mode, DisplayParams& params)
int bitValue = -1;
uint32 output_freq;
for (int j = 0; j < ARRAY_SIZE(postDividers); j++) {
for (int j = 0; j < B_COUNT_OF(postDividers); j++) {
output_freq = postDividers[j].divider * freq;
if (output_freq >= pll.min_pll_freq && output_freq <= pll.max_pll_freq) {
params.feedback_div = DivideWithRounding(pll.reference_div * output_freq,
@@ -117,11 +117,11 @@ I810_GetWatermark(const DisplayModeEx& mode)
switch (mode.bitsPerPixel) {
case 8:
table = watermarks_8;
tableLen = ARRAY_SIZE(watermarks_8);
tableLen = B_COUNT_OF(watermarks_8);
break;
case 16:
table = watermarks_16;
tableLen = ARRAY_SIZE(watermarks_16);
tableLen = B_COUNT_OF(watermarks_16);
break;
default:
return 0;
+3 -5
View File
@@ -128,8 +128,6 @@ static int8 y_saw_tooth_slope[5] = { 1, 2, 2, 4, 8 };
static int8 y_coeff_value[5] = { 2, 2, 0, 4, 0 };
static bool y_coeff_enable[5] = { 1, 1, 0, 1, 0 };
#define countof( a ) (sizeof( (a) ) / sizeof( (a)[0] ))
// fixed point resolution of saw filter parameters
#define TV_SAW_FILTER_FIX_SHIFT 13
#define TV_SAW_FILTER_FIX_SCALE (1 << TV_SAW_FILTER_FIX_SHIFT)
@@ -151,15 +149,15 @@ static void Radeon_CalcImpacTVFlickerFixer(
lower_border = ((params->uv_inc + TV_UV_INC_FIX_SCALE - 1) >> TV_UV_INC_FIX_SHIFT);
upper_border = ((2 * params->uv_inc) >> TV_UV_INC_FIX_SHIFT);
for( i = 0; i < countof( y_flicker_removal ); ++i ) {
for( i = 0; i < B_COUNT_OF( y_flicker_removal ); ++i ) {
if( lower_border <= y_flicker_removal[i] &&
upper_border > y_flicker_removal[i] )
break;
}
// use least aggresive filtering if not in list
if( i >= countof( y_flicker_removal ))
i = countof( y_flicker_removal ) - 1;
if( i >= B_COUNT_OF( y_flicker_removal ))
i = B_COUNT_OF( y_flicker_removal ) - 1;
flicker_removal = y_flicker_removal[i];
+8 -9
View File
@@ -349,7 +349,6 @@ typedef struct {
// = 0: source pixel increment = 1, 4-tap filter
} hscale_factor;
#define count_of( a ) (sizeof( a ) / sizeof( a[0] ))
// scaling/filter tables depending on overlay colour space:
// magnifying pixels is no problem, but minifying can lead to overload,
@@ -432,17 +431,17 @@ static space_params space_params_table[16] = {
{ 0, 0, 0, 0, 0, NULL, 0 }, // reserved
{ 0, 0, 0, 0, 0, NULL, 0 }, // reserved
{ 0, 0, 0, 0, 0, NULL, 0 }, // reserved
{ 1, 1, 1, 0, 0, scale_RGB16, count_of( scale_RGB16 ) }, // RGB15
{ 1, 1, 1, 0, 0, scale_RGB16, count_of( scale_RGB16 ) }, // RGB16
{ 1, 1, 1, 0, 0, scale_RGB16, B_COUNT_OF( scale_RGB16 ) }, // RGB15
{ 1, 1, 1, 0, 0, scale_RGB16, B_COUNT_OF( scale_RGB16 ) }, // RGB16
{ 0, 0, 0, 0, 0, NULL, 0 }, // reserved
{ 2, 2, 1, 0, 0, scale_RGB32, count_of( scale_RGB32 ) }, // RGB32
{ 2, 2, 1, 0, 0, scale_RGB32, B_COUNT_OF( scale_RGB32 ) }, // RGB32
{ 0, 0, 0, 0, 0, NULL, 0 }, // reserved
{ 0, 0, 0, 0, 0, NULL, 0 }, // reserved
{ 0, 0, 3, 2, 2, scale_YUV9, count_of( scale_YUV9 ) }, // YUV9
{ 0, 0, 3, 1, 1, scale_YUV12, count_of( scale_YUV12 ) }, // YUV12, three-plane
{ 1, 1, 1, 1, 0, scale_YUV, count_of( scale_YUV ) }, // VYUY422
{ 1, 1, 1, 1, 0, scale_YUV, count_of( scale_YUV ) }, // YVYU422
{ 0, 1, 2, 1, 1, scale_YUV12, count_of( scale_YUV12 ) }, // YUV12, two-plane
{ 0, 0, 3, 2, 2, scale_YUV9, B_COUNT_OF( scale_YUV9 ) }, // YUV9
{ 0, 0, 3, 1, 1, scale_YUV12, B_COUNT_OF( scale_YUV12 ) }, // YUV12, three-plane
{ 1, 1, 1, 1, 0, scale_YUV, B_COUNT_OF( scale_YUV ) }, // VYUY422
{ 1, 1, 1, 1, 0, scale_YUV, B_COUNT_OF( scale_YUV ) }, // YVYU422
{ 0, 1, 2, 1, 1, scale_YUV12, B_COUNT_OF( scale_YUV12 ) }, // YUV12, two-plane
{ 0, 1, 2, 1, 1, NULL, 0 }, // ???
{ 0, 0, 0, 0, 0, NULL, 0 } // reserved
};
@@ -1966,8 +1966,7 @@ encoder_output_lock(bool lock)
Write32(OUT, R600_SCRATCH_REG6, biosScratch6);
}
static const uint32 ENCODER_NAME_MATRIX_SIZE = 37;
static const char* encoder_name_matrix[ENCODER_NAME_MATRIX_SIZE] = {
static const char* encoder_name_matrix[] = {
"NONE",
"Internal Radeon LVDS",
"Internal Radeon TMDS1",
@@ -2010,7 +2009,7 @@ static const char* encoder_name_matrix[ENCODER_NAME_MATRIX_SIZE] = {
const char*
encoder_name_lookup(uint32 encoderID) {
if (encoderID < ENCODER_NAME_MATRIX_SIZE)
if (encoderID < B_COUNT_OF(encoder_name_matrix))
return encoder_name_matrix[encoderID];
else
return "Unknown";
+1 -1
View File
@@ -565,7 +565,7 @@ Savage_WriteMode(const DisplayModeEx& mode, const SavageRegRec& regRec)
WriteCrtcReg(0x11, 0x00, 0x80); // unlock CRTC reg's 0-7 by clearing bit 7 of cr11
for (int j = 0; j < NUM_ELEMENTS(regRec.CRTC); j++)
for (int j = 0; j < B_COUNT_OF(regRec.CRTC); j++)
WriteCrtcReg(j, regRec.CRTC[j]);
// Setup HSYNC & VSYNC polarity.
+1 -1
View File
@@ -178,7 +178,7 @@ Trio64_ModeInit(const DisplayModeEx& mode)
WriteCrtcReg(0x11, 0x00, 0x80); // unlock CRTC reg's 0-7 by clearing bit 7 of cr11
for (int k = 0; k < NUM_ELEMENTS(crtc); k++) {
for (int k = 0; k < B_COUNT_OF(crtc); k++) {
WriteCrtcReg(k, crtc[k]);
}
+1 -1
View File
@@ -396,7 +396,7 @@ Virge_WriteMode(const DisplayModeEx& mode, VirgeRegRec& regRec)
WriteCrtcReg(0x11, 0x00, 0x80); // unlock CRTC reg's 0-7 by clearing bit 7 of cr11
for (int j = 0; j < NUM_ELEMENTS(regRec.CRTC); j++) {
for (int j = 0; j < B_COUNT_OF(regRec.CRTC); j++) {
WriteCrtcReg(j, regRec.CRTC[j]);
}
@@ -64,8 +64,6 @@ struct usb_support_descriptor supported_devices[] = {
{0, 0, 0, 0, 0}
};
#define SIZEOF(array) (sizeof(array)/sizeof(array[0])) //?????
usb_device_info *usb_devices[MAX_DEVICES_COUNT];
/* main devices table locking semaphore */
sem_id usb_serial_lock = -1;
@@ -929,7 +927,7 @@ static status_t std_ops(int32 op, ...)
for(i = 0; i < MAX_DEVICES_COUNT; i++)
usb_devices[i] = NULL;
if((*usb->register_driver)(MODULE_NAME, supported_devices, SIZEOF(supported_devices), "usb_dsk") == B_OK){
if((*usb->register_driver)(MODULE_NAME, supported_devices, B_COUNT_OF(supported_devices), "usb_dsk") == B_OK){
if((*usb->install_notify)(MODULE_NAME, &notify_hooks) == B_OK){
entry.sim_init = sim_init;
entry.sim_action = sim_action;
@@ -372,7 +372,7 @@ Device::_MultiGetDescription(multi_description *multiDescription)
return B_BAD_ADDRESS;
if (Description.request_channel_count
>= (int)(_countof(channel_descriptions))) {
>= (int)(B_COUNT_OF(channel_descriptions))) {
if (user_memcpy(multiDescription->channels,
&channel_descriptions, sizeof(channel_descriptions)) != B_OK)
return B_BAD_ADDRESS;
@@ -42,7 +42,7 @@ init_hardware()
pci_info info = {0};
for (long i = 0; B_OK == (*gPCI->get_nth_pci_info)(i, &info); i++) {
for (size_t idx = 0; idx < _countof(cardInfos); idx++) {
for (size_t idx = 0; idx < B_COUNT_OF(cardInfos); idx++) {
if (info.vendor_id == cardInfos[idx].VendorId() &&
info.device_id == cardInfos[idx].DeviceId())
{
@@ -69,7 +69,7 @@ init_driver()
pci_info info = { 0 };
for (long i = 0; B_OK == (*gPCI->get_nth_pci_info)(i, &info); i++) {
for (size_t idx = 0; idx < _countof(cardInfos); idx++) {
for (size_t idx = 0; idx < B_COUNT_OF(cardInfos); idx++) {
if (info.vendor_id == cardInfos[idx].VendorId() &&
info.device_id == cardInfos[idx].DeviceId())
{
@@ -104,7 +104,7 @@ Mixer::_ReadSupportedFormats()
{ CAP_PCM_RATE_48000, B_SR_48000 }
};
for (size_t i = 0; i < _countof(caps); i++) {
for (size_t i = 0; i < B_COUNT_OF(caps); i++) {
if (ac97_has_capability(fAC97Dev, caps[i].fCap))
fOutputRates |= caps[i].fRate;
}
@@ -556,7 +556,7 @@ Mixer::_CreateMIXControlGroup(multi_mix_control_info* MultiInfo, int32& index,
TRACE("MUX:%#010x\n", Controls[index].id);
index++;
for (size_t i = 0; i < _countof(RecordSources); i++) {
for (size_t i = 0; i < B_COUNT_OF(RecordSources); i++) {
Controls[index].id = IdMUXReg | (i << stepShift) | MIX_MUX;
Controls[index].flags = B_MULTI_MIX_MUX_VALUE;
Controls[index].master = 0;
@@ -585,7 +585,7 @@ Mixer::ListMixControls(multi_mix_control_info* Info)
Controls[index].string = S_OUTPUT;
index++;
for (size_t i = 0; i < _countof(OutputControls); i++) {
for (size_t i = 0; i < B_COUNT_OF(OutputControls); i++) {
_CreateMIXControlGroup(Info, index, mixerGroup, OutputControls[i]);
}
@@ -596,7 +596,7 @@ Mixer::ListMixControls(multi_mix_control_info* Info)
Controls[index].string = S_INPUT;
index++;
for (size_t i = 0; i < _countof(InputControls); i++) {
for (size_t i = 0; i < B_COUNT_OF(InputControls); i++) {
_CreateMIXControlGroup(Info, index, inputGroup, InputControls[i]);
}
@@ -608,7 +608,7 @@ Mixer::ListMixControls(multi_mix_control_info* Info)
strlcpy(Controls[index].name, "Record", sizeof(Controls[index].name));
index++;
for (size_t i = 0; i < _countof(RecordControls); i++) {
for (size_t i = 0; i < B_COUNT_OF(RecordControls); i++) {
_CreateMIXControlGroup(Info, index, recordGroup, RecordControls[i]);
}
@@ -13,13 +13,6 @@
#include "Driver.h"
#ifdef _countof
#warning "_countof(...) WAS ALREADY DEFINED!!! Remove local definition!"
#undef _countof
#endif
#define _countof(array)(sizeof(array) / sizeof(array[0]))
void load_settings();
void release_settings();
@@ -231,7 +231,7 @@ _Terminal::_GetTerminalDescription(uint16 TerminalType)
{ USB_AUDIO_INSTRUMENT_IO, "Musical Instrument" }
};
for (size_t i = 0; _countof(termInfoPairs); i++)
for (size_t i = 0; B_COUNT_OF(termInfoPairs); i++)
if (termInfoPairs[i].type == TerminalType)
return termInfoPairs[i].description;
@@ -673,7 +673,7 @@ FeatureUnit::NormalizeAndTraceChannel(int32 Channel)
bool isRev1 = (fInterface->SpecReleaseNumber() < 0x200);
uint32 remappedBitmap = 0;
for (size_t i = 0; i < _countof(remapInfos); i++) {
for (size_t i = 0; i < B_COUNT_OF(remapInfos); i++) {
uint32 bits = isRev1 ? remapInfos[i].rev1Bits : remapInfos[i].rev2Bits;
if ((fControlBitmaps[Channel] & bits) > 0) {
if (isRev1)
@@ -1257,7 +1257,7 @@ AudioControlInterface::_InitGainLimits(multi_mix_control& Control)
Control.gain.granularity = 1.;
size_t actualLength = 0;
for (size_t i = 0; i < _countof(gainInfos); i++) {
for (size_t i = 0; i < B_COUNT_OF(gainInfos); i++) {
status_t status = gUSBModule->send_request(fDevice->USBDevice(),
USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_CLASS,
gainInfos[i].request, REQ_VALUE(Control.id),
@@ -1413,7 +1413,7 @@ AudioControlInterface::_ListFeatureUnitControl(int32& index, int32 parentIndex,
int32 masterIndex = 0; // in case master channel has no volume
// control - add following "L+R" channels into it
for (size_t i = 0; i < _countof(channelInfos); i++) {
for (size_t i = 0; i < B_COUNT_OF(channelInfos); i++) {
if ((channelsConfig & channelInfos[i].Mask) != channelInfos[i].Mask) {
// ignore non-listed and possibly non-paired stereo channels.
// note that master channel with zero mask pass this check! ;-)
@@ -1734,7 +1734,7 @@ AudioControlInterface::_ListMixControlsForMixerUnit(int32& index,
if (!outIsEx) {
// special case - extended (>2 channels) input cluster
// connected to 2-channels output - add into generic "Mixer" page
for (size_t i = 0; i < _countof(channelPairs); i++)
for (size_t i = 0; i < B_COUNT_OF(channelPairs); i++)
_CollectMixerUnitControls(controlIds,
channelPairs[i].inLeft, kLeftChannel,
channelPairs[i].inRight, kRightChannel,
@@ -1745,8 +1745,8 @@ AudioControlInterface::_ListMixControlsForMixerUnit(int32& index,
// make separate mixer pages for set of extended (>2) input
// channels connected to extended (>2 channels) output
for (size_t in = 0; in < _countof(channelPairs); in++) {
for (size_t out = 0; out < _countof(channelPairs); out++) {
for (size_t in = 0; in < B_COUNT_OF(channelPairs); in++) {
for (size_t out = 0; out < B_COUNT_OF(channelPairs); out++) {
char outName[sizeof(Info->controls->name)] = { 0 };
if (in == out)
strlcpy(outName, channelPairs[out].name, sizeof(outName));
@@ -281,7 +281,7 @@ AudioStreamAlternate::GetSamplingRateId(uint32 rate)
if (rate == 0)
rate = fSamplingRate;
for (size_t i = 0; i < _countof(ratesMap); i++)
for (size_t i = 0; i < B_COUNT_OF(ratesMap); i++)
if (ratesMap[i].rate == rate)
return ratesMap[i].rateId;
@@ -369,7 +369,7 @@ AudioStreamAlternate::GetFormatId()
uint32
AudioStreamAlternate::SamplingRateFromId(uint32 id)
{
for (size_t i = 0; i < _countof(ratesMap); i++)
for (size_t i = 0; i < B_COUNT_OF(ratesMap); i++)
if (ratesMap[i].rateId == id)
return ratesMap[i].rate;
@@ -22,13 +22,6 @@ const uint32 kSamplesBufferSize = 1024;
// [sub]buffers count
const uint32 kSamplesBufferCount = 2;
// calculate count of array members
#ifdef _countof
#warning "countof(...) WAS ALREADY DEFINED!!! Remove local definition!"
#undef countof
#endif
#define _countof(array)(sizeof(array) / sizeof(array[0]))
extern usb_module_info* gUSBModule;
@@ -536,7 +536,7 @@ Device::_InitRxFilter()
// disable disable packet filtering before address is set
WritePCI32(RxMACControl, (filter & ~RXM_Mask));
for (size_t i = 0; i < _countof(fMACAddress.ebyte); i++) {
for (size_t i = 0; i < B_COUNT_OF(fMACAddress.ebyte); i++) {
WritePCI8(RxMACAddress + i, fMACAddress.ebyte[i]);
}
@@ -581,7 +581,7 @@ Device::ReadMACAddress(ether_address_t& address)
TRACE("EEPROM Signature: %#06x\n", signature);
if (signature != 0x0000 && signature != EIInvalid) {
for (size_t i = 0; i < _countof(address.ebyte) / 2; i++) {
for (size_t i = 0; i < B_COUNT_OF(address.ebyte) / 2; i++) {
uint16 addr = _ReadEEPROM(EEPROMAddress + i);
address.ebyte[i * 2 + 0] = (uint8)addr;
address.ebyte[i * 2 + 1] = (uint8)(addr >> 8);
@@ -607,7 +607,7 @@ Device::ReadMACAddress(ether_address_t& address)
if (pciInfo.vendor_id != 0x1039)
continue;
for (size_t idx = 0; idx < _countof(ids); idx++) {
for (size_t idx = 0; idx < B_COUNT_OF(ids); idx++) {
if (pciInfo.device_id == ids[idx]) {
// enable ports 0x78 0x79 to access APC registers
@@ -621,7 +621,7 @@ Device::ReadMACAddress(ether_address_t& address)
pciInfo.device, pciInfo.function, 0x48, 1);
// read factory MAC address
for (size_t i = 0; i < _countof(address.ebyte); i++) {
for (size_t i = 0; i < B_COUNT_OF(address.ebyte); i++) {
gPCIModule->write_io_8(0x78, 0x09 + i);
address.ebyte[i] = gPCIModule->read_io_8(0x79);
}
@@ -735,7 +735,7 @@ Device::DumpRegisters()
{ Reserved2, "Reserved2", false }
};
for (size_t i = 0; i < _countof(RegisterEntries); i++) {
for (size_t i = 0; i < B_COUNT_OF(RegisterEntries); i++) {
uint32 registerContents = ReadPCI32(RegisterEntries[i].Base);
kprintf("%s:\t%08" B_PRIx32 "\n", RegisterEntries[i].Name,
registerContents);
@@ -48,7 +48,7 @@ init_hardware()
pci_info info = {0};
for (long i = 0; B_OK == (*gPCIModule->get_nth_pci_info)(i, &info); i++) {
for (size_t idx = 0; idx < _countof(cardInfos); idx++) {
for (size_t idx = 0; idx < B_COUNT_OF(cardInfos); idx++) {
if (CARDID(info.vendor_id, info.device_id) == cardInfos[idx].Id()) {
TRACE_ALWAYS("Found:%s %#010x\n",
cardInfos[idx].Description(), cardInfos[idx].Id());
@@ -122,7 +122,7 @@ init_driver()
pci_info info = {0};
for (long i = 0; B_OK == (*gPCIModule->get_nth_pci_info)(i, &info); i++) {
for (size_t idx = 0; idx < _countof(cardInfos); idx++) {
for (size_t idx = 0; idx < B_COUNT_OF(cardInfos); idx++) {
if (info.vendor_id == cardInfos[idx].VendorId()
&& info.device_id == cardInfos[idx].DeviceId())
{
@@ -77,7 +77,7 @@ MIIBus::Init()
TRACE("MII Info(addr:%d,id:%#010x): OUI:%04x; Model:%04x; rev:%02x.\n",
addr, Id, MII_OUI(Id), MII_MODEL(Id), MII_REV(Id));
for (size_t i = 0; i < _countof(miiChipTable); i++){
for (size_t i = 0; i < B_COUNT_OF(miiChipTable); i++){
ChipInfo& info = miiChipTable[i];
if (info.fId != UnknownPHY && info.fId != (Id & 0xfffffff0))
@@ -14,13 +14,6 @@
#include "Registers.h"
#ifdef _countof
#warning "_countof(...) WAS ALREADY DEFINED!!! Remove local definition!"
#undef _countof
#endif
#define _countof(array)(sizeof(array) / sizeof(array[0]))
void load_settings();
void release_settings();
@@ -411,7 +411,7 @@ AX88772Device::_WakeupPHY()
{ SW_RESET_IPRL, 31000 }
};
for (size_t i = 0; i < _countof(resetCommands); i++) {
for (size_t i = 0; i < B_COUNT_OF(resetCommands); i++) {
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
resetCommands[i].reset, 0, 0, 0, &actualLength);
@@ -90,7 +90,7 @@ lookup_and_create_device(usb_device device)
uint32 id = deviceDescriptor->vendor_id << 16
| deviceDescriptor->product_id;
int left = -1;
int right = _countof(gSupportedDevices);
int right = B_COUNT_OF(gSupportedDevices);
while ((right - left) > 1) {
int i = (left + right) / 2;
((gSupportedDevices[i].Key() < id) ? left : right) = i;
@@ -233,7 +233,7 @@ init_driver()
&usb_asix_device_removed
};
const size_t count = _countof(gSupportedDevices);
const size_t count = B_COUNT_OF(gSupportedDevices);
static usb_support_descriptor sDescriptors[count] = {{ 0 }};
for (size_t i = 0; i < count; i++) {
@@ -18,13 +18,6 @@
#include "Driver.h"
#ifdef _countof
#warning "_countof(...) WAS ALREADY DEFINED!!! Remove local definition!"
#undef _countof
#endif
#define _countof(array)(sizeof(array) / sizeof(array[0]))
void load_settings();
void release_settings();
@@ -64,7 +64,7 @@ lookup_and_create_device(usb_device device)
uint32 id = deviceDescriptor->vendor_id << 16
| deviceDescriptor->product_id;
int left = -1;
int right = _countof(gSupportedDevices);
int right = B_COUNT_OF(gSupportedDevices);
while ((right - left) > 1) {
int i = (left + right) / 2;
((gSupportedDevices[i].Key() < id) ? left : right) = i;
@@ -192,7 +192,7 @@ init_driver()
&usb_davicom_device_removed
};
const size_t count = _countof(gSupportedDevices);
const size_t count = B_COUNT_OF(gSupportedDevices);
static usb_support_descriptor sDescriptors[count] = {{ 0 }};
for (size_t i = 0; i < count; i++) {
@@ -7,13 +7,6 @@
#define _USB_DAVICOM_SETTINGS_H_
#ifdef _countof
#warning "_countof(...) WAS ALREADY DEFINED!!! Remove local definition!"
#undef _countof
#endif
#define _countof(array)(sizeof(array) / sizeof(array[0]))
void load_settings();
void release_settings();
void usb_davicom_trace(bool force, const char *func, const char *fmt, ...);
@@ -97,8 +97,6 @@ struct serial_config_descriptor {
};
/* Some usefull helper defines ... */
#define SIZEOF(array) (sizeof(array) / sizeof(array[0])) /* size of array */
/* This one rounds the size to integral count of segs (segments) */
#define ROUNDUP(size, seg) (((size) + (seg) - 1) & ~((seg) - 1))
/* Default device buffer size */
@@ -28,8 +28,6 @@ extern "C" {
#define DRIVER_NAME "usb_serial" // driver name for debug output
#define DEVICES_COUNT 20 // max simultaneously open devices
/* Some usefull helper defines ... */
#define SIZEOF(array) (sizeof(array) / sizeof(array[0])) /* size of array */
/* This one rounds the size to integral count of segs (segments) */
#define ROUNDUP(size, seg) (((size) + (seg) - 1) & ~((seg) - 1))
/* Default device buffer size */
@@ -131,11 +131,11 @@ ProlificDevice::ResetDevice()
{
TRACE_FUNCALLS("> ProlificDevice::ResetDevice(%08x)\n", this);
SendRequestList(prolific_reset_common, SIZEOF(prolific_reset_common));
SendRequestList(prolific_reset_common, B_COUNT_OF(prolific_reset_common));
if (fIsHX)
SendRequestList(prolific_reset_common_hx, SIZEOF(prolific_reset_common_hx));
SendRequestList(prolific_reset_common_hx, B_COUNT_OF(prolific_reset_common_hx));
else
SendRequestList(prolific_reset_common_nhx, SIZEOF(prolific_reset_common_nhx));
SendRequestList(prolific_reset_common_nhx, B_COUNT_OF(prolific_reset_common_nhx));
status_t status = B_OK; /* discard */
TRACE_FUNCRET("< ProlificDevice::ResetDevice() returns: 0x%08x\n", status);
@@ -60,7 +60,7 @@ status_t init_driver (void){
usb_vision_names[0] = NULL;
(*usb->register_driver)(DRIVER_NAME, supported_devices, SIZEOF(supported_devices), DRIVER_NAME);
(*usb->register_driver)(DRIVER_NAME, supported_devices, B_COUNT_OF(supported_devices), DRIVER_NAME);
(*usb->install_notify)(DRIVER_NAME, &notify_hooks);
usb_vision_lock = create_sem(1, DRIVER_NAME"_devices_table_lock");
@@ -348,7 +348,7 @@ status_t usb_vision_device_added(const usb_device *dev, void **cookie){
TRACE_ALWAYS("Probing device: %08x/%08x\n", udd->vendor_id, udd->product_id);
*cookie = 0;
for(dev_idx = 0; dev_idx < SIZEOF(supported_devices); dev_idx++)
for(dev_idx = 0; dev_idx < B_COUNT_OF(supported_devices); dev_idx++)
if(supported_devices[dev_idx].vendor == udd->vendor_id
&& supported_devices[dev_idx].product == udd->product_id){
const usb_configuration_info *uci;
@@ -14,8 +14,6 @@
#include "nt100x.h"
#include "tracing.h"
#define SIZEOF(array) (sizeof(array)/sizeof(array[0]))
/* "forgotten" attributes etc ...*/
#define USB_EP_ADDR_DIR_IN 0x80
#define USB_EP_ADDR_DIR_OUT 0x00
+1 -2
View File
@@ -37,7 +37,6 @@ extern "C" {
# define TRACE(x) ;
#endif
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define TRACE_MEMORY_MAP
// Define this to print the memory map to serial debug,
// You also need to define ENABLE_SERIAL in serial.cpp
@@ -323,7 +322,7 @@ init_page_directory()
// map our page directory region (TODO should not be identity mapped)
mmu_map_identity((addr_t)sPageDirectory, sPageTableRegionEnd, ARM_MMU_L2_FLAG_C);
for (uint32 i = 0; i < ARRAY_SIZE(LOADER_MEMORYMAP); i++) {
for (uint32 i = 0; i < B_COUNT_OF(LOADER_MEMORYMAP); i++) {
TRACE(("BLOCK: %s START: %lx END %lx\n", LOADER_MEMORYMAP[i].name,
LOADER_MEMORYMAP[i].start, LOADER_MEMORYMAP[i].end));