Skip to content

Commit 003b5c8

Browse files
committed
Split glibc brk
1 parent 4e6c49b commit 003b5c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3085
-2477
lines changed

Makefile_many

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
# by the Makefile default values.
99
MYCC ?= gcc
1010
MYCXX ?= g++
11-
D ?= #-D_XOPEN_SOURCE 700
1211
G ?= gdb3
1312
I ?= #-I/usr/include
1413
O ?= 0
1514
STD ?= c11
1615
PEDANTIC ?= -pedantic-errors
17-
CFLAGS ?= $(D) -g$(G) -O$(O) -std=$(STD) -Wextra $(PEDANTIC) $(CFLAGS_EXTRA)
18-
MYCXXFLAGS ?= $(D) -g$(G) -O$(O) -std=c++11 -Wextra $(PEDANTIC) $(CXXFLAGS_EXTRA)
16+
CFLAGS ?= -g$(G) -O$(O) -pthread -std=$(STD) -Wextra $(PEDANTIC) $(CFLAGS_EXTRA) #-pg
17+
MYCXXFLAGS ?= -g$(G) -O$(O) -pthread -std=c++11 -Wextra $(PEDANTIC) $(CXXFLAGS_EXTRA) #-pg
1918

20-
LIBS ?= -lm -pthread #-lGL -lGLU -lglut
19+
LIBS ?= -lm #-lGL -lGLU -lglut
2120

