Merge branch 'master' of gitorious.org:sortix/sortix

Conflicts:
	libmaxsi/c/hsrc/unistd.h
	libmaxsi/io.cpp
	sortix/io.cpp
	sortix/syscallnum.h
This commit is contained in:
Jonas 'Sortie' Termansen 2011-11-17 22:28:20 +01:00
commit dd349a150a
6 changed files with 27 additions and 8 deletions

View File

@ -56,8 +56,8 @@ void Reset()
case 3: velx = 0; vely = -1; break;
}
animalx = 2 + (rand() % width-4);
animaly = 2 + (rand() % height-4);
animalx = 2 + (rand() % (width-4));
animaly = 2 + (rand() % (height-4));
taillen = 0;
tailmax = 3;
@ -141,8 +141,10 @@ void Update()
if ( newx == animalx && newy == animaly )
{
tailmax++;
animalx = 2 + (rand() % width-4);
animaly = 2 + (rand() % height-4);
animalx = 2 + (rand() % (width-4));
animaly = 2 + (rand() % (height-4));
ASSERT(0 <= animalx && animalx < width);
ASSERT(0 <= animaly && animaly < height);
if ( maxspeed < speed ) { speed += speedincrease; }
}

View File

@ -83,7 +83,6 @@ int chown(const char*, uid_t, gid_t);
size_t confstr(int, char*, size_t);
char* crypt(const char*, const char*);
char* ctermid(char*);
int dup(int);
int dup2(int, int);
void encrypt(char [64], int);
int execl(const char*, const char*, ...);
@ -159,6 +158,7 @@ extern int opterr, optind, optopt;
#endif
int close(int);
int dup(int);
void _exit(int);
pid_t fork(void);
pid_t getpid(void);

View File

@ -34,6 +34,7 @@ namespace Maxsi
DEFN_SYSCALL3(ssize_t, SysWrite, 19, int, const void*, size_t);
DEFN_SYSCALL1(int, SysPipe, 20, int*);
DEFN_SYSCALL1(int, SysClose, 21, int);
DEFN_SYSCALL1(int, SysDup, 22, int);
size_t Print(const char* Message)
{
@ -83,6 +84,11 @@ namespace Maxsi
{
return SysClose(fd);
}
extern "C" int dup(int fd)
{
return SysDup(fd);
}
#endif
}

View File

@ -28,11 +28,11 @@ namespace Maxsi
{
namespace Random
{
int random_seed=1337;
unsigned random_seed = 1337;
extern "C" int rand()
{
random_seed = random_seed + 37 * 1103515245 + 12345;
return random_seed / 65536;
return random_seed >> 16;
}
}
}

View File

@ -126,11 +126,21 @@ namespace Sortix
return 0;
}
int SysDup(int fd)
{
Process* process = CurrentProcess();
Device* dev = process->descriptors.Get(fd);
if ( !dev ) { return -1; /* TODO: EBADF */ }
process->descriptors.Free(fd);
return process->descriptors.Allocate(dev);
}
void Init()
{
Syscall::Register(SYSCALL_WRITE, (void*) SysWrite);
Syscall::Register(SYSCALL_READ, (void*) SysRead);
Syscall::Register(SYSCALL_CLOSE, (void*) SysClose);
Syscall::Register(SYSCALL_DUP, (void*) SysDup);
}
}
}

View File

@ -47,7 +47,8 @@
#define SYSCALL_WRITE 19
#define SYSCALL_PIPE 20
#define SYSCALL_CLOSE 21
#define SYSCALL_MAX_NUM 22 /* index of highest constant + 1 */
#define SYSCALL_DUP 22
#define SYSCALL_MAX_NUM 23 /* index of highest constant + 1 */
#endif