Skip to content

Commit 8efd1a7

Browse files
committed
Split libsyscall's functions into independent files
This allows ld to only link the function used and will prepare the migration to a more recent, c99-compliant, newlib version.
1 parent ffcdc81 commit 8efd1a7

20 files changed

+451
-125
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
- ngdevkit-gngeo
3030
- python3-pygame
3131
- imagemagick
32+
- sox
33+
- libsox-fmt-mp3
3234
- libglew-dev
3335
- libsdl2-dev
3436
env:
@@ -47,6 +49,7 @@ jobs:
4749
# ngdevkit-examples deps
4850
- ngdevkit-gngeo
4951
- imagemagick
52+
- sox
5053
- glew
5154
- sdl2
5255
- sdl2_image

runtime/Makefile.in

+22-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,32 @@
1515
# along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
1616

1717
OBJS=libsyscalls.a ngdevkit-crt0.o
18+
SYSCALL_OBJS=\
19+
close \
20+
_exit \
21+
exit \
22+
fstat \
23+
getpid \
24+
gettimeofday \
25+
isatty \
26+
kill \
27+
link \
28+
lseek \
29+
open \
30+
raise \
31+
read \
32+
sbrk \
33+
times \
34+
unlink \
35+
write
36+
1837

1938
all: $(OBJS) ngdevkit-specs
2039

2140
-include ../Makefile.config
2241

23-
libsyscalls.a: syscalls.o
24-
$(NGAR) cru $@ $^ && $(NGRANLIB) $@
42+
libsyscalls.a: $(SYSCALL_OBJS:%=syscall/%.o)
43+
$(NGAR) cru $@ $^ && $(NGRANLIB) $@
2544

2645
ngdevkit-specs:
2746
$(NGGCC) -dumpspecs | sed -e 's/\(-lc\)/\1 -lsyscalls/' | \
@@ -49,6 +68,6 @@ install-specs: install-dirs ngdevkit-specs
4968
$(INSTALL) $(filter-out install-dirs,$^) $$DIR
5069

5170
clean:
52-
rm -f *.o *~ *.a ngdevkit-specs
71+
rm -f *.o syscall/*.o *~ *.a ngdevkit-specs
5372

5473
.PHONY: install clean

runtime/syscall/_exit.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
void _exit(int x) {
21+
}

runtime/syscall/close.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <errno.h>
21+
22+
23+
int close (int file) {
24+
errno = EBADF;
25+
return -1;
26+
}

runtime/syscall/exit.c

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
21+
void exit (int n) {
22+
for(;;);
23+
}

runtime/syscall/fstat.c

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <sys/types.h>
21+
#include <sys/stat.h>
22+
#include <unistd.h>
23+
#include <errno.h>
24+
25+
26+
int fstat (int file, struct stat * st) {
27+
errno = EBADF;
28+
return -1;
29+
}

runtime/syscall/getpid.c

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
21+
int getpid (int n) {
22+
return 1;
23+
}

runtime/syscall/gettimeofday.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <errno.h>
21+
22+
23+
int gettimeofday (void * tp, void * tzp) {
24+
errno = EINVAL;
25+
return -1;
26+
}

runtime/syscall/isatty.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
int isatty (int fd) {
21+
return 0;
22+
}

runtime/syscall/kill.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <sys/types.h>
21+
#include <signal.h>
22+
#include <errno.h>
23+
24+
25+
int kill (int n, int m) {
26+
errno = EINVAL;
27+
return -1;
28+
}

runtime/syscall/link.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <errno.h>
21+
22+
23+
int link (void) {
24+
errno = ENOENT;
25+
return -1;
26+
}

runtime/syscall/lseek.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <errno.h>
21+
22+
23+
int lseek (int file, int ptr, int dir) {
24+
errno = EBADF;
25+
return -1;
26+
}

runtime/syscall/open.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <errno.h>
21+
22+
23+
int open (const char * path, int flags, ... ) {
24+
errno = EMFILE;
25+
return -1;
26+
}

runtime/syscall/raise.c

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
void raise (void) {
2+
return;
3+
}

runtime/syscall/read.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Syscall implementation as expected by newlib
3+
* Copyright (c) 2015-2020 Damien Ciabrini
4+
* This file is part of ngdevkit
5+
*
6+
* ngdevkit is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* ngdevkit is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with ngdevkit. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <errno.h>
21+
22+
23+
int read (int file, char * ptr, int len) {
24+
errno = EBADF;
25+
return -1;
26+
}

0 commit comments

Comments
 (0)