Fixed getcwd to better match

This commit is contained in:
Jeremiah Orians 2020-01-28 04:24:29 -05:00
parent f77e0ed6cb
commit 308b201fd4
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
4 changed files with 32 additions and 4 deletions

View File

@ -19,7 +19,7 @@
//CONSTANT PATH_MAX 4096
#define PATH_MAX 4096
char* getcwd(char* buf, size_t size)
int _getcwd(char* buf, size_t size)
{
asm("LOAD_EFFECTIVE_ADDRESS_rdi %16"
"LOAD_INTEGER_rdi"
@ -29,6 +29,13 @@ char* getcwd(char* buf, size_t size)
"SYSCALL");
}
char* getcwd(char* buf, size_t size)
{
int c = _getcwd(buf, size);
if(0 == c) return NULL;
return buf;
}
char* getwd(char* buf)
{
return getcwd(buf, PATH_MAX);

View File

@ -19,7 +19,7 @@
//CONSTANT PATH_MAX 4096
#define PATH_MAX 4096
char* getcwd(char* buf, size_t size)
int _getcwd(char* buf, size_t size)
{
asm("!4 R0 SUB R12 ARITH_ALWAYS"
"!0 R0 LOAD32 R0 MEMORY"
@ -29,6 +29,13 @@ char* getcwd(char* buf, size_t size)
"SYSCALL_ALWAYS");
}
char* getcwd(char* buf, size_t size)
{
int c = _getcwd(buf, size);
if(0 == c) return NULL;
return buf;
}
char* getwd(char* buf)
{
return getcwd(buf, PATH_MAX);

View File

@ -19,13 +19,20 @@
//CONSTANT PATH_MAX 4096
#define PATH_MAX 4096
char* getcwd(char* buf, size_t size)
int _getcwd(char* buf, size_t size)
{
asm("LOAD R0 R14 0"
"LOAD R1 R14 4"
"GETCWD");
}
char* getcwd(char* buf, size_t size)
{
int c = _getcwd(buf, size);
if(0 == c) return NULL;
return buf;
}
char* getwd(char* buf)
{
return getcwd(buf, PATH_MAX);

View File

@ -19,7 +19,7 @@
//CONSTANT PATH_MAX 4096
#define PATH_MAX 4096
char* getcwd(char* buf, size_t size)
int _getcwd(char* buf, size_t size)
{
asm("LOAD_EFFECTIVE_ADDRESS_ebx %8"
"LOAD_INTEGER_ebx"
@ -29,6 +29,13 @@ char* getcwd(char* buf, size_t size)
"INT_80");
}
char* getcwd(char* buf, size_t size)
{
int c = _getcwd(buf, size);
if(0 == c) return NULL;
return buf;
}
char* getwd(char* buf)
{
return getcwd(buf, PATH_MAX);