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