<fossy>i'm wondering what the best way to implement tests for chdir() would be to check that chdir() actually worked... <fossy>was thinking a /usr/bin/ls call but that wont work in the lower stages of the bootstrap <fossy>also getcwd() will vary from system-to-system.. dont know how to do that one really either. i guess it would probably just be ensuring that it dosent error? <dddddd>I was thinking something like: getcwd (note the result) chdir to subdir (we can provide it, already created) note that it changes correctly with another getcwd <dddddd>Using the shell commands that call to those syscall, I mean. <fossy>also does anyone know how the heck you can do pass by reference or pass by pointer in M2-Planet?? trying to do pass by reference int func(int* ptr) { &ptr = 1; } dosen't work... and pass by pointer int func(int& ref) { ref = 1; } dosen't work <fossy>file.c:3:Received * in primary_expr <dddddd>I don't think *foo is supported. Neither any t& types. <dddddd>I guess I'd pass a struct for the function to change data of the caller. Maybe share a global instead. What's the use-case? M2-Planet is not C. <dddddd>just "happens to look and behave enough like C" <dddddd>I can think of some asm() trickery, but that's nasty and non-portable. <dddddd>nah, I don't think that would work. <fossy>yeah i'm thinking to just use a global <fossy>because you're right M2-Planet is a small subset of C <fossy>oriansj: get_current_dir_name() returns a variable that when referenced segfaults the program <oriansj>first there is no pass by references in M2-Planet and pass by pointer only works partially because there is no updating the caller from the callee. (aka passing struct foo* bar allows one to update the fields in bar but not change the value of bar in the caller. <oriansj>it also would be ptr = 1; not *ptr = 1; <oriansj>as M2-Planet doesn't support *foo = *bar; but it is possible do the same via: foo->a = bar->a; foo->b = bar->b; ... foo->N = bar->N <oriansj>also, I never bothered to check what the getcwd syscall actually returns in RAX <oriansj>in which case if getcwd works but get_current_dir_name doesn't; I would just have to do char* ret = malloc(MAX_PATH); getcwd(ret, MAX_PATH); return ret; <oriansj>hmmm, it looks like the syscall returns the number of chars in the pathname; rather than the string. Looks like my messy guess was wrong <oriansj>and I need to change getcwd to return buf if NULL was not returned. Easy to fix. <oriansj>I'll do that tomorrow if someone else doesn't do it while I sleep. Good night <oriansj>odd that GCC gives me: error: ‘PATH_MAX’ undeclared <oriansj>buildable via gcc with identical output <oriansj>if one uses the previously posted M2-Planet build script with the now up patch, you'll have it all working. <oriansj>fossy: one minor note: it is int fchdir(int fd); instead of int fchdir(FILE* fd) because FILE is a struct with quite a few fields (including its file descriptor) and fchdir is just a wrapper for a syscall which knows nothing about that struct and just wants a file descriptor. Other than that it looks good. <oriansj>and it looks like markjenkinsznc was kicking ass last night; good job ***ng0_ is now known as ng0
<fossy>oriansj: ah, I thought it was a mistake <fossy>oriansj: so how should you pass a FILE* to fchdir then