Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions library/c.lib_rev.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define REVISION 0
#define SUBREVISION 0

#define DATE "11.08.2024"
#define DATE "27.08.2024"
#define VERS "clib4.library 1.0.0"
#define VSTRING "clib4.library 1.0.0 (11.08.2024)\r\n"
#define VERSTAG "\0$VER: clib4.library 1.0.0 (11.08.2024)"
#define VSTRING "clib4.library 1.0.0 (27.08.2024)\r\n"
#define VERSTAG "\0$VER: clib4.library 1.0.0 (27.08.2024)"
2 changes: 1 addition & 1 deletion library/include/sys/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ __BEGIN_DECLS
#define WIFEXITED(w) (((w) & 0xff) == 0)
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f))
#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
#define WEXITSTATUS(w) (((w) >> 8) & 0xff)
#define WEXITSTATUS(w) (((w)) & 0x000000ff)
#define WTERMSIG(w) ((w) & 0x7f)
#define WSTOPSIG WEXITSTATUS

Expand Down
1 change: 0 additions & 1 deletion library/include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ extern int spawnve(int mode, const char *path, const char **argv, char * const e
extern int spawnvp(int mode, const char *path, const char **argv);
/* Non standard. Used to help linux ports */
extern int spawnvpe(const char *file, const char **argv, char **deltaenv, const char *dir, int fhin, int fhout, int fherr);
extern int spawnvpe_callback(const char *file, const char **argv, char **deltaenv, const char *dir, int fhin, int fhout, int fherr, void (*entry_fp)(void *), void* entry_data, void (*final_fp)(int, void *), void* final_data);

extern int profil(unsigned short *buffer, size_t bufSize, size_t offset, unsigned int scale);
extern long sysconf(int name);
Expand Down
11 changes: 6 additions & 5 deletions library/misc/children.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ insertSpawnedChildren(uint32 pid, uint32 gid) {

struct Clib4Resource *res = (APTR) OpenResource(RESOURCE_NAME);
if (res) {
uint32 me = GetPID(0, GPID_PROCESS);
uint32 parent = GetPID(0, GPID_PARENT);
size_t iter = 0;
void *item;

Expand All @@ -44,7 +44,7 @@ insertSpawnedChildren(uint32 pid, uint32 gid) {

while (hashmap_iter(res->children, &iter, &item)) {
const struct Clib4Node *node = item;
if (node->pid == me) {
if (node->pid == parent) {
hashmap_set(node->spawnedProcesses, &children);
break;
}
Expand Down Expand Up @@ -126,21 +126,22 @@ void
spawnedProcessExit(int32 rc, int32 data UNUSED) {
struct Clib4Resource *res = (APTR) OpenResource(RESOURCE_NAME);
if (res) {
int32 parent = GetPID(0, GPID_PARENT);
int32 me = GetPID(0, GPID_PROCESS);
size_t iter = 0;
void *item;

while (hashmap_iter(res->children, &iter, &item)) {
const struct Clib4Node *node = item;
if (node->pid == me) {
if (node->pid == parent) {
struct Clib4Children key;
key.pid = me;
struct Clib4Children *item = (struct Clib4Children *) hashmap_get(node->spawnedProcesses, &key);
if (item != NULL) {
DebugPrintF("[spawneeExit :] SUCCESS.\n");
item->returnCode = rc;
}
}
}
}
}

}
12 changes: 11 additions & 1 deletion library/misc/uuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ static uint64_t xorshift128plus(uint64_t *s) {
return s[1] + s0;
}

void uuid4_generate(char *dst) {
extern struct TimerIFace *ITimer;

void uuid4_generate(char *_dst) {
char *dst = _dst;
static const char *template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
static const char *chars = "0123456789abcdef";
uint64_t seed[2] = {0, 0};
struct RandomState state;
DECLARE_UTILITYBASE();
// DECLARE_TIMERBASE();



GetSysTime((struct TimeVal *)&state);

typedef union {
int64_t big;
Expand Down Expand Up @@ -70,4 +78,6 @@ void uuid4_generate(char *dst) {
dst++, p++;
}
*dst = '\0';

DebugPrintF("[uuid4_generate :] result : <%s>\n", _dst);
}
2 changes: 1 addition & 1 deletion library/shared_library/clib4_vectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ static void *clib4Vectors[] = {
(void *) (__get_tc_up), /* 4384 */
(void *) (__get_tc_bc), /* 4388 */

(void *) (spawnvpe_callback), /* 4392 */
(void *) (0), /* 4392 */

(void *) (sigsuspend), /* 4396 */
(void *) (spawnve), /* 4400 */
Expand Down
2 changes: 1 addition & 1 deletion library/shared_library/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ struct Clib4IFace {
char * (* __get_tc_up) (void); /* 4384 */
char * (* __get_tc_bc) (void); /* 4388 */

int ( *spawnvpe_callback) (const char *file, const char **argv, char **deltaenv, const char *dir, int fhin, int fhout, int fherr, void (*entry_fp)(void *), void* entry_data, void (*final_fp)(int, void *), void* final_data); /* 4392 */
int ( *spawnvpe_callback_UNUSED) (const char *file, const char **argv, char **deltaenv, const char *dir, int fhin, int fhout, int fherr, void (*entry_fp)(void *), void* entry_data, void (*final_fp)(int, void *), void* final_data); /* 4392 */

int (* sigsuspend) (const sigset_t *mask); /* 4396 */
int (* spawnve) (const char *path, const char **argv, char **deltaenv, const char *dir, int fhin, int fhout, int fherr); /* 4400 */
Expand Down
2 changes: 1 addition & 1 deletion library/shared_library/stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ Clib4Call(__get_tc_ospeed, 4380);
Clib4Call(__get_tc_up, 4384);
Clib4Call(__get_tc_bc, 4388);

Clib4Call(spawnvpe_callback, 4392);
// Clib4Call(spawnvpe_callback_UNUSED, 4392);

Clib4Call(sigsuspend, 4396);
Clib4Call(spawnve, 4400);
Expand Down
81 changes: 61 additions & 20 deletions library/unistd/spawnvpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,14 @@ get_arg_string_length(char *const argv[]) {
return (result);
}
int
spawnvpe_callback(
spawnvpe(
const char *file,
const char **argv,
char **deltaenv,
const char *cwd,
int fhin,
int fhout,
int fherr,

void (*entry_fp)(void *), void* entry_data,
void (*final_fp)(int, void *), void* final_data
int fherr
) {
int ret = -1;
struct name_translation_info nti_name;
Expand All @@ -144,10 +141,12 @@ spawnvpe_callback(
size_t parameter_string_len = 0;
struct _clib4 *__clib4 = __CLIB4;
struct Task *me = (struct Task *) __clib4->self;
BPTR seglist;

__set_errno(0);

D(("Starting new process [%s]\n", name));
// printf("[spawnvpe :] Starting new process [%s]\n", name);

int error = __translate_unix_to_amiga_path_name(&name, &nti_name);
if (error) {
Expand All @@ -158,6 +157,12 @@ spawnvpe_callback(

D(("name after conversion: [%s]\n", name));

#if 0
seglist = LoadSeg(name);
if (!seglist)
return -1;
#endif

BPTR fileLock = Lock(name, SHARED_LOCK);
if (fileLock) {
progdirLock = ParentDir(fileLock);
Expand Down Expand Up @@ -200,6 +205,8 @@ spawnvpe_callback(

D(("File to execute: [%s]\n", finalpath));

// printf("[spawnvpe :] full command == <%s>\n", finalpath);

if (fhin >= 0) {
err = __get_default_file(fhin, &fh);
if (err) {
Expand Down Expand Up @@ -244,7 +251,51 @@ spawnvpe_callback(

D(("(*)Calling SystemTags.\n"));

// struct EntryData ed;

struct Task *_me = FindTask(0);
#if 0
struct Process *p = CreateNewProcTags(
NP_Seglist, seglist,
NP_FreeSeglist, TRUE,

NP_Cli, TRUE,
NP_Child, TRUE,
NP_NotifyOnDeathSigTask, _me,

#if 1
NP_Input, iofh[0],
NP_CloseInput, closefh[0],
NP_Output, iofh[1],
NP_CloseOutput, closefh[1],
NP_Error, iofh[2],
NP_CloseError, closefh[2],
#else
NP_Input, IDOS->Input(),
NP_CloseInput, FALSE,
NP_Output, IDOS->Output(),
NP_CloseOutput, FALSE,
NP_Error, IDOS->ErrorOutput(),
NP_CloseError, FALSE,
#endif

NP_EntryCode, spawnvpe_entryCode,
NP_EntryData, &ed,

// NP_FinalCode, amiga_FinalCode,
// NP_FinalData, fd,

// NP_EntryCode, spawnedProcessEnter,
NP_ExitCode, spawnedProcessExit,

NP_Name, strdup(processName),
cwdLock ? NP_CurrentDir : TAG_SKIP, cwdLock,
progdirLock ? NP_ProgramDir : TAG_SKIP, progdirLock,
NP_Arguments, arg_string,
TAG_DONE
);
if (p) ret = 0;
#else
ret = SystemTags(finalpath,
NP_NotifyOnDeathSigTask, _me,
SYS_Input, iofh[0],
Expand All @@ -256,12 +307,12 @@ spawnvpe_callback(
progdirLock ? NP_ProgramDir : TAG_SKIP, progdirLock,
cwdLock ? NP_CurrentDir : TAG_SKIP, cwdLock,
NP_Name, strdup(processName),
entry_fp ? NP_EntryCode : TAG_SKIP, entry_fp,
entry_data ? NP_EntryData : TAG_SKIP, entry_data,
final_fp ? NP_FinalCode : TAG_SKIP, final_fp,
final_data ? NP_FinalData : TAG_SKIP, final_data,
NP_ExitCode, spawnedProcessExit,

NP_EntryCode, spawnedProcessEnter,
NP_ExitCode, spawnedProcessExit,

TAG_DONE);
#endif

D(("SystemTags completed. return value: [%ld]\n", ret));

Expand All @@ -280,16 +331,6 @@ spawnvpe_callback(
* just after SystemTags. In this case spawnv will return pid
*/
ret = IoErr();
if (insertSpawnedChildren(ret, getgid())) {
D(("Children with pid %ld and gid %ld inserted into list\n", ret, getgid()));
}
else {
D(("Cannot insert children with pid %ld and gid %ld into list\n", ret, getgid()));
}
}

return ret;
}
int spawnvpe(const char *file, const char **argv, char **deltaenv, const char *dir, int fhin, int fhout, int fherr) {
return spawnvpe_callback(file, argv, deltaenv, dir, fhin, fhout, fherr, 0, 0, 0, 0);
}