Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
59 user(s) are online (19 user(s) are browsing Forums)

Members: 2
Guests: 57

Valiant, slygon, more...

Support us!

Headlines

 
  Register To Post  

Do we have an execpl replacement?
Quite a regular
Quite a regular


See User information
Hello everyone,

as the title says, do we have an execpl replacement?

I know that Chris y. have execvp replacement (https://github.com/chris-y/git2/blob/m ... src/common/compat/amiga.c), but do we have repacements for execpl and other function of unistd?

Retired
Go to top
Re: Do we have an execpl replacement?
Home away from home
Home away from home


See User information
12.NGFSBoot:>

CLIB2 yes:

objdump -t sdk:clib2/lib/libunix.a | grep exec
unistd_execl.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execl.c
00000000 g F .text 0000023c execl
00000000 *UND* 00000000 execve
unistd_execle.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execle.c
00000000 g F .text 000002d0 execle
00000000 *UND* 00000000 execve
unistd_execlp.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execlp.c
00000000 g F .text 00000234 execlp
00000000 *UND* 00000000 execvp
unistd_execv.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execv.c
00000000 g F .text 0000000c execv
00000000 *UND* 00000000 execve
unistd_execve.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execve.c
00000b0c g F .text 00000610 execve
00000000 *UND* 00000000 __execve_environ_init
00000000 *UND* 00000000 __execve_exit
00000000 *UND* 00000000 __execve_environ_exit
unistd_execve_env_exit.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execve_env_exit.c
00000000 g F .text 00000004 __execve_environ_exit
unistd_execve_env_init.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execve_env_init.c
00000000 g F .text 00000008 __execve_environ_init
unistd_execve_exit.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execve_exit.c
00000000 g F .text 00000004 __execve_exit
unistd_execvp.o: file format elf32-amigaos
00000000 l df *ABS* 00000000 unistd_execvp.c
00000000 g F .text 00000338 execvp
00000000 *UND* 00000000 execve

NEWLIB:

12.NGFSBoot:> objdump -t sdk:newlib/lib/libc.a | grep exec
12.NGFSBoot:> objdump -t sdk:newlib/lib/libunix.a | grep exec

Not so much

But if you have a execvp() than you ofcourse have an execlp() seeing as execlp() is the varags version of execvp()


Go to top
Re: Do we have an execpl replacement?
Home away from home
Home away from home


See User information
@AmigaBlitter

It good start to read about command.

https://linux.die.net/man/3/execvp

what is suppose to return and so on...

it should be to hard to implemented.

you execute it with command system() its priority easy to use.

http://man7.org/linux/man-pages/man3/system.3.html

all you need to is kind create new command line string, should be too hard, you need some "" symbols around args, and you need to calculate size of buffer from number of args, and number of extra symbols like "", and null terminate symbol \0.

strcpy and strcat can do that, or you use sprintf, sure there are lots more, or you can write your own.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Do we have an execpl replacement?
Home away from home
Home away from home


See User information
Important to note that exec() is not a very amiga thing. In princliple never returns but even with a drop in replacement, you'll to deal the fact that it *does* return on AmigaOS (when the executed program returns).


Edited by broadblues on 2018/2/20 21:38:52
Go to top
Re: Do we have an execpl replacement?
Home away from home
Home away from home


See User information
@LiveForIt

"all you need "

exec#? (or should that be exec* seeing as it's posiix) are bit harder to do than that... see clib2/abc-shell/perl src code for inspiration.


Go to top
Re: Do we have an execpl replacement?
Home away from home
Home away from home


See User information
@AmigaBlitter

I think waitpid is lot more impotent to implement.

https://linux.die.net/man/2/waitpid

at some point the program will exit, and its going to wait for threads to finish, before exiting... this where badly ported programs sucks and fucks up memory and turn the Amiga into a brick.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Do we have an execpl replacement?
Home away from home
Home away from home


See User information
@broadblues

In that case all you need is dos.library, not exec.library, but using posix stuff make it more portable its part of the SDK should work.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Do we have an execpl replacement?
Quite a regular
Quite a regular


See User information
"ftime" is another missing function


Retired
Go to top
Re: Do we have an execpl replacement?
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter

AFAICT ftime() returns basically the same information as gettimeofday() only the fractional seconds part is milliseconds instead of microseconds, so the following simple replacement should work:

int ftime(struct timeb *tbp)
{
    
struct timeval  tv;
    
struct timezone tz;

    
gettimeofday(&tv, &tz);

    
tbp->time    tv.tv_sec;
    
tbp->millitm tv.tv_usec 1000;

    
tbp->timezone tz.tz_minuteswest;
    
tbp->dstflag  tz.tz_dsttime;

    return 
0;
}


Go to top
Re: Do we have an execpl replacement?
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter

Quote:

I know that Chris y. have execvp replacement (https://github.com/chris-y/git2/blob/m ... src/common/compat/amiga.c), but do we have repacements for execpl and other function of unistd?


The execvp() "replacement" you link to is just a dummy function which prints a message to the program's stdout.

In fact the pipe() function there is also wrong since it uses fopen() when it should be using open() instead.

Instead of:
fd[0] = fopen(fname"r");
fd[1] = fopen(fname"w");


the code should be:
fd[0] = open(fnameO_RDONLY);
fd[1] = open(fnameO_WRONLY);


Though without fork() the pipe() function is of somewhat questionable use, since they are most often used in combination.

The waitpid() function there is also a dummy BTW.

Go to top
Re: Do we have an execpl replacement?
Quite a regular
Quite a regular


See User information
@salass00

There a way to create those function grabbing them from https://github.com/sba1/clib2
or this would be too messy?

Retired
Go to top
Re: Do we have an execpl replacement?
Home away from home
Home away from home


See User information
@AmigaBlitter

Quote:


There a way to create those function grabbing them from https://github.com/sba1/clib2 or this would be too messy?



Clib2 license allows you to do so as far as I understand it. It wouldn't be messy unless you did it messily.

However, if you need to extract largish lumps of clib2 to add to your port you should consider actually linking against clib2 instead of newlib.

What kind of thing are you porting? If it needs shared object support for mosule loading etc then you are somewhat stuck with newlib, but other wise there's no reason not to use clib2, and can quite a few reasons *to* do it.

abc-shell and the core-utils are linked against clib2 for good reason, for example. (Command argument handling, libunix function requirements etc etc)




Go to top
Re: Do we have an execpl replacement?
Quite a regular
Quite a regular


See User information
@broadblues

I'm porting DosBox X (trying...)

Resized Image

Resized Image

Resized Image

I need an ftime replacement and a few others functions. I currently disabled serial and ftime.




Retired
Go to top
Re: Do we have an execpl replacement?
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter
If you compile your own clib2 you can also activate NULL pointer checking by editing the clib2 stdlib_null_pointer_check.h file.

Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

Go to top
Re: Do we have an execpl replacement?
Quite a regular
Quite a regular


See User information
Found this code on Amiga Wiki page, but seems not working or not updated

/* Get_Systime.c
 *
 * Get system time example
 *
 * Run from CLI only
 */
 
#include <exec/types.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <devices/timer.h>
 
#include <proto/exec.h>
#include <proto/dos.h>
 
 
int main(void)
{
  
int32 error;
  
uint32 days,hrs,secs,mins,mics;
 
  
struct MsgPort *TimerMP IExec->AllocSysObjectTags(ASOT_PORTTAG_END);
 
  if (
TimerMP != NULL)
  {
    
struct TimeRequest *TimerIO IExec->AllocSysObjectTags(ASOT_IOREQUEST,
      
ASOIOR_Sizesizeof(struct TimeRequest),
      
ASOIOR_ReplyPortTimerMP,
      
TAG_END);
 
    if (
TimerIO != NULL)
    {
        
/* Open with UNIT_VBLANK, but any unit can be used */
        
if (!(error IExec->OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)TimerIO,0L)))
        {
            
/* Issue the command and wait for it to finish, then get the reply */
            
TimerIO->tr_node.io_Command TR_GETSYSTIME;
            
IExec->DoIO((struct IORequest *) TimerIO);
 
            
/* Get the results and close the timer device */
            
mics TimerIO->tr_time.tv_micro;
            
secs TimerIO->tr_time.tv_secs;
 
            
/* Compute days, hours, etc. */
            
mins secs 60;
            
hrs  mins 60;
            
days hrs 24;
            
secs secs 60;
            
mins mins 60;
            
hrs  hrs 24;
 
            
/* Display the time */
            
IDOS->Printf("\nSystem Time (measured from Jan.1,1978)\n");
            
IDOS->Printf("  Days   Hours  Minutes Seconds Microseconds\n");
            
IDOS->Printf("%6ld %6ld %6ld %6ld %10ld\n"dayshrsminssecsmics);
 
            
/* Close the timer device */
            
IExec->CloseDevice((struct IORequest *) TimerIO);
        }
        else
            
IDOS->Printf("\nError: Could not open timer device\n");
 
        
/* Delete the IORequest structure */
        
IExec->FreeSysObject(ASOT_IOREQUESTTimerIO);
    }
    else
        
IDOS->Printf("\nError: Could not create I/O structure\n");
 
    
/* Delete the port */
    
IExec->FreeSysObject(ASOT_PORTTimerMP);
  }
  else
    
IDOS->Printf("\nError: Could not create port\n");
 
  return 
0;
}



