Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Commit e2f8e6e

Browse files
committed
do not ignore xpacks folder, it is used by tests
1 parent f73186b commit e2f8e6e

File tree

193 files changed

+43895
-1
lines changed

Some content is hidden

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

193 files changed

+43895
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ typings/
6161
.next
6262

6363
# xpm
64-
xpacks/
64+
# xpacks/
6565

6666
# Windows
6767
Thumbs.db
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Liviu Ionescu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## µOS++ complementary C library functions
2+
3+
These are some files that complement or extend the C library:
4+
5+
- `c-syscalls-empty.c` define weak empty syscalls to keep the linker happy; redefine those needed for retargeted configurations;
6+
- `_sbrk.c` allocates block of memory in the free store (the heap) at the end of RAM, up to the stack; must match the definitons in the linker script;
7+
- `stdlib/assert.c` defines the function to be called when assertions are taken;
8+
- `stdlib/atexit.cpp` defines a simple registry for functions to be called when the program is terminated; useful for semihosting applications that terminate normally; the size of the static array is `OS_INTEGER_ATEXIT_ARRAY_SIZE`, default 3;
9+
- `stdlib/exit.c` defines the functionality of `exit()` and `abort()`
10+
- `stdlib/init-fini.c` defines weak empty `_init()` and `_fini()`, to keep linker happy.
11+
12+
## Developer info
13+
14+
This section is intended to developers who plan to include this library in their own projects.
15+
16+
### Prerequisites
17+
18+
A recent [`xpm`](https://www.npmjs.com/package/xpm), which is a portable [Node.js](https://nodejs.org/) command line application.
19+
20+
### Easy install
21+
22+
This package is available as [`@micro-os-plus/c-libs`](https://www.npmjs.com/package/@micro-os-plus/c-libs) from the `npmjs.com` registry; with `xpm` available, installing the latest version of the package is quite easy:
23+
24+
```console
25+
$ xpm install @micro-os-plus/c-libs
26+
```
27+
28+
This package is also available from [GitHub](https://github.com/micro-os-plus/c-libs-xpack):
29+
30+
```console
31+
$ git clone https://github.com/micro-os-plus/c-libs-xpack.git c-libs-xpack.git
32+
```
33+
34+
## Maintainer info
35+
36+
### How to publish
37+
38+
* commit all changes
39+
* update `CHANGELOG.md`; commit with a message like _CHANGELOG: prepare v0.1.2_
40+
* `npm version patch`
41+
* push all changes to GitHub
42+
* `npm publish`
43+
44+
## License
45+
46+
The original content is released under the [MIT License](https://opensource.org/licenses/MIT), with all rights reserved to [Liviu Ionescu](https://github.com/ilg-ul).
47+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* This file is part of the µOS++ distribution.
3+
* (https://github.com/micro-os-plus)
4+
* Copyright (c) 2015 Liviu Ionescu.
5+
*
6+
* Permission is hereby granted, free of charge, to any person
7+
* obtaining a copy of this software and associated documentation
8+
* files (the "Software"), to deal in the Software without
9+
* restriction, including without limitation the rights to use,
10+
* copy, modify, merge, publish, distribute, sublicense, and/or
11+
* sell copies of the Software, and to permit persons to whom
12+
* the Software is furnished to do so, subject to the following
13+
* conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be
16+
* included in all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
* OTHER DEALINGS IN THE SOFTWARE.
26+
*/
27+
28+
#ifndef LIBC_NEWLIB_C_SYSCALLS_H_
29+
#define LIBC_NEWLIB_C_SYSCALLS_H_
30+
31+
#include <unistd.h>
32+
#include <sys/stat.h>
33+
#include <sys/times.h>
34+
35+
#if defined(__cplusplus)
36+
extern "C"
37+
{
38+
#endif /* defined(__cplusplus) */
39+
40+
// ----------------------------------------------------------------------------
41+
42+
// Declarations for most syscall implementations specific to newlib.
43+
// Should be included as `#include <newlib/c-syscalls.h>` in all files
44+
// that implement the retargetted system calls.
45+
46+
int
47+
_chown (const char* path, uid_t owner, gid_t group);
48+
49+
int
50+
_close (int fildes);
51+
52+
int
53+
_execve (const char* name, char* const argv[], char* const envp[]);
54+
55+
pid_t
56+
_fork (void);
57+
58+
int
59+
_fstat (int fildes, struct stat* st);
60+
61+
pid_t
62+
_getpid (void);
63+
64+
int
65+
_gettimeofday (struct timeval* ptimeval, void* ptimezone);
66+
67+
int
68+
_isatty (int fildes);
69+
70+
int
71+
_kill (pid_t pid, int sig);
72+
73+
int
74+
_link (const char* existing, const char* _new);
75+
76+
off_t
77+
_lseek (int fildes, int ptr, int dir);
78+
79+
int
80+
_open (const char* file, int flags, int mode);
81+
82+
int
83+
_openat (int dirfd, const char* name, int flags, int mode);
84+
85+
ssize_t
86+
_read (int fildes, void* ptr, size_t len);
87+
88+
int
89+
_readlink (const char* path, void* buf, size_t bufsize);
90+
91+
int
92+
_stat (const char* file, struct stat* st);
93+
94+
int
95+
_symlink (const char* existing, const char* _new);
96+
97+
clock_t
98+
_times (struct tms* buf);
99+
100+
int
101+
_unlink (const char* name);
102+
103+
pid_t
104+
_wait (int* status);
105+
106+
ssize_t
107+
_write (int fildes, const void* ptr, size_t len);
108+
109+
// ----------------------------------------------------------------------------
110+
111+
#if defined(__cplusplus)
112+
}
113+
#endif /* defined(__cplusplus) */
114+
115+
// ----------------------------------------------------------------------------
116+
117+
#endif /* LIBC_NEWLIB_C_SYSCALLS_H_ */
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@micro-os-plus/c-libs",
3+
"version": "1.0.6",
4+
"description": "An xPack with complementary C library functions",
5+
"main": "",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/micro-os-plus/c-libs-xpack.git"
12+
},
13+
"homepage": "https://github.com/micro-os-plus/c-libs-xpack",
14+
"keywords": [
15+
"xpack",
16+
"c++",
17+
"micro-os-plus",
18+
"library"
19+
],
20+
"author": {
21+
"name": "Liviu Ionescu",
22+
"email": "[email protected]",
23+
"url": "http://liviusdotnet.wordpress.com"
24+
},
25+
"license": "MIT",
26+
"bugs": {
27+
"url": "https://github.com/micro-os-plus/c-libs-xpack/issues"
28+
},
29+
"config": {},
30+
"dependencies": {},
31+
"xpack": {}
32+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* This file is part of the µOS++ distribution.
3+
* (https://github.com/micro-os-plus)
4+
* Copyright (c) 2015 Liviu Ionescu.
5+
*
6+
* Permission is hereby granted, free of charge, to any person
7+
* obtaining a copy of this software and associated documentation
8+
* files (the "Software"), to deal in the Software without
9+
* restriction, including without limitation the rights to use,
10+
* copy, modify, merge, publish, distribute, sublicense, and/or
11+
* sell copies of the Software, and to permit persons to whom
12+
* the Software is furnished to do so, subject to the following
13+
* conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be
16+
* included in all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
* OTHER DEALINGS IN THE SOFTWARE.
26+
*/
27+
28+
#include <unistd.h>
29+
#include <stdlib.h>
30+
#include <sys/types.h>
31+
#include <errno.h>
32+
#include <stddef.h>
33+
34+
// ----------------------------------------------------------------------------
35+
36+
void*
37+
_sbrk (ptrdiff_t incr);
38+
39+
// ----------------------------------------------------------------------------
40+
41+
// The definitions used here should be kept in sync with the
42+
// stack definitions in the linker script.
43+
44+
void*
45+
_sbrk (ptrdiff_t incr)
46+
{
47+
extern char __heap_begin__; // Defined by the linker.
48+
extern char __heap_end__; // Defined by the linker.
49+
50+
static char* current_heap_end; // STATIC! Zero after BSS init.
51+
char* current_block_address;
52+
53+
if (current_heap_end == 0)
54+
{
55+
current_heap_end = &__heap_begin__;
56+
}
57+
58+
current_block_address = current_heap_end;
59+
60+
// Need to align heap to word boundary, for efficiency reasons and
61+
// to possibly avoid hardware faults.
62+
// So we assume that the heap starts on word boundary,
63+
// hence make sure we always add a multiple of 4 to it.
64+
incr = (incr + 3) & (~3); // align value to 4
65+
if (current_heap_end + incr > &__heap_end__)
66+
{
67+
// Some of the libstdc++-v3 tests rely upon detecting 'out of memory'
68+
// errors, so DO NOT abort here, but return error.
69+
70+
errno = ENOMEM; // Heap has overflowed.
71+
return (caddr_t) -1;
72+
}
73+
74+
current_heap_end += incr;
75+
76+
return (caddr_t) current_block_address;
77+
}
78+
79+
// Guarantee that all standard and reentrant functions get here directly.
80+
81+
void*
82+
__attribute__((weak, alias ("_sbrk")))
83+
sbrk (ptrdiff_t incr);
84+
85+
void*
86+
_sbrk_r (struct _reent* impure, ptrdiff_t incr);
87+
88+
void*
89+
_sbrk_r (struct _reent* impure __attribute__((unused)), ptrdiff_t incr)
90+
{
91+
return _sbrk (incr);
92+
}
93+
94+
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)