default:
if (dev.get_minor () < MAX_CONS_DEV)
{
- unsigned long bitmask = fhandler_console::console_unit (-1);
+ unsigned long bitmask = fhandler_console::console_unit (CONS_LIST_USED);
return !!(bitmask & (1UL << dev.get_minor ()));
}
return false;
default:
if (dev.get_minor () < MAX_CONS_DEV)
{
- unsigned long bitmask = fhandler_console::console_unit (-1);
+ unsigned long bitmask = fhandler_console::console_unit (CONS_LIST_USED);
return !!(bitmask & (1UL << dev.get_minor ()));
}
return false;
}
fhandler_console::console_unit::console_unit (int n0):
- n (n0), bitmask (0)
+ n (n0), bitmask (0), shared_console_info (NULL)
{
EnumWindows (fhandler_console::enum_windows, (LPARAM) this);
- if (n < 0)
- n = (_minor_t) ffsl (~bitmask) - 1;
- if (n < 0)
+ if (n0 == CONS_SCAN_UNUSED && (n = ffsl (~bitmask) - 1) < 0)
api_fatal (sizeof (bitmask) == 8 ?
"console device allocation failure - "
"too many consoles in use, max consoles is 64" :
ProtectHandleINH (cygheap->console_h);
if (created)
{
- unit = console_unit (-1);
+ unit = console_unit (CONS_SCAN_UNUSED);
cs->tty_min_state.setntty (DEV_CONS_MAJOR, unit);
}
else
};
#define MAX_CONS_DEV (sizeof (unsigned long) * 8)
+#define CONS_SCAN_UNUSED (-1)
+#define CONS_LIST_USED (-2)
/* This is a input and output console handle */
class fhandler_console: public fhandler_termios
unsigned long bitmask;
console_state *shared_console_info;
public:
- operator _minor_t () const {return n;}
operator console_state * () const {return shared_console_info;}
- operator unsigned long () const {return bitmask;}
+ operator unsigned long () const {return n == CONS_LIST_USED ? bitmask : n;}
console_unit (int);
friend BOOL CALLBACK fhandler_console::enum_windows (HWND, LPARAM);
};