vitasdk / newlib Goto Github PK
View Code? Open in Web Editor NEWPS Vita Newlib port.
License: GNU General Public License v2.0
PS Vita Newlib port.
License: GNU General Public License v2.0
README for GNU development tools This directory contains various GNU compilers, assemblers, linkers, debuggers, etc., plus their support routines, definitions, and documentation. If you are receiving this as part of a GDB release, see the file gdb/README. If with a binutils release, see binutils/README; if with a libg++ release, see libg++/README, etc. That'll give you info about this package -- supported targets, how to use it, how to report bugs, etc. It is now possible to automatically configure and build a variety of tools with one command. To build all of the tools contained herein, run the ``configure'' script here, e.g.: ./configure make To install them (by default in /usr/local/bin, /usr/local/lib, etc), then do: make install (If the configure script can't determine your type of computer, give it the name as an argument, for instance ``./configure sun4''. You can use the script ``config.sub'' to test whether a name is recognized; if it is, config.sub translates it to a triplet specifying CPU, vendor, and OS.) If you have more than one compiler on your system, it is often best to explicitly set CC in the environment before running configure, and to also set CC when running make. For example (assuming sh/bash/ksh): CC=gcc ./configure make A similar example using csh: setenv CC gcc ./configure make Much of the code and documentation enclosed is copyright by the Free Software Foundation, Inc. See the file COPYING or COPYING.LIB in the various directories, for a description of the GNU General Public License terms under which you can copy the files. REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info on where and how to report problems.
I'm working on a homebrew that will read and download files from a http server. In the app I would check if the socket is open and still readable before trying to read from it. The app would randomly crash on the "select" function.
Here's the code sniplet of that function.
template <typename T> ssize_t handle_EINTR(T fn) {
ssize_t res = false;
while (true) {
res = fn();
if (res < 0 && errno == EINTR) { continue; }
break;
}
return res;
}
ssize_t select_read(socket_t sock, time_t sec, time_t usec) {
if (sock >= FD_SETSIZE) { return 1; }
fd_set fds;
FD_ZERO(&fds);
FD_SET(sock, &fds);
timeval tv;
tv.tv_sec = static_cast<long>(sec);
tv.tv_usec = static_cast<decltype(tv.tv_usec)>(usec);
return handle_EINTR([&]() {
return select(static_cast<int>(sock + 1), &fds, nullptr, nullptr, &tv); <<< crash on this line randomly
});
}
I have identified four missing methods for a port of the game creation system MegaZeux to the PlayStation Vita: getcwd, chdir, mkdir, rmdir. (I think they're missing, but I'm not 100% sure - perhaps 90%)
mktime() is supposed to use the local timezone, whereas the UTC equivalent is supposed to be gmtime(). However, since there is no TZ environment variable set up in the environment, mktime() winds up using UTC instead of the local time zone. This is the root cause of mgba-emu/mgba#2876, which I worked around in mgba-emu/mgba@e8ef801. A similar implementation may be plausible in newlib.
Time functions on the vita do not set the tz appropriately, so localtime stuff returns GMT.
C standard (N1570 7.21.4.2) states that
The rename function causes the file whose name is the string pointed to by old to be henceforth known by the name given by the string pointed to by new. The file named old is no longer accessible by that name. If a file named by the string pointed to by new exists prior to the call to the rename function, the behavior is implementation-defined.
posix, gcc and bsd (see error ENOTEMPTY) state that if to
exists, it shall be removed first, except if it is non-empty directory.
sceIoRename seems to follow MSVC implementation, e.g. fail if to
exists,
Currently, this affects curl (cookie jar), but maybe other code/libs too.
This is because sony errno does not match errno.h
For example,
sys/errno.h
41:#define EAGAIN 11 /* No more processes */
psp2/net/net.h
50: SCE_NET_ERROR_EAGAIN = 0x80410123,
171: SCE_NET_EAGAIN = 35,
recvfrom
does:
errno = res & SCE_ERRNO_MASK;
which would result in error code 35 for SCE_NET_EAGAIN
.
pthreads will automatically clean up thread reent data when threads are closed. Developers favouring the native API over pthreads may run into a situation where there are no reent resources available to allocate and the application crashes/aborts.
making ruby
make[1]: Entering directory '/home/silica/ruby'
arm-vita-eabi-gcc -O2 -g -Wall -Wno-parentheses -Wno-long-long -DRUBY_EXPORT -L. main.o -Wl,-R -Wl,/home/silica/ruby-bin/lib -L/home/silica/ruby-bin/lib -lruby-static -lm -o ruby
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: /usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/lib/libg.a(lib_a-syswait.o): in function `wait':
syswait.c:(.text.wait+0xe): undefined reference to `_wait_r'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:117: ruby] Error 1
make[1]: Leaving directory '/home/silica/ruby'
make: *** [Makefile:324: main] Error 2
some functions are hideen by macros.
for example getentropy
is hidden by __BSD_VISIBLE
to export functions like phoenix platform, we have to create or copy & modify this file.
it releated vitasdk/packages#273
stat
returns EINVAL for an empty path, but it should return ENOENT.
If developers are using the c++11 std::thread class then it will crash when invoking the underlying pthread implementation. This is because the starting thread does not have the correct context information setup in its TLS.
There should be some mechanism in place to automatically call pthread_init on the main thread prior to main() when pthread is linked.
tty0:
?Most of those are probably a no-go completely
Relevant parts from the IRC:
<noname120> Why are exceptions not supported in vitasdk? Is is especially hard to implement?
<davee[m]> i think there is just special data structures that need set
<davee[m]> eh_frame i think
<noname120> Interesting stuff: http://wiki.osdev.org/C++_Exception_Support
<xyz[m]> no one cared enough to implement it
<xyz[m]> maybe it already works fine
<davee[m]> it doesnt
<xyz[m]> it shouldn't require anything OS specific
<xyz[m]> maybe our toolchain garbles some sections
Since the mentioned commit (which is from September 2016) operations on file descriptors are extremely slow. This gives a significant slowdown e.g. in EasyRPG Player which was running 60 FPS before and regressed to 0-15 FPS depending on the game. (we noticed this two months ago because that was the time when we recompiled the SDK, we were on August 2016 before).
My bisect says that the first bad/slow commit is
fa92db8
The previous one didn't compile, which is very likely the real bad commit:
3350763
(And the last good/fast commit is 6a4dc0f)
Test case (thanks to @Rinnegatamante because I don't have a Vita)
You have to create a 100 kbyte file under "/data/test.bin". The content doesn't matter.
The test program does lots of 1byte fread calls. I have no idea what the real cause is, but the IO is slow ;).
In the end the program will tell you how long the newlib IO took. On newer (since that commit) newlib versions the result is around 2 seconds and on older version around 80 ms. This is a significant regression:
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <vitasdk.h>
#include <vita2d.h>
#define FILENAME "ux0:/data/test.bin"
vita2d_pgf* debug_font;
void drawText(uint32_t y, char* text, uint32_t color){
int i;
for (i=0;i<3;i++){
vita2d_start_drawing();
vita2d_pgf_draw_text(debug_font, 2, y, color, 1.0, text );
vita2d_end_drawing();
vita2d_wait_rendering_done();
vita2d_swap_buffers();
}
}
void drawLoopText(uint32_t y, char* text, uint32_t color){
vita2d_pgf_draw_text(debug_font, 2, y, color, 1.0, text );
}
int main(int argc, char** argp){
char res[256];
uint64_t tick1, tick2;
vita2d_init();
vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
debug_font = vita2d_load_default_pgf();
uint32_t white = RGBA8(0xFF, 0xFF, 0xFF, 0xFF);
drawText(25, "Starting SceIo test, please wait...", white);
tick1 = sceKernelGetProcessTimeWide();
SceUID fh = sceIoOpen(FILENAME, SCE_O_RDONLY, 0777);
SceOff size = sceIoLseek(fh, 0, SEEK_END);
sceIoLseek(fh, 0, SEEK_SET);
uint8_t dummy;
int i;
for (i = 0; i < size; i++){
sceIoRead(fh, &dummy, 1);
}
sceIoClose(fh);
tick2 = sceKernelGetProcessTimeWide();
sprintf(res, "Test took %lldms to finish.", (tick2 - tick1) / 1000);
drawText(45, res, white);
drawText(65, "Starting newlib io test, please wait...", white);
tick1 = sceKernelGetProcessTimeWide();
FILE* fd = fopen(FILENAME, "rb");
for (i = 0; i < size; i++){
fread(&dummy, 1, 1, fd);
}
fclose(fd);
tick2 = sceKernelGetProcessTimeWide();
sprintf(res, "Test took %lldms to finish.", (tick2 - tick1) / 1000);
drawText(85, res, white);
for (;;){}
}
Makefile, put main.c in "source":
TARGET := Testcase
TITLE := TESTCASE1
SOURCES := source
INCLUDES := include
LIBS = -lvita2d -lSceLibKernel_stub \
-lSceSysmodule_stub -lSceCtrl_stub \
-lm -lSceAppUtil_stub -lScePgf_stub -lfreetype \
-lc -lScePower_stub -lSceCommonDialog_stub -lpng16 -lz \
-lSceGxm_stub -lSceDisplay_stub
CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c))
CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp))
BINFILES := $(foreach dir,$(DATA), $(wildcard $(dir)/*.bin))
OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
CXX = $(PREFIX)-g++
CFLAGS = -Wl,-q -O3 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11
ASFLAGS = $(CFLAGS)
all: $(TARGET).vpk
$(TARGET).vpk: $(TARGET).velf
vita-make-fself $< .\build\eboot.bin
vita-mksfoex -s TITLE_ID=$(TITLE) "$(TARGET)" param.sfo
cp -f param.sfo ./build/sce_sys/param.sfo
%.velf: %.elf
$(PREFIX)-strip -g $<
vita-elf-create $< $@
vita-make-fself $@ eboot.bin
$(TARGET).elf: $(OBJS)
$(CC) $(CFLAGS) $^ $(LIBS) -o $@
clean:
@rm -rf $(TARGET).velf $(TARGET).elf $(OBJS)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.