Currently, the tcp and udp implementations are bound to each other in a
module called *destiny*. Thus, when using only one of them then the
other one gets also compiled into the binary and initialized,
which results in unnecessary RAM usage and workload for the CPU.
The approach in this PR defines a common module named *socket_base*,
which contains functions used by the posix layer. Compiled by it's own,
those functions return negative error codes, to symbolize upper layers
that they are not supported. When also including the modules *udp* or
*tcp* respectively, functions from *socket_base* get overwritten with the
correct functionality.
Defining *udp* or *tcp* in a Makefile also includes *socket_base*.
Defining *pnet* in a Makefile also includes *socket_base*.
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
Apparently all that whitespace was needed after all.
Next convert to new-style function declrations.
Also, don't prevent make from noticing a failing patch.
This is my second take on #669, because I was asked to separate it from #764.
This change adds a malloc implementation as a PKG, which uses *TLSF* (two
level segregated fit).
The patch file removes the 64bit capatibilities, debug functions, and the
option to have multiple "control blocks" (a control block holds multiple
memory pools). It wraps `malloc()` and friends in `disableIRQ() … restoreIRQ()`.
The implemention does not support 16bit platforms, yet, but probably only some
constants would need fixing. I limited the maximum size of a memory pool to
2**30 bytes = 1GB.
This PKG is not meant to be used by applicitions directly, but by the boards.
The board's initialition code needs to call
`int tlsf_add_pool(void *mem, size_t bytes)` for every free memory region it
has. If the board in using newlib, then this call needs to happen before the
first call to `puts`, `printf`, and friends, because newlib allocates the
control data IO streams (stdin, stdout, stderr) on the heap. Adding a small
(e.g. 1kB) pool before proper board initialization would be a possible solution.
Please read the additional information in the website of the implementator,
http://tlsf.baisoku.org/:
> TLSF (two level segregated fit) is a relatively new memory
allocator designed for embedded systems. It boasts constant
time O(1) malloc/free response time and a 4-byte block
overhead. Though it typically is slightly slower than other
allocators such as dlmalloc, it has no worst-case behavior.
> The original implementation, which comes alongside the white
paper, is distributed under the GNU GPL/LGPL. The code found
here is an original implementation, released into the public
domain, therefore is not subject to any licensing restrictions.
> Features:
- O(1) cost for malloc, free, realloc, memalign
- Extremely low overhead per allocation (4 bytes)
- Low overhead per pool (~3kB)
- Low fragmentation
- Compiles to only a few kB of code and data
> Caveats:
- Currently, assumes architecture can make 4-byte aligned accesses
- Not designed to be thread safe; the user must provide this
> Known Issues:
Due to the internal block structure size and the implementation
details of tlsf_memalign, there is worst-case behavior when requesting
small (<16 byte) blocks aligned to 8-byte boundaries. Overuse of memalign
will generally increase fragmentation, but this particular case will leave
lots of unusable "holes" in the heap. The solution would be to internally
align all blocks to 8 bytes, but this will require significantl changes
to the implementation. Contact me if you are interested.
Change the example Makefile.git as suggested in #895
abort when a patch fails to apply
fix build with GNU Make 4.0
reset git to the specified version instead of checking out a detached head
Currently pkg/USING says one should use
`EXTERNAL+=$(RIOTBASE)/pkg/<pkg_name>` to enable PKG modules.
Using this line the PKG will be compiled but not linked.
This change adds a USEPKG variable to be used like
`USEPKG += <pkg_name>`, which looks less clumsy and gets the PKG linked
in the binary.
Fixes the following error:
make[1]: Entering directory '/foo/RIOT/pkg/libcoap'
git clone http://git.code.sf.net/p/libcoap/code /foo/RIOT/pkg/libcoap/libcoap && \
cd /foo/RIOT/pkg/libcoap/libcoap && git checkout 89acaa6775ca3a4aedea510557e6b9c0c01fa5db
fatal: destination path '/foo/RIOT/pkg/libcoap/libcoap' already exists and is not an empty directory.
Makefile:25: recipe for target '/foo/RIOT/pkg/libcoap/libcoap' failed