Gettime.c: In function 'main':
Gettime.c:39: error: 'struct TimeRequest' has no member named 'tr_node'
Gettime.c:43: error: 'struct TimeRequest' has no member named 'tr_time'
Gettime.c:44: error: 'struct TimeRequest' has no member named 'tr_time'
Gettime.c:78:2: warning: no newline at end of file

@xenic

Thank you for the info

Retired
Go to top
Re: Do we have an execpl replacement?
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter

Replace tr_node with Request and tr_time with Time.
TimerIO->tr_time.tv_micro => TimerIO->Time.Microseconds
TimerIO->tr_time.tv_secs => TimerIO->Time.Seconds

Rock lobster bit me - so I'm here forever
X1000 + AmigaOS 4.1 FE
"Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Go to top
Re: Do we have an execpl replacement?
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter

Quote:

I need an ftime replacement and a few others functions. I currently disabled serial and ftime.


Did you miss the ftime() code that I posted earlier?

If you use timer.device directly you need to convert the time from AmigaOS to UNIX epoch and from local time to GMT, because this is the format that should be returned by the POSIX time functions.

Go to top
Re: Do we have an execpl replacement?
Amigans Defender
Amigans Defender


See User information
@salass00

Quote:
In fact the pipe() function there is also wrong since it uses fopen() when it should be using open() instead.


That's a dead project but I feel like I might have to fix this bug to stop it being continually quoted...

Go to top
Re: Do we have an execpl replacement?
Quite a regular
Quite a regular


See User information
@salass00

Yes, sorry i missed your post.

Thank you

Retired
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project