1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 10:07:40 +00:00

Kernel: Make sure we don't use any FPU/MMX/SSE instructions.

This commit is contained in:
Andreas Kling 2019-04-22 23:38:33 +02:00
parent 5c68929aa1
commit 2d7cad6a16
6 changed files with 10 additions and 16 deletions

View file

@ -248,10 +248,12 @@ one_more:
ret += print_hex(putch, bufptr, va_arg(ap, qword), 16); ret += print_hex(putch, bufptr, va_arg(ap, qword), 16);
break; break;
#ifndef KERNEL
case 'f': case 'f':
// FIXME: Print as float! // FIXME: Print as float!
ret += print_number(putch, bufptr, (int)va_arg(ap, double), leftPad, zeroPad, fieldWidth); ret += print_number(putch, bufptr, (int)va_arg(ap, double), leftPad, zeroPad, fieldWidth);
break; break;
#endif
case 'o': case 'o':
if (alternate_form) { if (alternate_form) {

View file

@ -10,20 +10,13 @@ RandomDevice::~RandomDevice()
{ {
} }
// Simple rand() and srand() borrowed from the POSIX standard: static dword next = 1;
static unsigned long next = 1; #define MY_RAND_MAX 4294967295U
dword RandomDevice::random_value()
#define MY_RAND_MAX 32767
int RandomDevice::random_value()
{ {
next = next * 1103515245 + 12345; next = next * 1103515245 + 12345;
return((unsigned)(next/((MY_RAND_MAX + 1) * 2)) % (MY_RAND_MAX + 1)); return next;
}
float RandomDevice::random_percentage()
{
return (float)random_value() / (float)MY_RAND_MAX;
} }
#if 0 #if 0

View file

@ -8,8 +8,7 @@ public:
RandomDevice(); RandomDevice();
virtual ~RandomDevice() override; virtual ~RandomDevice() override;
static int random_value(); static dword random_value();
static float random_percentage();
private: private:
// ^CharacterDevice // ^CharacterDevice

View file

@ -80,7 +80,7 @@ CXX_OBJS = $(KERNEL_OBJS) $(VFS_OBJS) $(AK_OBJS)
OBJS = $(CXX_OBJS) Boot/boot.ao OBJS = $(CXX_OBJS) Boot/boot.ao
KERNEL = kernel KERNEL = kernel
CXXFLAGS += -ffreestanding -mregparm=3 CXXFLAGS += -ffreestanding -mregparm=3 -mno-80387 -mno-mmx -mno-sse -mno-sse2
DEFINES += -DKERNEL DEFINES += -DKERNEL
LD = i686-pc-serenity-ld LD = i686-pc-serenity-ld
LDFLAGS += -T linker.ld LDFLAGS += -T linker.ld

View file

@ -181,7 +181,7 @@ int TCPSocket::protocol_allocate_source_port()
static const word first_ephemeral_port = 32768; static const word first_ephemeral_port = 32768;
static const word last_ephemeral_port = 60999; static const word last_ephemeral_port = 60999;
static const word ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port; static const word ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port;
word first_scan_port = first_ephemeral_port + (word)(RandomDevice::random_percentage() * ephemeral_port_range_size); word first_scan_port = first_ephemeral_port + RandomDevice::random_value() % ephemeral_port_range_size;
LOCKER(sockets_by_port().lock()); LOCKER(sockets_by_port().lock());
for (word port = first_scan_port;;) { for (word port = first_scan_port;;) {

View file

@ -91,7 +91,7 @@ int UDPSocket::protocol_allocate_source_port()
static const word first_ephemeral_port = 32768; static const word first_ephemeral_port = 32768;
static const word last_ephemeral_port = 60999; static const word last_ephemeral_port = 60999;
static const word ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port; static const word ephemeral_port_range_size = last_ephemeral_port - first_ephemeral_port;
word first_scan_port = first_ephemeral_port + (word)(RandomDevice::random_percentage() * ephemeral_port_range_size); word first_scan_port = first_ephemeral_port + RandomDevice::random_value() % ephemeral_port_range_size;
LOCKER(sockets_by_port().lock()); LOCKER(sockets_by_port().lock());
for (word port = first_scan_port;;) { for (word port = first_scan_port;;) {