Skip to content

Commit f76731b

Browse files
committed
v4l2
1 parent b4e20e9 commit f76731b

31 files changed

Lines changed: 1130 additions & 91 deletions

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ C and C++ minimal examples. Asserts used wherever possible. Cheatsheets, tutoria
3030
1. [GDB](gdb/)
3131
1. [cflow](cflow.md)
3232
1. Media
33-
1. [FFmpeg](ffmpeg/)
33+
1. [FFmpeg](ffmpeg/)
34+
1. [v4l2](v4l2/)
3435
1. [Linting tools](linting-tools.md)
35-
1. [Frama-C](frama-c/)
36+
1. [Frama-C](frama-c/)
3637
1. [Boost](boost/)
3738
1. [CMake](cmake.md)
3839
1. [Flex and Bison](flex-bison/)

‎TODO.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ Google unit test framework: <http://code.google.com/p/googletest/>
2727
### tokamak
2828

2929
Rigid body physical engine.
30+
31+
## IO
32+
33+
Mouse, keyboard:
34+
35+
- <http://stackoverflow.com/questions/2617359/cross-platform-keyboard-mouse-input-recommendation>

‎c/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
1. [struct](struct.c)
3939
1. [struct operators](struct_operators.c)
4040
1. [struct designated initializer](struct_designated_initializer.c)
41+
1. [Bitfield](bitfield.c)
4142
1. [union](union.c)
4243
1. [Literals](literals.c)
4344
1. [Compound struct literal](compound_struct_literal.c)

‎c/bitfield.c‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
# bitfield
3+
4+
Gives support for fields which contain a single bit in the language.
5+
*/
6+
7+
#include "common.h"
8+
9+
int main() {
10+
struct S {
11+
unsigned b1 : 1;
12+
unsigned b2 : 2;
13+
unsigned b3 : 3;
14+
15+
/* padding untill next int is added automatically because */
16+
/* next data is not a bitfield and accesses is faster if it is aligned */
17+
18+
int i;
19+
20+
unsigned b4 : 1;
21+
22+
/* manually adds padding untill next field */
23+
/* even if it is a bitfield */
24+
25+
unsigned : 0;
26+
27+
unsigned b5 : 1;
28+
} s ;
29+
30+
assert(sizeof(struct S) == 16);
31+
32+
s.b1 = 1;
33+
assert(s.b1 == 1);
34+
35+
/* WARN */
36+
/* overflow */
37+
/* truncate */
38+
/*s.b1 = 2;*/
39+
40+
int i = 2;
41+
s.b1 = i;
42+
assert(s.b1 == 0);
43+
44+
/* Only takes lsb. */
45+
i = 3;
46+
s.b1 = i;
47+
assert(s.b1 == 1);
48+
49+
return EXIT_SUCCESS;
50+
}

‎c/if.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ int main() {
2424
assert(0);
2525
}
2626

27+
if (1.1) {
28+
}
29+
2730
/* Can ommit braces for single statements. */
2831
{
2932
{

‎c/struct.c‎

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ int main() {
4444
assert(s.f == 2.0);
4545
}
4646

47+
/*
48+
Initialization with less members than the total.
49+
http://stackoverflow.com/questions/11152160/initializing-a-struct-to-0
50+
51+
Fine: missing fields get the same value as they would have
52+
if they were static storage duration objects, thus 0 for int.
53+
*/
54+
{
55+
struct S {int i; int j;};
56+
struct S s0 = {1};
57+
assert(s0.i == 1);
58+
assert(s0.j == 0);
59+
60+
/* empty braces for initialization: GNU extension. */
61+
{
62+
/*struct S s0 = {};*/
63+
}
64+
}
65+
4766
/* Define and initialize at the same time. */
4867
{
4968
struct S {int i; int j;} s0 = {0, 1}, s1 = {2, 3};
@@ -440,51 +459,5 @@ int main() {
440459
}
441460
}
442461

443-
/*
444-
# bitfields
445-
446-
Gives support for fields which contain a single bit in the language.
447-
*/
448-
{
449-
struct S {
450-
unsigned b1 : 1;
451-
unsigned b2 : 2;
452-
unsigned b3 : 3;
453-
454-
/* padding untill next int is added automatically because */
455-
/* next data is not a bitfield and accesses is faster if it is aligned */
456-
457-
int i;
458-
459-
unsigned b4 : 1;
460-
461-
/* manually adds padding untill next field */
462-
/* even if it is a bitfield */
463-
464-
unsigned : 0;
465-
466-
unsigned b5 : 1;
467-
} s ;
468-
469-
assert(sizeof(struct S) == 16);
470-
471-
s.b1 = 1;
472-
assert(s.b1 == 1);
473-
474-
/* WARN */
475-
/* overflow */
476-
/* truncate */
477-
/*s.b1 = 2;*/
478-
479-
int i = 2;
480-
s.b1 = i;
481-
assert(s.b1 == 0);
482-
483-
/* Only takes lsb. */
484-
i = 3;
485-
s.b1 = i;
486-
assert(s.b1 == 1);
487-
}
488-
489462
return EXIT_SUCCESS;
490463
}

‎cmake.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ CMake also comes with a test driver, `ctest`, which you can use as:
3636

3737
cd build
3838
ctest .
39+
40+
## Change install destination without recompile
41+
42+
<http://stackoverflow.com/questions/13480846/how-to-modify-the-install-path-without-running-the-configure-script-cmake-again>
43+
44+
Says:
45+
46+
make install DESTDIR=/opt/local
47+
48+
## Uninstall
49+
50+
Nope, not by default!
51+
52+
<http://stackoverflow.com/questions/19921017/cleaning-cmake-installed-files>
53+
54+
<https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F>
55+
56+
`install_manifest.txt` contains a list of installed files and seems to be generated by default under `build/` upon install, so you can just do:
57+
58+
sudo xargs rm <install_manifest.txt

‎cpp/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
1. [Pure virtual](pure_virtual.cpp)
3838
1. [Pure virtual from constructor](pure_virtual_from_constructor.cpp)
3939
1. [Covariant return](covariant_return.cpp)
40+
1. Virtual base class: TODO <http://stackoverflow.com/questions/21558/in-c-what-is-a-virtual-base-class>
4041
1. [Inheriting constructor](inheriting_constructor.cpp)
4142
1. [Inherit overload_hide](inherit_overload_hide.cpp)
4243
1. [namespace](namespace.cpp)
@@ -46,6 +47,8 @@
4647
1. [typecast](typecast.cpp)
4748
1. [new](new.cpp)
4849
1. [Preprocessor](preprocessor.cpp)
50+
1. using
51+
using type alias. TODO http://en.cppreference.com/w/cpp/language/type_alias
4952
1. [Standard library](standard_library.md)
5053
1. [Headers](common.hpp)
5154
1. [Containers](containers.md)

‎cpp/main.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int main() {
132132
*/
133133

134134
/*
135-
Get array length, find array length: <http://stackoverflow.com/questions/4108313/how-do-i-find-the-length-of-an-array>
135+
Get array length, find array length: http://stackoverflow.com/questions/4108313/how-do-i-find-the-length-of-an-array
136136
137137
Besides the C sizeof method which does not work for pointers and has lots of duplication, C++ offers:
138138
*/

‎ffmpeg/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sample-media/

0 commit comments

Comments
 (0)