2 Copyright © 2009-2019, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
9 #include <proto/timer.h>
14 #define IMPLEMENT() bug("------IMPLEMENT(%s)\n", __func__)
17 The purpose of this file is to provide implementation for C functions part
18 of arosnixc.library in code where one does not want to use this library.
23 int gettimeofday (struct timeval
* tv
,struct timezone
* tz
)
25 struct MsgPort
* timerport
= CreateMsgPort();
26 struct timerequest
* timereq
= (struct timerequest
*)CreateIORequest(timerport
, sizeof(*timereq
));
31 if (OpenDevice("timer.device", UNIT_VBLANK
, (struct IORequest
*)timereq
, 0) == 0)
33 #define TimerBase ((struct Device *)timereq->tr_node.io_Device)
39 CloseDevice((struct IORequest
*)timereq
);
43 DeleteIORequest((struct IORequest
*)timereq
);
44 DeleteMsgPort(timerport
);
49 int usleep (useconds_t usec
)
56 This implementation of atexit is different than the definition of atexit
57 function due to how libraries work in AROS.
59 Under Linux, when an .so file is used by an application, the library's code
60 is being shared but the library's data (global, static variables) are COPIED for
61 each process. Then, an atexit call inside .so will only operate on COPY of data
62 and thus can for example free memory allocated by one process without
63 influencing other processes.
65 Under AROS, when a .library file is used by an application, library code AND
66 library data is shared. This means, an atexit call inside .library which was
67 initially coded under Linux cannot be executed when process is finishing
68 (for example at CloseLibrary) because such call will most likely free shared
69 data which will make other processes crash. The best approximation of atexit
70 in case of .library is to call the atexit functions at library expunge/exit.
72 TODO: Check atexit() usage and determine best time to call atexit registered
76 static struct exit_list
{
77 struct exit_list
*next
;
81 int atexit(void (*function
)(void))
85 el
= malloc(sizeof(*el
));
96 void __exit_emul(void)
99 struct exit_list
*el
= exit_list
->next
;
107 ADD2EXIT(__exit_emul
, 0);