From 06e5f437d9343e6981f9b0939a483fa9b1e41150 Mon Sep 17 00:00:00 2001
From: Olaf Barthel I added some amiga.lib and debug.lib functionality to the library, but don't
count on it to be complete. The library code is supposed to be thread-safe if built with the __THREAD_SAFE
-preprocesssor symbold defined. Note that 'thread-safe' does not mean
-'reentrant'. Multiple callers for certain library functions are permitted, but
-not for all of them. For example, mkdtemp() is not thread-safe, and neither is
-rand() or localtime(). But as per POSIX 1003.1c-1995 there are thread-safe
-variants of rand() and localtime() called rand_r(), localtime_r(), and others. The use of the socket I/O functions is still problematic because the
-underlying bsdsocket.library API is not supposed to be used by any process
-other than the one that opened it. While one TCP/IP stack (my own "Roadshow") allows you
-to share the library base among different processes, if so configured, it is the
-exception. No other TCP/IP stack available for the Amiga robustly supports a similar
-feature. If the TCP/IP stack supports this feature, then the global variable
-__can_share_socket_library_base will be set to a non-zero value. Errors reported by the socket I/O functions which modify the global variables
-errno and h_errno may be directed to call the __set_errno()
-and __set_h_errno() functions instead if the TCP/IP stack supports this feature. The global
-variable __thread_safe_errno_h_errno will be set to a non-zero value if it does. A much more serious problem resides with the exit(), abort(),
-assert() and raise() functions, and the how SIGINT signal is
-processed. In the thread-safe library only the main() function may directly
-or indirectly call the exit() function. No child process may do so, since this
-would wreck its stack context, crashing it instantly; the main program would be very
-likely to crash, too, because exit() will clean up after all memory allocations
-and files currently in use. Functions such as abort() and raise() may
-call the exit() function indirectly. And the raise() function may
-be invoked as part of the Control+C checking. You should make sure that the
-signal handling does not affect any child processes. This can be done by replacing the
-__check_abort() function or by disabling SIGINT processing altogether,
-such as through a signal(SIGINT,SIG_IGN) call. This library is a departure from the typical 'C' runtime environments of the
@@ -174,6 +139,39 @@ yet. All that the thread-safety tries to afford you is not to get into big troub
if simultaneous and overlapping accesses to files, memory allocation and other
resources are taking place. The library code is supposed to be thread-safe if built with the __THREAD_SAFE
+preprocesssor symbold defined. Note that 'thread-safe' does not mean
+'reentrant'. Multiple callers for certain library functions are permitted, but
+not for all of them. For example, mkdtemp() is not thread-safe, and neither is
+rand() or localtime(). But as per POSIX 1003.1c-1995 there are thread-safe
+variants of rand() and localtime() called rand_r(), localtime_r(), and others. The use of the socket I/O functions is still problematic because the
+underlying bsdsocket.library API is not supposed to be used by any process
+other than the one that opened it. While one TCP/IP stack (my own "Roadshow") allows you
+to share the library base among different processes, if so configured, it is the
+exception. No other TCP/IP stack available for the Amiga robustly supports a similar
+feature. If the TCP/IP stack supports this feature, then the global variable
+__can_share_socket_library_base will be set to a non-zero value. Errors reported by the socket I/O functions which modify the global variables
+errno and h_errno may be directed to call the __set_errno()
+and __set_h_errno() functions instead if the TCP/IP stack supports this feature. The global
+variable __thread_safe_errno_h_errno will be set to a non-zero value if it does. A much more serious problem resides with the exit(), abort(),
+assert() and raise() functions, and the how SIGINT signal is
+processed. In the thread-safe library only the main() function may directly
+or indirectly call the exit() function. No child process may do so, since this
+would wreck its stack context, crashing it instantly; the main program would be very
+likely to crash, too, because exit() will clean up after all memory allocations
+and files currently in use. Functions such as abort() and raise() may
+call the exit() function indirectly. And the raise() function may
+be invoked as part of the Control+C checking. You should make sure that the
+signal handling does not affect any child processes. This can be done by replacing the
+__check_abort() function or by disabling SIGINT processing altogether,
+such as through a signal(SIGINT,SIG_IGN) call. Also take care with file I/O involving the stdin/stdout/stderr
streams; read/write operations on these streams will be mapped to the Input()/Output()/ErrorOutput()
file handles of the process performing these operations. Since only this small set of
@@ -352,7 +350,7 @@ character is accepted as an alternative to the period (.).2.1 Thread-safety
-
-3. What does it not do?
In the libunix.a implementation a request to allocate -0 (zero) bytes will result in an allocation of at least 1 byte, which will +0 (zero) bytes will result in an allocation of at least 4 bytes, which will be set to zero. Each zero length allocation will return a different memory address.