Skip to content

Commit be96b7b

Browse files
committed
bits16: Format code
Signed-off-by: Stefan Weil <[email protected]>
1 parent 146079f commit be96b7b

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

src/ccutil/bits16.h

+29-33
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: bits16.h (Formerly bits8.h)
33
* Description: Code for 8 bit field class.
44
* Author: Phil Cheatle
5-
* Created: Thu Oct 17 10:10:05 BST 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,43 +19,40 @@
2019
#ifndef BITS16_H
2120
#define BITS16_H
2221

23-
#include "host.h"
22+
#include <cstdint> // for uint8_t, ...
23+
#include "platform.h" // for DLLSYM
2424

25-
class DLLSYM BITS16
26-
{
27-
public:
28-
uint16_t val;
25+
class DLLSYM BITS16 {
26+
public:
27+
uint16_t val;
2928

30-
BITS16() {
31-
val = 0;
32-
} // constructor
29+
BITS16() { val = 0; } // constructor
3330

34-
BITS16(uint16_t init) {
35-
val = init;
36-
}
31+
BITS16(uint16_t init) { val = init; }
3732

38-
void turn_on_bit( // flip specified bit
39-
uint8_t bit_num) { // bit to flip 0..7
40-
val = val | 01 << bit_num;
41-
}
33+
void turn_on_bit( // flip specified bit
34+
uint8_t bit_num) { // bit to flip 0..7
35+
val = val | 01 << bit_num;
36+
}
37+
38+
void turn_off_bit( // flip specified bit
39+
uint8_t bit_num) { // bit to flip 0..7
40+
val = val & ~(01 << bit_num);
41+
}
4242

43-
void turn_off_bit( // flip specified bit
44-
uint8_t bit_num) { // bit to flip 0..7
43+
void set_bit( // flip specified bit
44+
uint8_t bit_num, // bit to flip 0..7
45+
bool value) { // value to flip to
46+
if (value)
47+
val = val | 01 << bit_num;
48+
else
4549
val = val & ~(01 << bit_num);
46-
}
47-
48-
void set_bit( // flip specified bit
49-
uint8_t bit_num, // bit to flip 0..7
50-
bool value) { // value to flip to
51-
if (value)
52-
val = val | 01 << bit_num;
53-
else
54-
val = val & ~(01 << bit_num);
55-
}
56-
57-
bool bit( // access bit
58-
uint8_t bit_num) const { // bit to access
59-
return (val >> bit_num) & 01;
60-
}
50+
}
51+
52+
bool bit( // access bit
53+
uint8_t bit_num) const { // bit to access
54+
return (val >> bit_num) & 01;
55+
}
6156
};
57+
6258
#endif

0 commit comments

Comments
 (0)