2221
# Fortran
2322
FF ?= gfortran

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Relies on [C++ boilerplate](https://github.com/cirosantilli/cpp-boilerplate) to
2525
1. [C from C++](c-from-cpp/)
2626
1. [C++ from C](cpp-from-c/)
2727
1. [Fortran from C](fortran-from-c/)
28+
1. [gprof](gprof.md)
2829
1. [GDB](gdb/)
2930
1. [Boost](boost/)
3031
1. [CMake](cmake.md)

bibliography.md

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
Many behaviour examples.
2222

23+
- Design and Evolution of C++ <http://www.stroustrup.com/dne.html>
24+
25+
Ultimate source for "Why is the language designed like that" questions.
26+
2327
- <http://www.parashift.com/c++-faq/index.html>
2428

2529
C++ FAQ.
@@ -52,6 +56,10 @@
5256

5357
Hardcore optimization tutorials for C++ and assembly.
5458

59+
- <http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html>
60+
61+
C++ specification official bug tracker.
62+
5563
## Non-free
5664

5765
- <http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list>

c/Makefile_params

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
CFLAGS_EXTRA := \
2+
-DIMPLEMENTATION_SIGNAL \
3+
-DUNDEFINED_BEHAVIOUR \
4+
-trigraphs \
25
-Wno-comment \
36
-Wno-ignored-qualifiers \
47
-Wno-missing-field-initializers \
58
-Wno-overflow \
69
-Wno-override-init \
710
-Wno-sequence-point \
811
-Wno-sign-compare \
9-
-Wno-uninitialized
12+
-Wno-uninitialized \
1013
-Wno-unused-but-set-variable \
1114
-Wno-unused-label \
1215
-Wno-unused-local-typedefs \
1316
-Wno-unused-value \
14-
-Wno-unused-variable \
15-
DEFINES := -DIMPLEMENTATION_SIGNAL -DUNDEFINED_BEHAVIOUR
17+
-Wno-unused-variable

c/README.md

+22-7
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,24 @@
3737
1. [_Generic](generic.c)
3838
1. [Constant expression](constant_expression.c)
3939
1. [_Static_assert](static_assert.c)
40+
1. [Pointer](pointer.c)
41+
1. Branching
42+
1. [if](if.c)
43+
1. [while](while.c)
44+
1. [switch](switch.c)
45+
1. [goto](goto.c)
4046
1. [Function](function.c)
4147
1. [Function pointer](function_pointer.c)
4248
1. [inline](inline.c)
4349
1. [Static array argument](static_array_argument.c)
4450
1. [_Noreturn](noreturn.c)
45-
1. [Preprocessor](preprocessor.c)
46-
1. [cpp](cpp.sh)
51+
1. [Operator](operator.c)
52+
1. [Sequence point](sequence_point.c)
53+
1. Preprocessor
54+
[Preprocessor inside C](preprocessor.c)
55+
[Preprocessor in isolation](preprocessor.sh)
4756
1. [Signal](signal.c)
57+
1. [Trigraph](trigraph.c)
4858
1. Multi-file
4959
1. [static](static.c)
5060
1. [extern](extern.c)
@@ -53,13 +63,17 @@
5363
1. [NDEBUG](ndebug.c)
5464
1. [assert fail](interactive/assert_fail.c)
5565
1. [stdio.h](stdio_h.c)
66+
[printf](printf.c)
5667
1. [stdint.h](stdint_h.c)
57-
1. stdlib.h
68+
1. [stdlib.h](stdlib_h.c)
69+
1. Exit related
70+
1. [exit()](exit.c)
71+
1. [atexit()](atexit.c)
72+
1. [abort()](interactive/abort.c.off)
73+
1. [abort()](interactive/abort.c.off)
74+
1. [abs()](abs.c)
5875
1. [malloc()](malloc.c)
59-
1. [exit()](exit.c)
60-
1. [atexit()](atexit.c)
61-
1. [abort()](interactive/abort.c.off)
62-
1. stddef.h
76+
1. [getenv](getenv.c)
6377
1. [offsetof()](offsetof.c)
6478
1. [string.h](string_h.c)
6579
1. [ctype.h](ctype_h.c)
@@ -73,6 +87,7 @@
7387
1. [varargs_h](varargs_h.c)
7488
1. [errno.h](errno_h.c)
7589
1. [iso646.h](iso646_h.c)
90+
1. [setjmp.h](setjmp_h.c)
7691
1. Applications
7792
1. [User input](interactive/user_input.c.off)
7893
1. [Design patterns](design_patterns.c)

c/abs.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
# abs
3+
4+
Absolute values, integer version.
5+
6+
For floating point values, use `fabs` in `math.h`.
7+
*/
8+
9+
#include "common.h"
10+
11+
int main() {
12+
assert(abs(-1) == 1);
13+
14+
/*
15+
There is one UB case in 2's complement: INT_MIN
16+
17+
TODO can there be more or less UB cases?
18+
*/
19+
{
20+
#ifdef UNDEFINED_BEHAVIOUR
21+
printf("abs(INT_MIN) = 0x%x\n", abs(INT_MIN));
22+
/* For comparison only. */
23+
printf("INT_MIN = 0x%x\n", INT_MIN);
24+
#endif
25+
}
26+
27+
return EXIT_SUCCESS;
28+
}

c/common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <errno.h>
44
#include <fenv.h>
55
#include <float.h>
6-
#include <inttypes.h> /* PRIxPTR */
6+
#include <inttypes.h> /* PRIxPTR, */
77
#include <iso646.h>
88
#include <limits.h> /* *_MAX, *_MIN for integer types */
99
#include <locale.h>

c/constant_expression.c

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
1515
- only constant expressions can be used in `_Static_assert`
1616
17+
- only constant expressions can be used in `case` expressions
18+
1719
C++ does not allow const pointer typecasts, so `const` variables generate constant expressions.
1820
There is an even more explicit language feature in C++11 via the `constexpr` keyword.
1921
*/

c/cpp.sh

-31
This file was deleted.

c/enum.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ int main() {
6262
assert(e == -1);
6363
}
6464
}
65+
66+
/*
67+
Repeat values.
68+
69+
Seems legal: http://stackoverflow.com/questions/5561142/duplicate-enum-values-in-c
70+
*/
71+
{
72+
enum E {
73+
E0 = 0,
74+
E0_2 = 0
75+
};
76+
assert(E0 == E0_2);
77+
}
6578
}
6679

6780
/*
@@ -176,7 +189,7 @@ int main() {
176189

177190
/* ERROR: lvalue required */
178191
/* Enum constans are not lvalues. */
179-
/*int *pe = &E1;*/
192+
/*int *pe = &E0;*/
180193

181194
/* TODO legal but useless? */
182195
enum E *pe;

0 commit comments

Comments
 (0)